Add support for checking an upstream file via rsync before updating all files.

This commit is contained in:
GRMrGecko 2023-12-13 11:17:39 -06:00
parent 3e5829918a
commit b1c386dd42
2 changed files with 19 additions and 1 deletions

View File

@ -267,6 +267,9 @@ A hook to run prior to the second stage sync.
#### upstream_check #### upstream_check
An http URL to check the last modified date as a reference for if the upstream mirror was possibly modified recently. This option is mainly here to lower the impact on upstream mirrors so that mirrorning happens less often. See `upstream_timestamp_min` and `upstream_max_age` for global configuration options of this check. An http URL to check the last modified date as a reference for if the upstream mirror was possibly modified recently. This option is mainly here to lower the impact on upstream mirrors so that mirrorning happens less often. See `upstream_timestamp_min` and `upstream_max_age` for global configuration options of this check.
### time_file_check
Name of a time file to check if the upstream has updated before syncing all files to reduce load on upstream mirrors.
#### report_mirror #### report_mirror
If you have Fedora report mirror installed, and need to report back to Fedora about the status of your repository, you can provide this option a configuration path for the `report_mirror` utility to run the report after a successful sync. If you have Fedora report mirror installed, and need to report back to Fedora about the status of your repository, you can provide this option a configuration path for the `report_mirror` utility to run the report after a successful sync.

View File

@ -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="20231122" VERSION="20231213"
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)
@ -781,6 +781,7 @@ rsync_sync() {
eval options_stage2="\$${MODULE}_options_stage2" eval options_stage2="\$${MODULE}_options_stage2"
eval pre_stage2_hook="\$${MODULE}_pre_stage2_hook" eval pre_stage2_hook="\$${MODULE}_pre_stage2_hook"
eval upstream_check="\$${MODULE}_upstream_check" eval upstream_check="\$${MODULE}_upstream_check"
eval time_file_check="\$${MODULE}_time_file_check"
eval report_mirror="\$${MODULE}_report_mirror" eval report_mirror="\$${MODULE}_report_mirror"
eval RSYNC_PASSWORD="\$${MODULE}_rsync_password" eval RSYNC_PASSWORD="\$${MODULE}_rsync_password"
if [[ $RSYNC_PASSWORD ]]; then if [[ $RSYNC_PASSWORD ]]; then
@ -821,6 +822,20 @@ rsync_sync() {
fi fi
fi fi
# If a time file check was defined, and check if needed.
if [[ ${time_file_check:-} ]]; then
echo "Checking if time file has changed since last sync."
checkresult=$($sync_timeout rsync \
--no-motd \
--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
# Run any hooks. # Run any hooks.
if [[ $pre_hook ]]; then if [[ $pre_hook ]]; then
echo "Executing pre-hook:" echo "Executing pre-hook:"