From 030030e546135281b2aef411efedbab70231eb53 Mon Sep 17 00:00:00 2001 From: Ducky Date: Tue, 22 Aug 2023 21:53:56 +0100 Subject: [PATCH] sh.zio.backup: add messages and extra error handling for toggle-mount --- usr/local/bin/sh.zio.backup | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/usr/local/bin/sh.zio.backup b/usr/local/bin/sh.zio.backup index a3d9f16..0f7d6df 100755 --- a/usr/local/bin/sh.zio.backup +++ b/usr/local/bin/sh.zio.backup @@ -307,10 +307,18 @@ elif [[ "$1" == "toggle-mount" ]]; then test_restic_mount="$(mountpoint "$restic_mount_path")" if [[ $? == 0 ]]; then + say info "Unmounting: $restic_mount_path" umount "$restic_mount_path" - rm -rf "$restic_mount_path" + + if [[ $? == 0 ]]; then + say warn "Deleting: $restic_mount_path" + rm -rf "$restic_mount_path" + else + die "Failed to umount (are you still in '$restic_mount_path'?)" + fi else - mkdir -fp "$restic_mount_path" + say info "Mounting: $restic_mount_path" + mkdir -p "$restic_mount_path" invoke_restic mount "$restic_mount_path" &>/dev/null & disown; fi else