Add aging support to the time file check.
This commit is contained in:
parent
7a87be349f
commit
61dae13b55
@ -5,7 +5,7 @@ PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/home/mirror/.
|
|||||||
|
|
||||||
# Variables for trace generation.
|
# Variables for trace generation.
|
||||||
PROGRAM="mirror-sync"
|
PROGRAM="mirror-sync"
|
||||||
VERSION="20240102"
|
VERSION="20240124"
|
||||||
TRACEHOST=$(hostname -f)
|
TRACEHOST=$(hostname -f)
|
||||||
mirror_hostname=$(hostname -f)
|
mirror_hostname=$(hostname -f)
|
||||||
DATE_STARTED=$(LC_ALL=POSIX LANG=POSIX date -u -R)
|
DATE_STARTED=$(LC_ALL=POSIX LANG=POSIX date -u -R)
|
||||||
@ -866,7 +866,7 @@ rsync_sync() {
|
|||||||
last_timestamp=$(cat "${timestamp:?}")
|
last_timestamp=$(cat "${timestamp:?}")
|
||||||
|
|
||||||
# If last update was not that long ago, we should check if upstream was updated recently.
|
# If last update was not that long ago, we should check if upstream was updated recently.
|
||||||
if [[ $((now-last_timestamp)) -lt ${upstream_timestamp_min:?} ]]; then
|
if (( now-last_timestamp < ${upstream_timestamp_min:?} )); then
|
||||||
echo "Checking upstream's last modified."
|
echo "Checking upstream's last modified."
|
||||||
|
|
||||||
# Get the last modified date.
|
# Get the last modified date.
|
||||||
@ -883,15 +883,21 @@ rsync_sync() {
|
|||||||
|
|
||||||
# If a time file check was defined, and check if needed.
|
# If a time file check was defined, and check if needed.
|
||||||
if [[ ${time_file_check:-} ]] && (( force == 0 )); then
|
if [[ ${time_file_check:-} ]] && (( force == 0 )); then
|
||||||
echo "Checking if time file has changed since last sync."
|
now=$(date +%s)
|
||||||
checkresult=$($sync_timeout rsync \
|
last_timestamp=$(cat "${timestamp:?}")
|
||||||
--no-motd \
|
|
||||||
--dry-run \
|
# Only check time file if the timestamp was recently updated.
|
||||||
--out-format="%n" \
|
if (( now-last_timestamp < ${upstream_timestamp_min:?} )); then
|
||||||
"${source:?}/${time_file_check:?}" "${repo:?}/${time_file_check:?}")
|
echo "Checking if time file has changed since last sync."
|
||||||
if [[ -z $checkresult ]]; then
|
checkresult=$($sync_timeout rsync \
|
||||||
echo "The time file has not changed since last sync, we are not updating at this time."
|
--no-motd \
|
||||||
exit 88
|
--dry-run \
|
||||||
|
--out-format="%n" \
|
||||||
|
"${source:?}/${time_file_check:?}" "${repo:?}/${time_file_check:?}")
|
||||||
|
if [[ -z $checkresult ]]; then
|
||||||
|
echo "The time file has not changed since last sync, we are not updating at this time."
|
||||||
|
exit 88
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user