Add bw, dns, and uptime checks.
[myops.git] / web / collect / client / update.sh
1 #!/bin/bash
2
3 if [ -f /etc/planetlab/plc_config ]; then
4         source /etc/planetlab/plc_config
5 else
6         PLC_SLICE_PREFIX='pl'
7 fi
8
9 IP=IPADDR
10 DIR=multiops
11 FILE=bootstrap.tar.gz
12 HDIR=/home/${PLC_SLICE_PREFIX}_myops
13
14 mkdir -p $HDIR
15 cd $HDIR
16
17 # before update
18 if [ -f $FILE ] ; then
19     mod_time_before=`stat -c %Y $FILE`
20     CURL_ARGS="-z $FILE"
21 else
22     mod_time_before=0
23     CURL_ARGS=""
24 fi
25
26 # if bootstrap file has been updated
27 curl $CURL_ARGS -s -O --insecure https://$IP/$DIR/$FILE
28
29 if [ -f $FILE ] ; then
30     mod_time_after=`stat -c %Y $FILE`
31 else
32     mod_time_after=0
33 fi
34
35 if [[ $mod_time_after -gt $mod_time_before ]] ; then
36     # then an update occurred, and we need to unpack it.   
37     tar -xzf $FILE
38     chmod 755 ./*.sh ./*.py
39     ./bootstrap.sh
40 fi
41