From ec14c1c073748595398fa47bf267dc8d1bc483a2 Mon Sep 17 00:00:00 2001 From: Thomas Forgione Date: Wed, 16 Feb 2022 16:09:13 +0100 Subject: [PATCH] Easy mount/umount luks encrypted partitions --- bin/lmount | 19 +++++++++++++++++++ bin/lumount | 19 +++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100755 bin/lmount create mode 100755 bin/lumount diff --git a/bin/lmount b/bin/lmount new file mode 100755 index 0000000..a5bc18c --- /dev/null +++ b/bin/lmount @@ -0,0 +1,19 @@ +#!/usr/bin/env bash + +if [ "$#" -ne 2 ]; then + echo -e >&2 "\x1B[1;31merror:\x1B[0;1m this program expects two arguments\x1B[0m" + echo -e >&2 "\x1B[1;33musage:\x1B[0;1m sudo lmount " + + exit 1 +fi + +if [ "$USER" != "root" ]; then + echo -e >&2 "\x1B[1;31merror:\x1B[0;1m this program must be run as root\x1B[0m" + echo -e >&2 "\x1B[1;33musage:\x1B[0;1m sudo lmount " + + exit 1 +fi + +# Mounts an encrypt external drive to a specified mount point +cryptsetup luksOpen $1 external +mount /dev/mapper/external $2 diff --git a/bin/lumount b/bin/lumount new file mode 100755 index 0000000..da87254 --- /dev/null +++ b/bin/lumount @@ -0,0 +1,19 @@ +#!/usr/bin/env bash + +if [ "$#" -ne 1 ]; then + echo -e >&2 "\x1B[1;31merror:\x1B[0;1m this program expects one argument\x1B[0m" + echo -e >&2 "\x1B[1;33musage:\x1B[0;1m sudo lumount " + + exit 1 +fi + +if [ "$USER" != "root" ]; then + echo -e >&2 "\x1B[1;31merror:\x1B[0;1m this program must be run as root\x1B[0m" + echo -e >&2 "\x1B[1;33musage:\x1B[0;1m sudo lumount " + + exit 1 +fi + +# Mounts an encrypt external drive to a specified mount point +umount $1 +cryptsetup luksClose external