add shortcut to mount LUKS volumes

This commit is contained in:
Frieder Schlesier 2018-06-09 19:18:47 +02:00
parent 9fc2541b3c
commit 8c4082f1cf
1 changed files with 41 additions and 0 deletions

41
bin/lmount Executable file
View File

@ -0,0 +1,41 @@
#!/bin/bash
#: lmount
#: open + mount luks encrypted storage
#:
set -e
set -o pipefail
set -x
device=$1
target=$2
main() {
if (( $# != 2 )); then
echo "Must be called with 2 args!"
echo " $0 $device $target"
exit 1
fi
if [ "$EUID" -ne 0 ]
then echo "Must be run as root!"
exit 1
fi
luksname=$(basename ${target})
if [ ! -d "${target}" ]; then
mkdir -p ${target}
fi
echo "Opening ${device} as ${luksname}"
sudo cryptsetup open ${device} ${luksname}
echo " ... mounting to ${target}"
sudo mount /dev/mapper/${luksname} ${target}
echo "done..."
}
main $@