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,8 +685,10 @@ 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
notify_info "Backup in progress" "NOTE: Skipping '$selected_config' configuration." if [ "$donotify" ]; then
continue notify_info "Backup in progress" "NOTE: Skipping '$selected_config' configuration."
fi
continue
fi fi
notify_info "Backup in progress" "Backing up data for configuration '$selected_config'." notify_info "Backup in progress" "Backing up data for configuration '$selected_config'."
@@ -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
notify_info "Finalize backup" "NOTE: Skipping '$selected_config' configuration." if [ "$donotify" ]; then
continue notify_info "Finalize backup" "NOTE: Skipping '$selected_config' configuration."
fi
continue
fi fi
notify_info "Finalize backup" "Cleanup tasks for configuration '$selected_config'." if [ "$donotify" ]; then
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,23 +1219,25 @@ parse_params $@
# read mounted BTRFS structures # read mounted BTRFS structures
get_disk_infos get_disk_infos
if [ "$target_cmdline" != "none" ]; then if [ "$donotify" ]; then
if [ -z "$remote" ]; then if [ "$target_cmdline" != "none" ]; then
notify_info "Backup started" "Starting backups to '$target_cmdline' ..." if [ -z "$remote" ]; then
notify_info "Backup started" "Starting backups to '$target_cmdline' ..."
else
notify_info "Backup started" "Starting backups to '$target_cmdline' at $remote ..."
fi
elif [ "$uuid_cmdline" != "none" ]; then
if [ -z "$remote" ]; then
notify_info "Backup started" "Starting backups to $uuid_cmdline..."
else
notify_info "Backup started" "Starting backups to $uuid_cmdline at $remote..."
fi
else else
notify_info "Backup started" "Starting backups to '$target_cmdline' at $remote ..." if [ -z "$remote" ]; then
fi notify_info "Backup started" "Starting backups. Use command line menu to select disk."
elif [ "$uuid_cmdline" != "none" ]; then else
if [ -z "$remote" ]; then notify_info "Backup started" "Starting backups. Use command line menu to select disk on $remote."
notify_info "Backup started" "Starting backups to $uuid_cmdline..." fi
else
notify_info "Backup started" "Starting backups to $uuid_cmdline at $remote..."
fi
else
if [ -z "$remote" ]; then
notify_info "Backup started" "Starting backups. Use command line menu to select disk."
else
notify_info "Backup started" "Starting backups. Use command line menu to select disk on $remote."
fi fi
fi fi
@@ -1250,8 +1266,10 @@ exec 3>&-
# cleanup # cleanup
run_cleanup run_cleanup
if [ "$uuid_cmdline" != "none" ]; then if [ "$donotify" ]; then
notify_info "Finished" "Backups to $uuid_cmdline complete!" if [ "$uuid_cmdline" != "none" ]; then
else notify_info "Finished" "Backups to $uuid_cmdline complete!"
notify_info "Finished" "Backups complete!" else
notify_info "Finished" "Backups complete!"
fi
fi fi