#!/bin/bash # On Solaris you might need to change the line above to: #!/usr/bin/bash # ch.indymedia.org fast mirror pull script # See also: # - http://docs.indymedia.org/view/Sysadmin/MirrorHowTo # this script assumes the rsync base address is # rsync://$RSYNC_SERVER/$SITE # On Solaris you need to set the paths # there seems to be no for this on Linux... #PATH="/usr/local/gcc-2.95.3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/usr/ccs/bin:/usr/ucb" #LD_LIBRARY_PATH="/usr/local/gcc-2.95.3/lib:/usr/local/lib:/usr/local/lib/mysql:/usr/lib" # this script uses lockfile which comes with procmail # for file locking: apt-get install procmail LOCKFILE_BINARY="/usr/bin/lockfile" # test if the lockfile binary can be found if [ ! -e "$LOCKFILE_BINARY" ] then echo "$LOCKFILE_BINARY not found, please install the procmail package." echo "On a Debian server running 'apt-get install procmail' should do " echo "the trick, on a Fedora server 'yum install procmail', for other " echo "distros please consult your sysadmin. " echo "" echo "If you do have procmail installed then please set the " echo "LOCKFILE_BINARY variable to point to the location of the lockfile " echo "binary. " else # the site we are getting SITE="ch.indymedia.org" # the rsync server we are using # rsync.indymedia.org.uk is the primary server, for initial updates please # use the secondary server, rsync2.indymedia.org.uk RSYNC_SERVER="rsync.ch.indymedia.org" # set this to the location of the mirror on your filesystem DESTINATION_BASE="/var/www/$SITE" # check that we have write perms for the site if [ ! -w "$DESTINATION_BASE" ] then echo "$DESTINATION_BASE needs to be writable by you." else # the user running this script needs to have # write permissions for the lockfile LOCKFILE="$HOME/`basename $0`.$SITE.lock" # if the $LOCKFILE exists then exit # the lockfile is read only # the timeout is set to 2 hours (7200 secs) # if the lockfile is older than this it will be # removed $LOCKFILE_BINARY -r 1 -l 7200 $LOCKFILE || exit 23 # check that the lock file is writable echo "Starting a fast sync for $SITE from $RSYNC_SERVER"; echo # our rsync command RSYNC="/usr/bin/rsync --timeout=360 -CLrptzvu" # exclude the tmp directory EXCLUDE_TMP=" --exclude=tmp" # exclude thinsg that are not often updated for a in img en rtsp do EXCLUDE_STATIC="$EXCLUDE_STATIC --exclude=$a" done # topic excludes for a in anticapglob antifa chiapas eco fem g8 guerre logement medias press \ repression sanspap trash war wef do for b in de demix fr frmix it itmix do EXCLUDE_TOPICS="$EXCLUDE_TOPICS --exclude=$b/$a" done done # generate exclude lists for past years THIS_YEAR=`date +%Y` LAST_YEAR=`expr $THIS_YEAR - 1` i=$LAST_YEAR while [ $i -gt 1999 ] do # media content for a in icon images media do EXCLUDE_YEARS="$EXCLUDE_YEARS --exclude=$a/$i" done # lang files for a in de demix fr frmix it itmix do EXCLUDE_YEARS="$EXCLUDE_YEARS --exclude=$a/$i" done i=`expr $i - 1` done # generate exclude lists for months in this year THIS_MONTH=`date +%m` LAST_MONTH=`expr $THIS_MONTH - 1` i=$LAST_MONTH while [ $i -gt 0 ] do # if the month has a single digit if [ $LAST_MONTH -lt 10 ]; then # media content for a in icon images media do EXCLUDE_MONTHS="$EXCLUDE_MONTHS --exclude=$a/$THIS_YEAR/0$i" done # lang files for a in de demix fr frmix it itmix do EXCLUDE_MONTHS="$EXCLUDE_MONTHS --exclude=$a/$THIS_YEAR/0$i" done else # media content for a in icon images media do EXCLUDE_MONTHS="$EXCLUDE_MONTHS --exclude=$a/$THIS_YEAR/$i" done # lang files for a in de demix fr frmix it itmix do EXCLUDE_MONTHS="$EXCLUDE_MONTHS --exclude=$a/$THIS_YEAR/$i" done fi i=`expr $i - 1` done # lets do some stuff echo ${RSYNC} ${EXCLUDE_TMP} ${EXCLUDE_STATIC} ${EXCLUDE_TOPICS} \ ${EXCLUDE_YEARS} ${EXCLUDE_MONTHS} \ rsync://${RSYNC_SERVER}/${SITE}/ ${DESTINATION_BASE}/ # delete the lockfile rm -vf $LOCKFILE fi fi