openmamba-headserver-tools/etc/cron.hourly/50-openmamba-ftpsync

63 lines
1.8 KiB
Plaintext
Raw Permalink Normal View History

2012-03-12 15:18:41 +01:00
#!/bin/bash
#
# openmamba repository mirror script
# (c) 2006-2007 by Silvan Calarco <silvan.calarco@mambasoft.it>
#
. /etc/sysconfig/openmamba-central
[ "$ftpsync" ] || exit 0
[ "$dest_ftp" ] || exit 0
ftp_sync() {
err=9
start=`date +%s`
elapsed=0
while [ $err -eq 9 ] && [ $elapsed -lt 300 ]; do
ftpsync -q -p $1 $2 ftpuser=$ftpuser ftppasswd=$ftppass timeout=20
err=$?
now=`date +%s`
elapsed=`expr $now - $start`
[ $err -gt 0 ] && echo " Error: ftpsync exited with error $err"
done
return 0
}
for rep in ${remote_reps[*]}; do
echo "==> Working on $rep remote repository"
echo " Syncyng APT database"
ftp_sync $local_ftp/$rep/base/ $dest_ftp/pub/openmamba/$rep/base
echo " Syncing log files"
for a in $local_ftp/$rep/*log; do
curl -s -T $a -u$ftpuser:$ftppass --url $dest_ftp/pub/openmamba/$rep/
done
done
for rep in ${local_reps[*]}; do
echo "==> Working on $rep local repository"
for a in ${archs[*]}; do
err=1
start=`date +%s`
elapsed=0
echo " Syncing RPMs for arch $a"
ftp_sync $local_ftp/$rep/RPMS.$a/ $dest_ftp/pub/openmamba/$rep/RPMS.$a
done
echo " Syncing APT database"
ftp_sync $local_ftp/$rep/base/ $dest_ftp/pub/openmamba/$rep/base
echo " Syncing SRPMs repository"
ftp_sync $local_ftp/$rep/SRPMS.base/ $dest_ftp/pub/openmamba/$rep/SRPMS.base
echo " Syncing logs"
for a in $local_ftp/$rep/*log; do
curl -s -T $a -u$ftpuser:$ftppass --url $dest_ftp/pub/openmamba/$rep/
done
done
echo "==> Syncing distromatic"
ftpsync -q -p $local_distromatic $dest_ftp/pub/openmamba/distromatic ftpuser=$ftpuser ftppasswd=$ftppass timeout=20
echo "==> Syncing media directory for devel repository"
ftp_sync $local_ftp/devel/media/ $dest_ftp/pub/openmamba/devel/media timeout=20