cron script for polling and pulling backend db from cdimage.d.o
authorSteve McIntyre <steve@einval.com>
Thu, 14 Apr 2011 20:56:42 +0000 (21:56 +0100)
committerSteve McIntyre <steve@einval.com>
Thu, 14 Apr 2011 20:56:42 +0000 (21:56 +0100)
watch_and_sync_db [new file with mode: 0755]

diff --git a/watch_and_sync_db b/watch_and_sync_db
new file mode 100755 (executable)
index 0000000..53c937d
--- /dev/null
@@ -0,0 +1,22 @@
+#!/bin/sh
+
+DBDIR="/srv/cdimage-search.debian.org/search-db"
+LOCK=$DBDIR/lock
+
+# Check to see if another sync is in progress
+if lockfile -! -l 43200 -r 0 "$LOCK" >/dev/null 2>&1 ; then
+#    echo `hostname` is unable to start CD sync, lock file exists
+    exit 1
+fi
+trap "rm -f $LOCK > /dev/null 2>&1" exit
+
+cd $DBDIR
+
+rsync cdimage.debian.org::cdimage/.search-db/trace trace.new
+OLDTRACE=`cat trace`
+NEWTRACE=`cat trace.new`
+if [ "$OLDTRACE"x != "$NEWTRACE"x ] || [ "$1"x = "-f"x ] ; then
+    rsync -4rtl --delete cdimage.debian.org::cdimage/.search-db/ $DBDIR/
+fi
+
+