#!/bin/bash set -e . ./OPTIONS.sh scriptname=$1 if [ -z "$scriptname" ]; then echo "Run with a fetch script as an argument:" (cd fetch-scripts && ls) exit 1 fi if ! [ -e fetch-scripts/"$scriptname" ]; then echo "Unknown fetch script $scriptname" exit 1 fi mkdir -p "$MIRRORDIR/.locks" exec >> "$MIRRORDIR/.logs/$scriptname-$(date +"%F-%R:%S").log" date +"Starting $scriptname: %c" #NB: -r is number of retries, at 8 second intervals if lockfile -r 900 "$MIRRORDIR/.locks/$scriptname"; then date +"Received lock: %c" (. fetch-scripts/"$scriptname") exitstatus=$? rm "$MIRRORDIR/.locks/$scriptname" fi date +"Done: %c" exit $exitstatus