Image

Image

Search This Blog

Friday, September 19, 2008

qd-update

#!/bin/bash
# quick and dirty update for our products - to be run from cron_daily
# (c)2008 neXt (sorin@xxxxxxxx.com) under the terms of GNU GPL v2

export log=/var/log/update.log
source='--ftp-user=ftpuser --ftp-password=ftppasswd ftp://my.site/update.tar.bz2'

date > $log
if [ ! -d /var/spool/update ]; then
mkdir -p /var/spool/update 1>>$log 2>&1
fi
cd /var/spool/update 1>>$log 2>&1
var=`/usr/bin/wget -N -t 10 -w 60 --random-wait -a $log -v $source; echo $?`

if [ $var -eq 0 ]; then
ls -l --time-style=long-iso update.tar.bz2 > newupd
if [ ! -f oldupd ]; then
touch oldupd 1>>$log 2>&1
fi
grep -v -f oldupd newupd > updres.$$
if [ -s updres.$$ ]; then
/bin/tar -xjf update.tar.bz2 1>>$log 2>&1
/bin/sh update/execute 1>>$log 2>&1
/bin/rm -rf update 1>>$log 2>&1
else
/bin/echo "No newer update downloaded" >> $log
fi
/bin/mv -f newupd oldupd 1>>$log 2>&1
/bin/rm -f updres.* 1>>$log 2>&1
else
/bin/echo "Wget returned an error" >> $log
fi
unset log
exit 0

No comments:

Post a Comment

Blog Archive