From 24eb7740e28a6272d3ab971ee26a9156c46eca51 Mon Sep 17 00:00:00 2001 From: Zane Williams Date: Tue, 23 Nov 2021 17:52:40 +0100 Subject: [PATCH 1/4] Re-wording this paragraph after participating in a converstaion about the sync of the mirrors on 15-NOV-2021: (https://chat.rockylinux.org/rocky-linux/pl/x7nembesc78kpr3wpgkszzrygw) Inserting this in a unique commit in case this particular piece is not acceptable. --- mirror/mirrorsync.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/mirror/mirrorsync.sh b/mirror/mirrorsync.sh index ce11bed..31db4c3 100644 --- a/mirror/mirrorsync.sh +++ b/mirror/mirrorsync.sh @@ -35,10 +35,12 @@ # You can change v to q if you do not want detailed logging opts=(-vrlptDSH --exclude="*.~tmp~" --delete-delay --delay-updates) -# Please use a mirror next to you for initial sync -# or if you are hosting a private rather than a pulic mirror. -# Local mirrors might be faster. -# Also we might restrict access to the master in the future. +# Please use a mirror geographically close to you for initial sync, +# or if you are hosting a private mirror(not publicly available). +# +# Note that local mirrors may be faster, and we might restrict +# access to the master in the future. +# # A complete list of mirrors can be found at # https://mirrors.rockylinux.org/mirrormanager/mirrors/Rocky src="msync.rockylinux.org::rocky/mirror/pub/rocky" From 595cc86748916db27abe869087157357164ee884 Mon Sep 17 00:00:00 2001 From: Zane Williams Date: Tue, 23 Nov 2021 17:53:49 +0100 Subject: [PATCH 2/4] Exit cleanly if file list is unchanged at mirrorsync run init. --- mirror/mirrorsync.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mirror/mirrorsync.sh b/mirror/mirrorsync.sh index 31db4c3..55f8a39 100644 --- a/mirror/mirrorsync.sh +++ b/mirror/mirrorsync.sh @@ -55,12 +55,12 @@ lockfile="$0.lockfile" logfile="$0.log" # Check if the filelistfile has changed on upstream mirror -# and exit if it is still the same +# and exit cleanly if it is still the same checkresult=$(rsync --no-motd --dry-run --out-format="%n" "${src}/${filelistfile}" "${dst}/${filelistfile}") if [[ -z "$checkresult" ]]; then printf "%s unchanged. Not updating at %(%c)T\n" "$filelistfile" -1 >> "$logfile" 2>&1 logger -t rsync "Not updating ${mirrormodule}: ${filelistfile} unchanged." - exit 1 + exit 0 fi # Check for existing lockfile to avoid multiple simultaneously running syncs From 1c99b76c8c3c4387630cf563f05c7cfc55ed1fd9 Mon Sep 17 00:00:00 2001 From: Zane Williams Date: Tue, 23 Nov 2021 17:56:47 +0100 Subject: [PATCH 3/4] Add variable for rsync path, in case rsync not in $PATH. --- mirror/mirrorsync.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/mirror/mirrorsync.sh b/mirror/mirrorsync.sh index 55f8a39..782b4bc 100644 --- a/mirror/mirrorsync.sh +++ b/mirror/mirrorsync.sh @@ -31,7 +31,8 @@ # SOFTWARE. # - +# Find rsync in path or use "/usr/bin/rsync". +rsync=$(which rsync || /usr/bin/rsync) # You can change v to q if you do not want detailed logging opts=(-vrlptDSH --exclude="*.~tmp~" --delete-delay --delay-updates) @@ -56,7 +57,7 @@ logfile="$0.log" # Check if the filelistfile has changed on upstream mirror # and exit cleanly if it is still the same -checkresult=$(rsync --no-motd --dry-run --out-format="%n" "${src}/${filelistfile}" "${dst}/${filelistfile}") +checkresult=$(${rsync} --no-motd --dry-run --out-format="%n" "${src}/${filelistfile}" "${dst}/${filelistfile}") if [[ -z "$checkresult" ]]; then printf "%s unchanged. Not updating at %(%c)T\n" "$filelistfile" -1 >> "$logfile" 2>&1 logger -t rsync "Not updating ${mirrormodule}: ${filelistfile} unchanged." @@ -79,7 +80,7 @@ fi printf '%s\n' "$$" > "$lockfile" printf "Started update at %(%c)T\n" -1 >> "$logfile" 2>&1 logger -t rsync "Updating ${mirrormodule}" -rsync "${opts[@]}" "${src}/" "${dst}/" >> "$logfile" 2>&1 +${rsync} "${opts[@]}" "${src}/" "${dst}/" >> "$logfile" 2>&1 logger -t rsync "Finished updating ${mirrormodule}" printf "End: %(%c)T\n" -1 >> "$logfile" 2>&1 rm -f "$lockfile" From e560f32668ca715dc76a97826a23b53cd8ead2fe Mon Sep 17 00:00:00 2001 From: Zane Williams Date: Thu, 25 Nov 2021 13:51:45 +0100 Subject: [PATCH 4/4] After further discussion in the Infrastructure channel, the check for rsync in path has been modified to become a rsync_run function instead. It will check to see if rsync exists in $PATH, including a fallback path via the builtin bash "command", and exit accordingly. --- mirror/mirrorsync.sh | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/mirror/mirrorsync.sh b/mirror/mirrorsync.sh index 782b4bc..46238c7 100644 --- a/mirror/mirrorsync.sh +++ b/mirror/mirrorsync.sh @@ -31,8 +31,15 @@ # SOFTWARE. # -# Find rsync in path or use "/usr/bin/rsync". -rsync=$(which rsync || /usr/bin/rsync) +# Find rsync in default path +rsync_run(){ + if command -v rsync >/dev/null; then + command rsync "$@"; + else + command -p rsync "$@"; + fi; +} + # You can change v to q if you do not want detailed logging opts=(-vrlptDSH --exclude="*.~tmp~" --delete-delay --delay-updates) @@ -57,7 +64,7 @@ logfile="$0.log" # Check if the filelistfile has changed on upstream mirror # and exit cleanly if it is still the same -checkresult=$(${rsync} --no-motd --dry-run --out-format="%n" "${src}/${filelistfile}" "${dst}/${filelistfile}") +checkresult=$(rsync_run --no-motd --dry-run --out-format="%n" "${src}/${filelistfile}" "${dst}/${filelistfile}") if [[ -z "$checkresult" ]]; then printf "%s unchanged. Not updating at %(%c)T\n" "$filelistfile" -1 >> "$logfile" 2>&1 logger -t rsync "Not updating ${mirrormodule}: ${filelistfile} unchanged." @@ -80,7 +87,7 @@ fi printf '%s\n' "$$" > "$lockfile" printf "Started update at %(%c)T\n" -1 >> "$logfile" 2>&1 logger -t rsync "Updating ${mirrormodule}" -${rsync} "${opts[@]}" "${src}/" "${dst}/" >> "$logfile" 2>&1 +rsync_run "${opts[@]}" "${src}/" "${dst}/" >> "$logfile" 2>&1 logger -t rsync "Finished updating ${mirrormodule}" printf "End: %(%c)T\n" -1 >> "$logfile" 2>&1 rm -f "$lockfile"