From c5df29fbd7ea89ca24c10ac7d35e20093868c40a Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Thu, 9 Jul 2026 10:15:56 +0300 Subject: add netbsd --- scripts/wol-f3s | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'scripts') diff --git a/scripts/wol-f3s b/scripts/wol-f3s index 95c1766..a5f8030 100755 --- a/scripts/wol-f3s +++ b/scripts/wol-f3s @@ -44,12 +44,15 @@ PI3_IP="192.168.1.128" # from ~/.shelly_plug if that file exists. # # The shutdown paths need root (to umount NFS), so this script is typically -# run via sudo. Under sudo $HOME becomes /root, where ~/.shelly_plug does not -# exist — so resolve the file relative to the invoking user's home when -# $SUDO_USER is set, falling back to $HOME otherwise. +# run elevated. When elevated, $HOME becomes root's home, where ~/.shelly_plug +# does not exist — so resolve the file relative to the invoking user's home +# ($SUDO_USER under sudo on Linux, $DOAS_USER under doas on NetBSD Pis), +# falling back to $HOME otherwise. Uses ~-expansion (portable) rather than +# getent, which does not exist on NetBSD. SHELLY_IP="192.168.1.28" -if [[ -n "${SUDO_USER:-}" ]]; then - _shelly_home="$(getent passwd "$SUDO_USER" | cut -d: -f6)" +_shelly_user="${SUDO_USER:-${DOAS_USER:-}}" +if [[ -n "$_shelly_user" ]]; then + _shelly_home="$(eval echo "~${_shelly_user}")" SHELLY_PASS_FILE="${_shelly_home:-$HOME}/.shelly_plug" else SHELLY_PASS_FILE="${HOME}/.shelly_plug" -- cgit v1.2.3