From e297dfd1b4714b29280df6d72885d275b677957a Mon Sep 17 00:00:00 2001 From: Andrew Ruthven Date: Thu, 26 Apr 2012 21:27:40 +1200 Subject: [PATCH] Install a molly-guard hook. --- debian/control | 5 ++--- debian/install | 1 + issues/i_893137d2.cil | 4 ++-- molly-guard/45-obnam | 29 +++++++++++++++++++++++++++++ 4 files changed, 34 insertions(+), 5 deletions(-) create mode 100755 molly-guard/45-obnam diff --git a/debian/control b/debian/control index e26d268..3b17b5e 100644 --- a/debian/control +++ b/debian/control @@ -1,16 +1,15 @@ Source: etc-obnam -Section: unknown +Section: optional Priority: extra Maintainer: Andrew Ruthven Build-Depends: debhelper (>= 7.0.50~) Standards-Version: 3.8.4 -Homepage: 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. diff --git a/debian/install b/debian/install index 5db8b39..ed80e9a 100644 --- a/debian/install +++ b/debian/install @@ -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 diff --git a/issues/i_893137d2.cil b/issues/i_893137d2.cil index 4a59bfc..cc060a7 100644 --- a/issues/i_893137d2.cil +++ b/issues/i_893137d2.cil @@ -1,8 +1,8 @@ Summary: Drop molly-guard hook into place to block reboots when backing up. -Status: New +Status: Finished CreatedBy: Andrew Ruthven 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 index 0000000..2ca431b --- /dev/null +++ b/molly-guard/45-obnam @@ -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 + -- 2.30.2