On 15/09/15 08:42, Andrew Gregory wrote:
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com> --- hooks/checkboot.hook | 17 +++++++++++++++++ hooks/checkmount | 13 +++++++++++++ hooks/checkmount.conf | 1 + hooks/checkmount.hook | 17 +++++++++++++++++
checkmount and checkboot seem a bit redundant. But patch is fine. A
hooks/sync.hook | 16 ++++++++++++++++ 5 files changed, 64 insertions(+) create mode 100644 hooks/checkboot.hook create mode 100644 hooks/checkmount create mode 100644 hooks/checkmount.conf create mode 100644 hooks/checkmount.hook create mode 100644 hooks/sync.hook
diff --git a/hooks/checkboot.hook b/hooks/checkboot.hook new file mode 100644 index 0000000..74a2dcf --- /dev/null +++ b/hooks/checkboot.hook @@ -0,0 +1,17 @@ +# Make sure /boot is mounted before we modify it + +[Trigger] +Operation = Sync +Type = File +Target = boot/* + +[Trigger] +Operation = Remove +Type = File +Target = boot/* + +[Action] +AbortOnFail +Depends = util-linux +When = PreTransaction +Exec = /usr/share/alpm/hooks/checkmount diff --git a/hooks/checkmount b/hooks/checkmount new file mode 100644 index 0000000..00fff7f --- /dev/null +++ b/hooks/checkmount @@ -0,0 +1,13 @@ +#!/usr/bin/bash + +[[ -f /etc/checkmount ]] || exit 0 + +source /etc/checkmount +ret=0 +for mp in "${mountpoints[@]}"; do + if ! findmnt "$mp" &>/dev/null; then + printf "error: $mp not mounted\n" >&2 + ret=1 + fi +done +exit $ret diff --git a/hooks/checkmount.conf b/hooks/checkmount.conf new file mode 100644 index 0000000..7ac515b --- /dev/null +++ b/hooks/checkmount.conf @@ -0,0 +1 @@ +mountpoints=( /boot ) diff --git a/hooks/checkmount.hook b/hooks/checkmount.hook new file mode 100644 index 0000000..7b9d9d7 --- /dev/null +++ b/hooks/checkmount.hook @@ -0,0 +1,17 @@ +# Make sure all our filesystems are mounted + +[Trigger] +Operation = Sync +Type = File +Target = * + +[Trigger] +Operation = Remove +Type = File +Target = * + +[Action] +AbortOnFail +Depends = util-linux +When = PreTransaction +Exec = /usr/share/alpm/hooks/checkmount diff --git a/hooks/sync.hook b/hooks/sync.hook new file mode 100644 index 0000000..43c2869 --- /dev/null +++ b/hooks/sync.hook @@ -0,0 +1,16 @@ +# Force disks to sync to prevent data corruption + +[Trigger] +Operation = Sync +Type = Package +Target = * + +[Trigger] +Operation = Remove +Type = Package +Target = * + +[Action] +Depends = coreutils +When = PostTransaction +Exec = /usr/bin/sync