Output each configuration name and snapshot number during transactions
This commit is contained in:
parent
14b9e99d04
commit
9de30a8075
4 changed files with 42 additions and 15 deletions
21
README.md
21
README.md
|
|
@ -100,12 +100,19 @@ Installing the `nano` package as normal:
|
|||
(1/1) checking for file conflicts [######################################] 100%
|
||||
(1/1) checking available disk space [######################################] 100%
|
||||
:: Running pre-transaction hooks...
|
||||
(1/1) snapper pre snapshot
|
||||
(1/1) Performing snapper pre snapshots...
|
||||
home N/A
|
||||
root 1033 ✓
|
||||
:: Processing package changes...
|
||||
(1/1) installing nano [######################################] 100%
|
||||
:: Running post-transaction hooks...
|
||||
(1/2) snapper post snapshot
|
||||
(2/2) generate GRUB configuration file
|
||||
(1/1) Performing snapper post snapshots...
|
||||
home N/A
|
||||
root 1034 ✓
|
||||
|
||||
The snapper snapshot number is given for each snapper configuration that is
|
||||
used (tip: this is also logged in pacman's log). "N/A" means that configuration
|
||||
is not set up for snap-pac (see above).
|
||||
|
||||
And here are the snapshots:
|
||||
|
||||
|
|
@ -176,6 +183,14 @@ removed before the post snapshot could be taken. When you initially install
|
|||
*snap-pac* the post hook is run, but the pre hook never was, so this message
|
||||
will show up then as well.
|
||||
|
||||
**I see an "N/A" next to one of my snapper configurations in the hook's output**
|
||||
|
||||
snap-pac lists all snapper configurations it finds and tells you which ones it
|
||||
took a snapshot of. "N/A" means the configuration is not set up for snap-pac, so
|
||||
no snapshot was taken.
|
||||
|
||||
See [configuration](#configuration).
|
||||
|
||||
## License
|
||||
|
||||
snap-pac
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ Type = Package
|
|||
Target = *
|
||||
|
||||
[Action]
|
||||
Description = Performing snapper pre snapshot...
|
||||
Description = Performing snapper pre snapshots...
|
||||
Depends = snap-pac
|
||||
When = PreTransaction
|
||||
Exec = /usr/share/libalpm/scripts/snap-pac pre
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ Type = Package
|
|||
Target = *
|
||||
|
||||
[Action]
|
||||
Description = Performing snapper post snapshot...
|
||||
Description = Performing snapper post snapshots...
|
||||
Depends = snap-pac
|
||||
When = PostTransaction
|
||||
Exec = /usr/share/libalpm/scripts/snap-pac post
|
||||
|
|
|
|||
|
|
@ -66,20 +66,32 @@ for CONFIG in $SNAPPER_CONFIGS; do
|
|||
# shellcheck source=/dev/null
|
||||
source /etc/snapper/configs/"$CONFIG"
|
||||
|
||||
[[ $PACMAN_PRE_POST != "yes" ]] && continue
|
||||
echo -n " $CONFIG "
|
||||
|
||||
prefile="/tmp/snap-pac-pre_$CONFIG"
|
||||
snapper_cmd="snapper --config $CONFIG create --type $pre_or_post --cleanup-algorithm $PACMAN_CLEANUP_ALGORITHM"
|
||||
if [[ $PACMAN_PRE_POST == "yes" ]]; then
|
||||
|
||||
x=$((x+1))
|
||||
prefile="/tmp/snap-pac-pre_$CONFIG"
|
||||
snapper_cmd="snapper --config $CONFIG create --type $pre_or_post --cleanup-algorithm $PACMAN_CLEANUP_ALGORITHM"
|
||||
|
||||
x=$((x+1))
|
||||
|
||||
if [[ "$pre_or_post" == "pre" ]]; then
|
||||
$snapper_cmd --description "$PACMAN_PRE_DESCRIPTION" --print-number > "$prefile"
|
||||
echo -n "$(< "$prefile") "
|
||||
elif [[ -f $prefile ]]; then
|
||||
postnum=$($snapper_cmd --description "$PACMAN_POST_DESCRIPTION" --print-number --pre-number "$(< "$prefile")")
|
||||
echo -n "$postnum "
|
||||
rm "$prefile"
|
||||
else
|
||||
echo "WARNING: $prefile does not exist, so no post snapshot will be taken. If you are initially installing snap-pac, this is normal."
|
||||
fi
|
||||
|
||||
echo "✓"
|
||||
|
||||
if [[ "$pre_or_post" == "pre" ]]; then
|
||||
$snapper_cmd --description "$PACMAN_PRE_DESCRIPTION" --print-number > "$prefile"
|
||||
elif [[ -f $prefile ]]; then
|
||||
$snapper_cmd --description "$PACMAN_POST_DESCRIPTION" --pre-number "$(< "$prefile")"
|
||||
rm "$prefile"
|
||||
else
|
||||
echo "WARNING: $prefile does not exist, so no post snapshot will be taken. If you are initially installing snap-pac, this is normal."
|
||||
|
||||
echo "N/A"
|
||||
|
||||
fi
|
||||
|
||||
done
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue