From 8c4082f1cf4c9e958176f5315a8ebe0f61f9ba74 Mon Sep 17 00:00:00 2001 From: Frieder Schlesier Date: Sat, 9 Jun 2018 19:18:47 +0200 Subject: [PATCH] add shortcut to mount LUKS volumes --- bin/lmount | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100755 bin/lmount diff --git a/bin/lmount b/bin/lmount new file mode 100755 index 0000000..e0e8df5 --- /dev/null +++ b/bin/lmount @@ -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 $@