]> gitweb.hhaalo.de Git - simple-backup.git/commitdiff
add umount volume
authorBastian Dehn <hhaalo@arcor.de>
Sun, 25 May 2025 07:13:26 +0000 (09:13 +0200)
committerBastian Dehn <hhaalo@arcor.de>
Sun, 25 May 2025 07:13:26 +0000 (09:13 +0200)
backupmount

index a1e5e2855ad9b87892fb9f2f26ba39c620ae4af5..bb8ab256148b8bcc4d48d11f68153ee0aa0e641a 100755 (executable)
@@ -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