I tend to use scripts for many things where I believe they can be useful, so here I list them for posterity’s sake.

This is my favourite script and is so useful when you come to do a reinstall of your distro -

Reinstall.sh

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/bin/bash
#
# simple bash script to re-install all the programmes after a fresh
install for debian
#
# Wayno Guerrini v1.0
# www.pkill-9.com

# quit does any processing before returning back from the script.
# here we are just exiting.
#
function quit {
exit
}

function doit {

#echo back to the terminal what we are trying to install
#

printf '\n'
echo 'installing: ' $1 $2
printf '\n'
apt-get -y install $1

# $? is the return code from the previous command in this case the
# apt-get

retval=$?

# check the return code from the apt-get if it's okay, continue on,
# if it's not zero, tell me the return code, but continue on

if [ $retval -ne 0 ] ; then
echo '>>>>>failed rc =' $retval
fi

}
#
# okay re-install all the programmes after a fresh install -- note,
# if you don't want it, comment it out with a # in front
#

doit rsync
doit gtkrsync
doit ntp
doit vnstat
doit mpd
doit mpc
doit ncmpcpp
doit lxde
doit deluge
doit zim
doit clipit
#doit claws-mail
doit chronicle
doit firestarter
doit grsync
doit i3lock
doit gpodder
doit conky
doit xpad
doit chromium
doit tomboy
doit k3b
doit konqueror
doit locate
doit dolphin
doit iptraf
doit numlockx
#doit lightdm
#doit lightdm-gtk-greeter
doit lxlauncher
doit logwatch
doit bluefish
doit pidgin
doit gwhere
doit uptimed
doit lxtask
doit xfmpc
doit claws-mail
doit claws-mail-plugins
doit claws-mail-extra-plugins
doit claws-mail-themes
doit xpad
doit vlc
#doit claws-mail-themes
doit xchat
doit xfmpc
#doit amarok
doit xscreensaver
#doit sudo
doit downtimed
# and we are done!
quit

jdiskreport.sh

This file is saved as ~/jdiskreport.sh

1
2
3
4
5
6
#!/bin/bash
# boudiccas January 2013
# a java based disk reporting tool with a nice GUI

cd /home/boztu/programmes/jdiskreport-1.4.0
java -jar jdiskreport-1.4.0.jar

JDiskReport is a free Java-based tool that displays the size, capacity, free space, and other parameters of your files, folders, and directories. You can get it from http://www.jgoodies.com/downloads/jdiskreport/. Its a lot better than Kdiff and very easy to install and get it set up.

EmptyTrash.sh

How many times have you gone to your trash can to restore the backup of the file that you've spent many hours on writing, and find that its already been permanently deleted? This script deletes files that are older than seven days, so it gradually empties your trash can, leaving you some time to restore your special file! :)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
#!/bin/bash
# emptytrash.sh

# call this manually or from crontab
# ENV may be impoverished so be explicit.
# 0 3 * * * /path/to/cleanTrash.sh
# r whatever
# remove the -v flag or dump STDOUT to /dev/null if you don't want output.
# I dump STDOUT in the crontab but run the script as-is when running
# from the terminal so I can see what gets torched.

DAYS=7 # retain for N days

for SUBDIR in files info
do
echo Lookin\' in Trash/${SUBDIR}...
#there can be subdirs under Trash/files at least.
#could make a nested loop and handle dirs and files seperately, but I'm tired
find ${HOME}/.local/share/Trash/$SUBDIR -mtime +${DAYS} -exec rm -vrf {} \;
done

All done, now back to sleep :)

Save this to your hard drive as emptytrash.sh, and it sends you an email after every days usage showing what's been deleted.

debian-timescale.rb

This is just a fun script that works out when 'Wheezy' [the debian testing distrobution] is released as 'stable', and not to be taken seriously.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/ruby
# written by Tobix, January 2013

require 'date'

class DebianRelease
def initialize(version, name, release, freeze = nil)
@version = version
@name = name
@release = release
@freeze = freeze
end

attr_reader :version, :name, :release, :freeze

def to_s
@version + ((@name)?" (%s)" % @name:"")
end

def -(other)
@release - other.release
end
end

data = [
DebianRelease.new("0.93R6", nil, Date::civil(1995, 10, 26)),
DebianRelease.new("no 1.0", nil, Date::civil(1995, 12, 11)),
DebianRelease.new("1.1", "buzz", Date::civil(1996, 6, 17)),
DebianRelease.new("1.2", "rex", Date::civil(1996, 12, 12)),
DebianRelease.new("1.3", "bo", Date::civil(1997, 6, 5)),
DebianRelease.new("2.0", "hamm", Date::civil(1998, 7, 24)),
DebianRelease.new("2.1", "slink", Date::civil(1999, 3, 9),
Date::civil(1998, 11, 4)),
DebianRelease.new("2.2", "potato", Date::civil(2000, 8, 15),
Date::civil(2000, 1, 16)),
DebianRelease.new("3.0", "woody", Date::civil(2002, 7, 19),
Date::civil(2001, 7, 1)),
DebianRelease.new("3.1", "sarge", Date::civil(2005, 6, 6),
Date::civil(2005, 5, 3)),
DebianRelease.new("4.0", "etch", Date::civil(2007, 4, 8),
Date::civil(2006, 8, 8)),
DebianRelease.new("5.0", "lenny", Date::civil(2009, 2, 15),
Date::civil(2008, 7, 27)),
DebianRelease.new("6.0", "squeeze", Date::civil(2011, 2, 6),
Date::civil(2010, 8, 6)),
DebianRelease.new("7.0", "wheezy", Date::civil(2013, 2, 6),
Date::civil(2012, 6, 30)),
DebianRelease.new("8.0?", "jessie", Date::civil(2015, 2, 6)),
]

puts "--- Debian history ---"
last = nil
data.sort_by {|e| e.release }.each { |ver|
if (last)
printf "%5i days (%1.5f years) later %s Version %s", ver -
last, (ver - last) / 365,
((ver.release > Date.today)? "maybe comes" : "came"), ver
else
printf "Version %s was released %s", ver, ver.release
end
 printf " (freeze time: %i days)", ver.release - ver.freeze if
ver.freeze
puts
last = ver
}

Startup.sh

Sometimes you have to have a programme start every time that you reboot, and this programme called from a cronjob can be very useful.

1
2
3
4
5
6
7
#!/bin/bash
/usr/bin/gnome-keyring-daemon --start --components=pkcs11 &

python /home/boztu/.conky/conkyweather/conkyWeather_arclance_v6.2.py

exit
fi

In your crontab, the line should appear like this -

@reboot /home/boztu/cron/startup.sh

UPDATE

I've had emails from wunderground saying that my weather script is contacting them in excess of 500 times a day, which is in breach of their terms of contract. I'm therefore monitoring the situation and if it continues then I'll take it out of commission.

podcast.sh

I enjoy listening to podcasts, but there are quite a few to try to keep up on their issuing every week. Put simply, I cant do it manually, so I've set the computer up to do it for me.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/bin/bash
# boudiccas January 2013
# a cronjob based daily getting of my podcasts

/usr/bin/podget>>/home/boztu/cron/podcasts.txt

echo "E: Podget script run" 1>&2
The podcasts that I'm getting are kept in the 'serverlist' and are ;-

http://downloads.bbc.co.uk/podcasts/radio4/comedy/rss.xml BBC Comedy
of the Week
http://feeds.feedburner.com/tdtrs-mp3 Linux The Dick Turpin Road Show
http://downloads.bbc.co.uk/podcasts/radio4/fricomedy/rss.xml BBC
Friday Night Comedy from BBC Radio 4
http://downloads.bbc.co.uk/podcasts/radio4/fooc/rss.xml BBC From Our
Own Correspondent
http://downloads.bbc.co.uk/podcasts/radio4/iot/rss.xml BBC In Our
Time With Melvyn Bragg
http://downloads.bbc.co.uk/podcasts/radio4/timc/rss.xml BBC The
Infinite Monkey Cage
http://feeds.feedburner.com/TheLinuxActionShow Linux The Linux
Action Show! MP3
http://www.tuxradar.com/files/podcast/podcast_mp3.rss Linux TuxRadar
Linux Podcast
http://downloads.bbc.co.uk/podcasts/radio4/medmatters/rss.xml BBC
Inside Health

First that we see is the url for the original podcast, then is the directory like 'BBC', and then the programme title. It makes it easier to see which ones you want to listen to.



Comments

comments powered by Disqus