make reading configuration a separate function

This commit is contained in:
James Barnett 2016-04-26 10:18:46 -05:00
parent d5e7860fb3
commit a13a5ab706

View file

@ -23,22 +23,27 @@
declare -r prefile_prefix="/usr/share/libalpm/hooks.bin/snap-pac/.pre" declare -r prefile_prefix="/usr/share/libalpm/hooks.bin/snap-pac/.pre"
declare -i i=0 function read_configs
for x in $(ls /etc/snapper/configs); do {
source /etc/snapper/configs/$x declare -r pacman_cmd="$(echo $(ps -C pacman -o args=) | sed 'sX/usr/bin/pacmanXpacmanXg')"
if [[ $x == "root" ]]; then declare -i i=0
take_snapshot[i]=${PACMAN_PRE_POST:-"yes"} for x in $(ls /etc/snapper/configs); do
else source /etc/snapper/configs/$x
take_snapshot[i]=${PACMAN_PRE_POST:-"no"} if [[ $x == "root" ]]; then
fi take_snapshot[i]=${PACMAN_PRE_POST:-"yes"}
cleanupalgo[i]=${PACMAN_CLEANUP_ALGORITHM:-"number"} else
pre_description[i]=${PACMAN_PRE_DESCRIPTION:-"$(echo $(ps -C pacman -o args=) | sed 'sX/usr/bin/pacmanXpacmanXg')"} take_snapshot[i]=${PACMAN_PRE_POST:-"no"}
post_description[i]=${PACMAN_POST_DESCRIPTION:-"$(echo $(ps -C pacman -o args=) | sed 'sX/usr/bin/pacmanXpacmanXg')"} fi
i=$(($i+1)) cleanupalgo[i]=${PACMAN_CLEANUP_ALGORITHM:-"number"}
done pre_description[i]=${PACMAN_PRE_DESCRIPTION:-"$pacman_cmd"}
post_description[i]=${PACMAN_POST_DESCRIPTION:-"$pacman_cmd"}
i=$(($i+1))
done
}
function pre function pre
{ {
read_configs
declare -i i=0 declare -i i=0
for x in $(ls /etc/snapper/configs); do for x in $(ls /etc/snapper/configs); do
if [[ ${take_snapshot[i]} == "yes" ]];then if [[ ${take_snapshot[i]} == "yes" ]];then
@ -50,6 +55,7 @@ function pre
function post function post
{ {
read_configs
declare -i i=0 declare -i i=0
for x in $(ls /etc/snapper/configs); do for x in $(ls /etc/snapper/configs); do
if [[ ${take_snapshot[i]} == "yes" ]];then if [[ ${take_snapshot[i]} == "yes" ]];then