From 5f43b704980023fe4e2b76d7888559e87c2ebef2 Mon Sep 17 00:00:00 2001 From: Joe Date: Tue, 31 Oct 2023 02:14:13 +0100 Subject: up --- .local/bin/hddumnt | 39 ++++++++++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 11 deletions(-) (limited to '.local/bin/hddumnt') diff --git a/.local/bin/hddumnt b/.local/bin/hddumnt index 4a883f7..75c6570 100755 --- a/.local/bin/hddumnt +++ b/.local/bin/hddumnt @@ -1,13 +1,30 @@ #!/bin/sh -e -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 ~/hdd' +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 $mountpoint" + fi + if ! doas cryptsetup close "$devname"; then + notify-send -u critical 'exthdd' " failed to close crypt dev $devname" + fi + rmdir "$mountpoint" + notify-send -t 5000 'exthdd' " crypt dev dismounted from $mountpoint" + ;; + 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 ~/hdd' + ;; +esac -- cgit v1.2.3