diff options
| author | Paul Buetow <paul@buetow.org> | 2026-07-09 10:15:56 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-07-09 10:15:56 +0300 |
| commit | c5df29fbd7ea89ca24c10ac7d35e20093868c40a (patch) | |
| tree | fc3096cfc0530a63f780283449283747f2148488 | |
| parent | 9956e4d355a2aefad8f78881974e7a004dd7447b (diff) | |
add netbsd
| -rwxr-xr-x | scripts/wol-f3s | 13 |
1 files changed, 8 insertions, 5 deletions
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" |
