doit.sh
author stephen
Tue, 07 Feb 2017 15:45:13 +0000
changeset 21 af4cfcf888fa
parent 18 5f5fbc348b7e
child 28 f610c2541dc7
permissions -rwxr-xr-x
feb 7
     1 #!/bin/bash
     2 
     3 #set -x
     4 
     5 if [[ "${@/noup}" != "$@" ]]
     6 then
     7 	echo "no update attempted"
     8 else
     9 	state=`./checkup.sh`
    10 
    11 	if [ "$state" == "up" ]
    12 	then
    13 		ssh basil.dsg.cs.tcd.ie scp loradtn@tunloradtn:/var/log/battery.log .
    14 		scp basil.dsg.cs.tcd.ie:battery.log .
    15 		./battery-seds.sh battery.log >sedded-battery.log
    16 	else 
    17 		echo "Node not up."
    18 		exit
    19 	fi
    20 fi
    21 
    22 if [[ "${@/today}" != "$@" ]]
    23 then
    24 	today=`date --rfc-3339=date`
    25 	cat loradtn.gpl \
    26 		| sed -e 's/2017-01-01/'$today'/' \
    27 		| sed -e 's/2017-02-28/'$today'/' \
    28 		| sed -e 's/loradtn.png/loradtn-'$today'.png/' \
    29 			>daily/loradtn-$today.gpl
    30 	gnuplot daily/loradtn-$today.gpl
    31 	mv loradtn-$today.png daily
    32 	hg add daily/loradtn-$today.*
    33 	exit
    34 fi
    35 
    36 others="${@/noup}"
    37 
    38 if [ "$others" != "" ]
    39 then
    40 	# assume parameter is nicely formed date
    41 	theday=`echo $others | sed -e 's/ //g'` 
    42 	cat loradtn.gpl \
    43 		| sed -e 's/2017-01-01/'$theday'/' \
    44 		| sed -e 's/2017-02-28/'$theday'/' \
    45 		| sed -e 's/loradtn.png/loradtn-'$theday'.png/' \
    46 			>daily/loradtn-$theday.gpl
    47 	gnuplot daily/loradtn-$theday.gpl
    48 	mv loradtn-$theday.png daily
    49 	hg add daily/loradtn-$theday.*
    50 else
    51 	# generate new overview
    52 	gnuplot loradtn.gpl
    53 fi
    54 
    55