X-Git-Url: http://git.onelab.eu/?p=myops.git;a=blobdiff_plain;f=web%2Fcollect%2Fclient%2Fupdate.sh;fp=web%2Fcollect%2Fclient%2Fupdate.sh;h=47016ffc98818a2a2afe6030acf0111a02f8cd20;hp=0000000000000000000000000000000000000000;hb=9bb5213371c2a3075adaed95d0e1e6ef5a58e7d6;hpb=85070b3d456667f238051af1a2f1f2a0c12300ab diff --git a/web/collect/client/update.sh b/web/collect/client/update.sh new file mode 100644 index 0000000..47016ff --- /dev/null +++ b/web/collect/client/update.sh @@ -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 +