Mirror: allow running the whole sync with '*' as an argument.

This commit is contained in:
Darren 'Tadgy' Austin 2026-05-22 13:33:36 +01:00
commit 0656dac7b6

64
mirror
View file

@ -7,7 +7,7 @@
# shellcheck disable=SC2034 # shellcheck disable=SC2034
# Script config. # Script config.
DEBUG="echo" # Set to 'echo' for debugging, or ':' for none DEBUG=":" # Set to 'echo' for debugging, or ':' for none
SLEEP="5m" # Sleep time between syncs when there was an error in the sync SLEEP="5m" # Sleep time between syncs when there was an error in the sync
ERRORS_MAX="3" # After this many errors in the sync tries, give up ERRORS_MAX="3" # After this many errors in the sync tries, give up
MAX_PROC="3600" # If a run takes longer than this time (in seconds), a new run is started MAX_PROC="3600" # If a run takes longer than this time (in seconds), a new run is started
@ -100,7 +100,7 @@ SALIX_FILTER=('--exclude=/sbo')
SBO_TYPE="rsync" SBO_TYPE="rsync"
SBO_MIRROR="slackbuilds.org" SBO_MIRROR="slackbuilds.org"
SBO_MODULE="slackbuilds/" SBO_MODULE="slackbuilds/"
SBO_DESTDIR="slackbuilds.org/" SBO_DESTDIR="sbo/"
SBO_OPTIONS=() SBO_OPTIONS=()
SBO_FILTER=() SBO_FILTER=()
@ -195,19 +195,25 @@ while [[ -n "$1" ]]; do
exit 0 exit 0
;; ;;
*) *)
ITEM="${1^^}" if [[ "$1" == "*" ]]; then
[[ ! -v ${ITEM}_DESTDIR ]] && { SYNC_ALL=1
echo "ERROR: '$1' is not a valid mirror ID" >&2 shift
exit 1 break
}
TYPE="${ITEM}_TYPE"
if [[ "${!TYPE}" == "rsync" ]]; then
RSYNC_LIST+=("${ITEM}")
elif [[ "${!TYPE}" == "lftp" ]]; then
LFTP_LIST+=("${!ITEM}")
else else
echo "ERROR: invalid type of mirroring for '${ITEM}'" >&2 ITEM="${1^^}"
exit 1 [[ ! -v ${ITEM}_DESTDIR ]] && {
echo "ERROR: '$1' is not a valid mirror ID" >&2
exit 1
}
TYPE="${ITEM}_TYPE"
if [[ "${!TYPE}" == "rsync" ]]; then
RSYNC_LIST+=("${ITEM}")
elif [[ "${!TYPE}" == "lftp" ]]; then
LFTP_LIST+=("${!ITEM}")
else
echo "ERROR: invalid type of mirroring for '${ITEM}'" >&2
exit 1
fi
fi fi
shift shift
;; ;;
@ -217,26 +223,26 @@ done
# What should be sync'd, if not provided on the command line. # What should be sync'd, if not provided on the command line.
(( ${#RSYNC_LIST[@]} == 0 )) && { (( ${#RSYNC_LIST[@]} == 0 )) && {
# Main tree. # Main tree.
[[ $(printf "%(%H)T") =~ .* ]] && RSYNC_LIST+=('SLACKTREE') (( ${SYNC_ALL:-0} == 1 )) || [[ $(printf "%(%H)T") =~ .* ]] && RSYNC_LIST+=('SLACKTREE')
# Other remotes. # Other remotes.
[[ $(printf "%(%H)T") =~ (02|08|14|20) ]] && RSYNC_LIST+=('ALIEN') (( ${SYNC_ALL:-0} == 1 )) || [[ $(printf "%(%H)T") =~ (02|08|14|20) ]] && RSYNC_LIST+=('ALIEN')
[[ $(printf "%(%H)T") =~ (02|08|14|20) ]] && RSYNC_LIST+=('CURRENTISO') (( ${SYNC_ALL:-0} == 1 )) || [[ $(printf "%(%H)T") =~ (02|08|14|20) ]] && RSYNC_LIST+=('CURRENTISO')
[[ $(printf "%(%H)T") =~ (02|08|14|20) ]] && RSYNC_LIST+=('KTOWN') (( ${SYNC_ALL:-0} == 1 )) || [[ $(printf "%(%H)T") =~ (02|08|14|20) ]] && RSYNC_LIST+=('KTOWN')
[[ $(printf "%(%H)T") =~ (02|08|14|20) ]] && RSYNC_LIST+=('LIVESLAK') (( ${SYNC_ALL:-0} == 1 )) || [[ $(printf "%(%H)T") =~ (02|08|14|20) ]] && RSYNC_LIST+=('LIVESLAK')
[[ $(printf "%(%H)T") =~ (02|08|14|20) ]] && RSYNC_LIST+=('PORTEUS') (( ${SYNC_ALL:-0} == 1 )) || [[ $(printf "%(%H)T") =~ (02|08|14|20) ]] && RSYNC_LIST+=('PORTEUS')
[[ $(printf "%(%H)T") =~ (02|08|14|20) ]] && RSYNC_LIST+=('R0NI') (( ${SYNC_ALL:-0} == 1 )) || [[ $(printf "%(%H)T") =~ (02|08|14|20) ]] && RSYNC_LIST+=('R0NI')
[[ $(printf "%(%H)T") =~ (02|08|14|20) ]] && RSYNC_LIST+=('RWORKMAN') (( ${SYNC_ALL:-0} == 1 )) || [[ $(printf "%(%H)T") =~ (02|08|14|20) ]] && RSYNC_LIST+=('RWORKMAN')
[[ $(printf "%(%H)T") =~ (02|08|14|20) ]] && RSYNC_LIST+=('SALIX') (( ${SYNC_ALL:-0} == 1 )) || [[ $(printf "%(%H)T") =~ (02|08|14|20) ]] && RSYNC_LIST+=('SALIX')
[[ $(printf "%(%H)T") =~ (02|08|14|20) ]] && RSYNC_LIST+=('SBO') (( ${SYNC_ALL:-0} == 1 )) || [[ $(printf "%(%H)T") =~ (02|08|14|20) ]] && RSYNC_LIST+=('SBO')
[[ $(printf "%(%H)T") =~ (02|08|14|20) ]] && RSYNC_LIST+=('ZENWALK') (( ${SYNC_ALL:-0} == 1 )) || [[ $(printf "%(%H)T") =~ (02|08|14|20) ]] && RSYNC_LIST+=('ZENWALK')
# Locals. # Locals.
[[ $(printf "%(%H)T") =~ .* ]] && RSYNC_LIST+=('SLACKARCHIVE') (( ${SYNC_ALL:-0} == 1 )) || [[ $(printf "%(%H)T") =~ .* ]] && RSYNC_LIST+=('SLACKARCHIVE')
[[ $(printf "%(%H)T") =~ (02|08|14|20) ]] && RSYNC_LIST+=('MULTILIBARCHIVE') (( ${SYNC_ALL:-0} == 1 )) || [[ $(printf "%(%H)T") =~ (02|08|14|20) ]] && RSYNC_LIST+=('MULTILIBARCHIVE')
} }
(( ${#LFTP_LIST[@]} == 0 )) && { (( ${#LFTP_LIST[@]} == 0 )) && {
# Nothing to sync here currently # Nothing to sync here currently.
: :
} }
@ -316,7 +322,7 @@ for RUN in $(seq -s' ' 1 "$MAX_RUNS"); do
;; ;;
esac esac
done done
echo "INFO: Finished processing of $VAR at $(printf "%(%c)T")." >&2 echo "INFO: Finished processing of '$VAR' at $(printf "%(%c)T")." >&2
done done
echo "INFO: End of rsync run $RUN at $(printf "%(%c)T")" >&2 echo "INFO: End of rsync run $RUN at $(printf "%(%c)T")" >&2