# This script should be sourced, not run.
# REBASE UPDATE. Should be run just after the beginning of the month.
set mirrors_dir=('/ftp/mirrors')
set oldpwd=`pwd`

cd $mirrors_dir

if ( ` wget -m 'ftp://ftp.ebi.ac.uk/pub/databases/rebase/*' |&amp; \
  tail -1 | awk '/^Downloaded:/{print $5}'` != "0" ) then 
	cd ftp.ebi.ac.uk/pub/databases/rebase
	cp `ls -t withrefm.*.Z|head -1` withrefm.Z
	cp `ls -t proto.*.Z|head -1` proto.Z
	uncompress withrefm.Z
        uncompress proto.Z
	rebaseextract \
  ${mirrors_dir}/ftp.ebi.ac.uk/pub/databases/rebase/withrefm \
  ${mirrors_dir}/ftp.ebi.ac.uk/pub/databases/rebase/proto 
	rm -f withrefm
	rm -f proto
endif 

cd $oldpwd
