From 8467cc13b7f185e0350d4437dcea0533014e9c30 Mon Sep 17 00:00:00 2001 From: Adam Williamson Date: Nov 29 2016 01:58:41 +0000 Subject: Add option to check in to MM with an external command Since the internal checkin code isn't baked yet, let's allow people to use an external command (i.e. report_mirror) to check in. This is better than just calling report_mirror after q-f-m from your cron job because that would run the (rather heavy) directory scrape and checkin process even if there were no changes. q-f-m exits earlier than this if there are no changes, so it will only check in if there are changes. --- diff --git a/quick-fedora-mirror b/quick-fedora-mirror index 3b57a7e..9a55709 100755 --- a/quick-fedora-mirror +++ b/quick-fedora-mirror @@ -107,6 +107,7 @@ do_rsync () { flopts=(--files-from=$files) while true; do + # ZSHISM: with bash, $RSYNC $RSYNCOPTS will only pass the first item in $RSYNCOPTS to $RSYNC # ZSHISM: (P) flag to act on a variable by name. Sadly, bash has # broken array handling. bash 4.3 has local -n for this. Older bash # needs hacks, or eval. More info: @@ -761,6 +762,22 @@ else finish fi +# External executable checkin +# =========================== +# Check in with external executable if requested via config. +if [[ -z $EXT_CHECKIN || -n $skipcheckin ]]; then + db4 external executable checkin not requested +else + db2 Performing external executable checkin + db3 Calling $EXT_CHECKIN $EXT_CHECKIN_OPTS + # ZSHISM: with bash, this will only pass the first item in $EXT_CHECKIN_OPTS to $EXT_CHECKIN + $EXT_CHECKIN $EXT_CHECKIN_OPTS + rvbash="${PIPESTATUS[0]}" rvzsh="${pipestatus[1]}" rr=$rvbash$rvzsh + if (( rr > 0 )); then + (>&2 echo Error running external checkin $EXT_CHECKIN $EXT_CHECKIN_OPTS) + fi +fi + # Mirrormanager Checkin # ===================== # At this point we know that we had a clean run with no complaints from rsync. diff --git a/quick-fedora-mirror.conf.dist b/quick-fedora-mirror.conf.dist index b198846..7985db4 100644 --- a/quick-fedora-mirror.conf.dist +++ b/quick-fedora-mirror.conf.dist @@ -64,7 +64,8 @@ TIMEFILE= # KEEPDIRTIMES= # DEFINE CHECKIN_SITE and CHECKIN_PASSWORD to perform a mirrormanager checkin -# at the completion of the run if rsync succeeded without error. +# at the completion of the run if there were any changes and rsync succeeded +# without error. # CHECKIN_HOST will default to the output of the hostname command. Set it if necessary. # This requires that "curl" be installed; see CURL above if it's not in /usr/bin. # Note: Not yet implemented; mirrormanager does not yet support this. @@ -72,6 +73,16 @@ TIMEFILE= # CHECKIN_PASSWORD= # CHECKIN_HOST= +# Define to the executable location to perform a mirror manager checkin by +# calling an external executable (usually report_mirror) at the completion of +# the run if there were any changes and rsync succeeded without error. Until +# q-f-m's own checkin code is baked, you might need this! +# EXT_CHECKIN=/usr/bin/report_mirror + +# If you need to pass any options to the external checkin executable, you can +# specify them here as an array. +# EXT_CHECKIN_OPTS=(--config=/config/file --exclude-from=/exclude/file) + # Verbosity levels - info sent to stdout; usually this gets mailed to root when # being run by cron # 0 - quiet