#!/bin/sh # # Template mirror script (provided by Shaun on the centos-mirror list) # Minor changes to reflect some sanity and caosity by GMK. # # This is a nice script because it utilizes a lock so it won't cause > 1 # rsync process and hammer the master. # # Easiest way to run this is to copy locally, chmod +x it, and copy it to # /etc/cron.daily. LOCAL_COPY=/srv/caosity/ MIRROR=mirror.caosity.org::caosity RSYNC="/usr/bin/rsync -aHv --delete --delete-after" PIDFILE=/var/run/caosity-mirror.pid if [ ! -d "$LOCAL_COPY" ]; then mkdir -p $LOCAL_COPY fi if [ -f "$PIDFILE" ]; then RUNPID=`cat $PIDFILE` if ps -p $RUNPID; then echo "Mirror is already running..." exit 1 else echo "Mirror pid found but process dead, cleaning up" rm -f $PIDFILE fi else echo "No Mirror Process Detected" fi echo $$ > $PIDFILE echo -n "Mirror Started at: " date $RSYNC $MIRROR $LOCAL_COPY echo -n "Mirror Ended at: " date rm -f $PIDFILE