]> asedeno.scripts.mit.edu Git - sipb-mirrors.git/blobdiff - fetch
mirrors.mit.edu has been added to Fedora's Internet2 ACL
[sipb-mirrors.git] / fetch
diff --git a/fetch b/fetch
index 2bf8a49b76334b283f298cbda67a58574f1cd593..3a16f887c9694f040c32494c24d3130ccee74d65 100755 (executable)
--- a/fetch
+++ b/fetch
@@ -20,7 +20,12 @@ fi
 
 mkdir -p "$MIRRORDIR/.locks"
 
-exec >> "$MIRRORDIR/.logs/$scriptname-$(date +"%F-%R:%S").log"
+# Save a copy of stdout on FD 3, so we can get it back again
+exec 3>&1
+
+logname="$MIRRORDIR/.logs/$scriptname-$(date +"%F-%R:%S").log"
+
+exec >> "$logname" 2>&1
 date +"Starting $scriptname: %c"
 
 #NB: -r is number of retries, at 8 second intervals
@@ -28,8 +33,15 @@ if lockfile -r 900 "$MIRRORDIR/.locks/$scriptname"; then
     date +"Received lock: %c"
     (. fetch-scripts/"$scriptname")
     exitstatus=$?
-    rm "$MIRRORDIR/.locks/$scriptname"
+    rm -f "$MIRRORDIR/.locks/$scriptname"
 fi
 
 date +"Done: %c"
-exit $exitstatus
\ No newline at end of file
+if [ $exitstatus -ne 0 ]; then
+    exec 1>&3 # Restore stdout
+    echo "Synchronization of $scriptname failed:"
+    echo "(last 100 lines)"
+    echo
+    tail -n 100 "$logname"
+fi
+exit $exitstatus