|| 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 $?
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"
if [ "$cmd" == "mount" ]; then
mount || return $?
elif [ "$cmd" == "umount" ]; then
- echo "umount"
+ umount || return $?
else
errlog "unknown command" || return $?
fi