summaryrefslogtreecommitdiffstats
path: root/.local/bin/hddumnt
blob: 1b5da66ebe93a664bf7b27a15a4067df994dae4e (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
			herbe "  failed to dismount $mountpoint" &
		fi
		if ! doas cryptsetup close "$devname"; then
			herbe "  failed to close crypt dev $devname" &
		fi
		rmdir "$mountpoint"
		herbe "  crypt dev dismounted from $mountpoint" &
		;;
	mars)
		if ! mount | grep -F /dev/da0p1; then
			herbe '  HDD not mounted' &
			exit 1
		fi
		if ! umount /dev/da0p1.eli; then
			herbe '  failed to dismount hdd' &
			exit 1
		fi
		geli detach da0p1.eli
		rmdir "$HOME"/hdd
		herbe '  hdd dismounted from ~/hdd' &
		;;
esac