From 9625951a11dfec436c9e2c8f3e28985818f048b1 Mon Sep 17 00:00:00 2001 From: James Barnett Date: Thu, 1 Sep 2016 07:30:22 -0500 Subject: [PATCH] update readme --- README.md | 18 ++++++++---------- scripts/snap-pac | 36 ++++++++++++++++++------------------ 2 files changed, 26 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index 66b0353..32dc271 100644 --- a/README.md +++ b/README.md @@ -37,9 +37,11 @@ The key's fingerprint is `8535CEF3F3C38EE69555BF67E4B5E45AA3B8C5C3`. ## Configuration Configuration is done via the snapper configuration files, with extra variables -specific to these pacman hooks. The defaults should be suitable for most users. +specific to these pacman hooks. The defaults should be suitable for most users, +so you shouldn't need to change anything. + The following are possible settings you can place in each snapper configuration -file: +file (*e.g.*, `/etc/snapper/configs/root`, etc.): * `PACMAN_PRE_POST` - perform pacman pre/post snapshots for this configuration. Default is `"no"` for all configurations, except for the `root` configuration @@ -54,14 +56,10 @@ which is `"yes"`. The following setting can be changed in the snapper configuration file `/etc/conf.d/snapper`: -* `PACMAN_ABORT_ON_FAIL` - If for some reason there is an error taking the pre - snapshot, abort the pacman transaction if this is set to `"yes"`. Default is -`"no"`, meaning if there is an error taking the pre snapshot then continue with -the pacman transaction as normal. Any other value than `"no"` is treated the -same as `"yes"`. - -These settings only need to be added to the snapper configuration files if you -want to change the default. +* `PACMAN_ABORT_ON_FAIL` - By default this is set to `"no"`. When set to `"yes"` + this causes pacman to abort a transaction if the snap-pac pre hook fails. This +prevents an upgrade/installation/removal from occurring if a pre snapshot cannot be +performed. ## Usage diff --git a/scripts/snap-pac b/scripts/snap-pac index a2cd342..d1bb478 100755 --- a/scripts/snap-pac +++ b/scripts/snap-pac @@ -38,46 +38,46 @@ fi if [[ $EUID -ne 0 ]]; then echo -e "$ERRORMSG Script must be run as root." - if [[ $PACMAN_ABORT_ON_FAIL == "no" ]]; then - exit 0 - else + if [[ $PACMAN_ABORT_ON_FAIL == "yes" ]]; then exit 1 + else + exit 0 fi fi if [[ ! -d /var/run/dbus ]]; then echo -e "$ERRORMSG Unable to use snapper without dbus. Are you in a chroot environment?" - if [[ $PACMAN_ABORT_ON_FAIL == "no" ]]; then - exit 0 - else + if [[ $PACMAN_ABORT_ON_FAIL == "yes" ]]; then exit 1 + else + exit 0 fi fi if [[ $# -ne 1 ]]; then echo -e "$ERRORMSG Only one argument should be passed to this script." - if [[ $PACMAN_ABORT_ON_FAIL == "no" ]]; then - exit 0 - else + if [[ $PACMAN_ABORT_ON_FAIL == "yes" ]]; then exit 1 + else + exit 0 fi fi if [[ $1 != "pre" ]] && [[ $1 != "post" ]]; then echo -e "$ERRORMSG First argument should either be 'pre' or 'post'." - if [[ $PACMAN_ABORT_ON_FAIL == "no" ]]; then - exit 0 - else + if [[ $PACMAN_ABORT_ON_FAIL == "yes" ]]; then exit 1 + else + exit 0 fi fi if [[ -z "$SNAPPER_CONFIGS" ]]; then echo -e "$WARNINGMSG No snapper configurations found, so not taking any snapshots!" - if [[ $PACMAN_ABORT_ON_FAIL == "no" ]]; then - exit 0 - else + if [[ $PACMAN_ABORT_ON_FAIL == "yes" ]]; then exit 1 + else + exit 0 fi fi @@ -132,10 +132,10 @@ done if [[ $x -eq 0 ]]; then echo -e "$WARNINGMSG No snapper configurations are set up for snapshots to be taken!" - if [[ $PACMAN_ABORT_ON_FAIL == "no" ]]; then - exit 0 - else + if [[ $PACMAN_ABORT_ON_FAIL == "yes" ]]; then exit 1 + else + exit 0 fi fi