#!/bin/bash

PATH=/usr/bin:/bin
RSYNC_ND="rsync -Havz --contimeout=60"
RSYNC="$RSYNC_ND --delete --delete-excluded"
CENTOS="rsync://mirror.nsc.liu.se/CentOS/"
EPEL="rsync://mirror.nsc.liu.se/fedora-epel/"
BASEDIR="/pub"
LOCKFILE="/pub/logs/rsync.lock"

cd $BASEDIR

PID=`cat $LOCKFILE 2>/dev/null`
EXE=`readlink /proc/$PID/exe 2>/dev/null`
test "$EXE" = /bin/bash && exit 1
echo $$ > $LOCKFILE

$RSYNC $CENTOS CentOS --exclude-from=excludes/centos.excludes
$RSYNC $EPEL epel --exclude-from=excludes/epel.excludes

rm -f $LOCKFILE
