Changed to use jpg
[clearscm.git] / bin / check4update
1 #!/bin/bash
2 expireTime=1200
3 systems="\
4   earth\
5   mars\
6   defaria.com\
7 "
8
9 function notify {
10   #zenity --notification --text "$1" 2> /dev/null
11   notify-send --expire-time=$expireTime "$1"
12   echo $1
13 }
14
15 function yesno {
16   question=$1
17
18   zenity --question --text "$question" --width=300 2> /dev/null
19 }
20     
21 update=$1;
22
23 for system in $systems; do
24   notify "Checking $system for updates"
25   ssh $system sudo apt-get -qq update
26   ssh $system apt list --upgradeable 2> /dev/null | grep -v "^Listing" > /tmp/check4update.list
27
28   if [ $(wc -l /tmp/check4update.list 2> /dev/null | cut -f1 -d' ') -ne 0 ]; then
29     cat /tmp/check4update.list
30
31     if yesno "There are updates for $system\nApply them now?" ]; then
32       ssh $system sudo /opt/clearscm/bin/update-system
33     else
34       notify "$system not updated"
35     fi
36   else
37     notify "$system is up to date"
38   fi
39
40   rm -f /tmp/check4update.list
41 done