#! /bin/sh set -e ## Make sure we're running as the right user. case $(id -un) in mirror) ;; *) exec userv -fstdin=/dev/null mirror run ;; esac ## Set up a plausible environment. HOME=/mnt/ftp/mirror-admin; export HOME; cd PATH=$HOME/bin:/usr/bin:/usr/sbin:/bin:/sbin:/usr/local/bin:/usr/local/sbin export PATH umask 002 ## Make sure we're running with a lock file. case "${MIRROR_LOCKED-nil}" in nil) exec env MIRROR_LOCKED=t locking -f var/mirror.lock "$0" "$@" ;; esac ## Before we start, rotate the logs. (Doing things this way means that we ## can be sure we don't lose new logs, even if the log rotation goes ## completely mental. logrotate -s var/logrotate.state etc/logrotate.conf ## Let SIGINT take out the children only. trap "" INT ## Now do the various mirroring things. for file in $(run-parts --list etc/mirrors.d); do [ -x "$file" ] || continue base=${file##*/}; base=${base#[0-9]*-} ( echo echo "***--------------------------------------------------" echo "*** Running $base at $(date +%Y-%m-%dT%H:%M:%S)" echo set +e; (trap - INT; exec "$file"); rc=$?; set -e echo echo "*** Finished $(date +%Y-%m-%dT%H:%M:%S); rc = $rc" ) >>log/$base.log 2>&1 done