#30 Add option to check in to MM with an external command
Opened 5 years ago by adamwill. Modified 4 years ago
adamwill/quick-fedora-mirror report-mirror  into  master

file modified
+17
@@ -107,6 +107,7 @@ 

      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 @@ 

      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.

file modified
+12 -1
@@ -64,7 +64,8 @@ 

  # 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 @@ 

  # 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

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.

rebased

5 years ago