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,16 +26,19 @@ if [ -z "$TOKEN" ] || [ -z "$NAME" ] || [ -z "$LABELS" ]; then
exit 1 exit 1
fi fi
# ── 0. Require root ──────────────────────────────────────────────── # ── 0. Require root — auto-elevate if possible ────────────────────
if [ "$(id -u)" -ne 0 ]; then if [ "$(id -u)" -ne 0 ]; then
echo "❌ This script must be run as root." # Try to re-execute with available privilege escalation
if [ -f /etc/alpine-release ]; then if command -v sudo >/dev/null 2>&1; then
echo " Use: doas $0 $*" exec sudo "$0" "$@"
elif command -v doas >/dev/null 2>&1; then
exec doas "$0" "$@"
else else
echo " Use: sudo $0 $*" echo "❌ This script must be run as root."
fi echo " Install sudo or doas, or run as root directly."
exit 1 exit 1
fi fi
fi
# ── 0. Detect OS + privilege elevation method ────────────────────── # ── 0. Detect OS + privilege elevation method ──────────────────────
if [ -f /etc/alpine-release ]; then if [ -f /etc/alpine-release ]; then