summaryrefslogtreecommitdiffstats
path: root/bin/do-diffs.in
diff options
context:
space:
mode:
Diffstat (limited to 'bin/do-diffs.in')
-rwxr-xr-xbin/do-diffs.in60
1 files changed, 60 insertions, 0 deletions
diff --git a/bin/do-diffs.in b/bin/do-diffs.in
new file mode 100755
index 0000000..4a310ef
--- /dev/null
+++ b/bin/do-diffs.in
@@ -0,0 +1,60 @@
+#!/bin/sh
+##
+# do diffs for each of the diff groups ($LIST_OF_GROUPS) from <BASEDIR>/bin/env
+##
+
+ENVFILE="`dirname $0`/env"
+
+. $ENVFILE
+
+if [ $# -ge 1 ] ; then
+ LIST_OF_GROUPS="$*"; export LIST_OF_GROUPS
+elif [ "$LIST_OF_GROUPS" = "" ] ; then
+ echo "LIST_OF_GROUPS is empty in $ENVFILE"
+ exit 1
+fi
+
+if [ ! -d $BASEDIR/logs ] ; then
+ mkdir $BASEDIR/logs
+fi
+
+for GROUP in $LIST_OF_GROUPS
+do
+
+ LOCKFILE=$TMPDIR/.$GROUP.run.lock
+
+ (
+ echo starting: `date`
+ echo
+
+ if [ -f $LOCKFILE ]
+ then
+ echo hourly config diffs failed: $LOCKFILE exists
+ /bin/ls -l $LOCKFILE
+
+ # Send email if the lock file is old.
+ if [ "X$LOCKTIME" = "X" ] ; then
+ LOCKTIME=4
+ fi
+ @PERLV_PATH@ -e "\$t = (stat(\"$LOCKFILE\"))[9]; print \"OLD\\n\" if (time() - \$t >= $LOCKTIME*60*60);" > $TMPDIR/.$GROUP.old
+ if [ -s $TMPDIR/.$GROUP.old ]
+ then
+ (
+ cat <<END
+rancid $GROUP hung on `hostname`? Old lockfile still exists:
+`/bin/ls -l $LOCKFILE`
+END
+ ) | Mail -s "rancid hung - $GROUP" rancid-admin-$GROUP
+ fi
+ rm -f $TMPDIR/.$GROUP.old
+
+ else
+ /usr/bin/touch $LOCKFILE
+ control_rancid $GROUP
+ /bin/rm -f $LOCKFILE
+ fi
+
+ echo
+ echo ending: `date`
+ ) >$BASEDIR/logs/$GROUP.`date +%Y%m%d.%H%M%S` 2>&1
+done