From 4bbb066ffe85b2ffc35ffdb2a03ce19779779e9b Mon Sep 17 00:00:00 2001 From: Bastian Dehn Date: Sun, 25 May 2025 09:13:26 +0200 Subject: [PATCH] add umount volume --- backupmount | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/backupmount b/backupmount index a1e5e28..bb8ab25 100755 --- a/backupmount +++ b/backupmount @@ -64,7 +64,7 @@ device_mount() || return $? infolog "use key $key" local volume=$(cat "config.yaml" \ - | yq --raw-output ".media.\"$media\".volume") + | yq --raw-output ".media.volume") [ "$volume" != "null" ] \ || errlog "config.yaml volume for $media missing" \ || return $? @@ -102,6 +102,38 @@ mount() errlog "no device was mounted" } +umount() +{ + + local backup_path=$(cat config.yaml \ + | yq --raw-output ".backup_path") + [ "$backup_path" == "null" ] \ + || errlog "config.yaml backup path missing" + || return $? + + infolog "umount backup path $backup_path" + umount "$backup_path" \ + || errlog "could not unmount $backup_path" \ + || return $? + + infolog "remove backup path $backup_path" + rmdir --parents "$backup_path" \ + || errlog "clound not remote $backup_path" \ + || return $? + + infolog "close volume" + local volume=$(cat "config.yaml" \ + | yq --raw-output ".media.volume") + [ "$volume" != "null" ] \ + || errlog "config.yaml volume for $media missing" \ + || return $? + + infolog "close volume $volume" + cryptsetup close "$volume" \ + || errlog "could not close $volume" \ + || return $? +} + main() { local cmd="$1" @@ -121,7 +153,7 @@ main() if [ "$cmd" == "mount" ]; then mount || return $? elif [ "$cmd" == "umount" ]; then - echo "umount" + umount || return $? else errlog "unknown command" || return $? fi -- 2.47.3