Add bw, dns, and uptime checks.
[myops.git] / web / collect / client / update.sh
diff --git a/web/collect/client/update.sh b/web/collect/client/update.sh
new file mode 100644 (file)
index 0000000..47016ff
--- /dev/null
@@ -0,0 +1,41 @@
+#!/bin/bash
+
+if [ -f /etc/planetlab/plc_config ]; then
+       source /etc/planetlab/plc_config
+else
+       PLC_SLICE_PREFIX='pl'
+fi
+
+IP=IPADDR
+DIR=multiops
+FILE=bootstrap.tar.gz
+HDIR=/home/${PLC_SLICE_PREFIX}_myops
+
+mkdir -p $HDIR
+cd $HDIR
+
+# before update
+if [ -f $FILE ] ; then
+    mod_time_before=`stat -c %Y $FILE`
+    CURL_ARGS="-z $FILE"
+else
+    mod_time_before=0
+    CURL_ARGS=""
+fi
+
+# if bootstrap file has been updated
+curl $CURL_ARGS -s -O --insecure https://$IP/$DIR/$FILE
+
+if [ -f $FILE ] ; then
+    mod_time_after=`stat -c %Y $FILE`
+else
+    mod_time_after=0
+fi
+
+if [[ $mod_time_after -gt $mod_time_before ]] ; then
+    # then an update occurred, and we need to unpack it.   
+    tar -xzf $FILE
+    chmod 755 ./*.sh ./*.py
+    ./bootstrap.sh
+fi
+