X-Git-Url: https://git.distorted.org.uk/~mdw/mirror-admin/blobdiff_plain/0f8f73ed9f04fb478ccd15449c259f553be44f37..HEAD:/bin/run-mirrors diff --git a/bin/run-mirrors b/bin/run-mirrors index ef7f92c..cddea70 100755 --- a/bin/run-mirrors +++ b/bin/run-mirrors @@ -5,11 +5,12 @@ set -e ## Make sure we're running as the right user. case $(id -un) in mirror) ;; - *) exec userv -fstdin=/dev/null mirror run ;; + *) exec userv -fstdin=/dev/null mirror run "$@";; esac ## Set up a plausible environment. HOME=/var/lib/mirror-admin; export HOME; cd +MIRRORS=/mnt/mirrors; export MIRRORS PATH=$HOME/bin:/usr/bin:/usr/sbin:/bin:/sbin:/usr/local/bin:/usr/local/sbin export PATH umask 002 @@ -32,9 +33,20 @@ logrotate -s var/logrotate.state etc/logrotate.conf ## Let SIGINT take out the children only. trap "" INT +## By default run all of the scripts. +case $# in 0) set "*" ;; esac + ## Now do the various mirroring things. for file in $(run-parts --list etc/mirrors.d); do [ -x "$file" ] || continue + + matchp=nil + leaf=$(echo "$file" | sed 's:^.*/::; s/^[0-9]\+[-_.]//') + for pat in "$@"; do + case "$leaf" in $pat) matchp=t; break ;; esac + done + case $matchp in nil) continue ;; esac + base=${file##*/}; base=${base#[0-9]*-} ( echo @@ -44,5 +56,15 @@ for file in $(run-parts --list etc/mirrors.d); do set +e; (trap - INT; exec "$file"); rc=$?; set -e echo echo "*** Finished $(date +%Y-%m-%dT%H:%M:%S); rc = $rc" + if [ -d etc/post-$base.d ]; then + for i in $(run-parts --list etc/post-$base.d); do + s=${i##*/} + echo + echo "*** Running post-script $s at $(date +%Y-%m-%dT%H:%M:%S)" + set +e; (trap - INT; exec "$i"); rc=$?; set -e + echo + echo "*** Finished post-script $s $(date +%Y-%m-%dT%H:%M:%S); rc = $rc" + done + fi ) >>log/$base.log 2>&1 done