From 9f0524262db6b601d1a45fc3e40ba9d129800c3e Mon Sep 17 00:00:00 2001 From: Ralf Zerres Date: Wed, 22 Nov 2017 16:04:59 +0100 Subject: [PATCH] snap-sync: track script-name as 'progname' - change variable 'name' to 'progname' --- bin/snap-sync | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/bin/snap-sync b/bin/snap-sync index 5cd5c50..96c267e 100755 --- a/bin/snap-sync +++ b/bin/snap-sync @@ -27,23 +27,23 @@ set -o errtrace version="0.4.2" -name="snap-sync" +progname="snap-sync" # The following line is modified by the Makefile or # find_snapper_config script SNAPPER_CONFIG=/etc/sysconfig/snapper TMPDIR=$(mktemp -d) -PIPE=$TMPDIR/$name.out +PIPE=$TMPDIR/$progname.out mkfifo $PIPE -systemd-cat -t "$name" < $PIPE & +systemd-cat -t "$progname" < $PIPE & exec 3>$PIPE notify() { for u in $(users | sed 's/ /\n/' | sort -u); do sudo -u $u DISPLAY=:0 \ DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$(sudo -u $u id -u)/bus \ - notify-send -a $name "$1" "$2" --icon="dialog-$3" + notify-send -a $progname "$1" "$2" --icon="dialog-$3" done } @@ -70,7 +70,7 @@ traperror() { printf "exit status: %s\n" "$2" printf "command: %s\n" "$3" printf "bash line: %s\n" "$4" - printf "function name: %s\n" "$5" + printf "function progname: %s\n" "$5" exit 1 } @@ -83,8 +83,8 @@ trap trapkill SIGTERM SIGINT usage() { cat < Change the snapper description. Default: "latest incremental backup" @@ -258,8 +258,8 @@ for x in $selected_configs; do continue fi - if [[ "$(snapper -c $x list -t single | awk '/'$name' backup in progress/ {cnt++} END {print cnt}')" -gt 0 ]]; then - printf "\nNOTE: Previous failed %s backup snapshots found for '%s'.\n" "$name" "$x" | tee $PIPE + if [[ "$(snapper -c $x list -t single | awk '/'$progname' backup in progress/ {cnt++} END {print cnt}')" -gt 0 ]]; then + printf "\nNOTE: Previous failed %s backup snapshots found for '%s'.\n" "$progname" "$x" | tee $PIPE read -r -p "Delete failed backup snapshots [y/N]? " delete_failed while [[ -n "$delete_failed" && "$delete_failed" != [Yy]"es" && "$delete_failed" != [Yy] && "$delete_failed" != [Nn]"o" && @@ -272,7 +272,7 @@ for x in $selected_configs; do fi done if [[ "$delete_failed" == [Yy]"es" || "$delete_failed" == [Yy] ]]; then - snapper -c $x delete $(snapper -c $x list | awk '/'$name' backup in progress/ {print $3}') + snapper -c $x delete $(snapper -c $x list | awk '/'$progname' backup in progress/ {print $3}') fi fi @@ -311,7 +311,7 @@ for x in $selected_configs; do MYBACKUPDIR_ARRAY[$i]="$mybackupdir" printf "Creating new snapshot for %s...\n" "$x" | tee $PIPE - new_num=$(snapper -c "$x" create --print-number -d "$name backup in progress") + new_num=$(snapper -c "$x" create --print-number -d "$progname backup in progress") new_snap=$SUBVOLUME/.snapshots/$new_num/snapshot new_info=$SUBVOLUME/.snapshots/$new_num/info.xml sync