mirrormanager2: change umdl-required script

The umdl-required script used to query the message bus if there have
been changes on the master mirror. With the new stat()-less umdl
implementation the message bus is no longer queried but only the ctime
of the fullfiletimelist-* is checked to see if it has changed since the
last run.

Signed-off-by: Adrian Reber <adrian@lisas.de>
This commit is contained in:
Adrian Reber 2017-06-18 17:14:21 +02:00
parent 1554e47a10
commit 809bb3f2ce

View file

@ -9,45 +9,44 @@ exec >> $2
exec 2>&1 exec 2>&1
CURDATE=`date +%s` CURDATE=`date +%s`
LAST_SYNC_ARG=""
ALWAYS_RUN=false
if [ "${1}" == "Linux" ]; then
LAST_SYNC_ARG="-f -r" if [ "${1}" == "fedora" ]; then
CATEGORY="${1}" CATEGORY="Linux"
elif [ "${1}" == "EPEL" ]; then elif [ "${1}" == "epel" ]; then
LAST_SYNC_ARG="-e" CATEGORY="EPEL"
CATEGORY="${1}" elif [ "${1}" == "alt" ]; then
elif [ "${1}" == "Secondary" ]; then CATEGORY="Other"
LAST_SYNC_ARG="-s" elif [ "${1}" == "fedora-secondary" ]; then
CATEGORY="Secondary Arches" CATEGORY="Secondary Arches"
# Skipping umdl check since we have no notifs for secondary elif [ "${1}" == "archive" ]; then
ALWAYS_RUN=true CATEGORY="Archive"
fi
if [ "${LAST_SYNC_ARG}" == "" ]; then
echo "Category is either Linux or EPEL"
exit 1
fi fi
if [ -e /var/run/mirrormanager/umdl-${1} ]; then if [ -e /var/run/mirrormanager/umdl-${1} ]; then
. /var/run/mirrormanager/umdl-${1} . /var/run/mirrormanager/umdl-${1}
else else
# 48 hours -> 172800 seconds # 24 hours -> 86400 seconds
let LASTRUN=CURDATE-172800 let LASTRUN=CURDATE-86400
fi fi
let DELTA=CURDATE-LASTRUN # FULLFILETIMELIST -> FFTL
FFTL="/srv/pub/${1}/fullfiletimelist-${1}"
/usr/local/bin/last-sync -d ${DELTA} -q ${LAST_SYNC_ARG} FILEDATE=`stat -c %Z ${FFTL} 2> /dev/null`
if [ "$?" -ne "0" -a "$ALWAYS_RUN" = false ]; then if [ "$?" -eq "1" ]; then
echo "Error stat() of ${FFTL} failed. This should not happen."
exit 1
fi
if [ "$LASTRUN" -gt "$FILEDATE" ]; then
# no changes on the master mirror # no changes on the master mirror
# abort # abort
exit 0 exit 0
fi fi
echo -n "Last sync more than ${DELTA} seconds ago. Running umdl for Fedora ${CATEGORY} at " echo -n "${FFTL} has changed since last run. Running umdl for Fedora ${CATEGORY} at "
date date
/usr/local/bin/lock-wrapper umdl-${1} "/usr/bin/mm2_update-master-directory-list --category \"Fedora ${CATEGORY}\"" /usr/local/bin/lock-wrapper umdl-${1} "/usr/bin/mm2_update-master-directory-list --category \"Fedora ${CATEGORY}\""