Magic
This commit is contained in:
parent
47f3813ec1
commit
39c3b665ad
|
@ -5,10 +5,9 @@ if [[ $# < 3 ]]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
RSYNC="nice rsync"
|
||||
|
||||
set -e
|
||||
|
||||
RSYNC="rsync"
|
||||
TOP_DIR=/mirror
|
||||
TO=$TOP_DIR/root/$1
|
||||
RSYNC_HOST=$2
|
||||
|
@ -223,7 +222,7 @@ fi
|
|||
# First sync /pool
|
||||
$RSYNC -rlHtv \
|
||||
$TMP_EXCLUDE $EXCLUDE $SOURCE_EXCLUDE \
|
||||
--address=$ADDRESS \
|
||||
--timeout=3600 --address=$ADDRESS \
|
||||
$RSYNC_HOST::$RSYNC_DIR/pool/ $TO/pool/ >> $LOGFILE 2>&1
|
||||
result=$?
|
||||
|
||||
|
@ -232,7 +231,7 @@ if [ 0 = $result ]; then
|
|||
$RSYNC -rlHtv --delay-updates --delete-after \
|
||||
--exclude "Archive-Update-in-Progress-${HOSTNAME}" \
|
||||
--exclude "${TRACE_DIR}/${HOSTNAME}" \
|
||||
--address=$ADDRESS \
|
||||
--timeout=3600 --address=$ADDRESS \
|
||||
$TMP_EXCLUDE $EXCLUDE $SOURCE_EXCLUDE \
|
||||
$RSYNC_HOST::$RSYNC_DIR $TO >> $LOGFILE 2>&1
|
||||
|
||||
|
|
|
@ -0,0 +1,109 @@
|
|||
#! /bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
RSYNC="rsync"
|
||||
TOP_DIR=/mirror
|
||||
TO=$TOP_DIR/root/debian-cd
|
||||
RSYNC_HOST=cdimage.debian.org
|
||||
RSYNC_DIR=debian-cd
|
||||
LOGDIR=/var/log/mirror/debian-cd_cdimage.debian.org
|
||||
ADDRESS=129.97.134.71
|
||||
|
||||
mkdir -p $LOGDIR
|
||||
|
||||
# LOCK_TIMEOUT is a timeout in minutes. Defaults to 360 (6 hours).
|
||||
# This program creates a lock to ensure that only one copy
|
||||
# of it is mirroring any one archive at any one time.
|
||||
# Locks held for longer than the timeout are broken, unless
|
||||
# a running rsync process appears to be connected to $RSYNC_HOST.
|
||||
|
||||
LOCK_TIMEOUT=360
|
||||
|
||||
# There should be no need to edit anything below this point, unless there
|
||||
# are problems.
|
||||
|
||||
#-----------------------------------------------------------------------------#
|
||||
|
||||
# If you are accessing a rsync server/module which is password-protected,
|
||||
# uncomment the following lines (and edit the other file).
|
||||
|
||||
# . ftpsync.conf
|
||||
export RSYNC_PASSWORD
|
||||
if [[ "$RSYNC_USER" != "" ]]; then
|
||||
RSYNC_HOST=$RSYNC_USER@$RSYNC_HOST
|
||||
fi
|
||||
|
||||
#-----------------------------------------------------------------------------#
|
||||
|
||||
# Check for some environment variables
|
||||
if [ -z $TO ] || [ -z $RSYNC_HOST ] || [ -z $RSYNC_DIR ] || [ -z $LOGDIR ]; then
|
||||
echo "One of the following variables seems to be empty:"
|
||||
echo "TO, RSYNC_HOST, RSYNC_DIR or LOGDIR"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
# Note: on some non-Debian systems, hostname doesn't accept -f option.
|
||||
# If that's the case on your system, make sure hostname prints the full
|
||||
# hostname, and remove the -f option. If there's no hostname command,
|
||||
# explicitly replace `hostname -f` with the hostname.
|
||||
|
||||
HOSTNAME=`hostname -f`
|
||||
|
||||
# The hostname must match the "Site" field written in the list of mirrors.
|
||||
# If hostname doesn't returns the correct value, fill and uncomment below
|
||||
HOSTNAME=mirror.csclub.uwaterloo.ca
|
||||
|
||||
LOCK="${TO}/Archive-Update-in-Progress-${HOSTNAME}"
|
||||
|
||||
# The temp directory used by rsync --delay-updates is not
|
||||
# world-readable remotely. It must be excluded to avoid errors.
|
||||
TMP_EXCLUDE="--exclude .~tmp~/"
|
||||
|
||||
# Logfile
|
||||
LOGFILE=$LOGDIR/mirror.log
|
||||
|
||||
# Get in the right directory and set the umask to be group writable
|
||||
#
|
||||
cd $HOME
|
||||
umask 002
|
||||
|
||||
# Check to see if another sync is in progress
|
||||
if [ -f "$LOCK" ]; then
|
||||
# Note: this requires the findutils find; for other finds, adjust as necessary
|
||||
if [ "`find $LOCK -maxdepth 1 -amin -$LOCK_TIMEOUT`" = "" ]; then
|
||||
# Note: this requires the procps ps; for other ps', adjust as necessary
|
||||
if ps ax | grep '[r]'sync | grep -q $RSYNC_HOST; then
|
||||
echo "stale lock found, but a rsync is still running, aiee!" > /dev/stderr
|
||||
exit 1
|
||||
else
|
||||
echo "stale lock found (not accessed in the last $LOCK_TIMEOUT minutes), forcing update!"
|
||||
rm -f $LOCK
|
||||
fi
|
||||
else
|
||||
echo "current lock file exists, unable to start rsync!"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
touch $LOCK
|
||||
# Note: on some non-Debian systems, trap doesn't accept "exit" as signal
|
||||
# specification. If that's the case on your system, try using "0".
|
||||
trap "rm -f $LOCK" exit
|
||||
|
||||
set +e
|
||||
|
||||
# Now sync the remaining stuff
|
||||
$RSYNC -rlHtv --delete \
|
||||
--include='*businesscard*.iso' --include='*netinst*.iso' \
|
||||
--exclude='*.iso' --timeout=3600 --address=$ADDRESS $TMP_EXCLUDE \
|
||||
--exclude "Archive-Update-in-Progress-${HOSTNAME}" \
|
||||
$RSYNC_HOST::$RSYNC_DIR $TO >> $LOGFILE 2>&1
|
||||
if [[ "$?" != "0" ]]; then
|
||||
echo "ERROR: Help, something weird happened" | tee -a $LOGFILE
|
||||
echo "mirroring /pool exited with exitcode" $result | tee -a $LOGFILE
|
||||
fi
|
||||
|
||||
savelog $LOGFILE >/dev/null
|
||||
|
||||
rm $LOCK
|
|
@ -7,6 +7,7 @@ fi
|
|||
|
||||
set -e
|
||||
|
||||
RSYNC="rsync"
|
||||
TOP_DIR=/mirror
|
||||
TO=$TOP_DIR/root/$1
|
||||
RSYNC_HOST=$2
|
||||
|
@ -98,9 +99,9 @@ trap "rm -f $LOCK" exit
|
|||
set +e
|
||||
|
||||
# Now sync the remaining stuff
|
||||
rsync -rlHtv --delete \
|
||||
$RSYNC -rlHtv --delete \
|
||||
--exclude "Archive-Update-in-Progress-${HOSTNAME}" \
|
||||
--address=$ADDRESS $TMP_EXCLUDE \
|
||||
--timeout=3600 --address=$ADDRESS $TMP_EXCLUDE \
|
||||
$RSYNC_HOST::$RSYNC_DIR $TO >> $LOGFILE 2>&1
|
||||
if [[ "$?" != "0" ]]; then
|
||||
echo "ERROR: Help, something weird happened" | tee -a $LOGFILE
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
#upload_rate = 0
|
||||
|
||||
# Default directory to save the downloaded torrents.
|
||||
directory = /www/files
|
||||
directory = /mirror/root/csclub
|
||||
|
||||
# Default session directory. Make sure you don't run multiple instance
|
||||
# of rtorrent using the same session directory. Perhaps using a
|
||||
|
|
Loading…
Reference in New Issue