ansible/files/download/sync-up-downloads.sh.ib01

72 lines
1.8 KiB
Text
Raw Normal View History

2016-02-26 18:01:10 +00:00
#!/bin/bash
##
## This script is used to sync data from main download servers to
## secondary server at ibiblio.
##
RSYNC='/usr/bin/rsync'
RS_OPT="-avSHP --numeric-ids"
RS_DEADLY="--delete --delete-excluded --delete-delay --delay-updates"
ALT_EXCLUDES=""
EPL_EXCLUDES=""
FED_EXCLUDES=""
DATE_EPEL='/root/last-epel-sync'
DATE_FED='/root/last-fed-sync'
touch ${DATE_EPEL}
touch ${DATE_FED}
LAST_SYNC='/usr/local/bin/last-sync'
2016-02-26 18:01:10 +00:00
SERVER=dl.fedoraproject.org
## Do the EPEL download if we have had a sync since the last update.
CURDATE=`date +%s`
if [[ -s ${DATE_EPEL} ]]; then
LASTRUN=$( cat DATE_EPEL | awk '{print int($NF)}' )
else
LASTRUN=$( date +%s --date="Jan 1 00:00:00 UTC 2007" )
fi
DELTA=`echo ${CURDATE}-${LASTRUN} | bc`
2016-04-06 16:06:27 +00:00
${LAST_SYNC} -d ${DELTA} -q
if [ "$?" -eq "0" ]; then
# EPEL
${RSYNC} ${RS_OPT} ${RS_DEADLY} ${ALT_EXCLUDES} ${SERVER}::fedora-epel0/ /srv/pub/epel/ | tail -n2 | logger -p local0.notice -t rsync_epel
echo ${CURDATE} > ${DATE_EPEL}
else
logger -p local0.notice -t rsync_epel "No change found. Not syncing"
fi
2016-04-06 16:06:27 +00:00
#######
####### CODE REUSE ALERT. THIS NEEDS TO BE A SUBROUTINE YOU SILLY
## Do the FEDORA download if we have had a sync since the last update.
CURDATE=`date +%s`
if [[ -s ${DATE_FED} ]]; then
LASTRUN=$( cat DATE_FED | awk '{print int($NF)}' )
else
LASTRUN=$( date +%s --date="Jan 1 00:00:00 UTC 2007" )
fi
DELTA=`echo ${CURDATE}-${LASTRUN} | bc`
2016-04-06 16:06:27 +00:00
${LAST_SYNC} -d ${DELTA} -q
if [ "$?" -eq "0" ]; then
# Enchilada
${RSYNC} ${RS_OPT} ${RS_DEADLY} ${ALT_EXCLUDES} ${SERVER}::fedora-enchilada0/ /srv/pub/fedora/ | tail -n2 | logger -p local0.notice -t rsync_fedora
echo ${CURDATE} > ${DATE_FED}
else
logger -p local0.notice -t rsync_fedora "No change found. Not syncing"
fi
2016-02-26 18:01:10 +00:00
# Let MM know I'm all up to date
#/usr/bin/report_mirror