fix: auto-elevate to root via sudo or doas in install script
CI / lint (push) Successful in 22s
CI / security (push) Successful in 14s
CI / test (push) Successful in 28s
CI / build (push) Successful in 6s
CI / e2e (push) Failing after 12s

- Script now re-executes itself with 'sudo' if available (or 'doas' as fallback)
- No need to prefix with sudo/doas — just run ./install-gitea-runner.sh ...
- Falls back to clear error if neither sudo nor doas is installed
This commit is contained in:
2026-07-25 10:10:31 -04:00
parent 65a0221557
commit ed031baf92
+9 -6
View File
@@ -26,15 +26,18 @@ if [ -z "$TOKEN" ] || [ -z "$NAME" ] || [ -z "$LABELS" ]; then
exit 1
fi
# ── 0. Require root ────────────────────────────────────────────────
# ── 0. Require root — auto-elevate if possible ────────────────────
if [ "$(id -u)" -ne 0 ]; then
echo "❌ This script must be run as root."
if [ -f /etc/alpine-release ]; then
echo " Use: doas $0 $*"
# Try to re-execute with available privilege escalation
if command -v sudo >/dev/null 2>&1; then
exec sudo "$0" "$@"
elif command -v doas >/dev/null 2>&1; then
exec doas "$0" "$@"
else
echo " Use: sudo $0 $*"
echo "❌ This script must be run as root."
echo " Install sudo or doas, or run as root directly."
exit 1
fi
exit 1
fi
# ── 0. Detect OS + privilege elevation method ──────────────────────