snap-sync: track script-name as 'progname'
- change variable 'name' to 'progname'
This commit is contained in:
@@ -27,23 +27,23 @@
|
|||||||
set -o errtrace
|
set -o errtrace
|
||||||
|
|
||||||
version="0.4.2"
|
version="0.4.2"
|
||||||
name="snap-sync"
|
progname="snap-sync"
|
||||||
|
|
||||||
# The following line is modified by the Makefile or
|
# The following line is modified by the Makefile or
|
||||||
# find_snapper_config script
|
# find_snapper_config script
|
||||||
SNAPPER_CONFIG=/etc/sysconfig/snapper
|
SNAPPER_CONFIG=/etc/sysconfig/snapper
|
||||||
|
|
||||||
TMPDIR=$(mktemp -d)
|
TMPDIR=$(mktemp -d)
|
||||||
PIPE=$TMPDIR/$name.out
|
PIPE=$TMPDIR/$progname.out
|
||||||
mkfifo $PIPE
|
mkfifo $PIPE
|
||||||
systemd-cat -t "$name" < $PIPE &
|
systemd-cat -t "$progname" < $PIPE &
|
||||||
exec 3>$PIPE
|
exec 3>$PIPE
|
||||||
|
|
||||||
notify() {
|
notify() {
|
||||||
for u in $(users | sed 's/ /\n/' | sort -u); do
|
for u in $(users | sed 's/ /\n/' | sort -u); do
|
||||||
sudo -u $u DISPLAY=:0 \
|
sudo -u $u DISPLAY=:0 \
|
||||||
DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$(sudo -u $u id -u)/bus \
|
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
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -70,7 +70,7 @@ traperror() {
|
|||||||
printf "exit status: %s\n" "$2"
|
printf "exit status: %s\n" "$2"
|
||||||
printf "command: %s\n" "$3"
|
printf "command: %s\n" "$3"
|
||||||
printf "bash line: %s\n" "$4"
|
printf "bash line: %s\n" "$4"
|
||||||
printf "function name: %s\n" "$5"
|
printf "function progname: %s\n" "$5"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,8 +83,8 @@ trap trapkill SIGTERM SIGINT
|
|||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
$name $version
|
$progname $version
|
||||||
Usage: $name [options]
|
Usage: $progname [options]
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
-d, --description <desc> Change the snapper description. Default: "latest incremental backup"
|
-d, --description <desc> Change the snapper description. Default: "latest incremental backup"
|
||||||
@@ -258,8 +258,8 @@ for x in $selected_configs; do
|
|||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$(snapper -c $x list -t single | awk '/'$name' backup in progress/ {cnt++} END {print cnt}')" -gt 0 ]]; then
|
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" "$name" "$x" | tee $PIPE
|
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
|
read -r -p "Delete failed backup snapshots [y/N]? " delete_failed
|
||||||
while [[ -n "$delete_failed" && "$delete_failed" != [Yy]"es" &&
|
while [[ -n "$delete_failed" && "$delete_failed" != [Yy]"es" &&
|
||||||
"$delete_failed" != [Yy] && "$delete_failed" != [Nn]"o" &&
|
"$delete_failed" != [Yy] && "$delete_failed" != [Nn]"o" &&
|
||||||
@@ -272,7 +272,7 @@ for x in $selected_configs; do
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
if [[ "$delete_failed" == [Yy]"es" || "$delete_failed" == [Yy] ]]; then
|
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
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -311,7 +311,7 @@ for x in $selected_configs; do
|
|||||||
MYBACKUPDIR_ARRAY[$i]="$mybackupdir"
|
MYBACKUPDIR_ARRAY[$i]="$mybackupdir"
|
||||||
|
|
||||||
printf "Creating new snapshot for %s...\n" "$x" | tee $PIPE
|
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_snap=$SUBVOLUME/.snapshots/$new_num/snapshot
|
||||||
new_info=$SUBVOLUME/.snapshots/$new_num/info.xml
|
new_info=$SUBVOLUME/.snapshots/$new_num/info.xml
|
||||||
sync
|
sync
|
||||||
|
|||||||
Reference in New Issue
Block a user