ansible/files/download/sync-up-downloads.sh.cc-rdu01
Stephen Smoogen 618bd95cf4 syncronize the ib01 and rdu01 download scripts to be more in line. This may not work but we can try
Signed-off-by: Stephen Smoogen <ssmoogen@redhat.com>
2021-09-30 15:14:07 -04:00

67 lines
2.1 KiB
Bash
Executable file

#!/bin/bash
##
## This script is used to sync data from main download servers to
## secondary server at RDU community cage.
##
RSYNC='/usr/bin/rsync'
RS_OPT="-avSHP --numeric-ids --log-file=/var/log/rsync-update.log"
RS_DEADLY="--delete --delete-excluded --delete-delay --delay-updates"
ALT_EXCLUDES=""
EPL_EXCLUDES=""
FED_EXCLUDES=""
SERVER=download-ib01.fedoraproject.org
function sync_stuff() {
if [[ $# -ne 5 ]]; then
echo "Illegal number of arguments to sync_stuff: " $#
exit 1
fi
DATE_FILE=$1
LOGGER_NAME=$2
RSYNC_FROM=$3
RSYNC_TO=$4
FLAG="$5"
CURDATE=$( date +%s )
if [[ -s ${DATE_FILE} ]]; then
LASTRUN=$( cat ${DATE_FILE} | awk '{print int($NF)}' )
else
LASTRUN=$( date +%s --date="Jan 1 00:00:00 UTC 2007" )
fi
DELTA=`echo ${CURDATE}-${LASTRUN} | bc`
${LAST_SYNC} -d ${DELTA} -q ${FLAG}
if [ "$?" -eq "0" ]; then
${RSYNC} ${RS_OPT} ${RS_DEADLY} ${ALT_EXCLUDES} ${SERVER}::${RSYNC_FROM} ${RSYNC_TO} | tail -n2 | logger -p local0.notice -t ${LOGGER_NAME}
echo ${CURDATE} > ${DATE_FILE}
else
logger -p local0.notice -t ${LOGGER_NAME} "No change found. Not syncing"
fi
}
sync_stuff ${DATE_EPEL} rsync_epel fedora-epel0 /srv/pub/epel/ "-e"
sync_stuff ${DATE_FED} rsync_fedora fedora-enchilada0 /srv/pub/fedora/ "-f"
sync_stuff ${DATE_SECOND} rsync_second fedora-secondary0 /srv/pub/fedora-secondary/ "-f"
# CentOS
${RSYNC} ${RS_OPT} ${RS_DEADLY} master-1.centos.org::CentOS-community-cage/centos/ /srv/pub/centos/ | tail -n2 | logger -p local0.notice -t rsync_centos
if [[ $? -ne 0 ]]; then
echo "Unable to finish sync to CentOS"
fi
# CentOS-altarch
${RSYNC} ${RS_OPT} ${RS_DEADLY} master-1.centos.org::CentOS-community-cage/altarch/ /srv/pub/centos-altarch/ | tail -n2 | logger -p local0.notice -t rsync_centos_alt
if [[ $? -ne 0 ]]; then
echo "Unable to finish sync to CentOS-altarch"
fi
${RSYNC} ${RS_OPT} ${RS_DEADLY} rsync.stream.centos.org::CentOS-Stream-All/ /srv/pub/centos-stream/ | tail -n2 | logger -p local0.notice -t rsync_centos_stream
if [[ $? -ne 0 ]]; then
echo "Unable to finish sync to CentOS-stream"
fi
# Let MM know I'm all up to date
#/usr/bin/report_mirror