snap-sync: make graphical notification via DBUS selectable

- introduce new configuration option --nonotify
- DBUS notificaton dialog only in interactive mode
This commit is contained in:
2018-01-19 14:25:34 +01:00
parent b91b1e0cc0
commit 4824959c2c

View File

@@ -320,6 +320,10 @@ parse_params () {
donotify=false donotify=false
shift shift
;; ;;
--nonotify)
donotify=false
shift 1
;;
-p|--port) -p|--port)
port=$2 port=$2
shift 2 shift 2
@@ -444,10 +448,13 @@ parse_params () {
subvolid_cmdline=${subvolid_cmdline:-"none"} subvolid_cmdline=${subvolid_cmdline:-"none"}
backupdir_cmdline=${backupdir_cmdline:-"none"} backupdir_cmdline=${backupdir_cmdline:-"none"}
if [ -z $remote ]; then if [ -z "$remote" ]; then
ssh="" ssh=""
else else
ssh="ssh $remote" ssh="ssh $remote"
if [ ! -z "$port" ]; then
ssh="$ssh -p $port"
fi
fi fi
if [ "$verbose" ]; then if [ "$verbose" ]; then
@@ -470,6 +477,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 [ "$batch" ]; then snap_sync_options="${snap_sync_options} batch=true do_pv_cmd=false" ; fi if [ "$batch" ]; then snap_sync_options="${snap_sync_options} batch=true do_pv_cmd=false" ; fi
if [ "$nonotify" ]; then snap_sync_options="${snap_sync_options} donotify=false"; fi
if [ "$interactive" ]; then snap_sync_options="${snap_sync_options} interactive=true batch=false"; fi if [ "$interactive" ]; then snap_sync_options="${snap_sync_options} interactive=true batch=false"; fi
printf "Options: '%s'\n" "${snap_sync_options}" printf "Options: '%s'\n" "${snap_sync_options}"
fi fi
@@ -677,7 +685,9 @@ 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
notify_info "Backup in progress" "NOTE: Skipping '$selected_config' configuration." notify_info "Backup in progress" "NOTE: Skipping '$selected_config' configuration."
fi
continue continue
fi fi
@@ -820,12 +830,15 @@ 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
notify_info "Finalize backup" "NOTE: Skipping '$selected_config' configuration." notify_info "Finalize backup" "NOTE: Skipping '$selected_config' configuration."
fi
continue continue
fi fi
if [ "$donotify" ]; then
notify_info "Finalize backup" "Cleanup tasks for configuration '$selected_config'." notify_info "Finalize backup" "Cleanup tasks for configuration '$selected_config'."
fi
printf "\n" printf "\n"
# retrieve config specific infos from pseudo Arrays # retrieve config specific infos from pseudo Arrays
@@ -1055,6 +1068,7 @@ Options:
(e.g. -c "root home"). (e.g. -c "root home").
-n, --noconfirm Do not ask for confirmation for each configuration. Will still prompt for backup -n, --noconfirm Do not ask for confirmation for each configuration. Will still prompt for backup
--batch directory name on first backup" --batch directory name on first backup"
--nonotify Disable graphical notification (via dbus)
-r, --remote <address> Send the snapshot backup to a remote machine. The snapshot will be sent via ssh. -r, --remote <address> Send the snapshot backup to a remote machine. The snapshot will be sent via ssh.
You should specify the remote machine's hostname or ip address. The 'root' user You should specify the remote machine's hostname or ip address. The 'root' user
must be permitted to login on the remote machine. must be permitted to login on the remote machine.
@@ -1205,6 +1219,7 @@ parse_params $@
# read mounted BTRFS structures # read mounted BTRFS structures
get_disk_infos get_disk_infos
if [ "$donotify" ]; 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' ..."
@@ -1224,6 +1239,7 @@ else
notify_info "Backup started" "Starting backups. Use command line menu to select disk on $remote." notify_info "Backup started" "Starting backups. Use command line menu to select disk on $remote."
fi fi
fi fi
fi
# select the target BTRFS subvol # select the target BTRFS subvol
select_target_disk select_target_disk
@@ -1250,8 +1266,10 @@ exec 3>&-
# cleanup # cleanup
run_cleanup run_cleanup
if [ "$donotify" ]; 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
notify_info "Finished" "Backups complete!" notify_info "Finished" "Backups complete!"
fi fi
fi