nextwks.sh: add root check with clear error message

This commit is contained in:
Claus Lohmar 2026-07-11 00:13:01 +01:00
parent 6113f62ad2
commit 6e95c088e4

View file

@ -21,6 +21,13 @@ usage() {
MODE="${1#--}"
case "$MODE" in install|update|destroy) ;; *) usage ;; esac
# --- Must be root ---
if [ "$(id -u)" -ne 0 ]; then
echo "ERROR: This script must be run as root (use sudo)."
echo " sudo bash ~/nextwks.sh --$MODE"
exit 1
fi
# --- Load existing env (if any) ---
if [ -f "$BACKUP_DIR/.env" ]; then
set -a; source "$BACKUP_DIR/.env"; set +a