fix $SUDO detection: skip when root, check doas.conf exists

On OpenBSD the doas binary exists but /etc/doas.conf may not, causing
'doas is not enabled' errors. Now checks: root → no sudo needed,
doas + config exists → use doas, sudo available → use sudo.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Anton Volnuhin 2026-03-03 02:58:09 +03:00
parent 9af745427e
commit b957dc3c90

View File

@ -36,8 +36,10 @@ PAD_LEN=4
BASE_PACKAGES="gnupg curl wget git" BASE_PACKAGES="gnupg curl wget git"
ACT_PACKAGES="ripgrep unzip htop fzf bat gawk jq nnn tmux mc nethogs ngrep mtr gcc" ACT_PACKAGES="ripgrep unzip htop fzf bat gawk jq nnn tmux mc nethogs ngrep mtr gcc"
# Prefer doas over sudo (FreeBSD) # Prefer doas over sudo (FreeBSD/OpenBSD), skip if already root
if command -v doas >/dev/null 2>&1; then if [ "$(id -u)" -eq 0 ]; then
SUDO=""
elif command -v doas >/dev/null 2>&1 && [ -f /etc/doas.conf ]; then
SUDO="doas" SUDO="doas"
elif command -v sudo >/dev/null 2>&1; then elif command -v sudo >/dev/null 2>&1; then
SUDO="sudo" SUDO="sudo"