]> git.etc.gen.nz Git - etc-obnam.git/commitdiff
Install a molly-guard hook.
authorAndrew Ruthven <andrew@etc.gen.nz>
Thu, 26 Apr 2012 09:27:40 +0000 (21:27 +1200)
committerAndrew Ruthven <andrew@etc.gen.nz>
Thu, 26 Apr 2012 09:27:40 +0000 (21:27 +1200)
debian/control
debian/install
issues/i_893137d2.cil
molly-guard/45-obnam [new file with mode: 0755]

index e26d268f276416b8409db9af7dbdbd4cb2cc8eea..3b17b5e2e7aa729aea77955fd98a882a0d3fe53f 100644 (file)
@@ -1,16 +1,15 @@
 Source: etc-obnam
-Section: unknown
+Section: optional
 Priority: extra
 Maintainer: Andrew Ruthven <andrew@etc.gen.nz>
 Build-Depends: debhelper (>= 7.0.50~)
 Standards-Version: 3.8.4
-Homepage: <insert the upstream URL, if relevant>
 Vcs-Git: git://git.etc.gen.nz/etc-obnam.git
 Vcs-Browser: http://git.etc.gen.nz/cgi-bin/gitweb.cgi?p=etc-obnam.git;a=summary
 
 Package: etc-obnam
 Architecture: all
 Depends: ${misc:Depends}
-Recommends: obnam
+Recommends: obnam, molly-guard
 Description: Wrapper around obnam for backing up laptops and PCs
  Runs obnam on a schedule, but only if we're on the right network.
index 5db8b396510d42fe3967873f20cc7019b4f54887..ed80e9a10ae46c46c02ee766e0a0c64bd520e0f7 100644 (file)
@@ -1,2 +1,3 @@
 obnam.list /etc/apt/sources.list.d/
 run-backup /usr/lib/etc-obnam/
+molly-guard/45-obnam /etc/molly-guard/run.d
index 4a59bfc49a588a96863be203cb04abfef06ead72..cc060a7e54e47ef1df5609dadf6017c8d93ef378 100644 (file)
@@ -1,8 +1,8 @@
 Summary: Drop molly-guard hook into place to block reboots when backing up.
-Status: New
+Status: Finished
 CreatedBy: Andrew Ruthven <andrew@etc.gen.nz>
 AssignedTo: andrew
 Inserted: 2012-04-26T08:57:44
-Updated: 2012-04-26T08:58:37
+Updated: 2012-04-26T09:27:24
 
 Drop in a molly-guard file to make it harder to reboot during a backup.
diff --git a/molly-guard/45-obnam b/molly-guard/45-obnam
new file mode 100755 (executable)
index 0000000..2ca431b
--- /dev/null
@@ -0,0 +1,29 @@
+#!/bin/sh
+
+ME=molly-guard
+
+COUNT=$(ps ax | grep obnam | grep -v grep | wc -l)
+if [ $COUNT -eq 0 ]; then
+  echo "I: I can't find any running obnam backups, skipping check" >&2
+  exit 0;
+fi
+
+HOSTNAME="$(hostname --short)"
+
+sigh()
+{
+  echo "Good thing I asked; I won't $MOLLYGUARD_CMD $HOSTNAME ..." >&2
+  exit 1
+}
+
+
+trap 'echo;sigh' 1 2 3 9 10 12 15
+echo -n "Obnam is running a backup. Type YES to $MOLLYGUARD_CMD: "
+read CONFIRM || :
+
+[ $(echo "x$CONFIRM" | tr 'A-Z' 'a-z') = "xyes" ] || sigh
+
+trap - 1 2 3 9 10 12 15
+
+exit 0
+