Update 2025-01-01 10:04 OpenBSD/amd64-t14
This commit is contained in:
32
.bin/mount-cryptoffs
Executable file
32
.bin/mount-cryptoffs
Executable file
@@ -0,0 +1,32 @@
|
||||
#!/bin/sh
|
||||
_dev=${1:-sd2}
|
||||
|
||||
if mount | grep -q "/mnt"
|
||||
then
|
||||
echo "already mounted"
|
||||
mount | grep "/mnt"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# check if already decrypted
|
||||
_biodev=$(doas bioctl softraid0 | grep -B1 $_dev | head -1 | awk '{print $5}' \
|
||||
|| exit 1)
|
||||
|
||||
# if not
|
||||
if [ -z "$_biodev" ]
|
||||
then
|
||||
# decrypt
|
||||
doas bioctl -c C -l ${_dev}a softraid0
|
||||
# and read again
|
||||
_biodev=$(doas bioctl softraid0 | grep -B1 $_dev | head -1 | awk '{print $5}' \
|
||||
|| exit 1)
|
||||
fi
|
||||
|
||||
# it still might not be there (wrong password etc..)
|
||||
if [ -n "$_biodev" ]
|
||||
then
|
||||
echo "${_dev}a attached as $_biodev"
|
||||
# mount biodev
|
||||
doas mount /dev/${_biodev}a /mnt \
|
||||
&& echo "${_biodev}a mounted to /mnt"
|
||||
fi
|
||||
Reference in New Issue
Block a user