33 lines
711 B
Bash
Executable File
33 lines
711 B
Bash
Executable File
#!/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
|