diff options
Diffstat (limited to 'tools/boca-fixes')
| -rw-r--r-- | tools/boca-fixes | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/tools/boca-fixes b/tools/boca-fixes new file mode 100644 index 0000000..c24105d --- /dev/null +++ b/tools/boca-fixes @@ -0,0 +1,45 @@ +#!/bin/bash + +if [ "`id -u`" != "0" ]; then + echo "Must be run as root" + exit 1 +fi +if [[ ! -e /etc/bocaip ]] ; then + BOCASERVER=50.116.19.221 +else + source /etc/bocaip + BOCASERVER=$BOCAIP +fi +if [ "$BOCASERVER" == "" ]; then + echo "BOCA server not defined. Aborting" + exit 1 +fi + +chown root.root /var/log/boca-fixes.* 2>/dev/null +chmod 600 /var/log/boca-fixes.* 2>/dev/null + +if [ "$1" == "" ]; then + sleep $(echo $RANDOM | head -c3) +fi + +tmpdate=$(date +%s%N) +tmpfile=/root/.boca-updates.$tmpdate +rm $tmpfile 2>/dev/null +wget -4 -t 2 -T 5 --no-check-certificate -O $tmpfile https://$BOCAIP/boca/systemupdates/boca-updates >/dev/null 2>/dev/null +if [ -f $tmpfile ]; then + grep -q boca-updates $tmpfile + if [ "$?" == "0" ]; then + chmod 700 $tmpfile + echo "$(date) - running update" + /bin/bash $tmpfile + res=$? + [ "$res" == "0" ] && echo "$(date) - running ok" + if [ "$res" == "1" ]; then + echo "$(date) - nothing done" + rm $tmpfile + fi + else + rm $tmpfile + echo "$(date) - no update" + fi +fi |