mirror of
https://github.com/rocky-linux/rocky-tools.git
synced 2024-11-22 05:01:25 +00:00
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.
This commit is contained in:
parent
1c99b76c8c
commit
e560f32668
@ -31,8 +31,15 @@
|
|||||||
# SOFTWARE.
|
# SOFTWARE.
|
||||||
#
|
#
|
||||||
|
|
||||||
# Find rsync in path or use "/usr/bin/rsync".
|
# Find rsync in default path
|
||||||
rsync=$(which rsync || /usr/bin/rsync)
|
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
|
# You can change v to q if you do not want detailed logging
|
||||||
opts=(-vrlptDSH --exclude="*.~tmp~" --delete-delay --delay-updates)
|
opts=(-vrlptDSH --exclude="*.~tmp~" --delete-delay --delay-updates)
|
||||||
|
|
||||||
@ -57,7 +64,7 @@ logfile="$0.log"
|
|||||||
|
|
||||||
# Check if the filelistfile has changed on upstream mirror
|
# Check if the filelistfile has changed on upstream mirror
|
||||||
# and exit cleanly 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}")
|
checkresult=$(rsync_run --no-motd --dry-run --out-format="%n" "${src}/${filelistfile}" "${dst}/${filelistfile}")
|
||||||
if [[ -z "$checkresult" ]]; then
|
if [[ -z "$checkresult" ]]; then
|
||||||
printf "%s unchanged. Not updating at %(%c)T\n" "$filelistfile" -1 >> "$logfile" 2>&1
|
printf "%s unchanged. Not updating at %(%c)T\n" "$filelistfile" -1 >> "$logfile" 2>&1
|
||||||
logger -t rsync "Not updating ${mirrormodule}: ${filelistfile} unchanged."
|
logger -t rsync "Not updating ${mirrormodule}: ${filelistfile} unchanged."
|
||||||
@ -80,7 +87,7 @@ fi
|
|||||||
printf '%s\n' "$$" > "$lockfile"
|
printf '%s\n' "$$" > "$lockfile"
|
||||||
printf "Started update at %(%c)T\n" -1 >> "$logfile" 2>&1
|
printf "Started update at %(%c)T\n" -1 >> "$logfile" 2>&1
|
||||||
logger -t rsync "Updating ${mirrormodule}"
|
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}"
|
logger -t rsync "Finished updating ${mirrormodule}"
|
||||||
printf "End: %(%c)T\n" -1 >> "$logfile" 2>&1
|
printf "End: %(%c)T\n" -1 >> "$logfile" 2>&1
|
||||||
rm -f "$lockfile"
|
rm -f "$lockfile"
|
||||||
|
Loading…
Reference in New Issue
Block a user