From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Date: Wed, 28 Apr 2004 17:01:21 +0300 From: Michael Shigorin To: devel@altlinux.ru Message-ID: <20040428140120.GX26609@osdn.org.ua> Mail-Followup-To: devel@altlinux.ru References: <200404281637.39984.ngrechukh@ua.fm> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="iwjEIfU64POCkTAH" Content-Disposition: inline In-Reply-To: <200404281637.39984.ngrechukh@ua.fm> User-Agent: Mutt/1.4.1i Subject: [devel] Re: sis mirroring script X-BeenThere: devel@altlinux.ru X-Mailman-Version: 2.1.4 Precedence: list Reply-To: ALT Devel discussion list List-Id: ALT Devel discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 28 Apr 2004 14:01:23 -0000 Archived-At: List-Archive: List-Post: --iwjEIfU64POCkTAH Content-Type: multipart/mixed; boundary="KSyhVCl2eeZHT0Rn" Content-Disposition: inline Content-Transfer-Encoding: 8bit --KSyhVCl2eeZHT0Rn Content-Type: text/plain; charset=koi8-r Content-Disposition: inline Content-Transfer-Encoding: 8bit On Wed, Apr 28, 2004 at 04:37:37PM +0300, Nick S. Grechukh wrote: > вот похвастаюсь :-) исходники: две кружки кофе и 20 минут. Ууу.... rsync(1) видели? ;-) -- ---- WBR, Michael Shigorin ------ Linux.Kiev http://www.linux.kiev.ua/ --KSyhVCl2eeZHT0Rn Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="daily-rsync.sh" #!/bin/sh # script by Michael Shigorin for snapshotting # ALT Linux Sisyphus locally; feel free to use and modify, would # be glad to hear back about changes # mirror/site-specific SRC="ftp.altlinux.org.ua::ALTLinux/Sisyphus/" BASEDIR="/var/ftp/pub/EMT/Sisyphus/" # retry params MAXCOUNT=5 TIMEOUT=60 # shouldn't need to be changed DATE=`date +%Y%m%d` LOGDIR="$BASEDIR/log/" LOGFILE="$LOGDIR/$DATE.log" DEST="$BASEDIR/.syncing/" RSYNCARGS="-av --partial --delete" RPMARGS="-qp --queryformat %{RELEASE}\n" TAGFILE="$DEST/files/i586/RPMS/altlinux-release-Sisyphus-alt*.noarch.rpm" unset OK # init env mkdir -p "$BASEDIR" "$LOGDIR" cd "$BASEDIR" # create hardlinked copy or init dir; order critical LAST=`ls -d1 20?????? 2>/dev/null | tail -1` rm -rf "$DEST" [ -n "$LAST" ] && cp -al "$LAST" "$DEST" || mkdir -p "$DEST" # try to sync up for attempt in `seq 1 $MAXCOUNT`; do rsync $RSYNCARGS "$SRC" "$DEST" 2>&1 >> "$LOGFILE" && { OK="yes" break } sleep "$TIMEOUT" done [ -z "$OK" ] && exit 1 # get timestamp from specific package and move to it TIMESTAMP=`rpm $RPMARGS $TAGFILE | tail -1 | sed 's/alt//'` [ ! -d "$TIMESTAMP" ] && { mv "$DEST" "$TIMESTAMP" touch -d "$DATE" "$TIMESTAMP" # fix symlink rm -f current ln -s "$TIMESTAMP" current } || rm -rf "$DEST" # that's all :) echo "** $TIMESTAMP sync OK" >> "$LOGFILE" --KSyhVCl2eeZHT0Rn Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="rsync-all.sh" #!/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 Mozilla OpenOffice Daedalus" LIST="updates Sisyphus Mozilla Daedalus" #LIST="updates" RSYNC=/usr/bin/rsync RSYNCARGS="-rltgoDuz --partial --timeout=$TMOUT1 --delete --delete-after" #RSYNCARGS="-rltgoDuz --partial --timeout=$TMOUT1 --delete " 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 $FLAG } rm -f $LOCK date >> $LOG done nice symlinks -dr $DESTROOT >/dev/null --KSyhVCl2eeZHT0Rn-- --iwjEIfU64POCkTAH Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.1 (GNU/Linux) iD8DBQFAj7kwbsPDprYMm3IRAp1yAJ9Mb7Y10GAEHwymxpOIYhcy/xQqwACgpFaL Weosm9z5DWyTrRZ+nz4GRAU= =rrnb -----END PGP SIGNATURE----- --iwjEIfU64POCkTAH--