add script dmount.sh to open the dick and dumount.sh to close it

This commit is contained in:
primardj 2024-01-22 17:24:27 +00:00
parent 1c9bca2f7b
commit 5d323aed1b
2 changed files with 37 additions and 0 deletions

6
dmount.sh Executable file
View file

@ -0,0 +1,6 @@
#/bin/bash
echo "unlocking device cryptdata"
doas rc-service dmcrypt restart
doas vgchange -a y cryptdata
doas mount -a

31
dumount.sh Executable file
View file

@ -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