-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmount.sh
executable file
·32 lines (29 loc) · 931 Bytes
/
mount.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/env bash
# a script to mount my luks drive
enmount() {
drives=$(lsblk -l | grep disk | grep -v nvme0n1 | awk '{print $1}')
drive=$(printf "%s\n" "${drives[@]}" | rofi -dmenu -prompt="Drive:")
[[ -z $drive ]] && exit 1
sudo cryptsetup open /dev/$drive vault
posmounts=$(find /mnt -maxdepth 3 2>/dev/null)
mountpoint=$(printf "%s\n" "${posmounts[@]}" | rofi -dmenu -prompt="mount:")
[[ -z $mountpoint ]] && exit 1
sudo mount /dev/mapper/vault $mountpoint
}
enunmount() {
mountpoints=$(find /mnt -maxdepth 3 2>/dev/null)
MOUNTPOINT=$(printf "%s\n" "${mountpoints[@]}" | rofi -dmenu -prompt="Mountpoint:")
[[ -z $MOUNTPOINT ]] && exit 1
sudo umount $MOUNTPOINT
sudo cryptsetup close vault
}
OPTIONS=("Mount" "Unmount")
OPTION=$(printf "%s\n" "${OPTIONS[@]}" | rofi -dmenu -prompt="Options:")
case $OPTION in
"Mount")
enmount
;;
"Unmount")
enunmount
;;
esac