From b957dc3c90c75d74a4bb26100074f81703547a00 Mon Sep 17 00:00:00 2001 From: Anton Volnuhin Date: Tue, 3 Mar 2026 02:58:09 +0300 Subject: [PATCH] fix $SUDO detection: skip when root, check doas.conf exists MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- run_onchange_after_install_main_deps.sh.tmpl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/run_onchange_after_install_main_deps.sh.tmpl b/run_onchange_after_install_main_deps.sh.tmpl index 39ea8bc..71819d8 100644 --- a/run_onchange_after_install_main_deps.sh.tmpl +++ b/run_onchange_after_install_main_deps.sh.tmpl @@ -36,8 +36,10 @@ PAD_LEN=4 BASE_PACKAGES="gnupg curl wget git" ACT_PACKAGES="ripgrep unzip htop fzf bat gawk jq nnn tmux mc nethogs ngrep mtr gcc" -# Prefer doas over sudo (FreeBSD) -if command -v doas >/dev/null 2>&1; then +# Prefer doas over sudo (FreeBSD/OpenBSD), skip if already root +if [ "$(id -u)" -eq 0 ]; then + SUDO="" +elif command -v doas >/dev/null 2>&1 && [ -f /etc/doas.conf ]; then SUDO="doas" elif command -v sudo >/dev/null 2>&1; then SUDO="sudo"