2024-01-22 18:24:27 +01:00
|
|
|
#/bin/bash
|
|
|
|
|
2024-01-22 18:43:04 +01:00
|
|
|
|
|
|
|
Version=1.0.0
|
|
|
|
Usage="dumount.sh [PARAMETTER]
|
|
|
|
|
|
|
|
Umount a LVM on LUKS device. In case it was unplugged without being unmounted, use dmsetup tu force the deactivation of the lvm drive.
|
|
|
|
|
|
|
|
PARAMETER
|
|
|
|
-h, --help Print this help and exit
|
|
|
|
-v, --version Print the version of this program and exit
|
|
|
|
"
|
|
|
|
|
|
|
|
for i in $@; do
|
|
|
|
case "$i" in
|
|
|
|
"-h" | "--help")
|
|
|
|
echo "${Usage}"
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
"-v" | "--version")
|
|
|
|
echo "dmount.sh v.${Version}"
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-01-22 18:24:27 +01:00
|
|
|
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
|