#!/bin/ksh

LOCK=/tmp/rsync.lock
SYSTEM=`hostname`

SOURCE=content.example.com::content/htdocs/
DEST=/httpd/content
HTTPD_PID=`cat /etc/httpd/run/httpd.pid`

if [ -f $LOCK ]; then
        echo "Rsync failed on ${SYSTEM} -- lock in place."
        exit
fi

touch $LOCK
rsync -r --delete $SOURCE $DEST

if [ $! -eq 1 ]; then
        echo "Rsync failed on ${SYSTEM} -- please check manually."
        exit
fi

kill -HUP $HTTPD_PID
rm -f $LOCK

echo "Rsync succeeded on ${SYSTEM}."