openmamba-headserver-tools/etc/cron.hourly/40-openmamba-rsync

79 lines
2.3 KiB
Plaintext
Raw Normal View History

2012-03-12 15:18:41 +01:00
#!/bin/bash
#
# openmamba rsync script
#
. /etc/sysconfig/openmamba-central
#BWLIMIT="--bwlimit=400"
TIMEOUT="--timeout=120"
[ "$1" ] && JOB=$1 || unset JOB
[ "$dest_rsync" ] || exit 0
[ "`pidof rsync`" -a ! "$FORCE" -a ! "$JOB" ] && {
echo "Error: an rsync process is already running; exiting for safety."
exit 1
}
# use ssh method if dest_ssh is defined
[ "$dest_ssh" ] && dest_rsync=$dest_ssh
RSYNC_OPT="-av -P --no-o --delete-after \
$BWLIMIT $TIMEOUT"
[ "$PROGRESS" = "1" ] && RSYNC_OPT="$RSYNC_OPT --progress"
#echo rsync $RSYNC_OPT /var/ftp/pub/openmamba/ $RSYNC_DEST --password-file=/etc/rsync.password
if [ ! "$JOB" -o "$JOB" = "distromatic" ]; then
echo "==> Syncing distromatic directory"
eval rsync \
$RSYNC_OPT \
$local_ftp/distromatic $dest_rsync \
--exclude distromatic/devel* \
--exclude distromatic/milestone*
fi
for rep in ${local_reps[*]}; do
if [ ! "$JOB" -o "$JOB" = "$rep" ]; then
echo "==> Syncing $rep local repository"
eval rsync \
$RSYNC_OPT --exclude base --exclude media --exclude "*/developers-status.inc" \
$local_ftp/$rep $dest_rsync \
--exclude "*/old"
if [ $? -eq 0 -a -d $local_ftp/$rep/base ]; then
echo "==> Syncing apt for $rep local repository"
eval rsync \
$RSYNC_OPT $local_ftp/$rep/base $dest_rsync/$rep
echo "==> Syncing distromatic directory for $rep local repository"
eval rsync \
$RSYNC_OPT \
$local_ftp/distromatic/$rep $dest_rsync/distromatic
fi
if [ -d $local_ftp/$rep/media ]; then
echo "==> Syncing media directory for $rep local repository"
eval rsync \
$RSYNC_OPT $local_ftp/$rep/media \
--exclude "*/old" --exclude "*/downloads.inc"\
$dest_rsync/$rep
fi
fi
done
for rep in ${remote_reps[*]}; do
if [ ! "$JOB" -o "$JOB" = "$rep" ]; then
echo "==> Syncing $rep remote repository"
eval rsync \
$RSYNC_OPT \
$local_ftp/$rep $dest_rsync \
--exclude $rep/SRPMS.base \
--exclude "$rep/RPMS.*" \
--exclude $rep/home \
--exclude $rep/autoupdate \
--exclude $rep/old
echo "==> Syncing distromatic directory for $rep local repository"
eval rsync \
$RSYNC_OPT \
$local_ftp/distromatic/$rep $dest_rsync/distromatic
fi
done