script support for doas added (actually now)

This commit is contained in:
Martin Dvořák 2026-09-24 07:12:14 +00:00
commit 7638fac97b

View file

@ -13,7 +13,6 @@
# ./install-dependencies-deb.sh --no-build # install deps + npm install only
# ./install-dependencies-deb.sh --no-npm # system packages only
#
alias sudo=doas
set -euo pipefail
MIN_NODE_MAJOR=20
@ -66,12 +65,19 @@ case "${ID:-}${ID_LIKE:-}" in
esac
# --- root / sudo helper ---------------------------------------------------
# Prefer sudo when present, otherwise fall back to OpenDoas (doas).
SUDO=""
SUDO_ENV_FLAG=""
if [ "$(id -u)" -eq 0 ]; then
SUDO=""
elif command -v sudo >/dev/null 2>&1; then
SUDO="sudo"
SUDO_ENV_FLAG="-E" # sudo resets the environment by default; keep ours
elif command -v doas >/dev/null 2>&1; then
SUDO="doas"
SUDO_ENV_FLAG="" # doas has no -E; it preserves the environment itself
else
die "Not root and 'sudo' is not installed. Re-run as root."
die "Not root and neither 'sudo' nor 'doas' is installed. Re-run as root."
fi
# --- system packages ------------------------------------------------------
@ -108,7 +114,7 @@ else
warn "Node.js $(node -v) is too old for Next.js 16; installing current LTS."
fi
log "Installing Node.js LTS from NodeSource"
curl -fsSL https://deb.nodesource.com/setup_lts.x | $SUDO -E bash -
curl -fsSL https://deb.nodesource.com/setup_lts.x | $SUDO $SUDO_ENV_FLAG bash -
$SUDO apt-get install -y nodejs
fi