dsnap-sync: change notification to use int value
This commit is contained in:
@@ -50,7 +50,7 @@ BTRFS_PIPE=$TMPDIR_PIPE/btrfs.out
|
|||||||
exec 3>$PIPE 4>$BTRFS_PIPE
|
exec 3>$PIPE 4>$BTRFS_PIPE
|
||||||
|
|
||||||
# global variables
|
# global variables
|
||||||
donotify=false
|
donotify=0
|
||||||
answer=no
|
answer=no
|
||||||
disk_count=-1
|
disk_count=-1
|
||||||
disk_uuid_match_count=0
|
disk_uuid_match_count=0
|
||||||
@@ -82,7 +82,7 @@ check_prerequisites () {
|
|||||||
which wc >/dev/null 2>&1 || { printf "'wc' is not installed." && exit 1; }
|
which wc >/dev/null 2>&1 || { printf "'wc' is not installed." && exit 1; }
|
||||||
|
|
||||||
# optional binaries:
|
# optional binaries:
|
||||||
which notify-send >/dev/null 2>&1 && { donotify=true; }
|
which notify-send >/dev/null 2>&1 && { donotify=1; }
|
||||||
which pv >/dev/null 2>&1 && { do_pv_cmd=true; }
|
which pv >/dev/null 2>&1 && { do_pv_cmd=true; }
|
||||||
|
|
||||||
if [ $(id -u) -ne 0 ] ; then printf "$progname: must be run as root\n" ; exit 1 ; fi
|
if [ $(id -u) -ne 0 ] ; then printf "$progname: must be run as root\n" ; exit 1 ; fi
|
||||||
@@ -295,7 +295,7 @@ get_disk_infos () {
|
|||||||
|
|
||||||
notify () {
|
notify () {
|
||||||
# estimation: batch calls should just log
|
# estimation: batch calls should just log
|
||||||
if [ "$donotify" = "true" ]; then
|
if [ $donotify -gt 0 ]; then
|
||||||
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 \
|
||||||
@@ -310,7 +310,7 @@ notify_info () {
|
|||||||
notify "$1" "$2" "information"
|
notify "$1" "$2" "information"
|
||||||
}
|
}
|
||||||
|
|
||||||
notify_error() {
|
notify_error () {
|
||||||
notify "$1" "$2" "error"
|
notify "$1" "$2" "error"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -375,17 +375,17 @@ parse_params () {
|
|||||||
;;
|
;;
|
||||||
-i|--interactive)
|
-i|--interactive)
|
||||||
interactive=1
|
interactive=1
|
||||||
donotify=true
|
donotify=1
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
-n|--noconfirm|--batch)
|
-n|--noconfirm|--batch)
|
||||||
batch=1
|
batch=1
|
||||||
do_pv_cmd=false
|
do_pv_cmd=false
|
||||||
donotify=false
|
donotify=0
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
--nonotify)
|
--nonotify)
|
||||||
donotify=false
|
donotify=0
|
||||||
shift 1
|
shift 1
|
||||||
;;
|
;;
|
||||||
--nopv)
|
--nopv)
|
||||||
@@ -549,7 +549,7 @@ parse_params () {
|
|||||||
|
|
||||||
if [ "$verbose" ]; then snap_sync_options="verbose=true"; fi
|
if [ "$verbose" ]; then snap_sync_options="verbose=true"; fi
|
||||||
if [ "$dryrun" ]; then snap_sync_options="${snap_sync_options} dry-run=true"; fi
|
if [ "$dryrun" ]; then snap_sync_options="${snap_sync_options} dry-run=true"; fi
|
||||||
if [ "$nonotify" ]; then snap_sync_options="${snap_sync_options} donotify=false"; fi
|
if [ "$nonotify" ]; then snap_sync_options="${snap_sync_options} donotify=0"; fi
|
||||||
if [ "$batch" ]; then
|
if [ "$batch" ]; then
|
||||||
snap_sync_options="${snap_sync_options} batch=true do_pv_cmd=false"
|
snap_sync_options="${snap_sync_options} batch=true do_pv_cmd=false"
|
||||||
else
|
else
|
||||||
@@ -772,7 +772,7 @@ run_backup () {
|
|||||||
|
|
||||||
cont_backup=$(eval echo \$snapper_activate_$i)
|
cont_backup=$(eval echo \$snapper_activate_$i)
|
||||||
if [ "$cont_backup" = "no" ] || [ "$SNAP_SYNC_EXCLUDE" = "yes" ]; then
|
if [ "$cont_backup" = "no" ] || [ "$SNAP_SYNC_EXCLUDE" = "yes" ]; then
|
||||||
if [ "$donotify" ]; then
|
if [ $donotify -gt 0 ]; then
|
||||||
notify_info "Backup in progress" "NOTE: Skipping '$selected_config' configuration."
|
notify_info "Backup in progress" "NOTE: Skipping '$selected_config' configuration."
|
||||||
fi
|
fi
|
||||||
continue
|
continue
|
||||||
@@ -934,13 +934,13 @@ run_finalize () {
|
|||||||
|
|
||||||
cont_backup=$(eval echo \$snapper_activate_$i)
|
cont_backup=$(eval echo \$snapper_activate_$i)
|
||||||
if [ "$cont_backup" = "no" ] || [ "$SNAP_SYNC_EXCLUDE" = "yes" ]; then
|
if [ "$cont_backup" = "no" ] || [ "$SNAP_SYNC_EXCLUDE" = "yes" ]; then
|
||||||
if [ "$donotify" ]; then
|
if [ $donotify -gt 0 ]; then
|
||||||
notify_info "Finalize backup" "NOTE: Skipping '$selected_config' configuration."
|
notify_info "Finalize backup" "NOTE: Skipping '$selected_config' configuration."
|
||||||
fi
|
fi
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$donotify" ]; then
|
if [ $donotify -gt 0 ]; then
|
||||||
notify_info "Finalize backup" "Cleanup tasks for configuration '$selected_config'."
|
notify_info "Finalize backup" "Cleanup tasks for configuration '$selected_config'."
|
||||||
fi
|
fi
|
||||||
printf "\n"
|
printf "\n"
|
||||||
@@ -1371,7 +1371,7 @@ parse_params $@
|
|||||||
# read mounted BTRFS structures
|
# read mounted BTRFS structures
|
||||||
get_disk_infos
|
get_disk_infos
|
||||||
|
|
||||||
if [ "$donotify" ]; then
|
if [ $donotify -gt 0 ]; then
|
||||||
if [ "$target_cmdline" != "none" ]; then
|
if [ "$target_cmdline" != "none" ]; then
|
||||||
if [ -z "$remote" ]; then
|
if [ -z "$remote" ]; then
|
||||||
notify_info "Backup started" "Starting backups to '$target_cmdline' ..."
|
notify_info "Backup started" "Starting backups to '$target_cmdline' ..."
|
||||||
@@ -1418,7 +1418,7 @@ exec 3>&-
|
|||||||
# cleanup
|
# cleanup
|
||||||
run_cleanup
|
run_cleanup
|
||||||
|
|
||||||
if [ "$donotify" ]; then
|
if [ $donotify -gt 0 ]; then
|
||||||
if [ "$uuid_cmdline" != "none" ]; then
|
if [ "$uuid_cmdline" != "none" ]; then
|
||||||
notify_info "Finished" "Backups to $uuid_cmdline complete!"
|
notify_info "Finished" "Backups to $uuid_cmdline complete!"
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in New Issue
Block a user