add shortcut to mount LUKS volumes
This commit is contained in:
parent
9fc2541b3c
commit
8c4082f1cf
|
@ -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 $@
|
Loading…
Reference in New Issue