#!/bin/sh RSYNC_RSH=rsh MAXATTEMPTS=5 TMOUT1=500 TMOUT2=15 SRCROOT=rsync://rsync.altlinux.ru/ALTLinux # 2003-04-15 #SRCROOT=rsync://ibiblio.org/Linux/distributions/altlinux # 2002-12-07 #SRCROOT=rsync://ftp.leo.org/ALTLinux # 2002-12-09 DESTROOT=~ftp/pub/Linux/ALT #LIST="updates Sisyphus OpenOffice Mozilla" LIST="updates Sisyphus OpenOffice Mozilla" #LIST="updates" RSYNC=/usr/bin/rsync RSYNCARGS="-rltgoDu --partial --timeout=$TMOUT1 --delete --delete-after" RSHOME=~/rsync MAINTAINER=mike@osdn.org.ua for mirror in $LIST; do OK= attempt=1 LOG=$RSHOME/rsync-$mirror.log LOCK=$RSHOME/lock.$mirror FLAG=$DESTROOT/$mirror/__SYNCING__ date >> $LOG [ -f $LOCK ] && { ps auxww | grep rsync | mail -s "OSDN: $mirror: lockfile exists" $MAINTAINER echo "Lockfile for $mirror exists, quitting" >> $LOG continue } trap "rm -f $LOCK; exit 1" INT touch $LOCK $FLAG while [ -z "$OK" -a $attempt -lt $MAXATTEMPTS ]; do $RSYNC $RSYNCARGS $* $SRCROOT/$mirror/ $DESTROOT/$mirror \ >> $LOG 2>&1 && OK=1 sleep $TMOUT2 attempt=$(($attempt+1)) done [ -z "$OK" ] && { tail $LOG | mail -s "OSDN: $mirror trouble" $MAINTAINER rm -f $LOCK } || { rm -f $LOCK $FLAG } date >> $LOG done