doit.sh
author stephen
Thu, 17 Aug 2017 12:43:07 +0100
changeset 62 5fa8703565c4
parent 55 6559c3bacf09
permissions -rwxr-xr-x
aug17
     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 		# there's a chance of loss of battery.log here if device went
    14 		# down just as we're copying from it. But given we have all
    15 		# in mercurial that's ok, we can recover.
    16 		ssh basil.dsg.cs.tcd.ie scp loradtn@tunloradtn:/var/log/battery.log .
    17 		scp basil.dsg.cs.tcd.ie:battery.log .
    18 		./battery-seds.sh battery.log >sedded-battery.log
    19 	else 
    20 		echo "Node not up."
    21 		exit
    22 	fi
    23 fi
    24 
    25 if [[ "${@/today}" != "$@" ]]
    26 then
    27 	today=`date --rfc-3339=date`
    28 	cat loradtn.gpl \
    29 		| sed -e 's/2017-01-01/'$today'/' \
    30 		| sed -e 's/2017-09-30/'$today'/' \
    31 		| sed -e 's/loradtn.png/loradtn-'$today'.png/' \
    32 			>daily/loradtn-$today.gpl
    33 	gnuplot daily/loradtn-$today.gpl
    34 	mv loradtn-$today.png daily
    35 	hg add daily/loradtn-$today.*
    36 	exit
    37 fi
    38 
    39 others="${@/noup}"
    40 
    41 if [ "$others" != "" ]
    42 then
    43 	# assume parameter is nicely formed date
    44 	theday=`echo $others | sed -e 's/ //g'` 
    45 	cat loradtn.gpl \
    46 		| sed -e 's/2017-01-01/'$theday'/' \
    47 		| sed -e 's/2017-09-30/'$theday'/' \
    48 		| sed -e 's/loradtn.png/loradtn-'$theday'.png/' \
    49 			>daily/loradtn-$theday.gpl
    50 	gnuplot daily/loradtn-$theday.gpl
    51 	mv loradtn-$theday.png daily
    52 	hg add daily/loradtn-$theday.*
    53 else
    54 	# generate new overview
    55 	gnuplot loradtn.gpl
    56 fi
    57 
    58