fix: add root privilege check to install-gitea-runner.sh
- Exits early with clear error if not run as root - Suggests 'doas' on Alpine, 'sudo' on Debian/Arch - Prevents silent failure from apk add / apt-get requiring root
This commit is contained in:
@@ -26,6 +26,17 @@ if [ -z "$TOKEN" ] || [ -z "$NAME" ] || [ -z "$LABELS" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# ── 0. Require root ────────────────────────────────────────────────
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo "❌ This script must be run as root."
|
||||
if [ -f /etc/alpine-release ]; then
|
||||
echo " Use: doas $0 $*"
|
||||
else
|
||||
echo " Use: sudo $0 $*"
|
||||
fi
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# ── 0. Detect OS + privilege elevation method ──────────────────────
|
||||
if [ -f /etc/alpine-release ]; then
|
||||
OS="alpine"
|
||||
|
||||
Reference in New Issue
Block a user