From 2402a4b42d7e14806ed859dc1e756a2459051891 Mon Sep 17 00:00:00 2001 From: Ducky Date: Tue, 22 Aug 2023 22:01:09 +0100 Subject: [PATCH] various --- usr/local/bin/sh.zio.backup | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/usr/local/bin/sh.zio.backup b/usr/local/bin/sh.zio.backup index c351906..7e2c800 100755 --- a/usr/local/bin/sh.zio.backup +++ b/usr/local/bin/sh.zio.backup @@ -304,15 +304,18 @@ elif [[ "$1" == "rescue" ]]; then --target "/srv/dumps/$host/restic/$snapshot" \ "$snapshot" elif [[ "$1" == "toggle-mount" ]]; then - mkdir -p "$restic_mount_path" - test_restic_mount="$(mountpoint "$restic_mount_path")" + function test_restic_mount() { + mountpoint "$restic_mount_path" &>/dev/null + echo $? + } - if [[ $? == 0 ]]; then + mkdir -p "$restic_mount_path" + + if [[ $(test_restic_mount) == 0 ]]; then say info "Unmounting: $restic_mount_path" umount "$restic_mount_path" if [[ $? == 0 ]]; then - say warning "Deleting: $restic_mount_path" rm -rf "$restic_mount_path" else die "Failed to umount (are you still in '$restic_mount_path'?)"