diff --git a/README.md b/README.md index df18490..314fc7f 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,12 @@ AUR](https://aur.archlinux.org/packages/snap-pac/). After installation, the hooks are located at `/usr/share/libalpm/hooks`, and the scripts are located at `/usr/share/libalpm/hooks.bin/snap-pac`. +## Configuration + +The configuration file is located at `/etc/snap-pac.conf`. There you can choose +which snapper configurations of which to take snapshots, the descriptions used +for the snapshots, and the snapper algorithm to use. + ## Usage ### Taking snapshots diff --git a/snapper-post b/snapper-post index 17afb48..a02d38e 100755 --- a/snapper-post +++ b/snapper-post @@ -22,11 +22,14 @@ source /etc/snap-pac.conf +cleanupalgo=${CLEANUP_ALGORITHM:-"number"} +description=${POST_DESCRIPTION:-"$(ps -C pacman -o args=)"} +configurations=${CONFIGS:-"root"} PREFILE_PREFIX="/usr/share/libalpm/hooks.bin/snap-pac/.pre" -for x in $CONFIGS; do +for x in $configurations; do if [ -f $PREFILE_PREFIX"_"$x ]; then SNAPPERPACPRE=$(cat $PREFILE_PREFIX"_"$x) - snapper --config $x create --cleanup-algorithm $CLEANUP_ALGORITHM --type post --pre-number $SNAPPERPACPRE --description "$PRE_DESCRIPTION" + snapper --config $x create --cleanup-algorithm $cleanupalgo --type post --pre-number $SNAPPERPACPRE --description "$description" rm $PREFILE_PREFIX"_"$x else echo "WARNING: $PREFILE_PREFIX"_"$x does not exist, so not performing post snapshot. If you are initially installing snap-pac, this is normal." diff --git a/snapper-pre b/snapper-pre index d042209..0920de6 100755 --- a/snapper-pre +++ b/snapper-pre @@ -22,7 +22,10 @@ source /etc/snap-pac.conf +cleanupalgo=${CLEANUP_ALGORITHM:-"number"} +description=${PRE_DESCRIPTION:-"$(ps -C pacman -o args=)"} +configurations=${CONFIGS:-"root"} PREFILE_PREFIX="/usr/share/libalpm/hooks.bin/snap-pac/.pre" -for x in $CONFIGS; do - snapper --config $x create --type pre --cleanup-algorithm $CLEANUP_ALGORITHM --print-number --description "$POST_DESCRIPTION" > $PREFILE_PREFIX"_"$x +for x in $configurations; do + snapper --config $x create --type pre --cleanup-algorithm $cleanupalgo --print-number --description "$description" > $PREFILE_PREFIX"_"$x done