fix: auto-elevate to root via sudo or doas in install script
- 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:
@@ -26,16 +26,19 @@ 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 $*"
|
||||
fi
|
||||
echo "❌ This script must be run as root."
|
||||
echo " Install sudo or doas, or run as root directly."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# ── 0. Detect OS + privilege elevation method ──────────────────────
|
||||
if [ -f /etc/alpine-release ]; then
|
||||
|
||||
Reference in New Issue
Block a user