add verbose option

This commit is contained in:
James Barnett 2016-04-25 13:15:19 -05:00
parent 3a9aaadb1f
commit 7ad490c283
3 changed files with 17 additions and 2 deletions

View file

@ -13,3 +13,6 @@
# Snapper cleanup algorithm to use.
#CLEANUP_ALGORITHM="number"
# Set to "true" to make commands verbose
#VERBOSE="false"

View file

@ -29,12 +29,20 @@ fi
cleanupalgo=${CLEANUP_ALGORITHM:-"number"}
description=${POST_DESCRIPTION:-"$(echo $(ps -C pacman -o args=) | sed 'sX/usr/bin/pacmanXpacmanXg')"}
configurations=${CONFIGS:-"root"}
be_verbose=${VERBOSE:-"false"}
PREFILE_PREFIX="/usr/share/libalpm/hooks.bin/snap-pac/.pre"
for x in $configurations; do
if [ -f $PREFILE_PREFIX"_"$x ]; then
SNAPPERPACPRE=$(cat $PREFILE_PREFIX"_"$x)
snapper --config $x create --cleanup-algorithm $cleanupalgo --type post --pre-number $SNAPPERPACPRE --description "$description"
case "${be_verbose}" in
true)
snapper -v --config $x create --cleanup-algorithm $cleanupalgo --type post --pre-number $SNAPPERPACPRE --description "$description"
rm -v $PREFILE_PREFIX"_"$x;;
*)
snapper --config $x create --cleanup-algorithm $cleanupalgo --type post --pre-number $SNAPPERPACPRE --description "$description"
rm $PREFILE_PREFIX"_"$x
esac
else
echo "WARNING: $PREFILE_PREFIX"_"$x does not exist, so no post snapshot will be taken. If you are initially installing snap-pac, this is normal."
fi

View file

@ -29,7 +29,11 @@ fi
cleanupalgo=${CLEANUP_ALGORITHM:-"number"}
description=${POST_DESCRIPTION:-"$(echo $(ps -C pacman -o args=) | sed 'sX/usr/bin/pacmanXpacmanXg')"}
configurations=${CONFIGS:-"root"}
be_verbose=${VERBOSE:-"false"}
PREFILE_PREFIX="/usr/share/libalpm/hooks.bin/snap-pac/.pre"
for x in $configurations; do
snapper --config $x create --type pre --cleanup-algorithm $cleanupalgo --print-number --description "$description" > $PREFILE_PREFIX"_"$x
case "${be_verbose}" in
true) snapper -v --config $x create --type pre --cleanup-algorithm $cleanupalgo --print-number --description "$description" > $PREFILE_PREFIX"_"$x;;
*) snapper --config $x create --type pre --cleanup-algorithm $cleanupalgo --print-number --description "$description" > $PREFILE_PREFIX"_"$x
esac
done