From: Bastian Dehn Date: Sun, 25 May 2025 06:46:15 +0000 (+0200) Subject: add mount logic X-Git-Url: https://gitweb.hhaalo.de/?a=commitdiff_plain;h=5c8e152837058ce9ffd65864972ef4e7e03f7b9a;p=simple-backup.git add mount logic --- diff --git a/backupmount b/backupmount index a175437..8b0b7bf 100755 --- a/backupmount +++ b/backupmount @@ -21,10 +21,33 @@ infolog() device_mount() { - local device="$1" + local media="$1" + local device="$2" + [ -b "$device" ] \ || infolog "block device $device not found" \ || return $? + + infolog "media $media with device $device found" + + local key=$(cat "config.yaml" \ + | yq --raw-output ".media.\"$media\".key") + [ "$key" != "null" ] \ + || errlog "config.yaml key for $media missing" \ + || return $? + infolog "use key $key" + local volume=$(cat "config.yaml" \ + | yq --raw-output ".media.\"$media\".volume") + [ "$volume" != "null" ] \ + || errlog "config.yaml volume for $media missing" \ + || return $? + infolog "volume mount $volume" + + cryptsetup open --key-file "$key" \ + "$device" \ + "$volume" \ + || errlog "could not open $device with $key" + || return $? } mount() @@ -44,10 +67,10 @@ mount() [ "$device" != "null" ] \ || errlog "missing path for $media" \ || return $? - device_mount "$device" && return 0 + device_mount "$media" "$device" && return 0 done - errlog "no device found" + errlog "no device was mounted" } main()