#! /bin/sh
#
# This small script automatically downloads wims source distribution.
# It can be executed periodically via cron (say once a week).
# For example you may drop it into /etc/cron.weekly.
# You may change the definition of wimssrc to fit your setup.
# You also need the program 'wget' which is part of RedHat 7.1 for example.
#
#
#########################################
#					#
# 	SETUP configuration values	#
#					#
#########################################

# WIMS source directory on the localhost.
# You do not need to change these two lines if this script is in
# the directory of the downloaded source.
# wimssrc=/var/wims/download
wimssrc=`dirname $0`

# Remote WIMS source address (http on wims.unice.fr)
wimsurl=http://wims.unice.fr/download

#########################################
#					#
# 	END of setup section		#
#					#
#########################################

wget=`which wget 2>/dev/null`
if [ -z "$wget" ]; then
 echo wget unavailable. >&2
 exit 1
fi

wgetopts="-e robots=off -m -l1 -nd -t10 -nH --no-parent -o wget.log"
cd $wimssrc
test=`cat ../public_html/bases/site/.rpm 2>/dev/null`
if [ ! -z "$test" ]; then
 $wget $wgetopts $wimsurl/rpms/
else
 $wget $wgetopts $wimsurl/wims/
fi

rm -f '?'* 2>/dev/null

