tidy up
This commit is contained in:
parent
b4fa01786d
commit
268256123e
1 changed files with 12 additions and 24 deletions
26
snap-pac
26
snap-pac
|
|
@ -37,7 +37,6 @@ if [[ $1 != "pre" ]] && [[ $1 != "post" ]]; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Get configurations directly from snapper
|
|
||||||
if [[ -f /etc/conf.d/snapper ]]; then
|
if [[ -f /etc/conf.d/snapper ]]; then
|
||||||
source /etc/conf.d/snapper
|
source /etc/conf.d/snapper
|
||||||
else
|
else
|
||||||
|
|
@ -46,40 +45,29 @@ else
|
||||||
fi
|
fi
|
||||||
|
|
||||||
declare -r pre_or_post=$1
|
declare -r pre_or_post=$1
|
||||||
|
declare -r pacman_cmd="$(sed 's./usr/bin/pacman.pacman.g' <(ps -C pacman -o args=))"
|
||||||
|
|
||||||
for CONFIG in $SNAPPER_CONFIGS; do
|
for CONFIG in $SNAPPER_CONFIGS; do
|
||||||
|
|
||||||
|
PACMAN_PRE_POST="no"
|
||||||
if [[ $CONFIG == "root" ]]; then
|
if [[ $CONFIG == "root" ]]; then
|
||||||
PACMAN_PRE_POST="yes"
|
PACMAN_PRE_POST="yes"
|
||||||
else
|
|
||||||
PACMAN_PRE_POST="no"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
PACMAN_CLEANUP_ALGORITHM="number"
|
|
||||||
PACMAN_PRE_DESCRIPTION="$(sed 's./usr/bin/pacman.pacman.g' <(ps -C pacman -o args=))"
|
|
||||||
PACMAN_POST_DESCRIPTION="$(sed 's./usr/bin/pacman.pacman.g' <(ps -C pacman -o args=))"
|
|
||||||
|
|
||||||
source /etc/snapper/configs/$CONFIG
|
source /etc/snapper/configs/$CONFIG
|
||||||
|
|
||||||
if [[ $PACMAN_PRE_POST == "yes" ]]; then
|
[[ $PACMAN_PRE_POST != "yes" ]] && continue
|
||||||
|
|
||||||
prefile="/tmp/snap-pac-pre_$CONFIG"
|
prefile="/tmp/snap-pac-pre_$CONFIG"
|
||||||
|
snapper_cmd="snapper --config $CONFIG create --type $pre_or_post --cleanup-algorithm ${PACMAN_CLEANUP_ALGORITHM:-"number"}"
|
||||||
|
|
||||||
if [[ "$pre_or_post" == "pre" ]]; then
|
if [[ "$pre_or_post" == "pre" ]]; then
|
||||||
|
$snapper_cmd --description "${PACMAN_PRE_DESCRIPTION:-$pacman_cmd}" --print-number > $prefile
|
||||||
snapper --config $CONFIG create --type $pre_or_post --cleanup-algorithm $PACMAN_CLEANUP_ALGORITHM --description "$PACMAN_PRE_DESCRIPTION" --print-number > $prefile
|
elif [[ -f $prefile ]]; then
|
||||||
|
$snapper_cmd --description "${PACMAN_POST_DESCRIPTION:-$pacman_cmd}" --pre-number $(< $prefile)
|
||||||
elif [[ "$pre_or_post" == "post" ]]; then
|
|
||||||
|
|
||||||
if [[ -f $prefile ]]; then
|
|
||||||
snapper --config $CONFIG create --type $pre_or_post --cleanup-algorithm $PACMAN_CLEANUP_ALGORITHM --description "$PACMAN_POST_DESCRIPTION" --pre-number $(< $prefile)
|
|
||||||
rm $prefile
|
rm $prefile
|
||||||
else
|
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 "WARNING: $prefile does not exist, so no post snapshot will be taken. If you are initially installing snap-pac, this is normal."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
fi
|
|
||||||
|
|
||||||
fi
|
|
||||||
|
|
||||||
done
|
done
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue