summaryrefslogtreecommitdiffstats
path: root/.local/bin/hddumnt
blob: 9a5319b0ba98a48630688f8649f052fa24064395 (plain)
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
#!/bin/sh -e

devname="exthdd"
mountpoint="$HOME/$devname"

case "$(hostname -s)" in
	mother|po-rbo)
		if ! doas umount "$mountpoint"; then
			notify-send -u critical 'exthdd' "  failed to dismount <b>$mountpoint</b>"
		fi
		if ! doas cryptsetup close "$devname"; then
			notify-send -u critical 'exthdd' "  failed to close crypt dev <b>$devname</b>"
		fi
		rmdir "$mountpoint"
		notify-send -t 5000 'exthdd' "  crypt dev dismounted from <b>$mountpoint</b>"
		;;
	mars)
		if ! mount | grep -F /dev/da0p1; then
			notify-send -u critical 'fathdd' '  HDD not mounted'
			exit 1
		fi
		if ! umount /dev/da0p1.eli; then
			notify-send -u critical 'fathdd' '  Failed to dismount HDD'
			exit 1
		fi
		geli detach da0p1.eli
		rmdir "$HOME"/hdd
		notify-send -t 5000 'fathdd' '  HDD dismounted from <b>~/hdd</b>'
		;;
esac