mirror of
https://github.com/rocky-linux/rocky-tools.git
synced 2024-11-12 16:31:25 +00:00
Merge pull request #127 from knalb/mirrorsync_updates
* Exit cleanly when upstream is unchanged instead of with code 1. * Find & use rsync in user's path
This commit is contained in:
commit
c39b5064bd
@ -31,14 +31,24 @@
|
||||
# SOFTWARE.
|
||||
#
|
||||
|
||||
# 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)
|
||||
|
||||
# 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"
|
||||
@ -53,12 +63,12 @@ lockfile="$0.lockfile"
|
||||
logfile="$0.log"
|
||||
|
||||
# Check if the filelistfile has changed on upstream mirror
|
||||
# and exit if it is still the same
|
||||
checkresult=$(rsync --no-motd --dry-run --out-format="%n" "${src}/${filelistfile}" "${dst}/${filelistfile}")
|
||||
# and exit cleanly if it is still the same
|
||||
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."
|
||||
exit 1
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Check for existing lockfile to avoid multiple simultaneously running syncs
|
||||
@ -77,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"
|
||||
|
Loading…
Reference in New Issue
Block a user