Skip to content

Commit 19323a3

Browse files
committed
handle undefined devices during 'unlock' and 'mount' operations
1 parent 60bbfcf commit 19323a3

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

srv-ctl.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,9 @@ function unlock_device() {
9090
local l_mapper=$2
9191
local l_key_file=$3
9292

93-
if cryptsetup status "$l_mapper" >/dev/null; then
93+
if [ "$l_device_uuid" == "none" ] || [ "$l_mapper" == "none" ]; then
94+
echo -e "Device not configured (device_uuid=\"$l_device_uuid\"; mapper=\"$l_mapper\"). Skipping.\n"
95+
elif cryptsetup status "$l_mapper" >/dev/null; then
9496
echo -e "Partition \"$l_mapper\" unlocked. Skipping.\n"
9597
else
9698
echo "Unlocking $l_mapper..."
@@ -143,7 +145,9 @@ function mount_device() {
143145
local l_mapper=$1
144146
local l_mount=$2
145147

146-
if mountpoint -q "/mnt/$l_mount"; then
148+
if [ "$l_mapper" == "none" ] || [ "$l_mount" == "none" ]; then
149+
echo -e "Mount not configured (mapper=\"$l_mapper\"; mount_point=\"$l_mount\"). Skipping.\n"
150+
elif mountpoint -q "/mnt/$l_mount"; then
147151
echo -e "Mountpoint \"$l_mount\" mounted. Skipping.\n"
148152
else
149153
echo "Mounting $l_mount..."

0 commit comments

Comments
 (0)