Various updates; Add logAxis patch for graphite; Add namespaces to summary scripts.
[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=PlanetLabConf
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 [ -f /usr/boot/myops_cacert.pem ] ; then
27         CURL_ARGS="$CURL_ARGS --cacert /usr/boot/myops_cacert.pem"
28 else
29         CURL_ARGS="$CURL_ARGS --insecure"
30 fi
31
32 # if bootstrap file has been updated
33 curl $CURL_ARGS -s -O https://$IP/$DIR/$FILE
34
35 if [ -f $FILE ] ; then
36     mod_time_after=`stat -c %Y $FILE`
37 else
38     mod_time_after=0
39 fi
40
41 if [[ $mod_time_after -gt $mod_time_before ]] ; then
42     # then an update occurred, and we need to unpack it.   
43     tar -xzf $FILE
44     chmod 755 ./*.sh ./*.py
45     ./bootstrap.sh || exit 1
46     touch $HDIR/update_ok
47 fi
48