swapwatch/swapupdate.sh

40 lines
1.2 KiB
Bash
Raw Normal View History

2015-03-30 19:25:55 -04:00
#!/bin/bash
#this script is run via cron and checks for updates to swapwatch
#unless the conf says not to
2015-03-30 19:31:20 -04:00
swapURL="http://DOMAIN.com/swapwatch.sh"
swapupdateURL="http://DOMAIN.com/swapupdate.sh"
2015-03-30 19:25:55 -04:00
APPDIR="/usr/local/sw/apps/swapwatch"
TMPDIR="/usr/local/sw/temp"
LOGDIR="/usr/local/sw/logs"
. /usr/local/sw/configs/swapwatch/swapwatch.conf
################################################################################
#if we are allowed to update
2015-03-30 19:31:20 -04:00
2015-03-30 19:25:55 -04:00
if [ $update = "yes" ]
then
#update swapwatch.sh
wget -O "$TMPDIR/swapwatch.tmp" $swapURL
#only overwrite if the dl worked
if [ "$?" -eq 0 ]
2015-03-30 19:31:20 -04:00
then
2015-03-30 19:25:55 -04:00
#just overwrite... probably with identical data. that's fine
mv -f "$TMPDIR/swapwatch.tmp" "$APPDIR/swapwatch.sh"
chmod +x "$APPDIR/swapwatch.sh"
fi
#update swapupdate.sh
wget -O "$TMPDIR/swapupdate.tmp" $swapupdateURL
if [ "$?" -eq 0 ]
then
mv -f "$TMPDIR/swapupdate.tmp" "$APPDIR/swapupdate.sh"
chmod +x "$APPDIR/swapupdate.sh"
#log
echo "[ $(date +%c) ] swapwatch checked for updates" >> $LOGDIR/swapwatch.log
else
echo "[ $(date +%c) ] swapwatch update failed" >> $LOGDIR/swapwatch.log
fi
fi
################################################################################