1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
|
#!/bin/sh
#
# measuresdata-update
# Must be executable. Call it with all defaults or arguments for measuresdata
#
echo Calling measuresdata "$@"
measuresdata "$@"
if [ $? -ne 0 ] ; then
echo Severe error calling measuresdata with "$@"
exit 1
fi
if [ ! -f measuresdata.rc ] ; then
echo Severe error: no measuresdata.rc file returned
exit 1
fi
while grep -qe "^status:\\Wcont" measuresdata.rc ; do
data=$(grep "^data:" measuresdata.rc | cut -d\ -f2-)
ftp=$(grep "^ftp:" measuresdata.rc | cut -d\ -f2-)
http=$(grep "^http:" measuresdata.rc | cut -d\ -f2-)
https=$(grep "^https:" measuresdata.rc | cut -d\ -f2-)
dir=$(grep "^dir:" measuresdata.rc | cut -d\ -f2-)
file=$(grep "^file:" measuresdata.rc | cut -d\ -f2-)
arg=$(grep "^arg:" measuresdata.rc | cut -d\ -f2-)
if [ "$data" != "ascii" ] ; then
echo Severe: only ascii data protocol supported
exit 1
elif [ -z "$dir" -o -z "$file" -o -z "$arg" ] ; then
echo Severe: missing dir, file or arg data
exit 1
fi
if [ -n "$http" ] ; then
url="http://$http/$dir/$file"
elif [ -n "$https" ] ; then
url="https://$https/$dir/$file"
elif [ -n "$ftp" ] ; then
url="ftp://$ftp/$dir/$file"
else
echo Severe: missing ftp/http/https
exit 1
fi
if [ "$url" = "$old_url" ] ; then
echo Warning: measuresdata requests the same url twice: $url
# exit 1
fi
old_url=$url
echo Getting $url
curl -L -O $url
echo Calling measuresdata $arg
measuresdata $arg
if [ $? -ne 0 ] ; then
echo Severe error calling measuresdata with $arg
exit 1
fi
if [ ! -f measuresdata.rc ] ; then
echo Severe error: no measuresdata.rc file returned
exit 1
fi
done
if grep -qe "^status:\\Wend" measuresdata.rc ; then
echo measuresdata-update finished normally
exit 0
else
echo Severe: unknown status given in measuresdata.rc
exit 1
fi
|