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
|
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
|
||||||
|
|||||||
Reference in New Issue
Block a user