Added debug logging to certbot scripts
[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 }
13
14 function yesno {
15   question=$1
16
17   zenity --question --text "$question" --width=300 2> /dev/null
18 }
19     
20 update=$1;
21
22 for system in $systems; do
23   notify "Checking $system for updates"
24   ssh $system sudo apt-get -qq update
25   ssh $system apt list --upgradeable 2> /dev/null | grep -v "^Listing" > /tmp/check4update.list
26
27   if [ $(wc -l /tmp/check4update.list 2> /dev/null | cut -f1 -d' ') -ne 0 ]; then
28     cat /tmp/check4update.list
29
30     if yesno "There are updates for $system\nApply them now?" ]; then
31       ssh $system sudo /opt/clearscm/bin/update-system
32     else
33       notify "$system not updated"
34     fi
35   else
36     notify "$system is up to date"
37   fi
38
39   rm -f /tmp/check4update.list
40 done