From 433c1067a166d88cef7d1c12cc0c6180bf497f47 Mon Sep 17 00:00:00 2001 From: Joe Date: Sun, 26 Jun 2022 21:33:40 +0200 Subject: update --- .local/bin/hddmnt | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to '.local/bin/hddmnt') diff --git a/.local/bin/hddmnt b/.local/bin/hddmnt index 242f4d0..62bfff6 100755 --- a/.local/bin/hddmnt +++ b/.local/bin/hddmnt @@ -1,8 +1,21 @@ #!/bin/sh -e -tmp=$(mktemp) - -dmenu -p "Enter password: " -nb '#1d2021' -nf '#1d2021' <&- >"$tmp" -geli attach -k /root/geli_keys/hdd_ext.key -j "$tmp" /dev/da0 +if ! diskinfo da0 >/dev/null; then + notify-send -u critical 'fathdd' ' HDD not detected' + exit 1 +fi +if mount | grep -F /dev/da0p1; then + notify-send -u critical \ + 'fathdd' \ + " HDD already mounted to \ +$(mount | grep -F '/dev/da0p1' | awk '{print $3}')" + exit 1 +fi +if ! dmenu -p 'Enter password: ' -P | + geli attach -k /root/geli_keys/fathdd_ext.key -j - da0p1; then + notify-send -u critical 'fathdd' ' Failed to mount HDD' + exit 1 +fi mkdir -p "$HOME"/hdd -mount /dev/da0.eli "$HOME"/hdd +mount /dev/da0p1.eli "$HOME"/hdd +notify-send -t 5000 'fathdd' ' HDD mounted to ~/hdd' -- cgit v1.2.3