From 5d323aed1be9b507f4a8e39369cbdeb05a63e978 Mon Sep 17 00:00:00 2001 From: primardj Date: Mon, 22 Jan 2024 17:24:27 +0000 Subject: [PATCH] add script dmount.sh to open the dick and dumount.sh to close it --- dmount.sh | 6 ++++++ dumount.sh | 31 +++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100755 dmount.sh create mode 100755 dumount.sh diff --git a/dmount.sh b/dmount.sh new file mode 100755 index 0000000..0920c7e --- /dev/null +++ b/dmount.sh @@ -0,0 +1,6 @@ +#/bin/bash + +echo "unlocking device cryptdata" +doas rc-service dmcrypt restart +doas vgchange -a y cryptdata +doas mount -a diff --git a/dumount.sh b/dumount.sh new file mode 100755 index 0000000..048920e --- /dev/null +++ b/dumount.sh @@ -0,0 +1,31 @@ +#/bin/bash + +MOUNTPOINT_cours=/home/primardj/cours +MOUNTPOINT_doc=/home/primardj/Documents +MOUNTPOINT_virt_machine=/home/primardj/virtual_machine +MOUNTPOINT_data=/home/primardj/data + + + + +remove_vgdevices() { + echo "force remove devices." >&2 + doas dmsetup info --columns + echo "removing all cryptdata volumes" >&2 + sleep 3 + array=(/dev/mapper/cryptdata-*) + for i in ${array[@]}; do + echo "$i" + doas dmsetup remove "$i" + done + doas dmsetup remove cryptdata +} + +echo locking device cryptdata +doas umount -R $MOUNTPOINT_cours +doas umount -R $MOUNTPOINT_doc +doas umount -R $MOUNTPOINT_virt_machine +doas umount -R $MOUNTPOINT_data + +doas lvchange -a n cryptdata || remove_vgdevices +doas cryptsetup close cryptdata