6 TO=$TOP_DIR/root/debian-cd
7 RSYNC_HOST=cdimage.debian.org
9 LOGDIR=/var/log/mirror/debian-cd_cdimage.debian.org
14 # LOCK_TIMEOUT is a timeout in minutes. Defaults to 360 (6 hours).
15 # This program creates a lock to ensure that only one copy
16 # of it is mirroring any one archive at any one time.
17 # Locks held for longer than the timeout are broken, unless
18 # a running rsync process appears to be connected to $RSYNC_HOST.
22 # There should be no need to edit anything below this point, unless there
25 #-----------------------------------------------------------------------------#
27 # If you are accessing a rsync server/module which is password-protected,
28 # uncomment the following lines (and edit the other file).
32 if [[ "$RSYNC_USER" != "" ]]; then
33 RSYNC_HOST=$RSYNC_USER@$RSYNC_HOST
36 #-----------------------------------------------------------------------------#
38 # Check for some environment variables
39 if [ -z $TO ] || [ -z $RSYNC_HOST ] || [ -z $RSYNC_DIR ] || [ -z $LOGDIR ]; then
40 echo "One of the following variables seems to be empty:"
41 echo "TO, RSYNC_HOST, RSYNC_DIR or LOGDIR"
45 # Note: on some non-Debian systems, hostname doesn't accept -f option.
46 # If that's the case on your system, make sure hostname prints the full
47 # hostname, and remove the -f option. If there's no hostname command,
48 # explicitly replace `hostname -f` with the hostname.
50 HOSTNAME=`hostname -f`
52 # The hostname must match the "Site" field written in the list of mirrors.
53 # If hostname doesn't returns the correct value, fill and uncomment below
54 HOSTNAME=mirror.csclub.uwaterloo.ca
56 LOCK="${TO}/Archive-Update-in-Progress-${HOSTNAME}"
58 # The temp directory used by rsync --delay-updates is not
59 # world-readable remotely. It must be excluded to avoid errors.
60 TMP_EXCLUDE="--exclude .~tmp~/"
63 LOGFILE=$LOGDIR/mirror.log
65 # Get in the right directory and set the umask to be group writable
70 # Check to see if another sync is in progress
71 if [ -f "$LOCK" ]; then
72 # Note: this requires the findutils find; for other finds, adjust as necessary
73 if [ "`find $LOCK -maxdepth 1 -amin -$LOCK_TIMEOUT`" = "" ]; then
74 # Note: this requires the procps ps; for other ps', adjust as necessary
75 if ps ax | grep '[r]'sync | grep -q $RSYNC_HOST; then
76 echo "stale lock found, but a rsync is still running, aiee!" >&2
79 echo "stale lock found (not accessed in the last $LOCK_TIMEOUT minutes), forcing update!"
83 echo "current lock file exists, unable to start rsync!"
89 # Note: on some non-Debian systems, trap doesn't accept "exit" as signal
90 # specification. If that's the case on your system, try using "0".
91 trap "rm -f $LOCK" exit
95 # Now sync the remaining stuff
96 nice rsync -rlHtv --delete \
97 --include='*-businesscard.iso' \
98 --include='*-netinst.iso' \
99 --include='*-CD-1.iso' \
100 --include='*-amd64-DVD-1.iso' \
101 --include='*-i386-DVD-1.iso' \
102 --exclude='*.iso' --timeout=3600 -4 --address=$ADDRESS $TMP_EXCLUDE \
103 --exclude "Archive-Update-in-Progress-${HOSTNAME}" \
104 $RSYNC_HOST::$RSYNC_DIR $TO >> $LOGFILE 2>&1
105 if [[ "$?" != "0" ]]; then
106 echo "ERROR: Help, something weird happened" | tee -a $LOGFILE
107 echo "mirroring /pool exited with exitcode" $result | tee -a $LOGFILE
110 savelog $LOGFILE >/dev/null