[CentOS-mirror] Cron Script
Brian Elliott Finley
finley at anl.gov
Mon Dec 18 16:15:36 UTC 2006
Have a look at these, modify as appropriate.
-Brian
David Stanford wrote:
> Hello,
>
> Would somebody be kind enough to provide me with a cron script using a
> lock
> file for updating via rsync. I'd rather not have to reinvent the wheel...
>
> Thanks!
>
> -David
> ------------------------------------------------------------------------
>
> _______________________________________________
> CentOS-mirror mailing list
> CentOS-mirror at centos.org
> http://lists.centos.org/mailman/listinfo/centos-mirror
>
--
Brian Elliott Finley
Linux Strategist, CIS
Desk: 630.252.4742
Cell: 630.631.6621
-------------- next part --------------
#!/bin/sh
#
# $Id: mirror.centos 141 2006-10-04 17:28:41Z finley $
#
# 2005.02.09 Brian Elliott Finley
# - created
# 2005.06.21 Brian Elliott Finley
# - refined
#
. /opt/alpaca-farm/lib/functions
. /opt/alpaca-farm/lib/variables
#
# WARNING!!! Be _sure_ to set DEST first. So's that you don't accidentally
# overwrite a good mirror, eh?
#
# Uncomment these two, and change, if using a password.
# RSYNC_USER="bogus_user@"
# OPTS="$OPTS --password-file /home/mirror/CHANGE_ME.passwd"
DEST=`/opt/alpaca-farm/bin/which_nfs_mount_point centos`
SOURCE="${RSYNC_USER}msync.centos.org::CentOS"
# SOURCE="rsync://${RSYNC_USER}masterdistfiles.bogus.org/bogus"
lock_it
echo rsync $OPTS $SOURCE/ $DEST/
rsync $OPTS $SOURCE/ $DEST/ && stamp_it_good || stamp_it_bad
hardlink_identical_files
unlock_it
-------------- next part --------------
#
# $Id: functions,v 1.3 2005/07/20 22:21:08 finley Exp $
#
# 2005.06.29 Brian Elliott Finley
# - add stamp_it_bad
# 2005.07.20 Brian Elliott Finley
# - add lock_it and unlock_it
# 2006.02.27 Brian Elliott Finley
# - remove stamp.bad if stamping good
#
hardlink_identical_files() {
/opt/alpaca-farm/bin/hardlink.py -v 0 $DEST
}
stamp_it_good() {
echo stamp_it_good
echo "Last update succeeded on `hostname -f` at: `date`" > $DEST/SYNC_STAMP.txt
rm -f $DEST/SYNC_STAMP.bad.txt
unlock_it
}
stamp_it_bad() {
echo stamp_it_bad
echo "Last update failed on `hostname -f` at: `date`" > $DEST/SYNC_STAMP.bad.txt
unlock_it
}
lock_it() {
local lockdir="/opt/alpaca-farm/lock"
local progname=`basename $0`
local lockfile="$lockdir/$progname"
# if lockfile exists, and is in the process table
if [ -e $lockfile ]; then
if [ -e /proc/`cat $lockfile` ]; then
echo "I'm already running. Exiting cleanly."
exit 0
fi
fi
echo $$ > $lockfile
echo "Sync started on `hostname -f` at: `date`" > $DEST/SYNC_IN_PROGRESS.txt
}
unlock_it() {
rm -f $DEST/SYNC_IN_PROGRESS.txt
local lockdir="/opt/alpaca-farm/lock"
local progname=`basename $0`
local lockfile="$lockdir/$progname"
rm -f $lockfile
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: hardlink.py
Type: text/x-python
Size: 16410 bytes
Desc: not available
Url : http://lists.centos.org/pipermail/centos-mirror/attachments/20061218/394f92c0/hardlink.py
More information about the CentOS-mirror
mailing list