nextwks.sh: add root check with clear error message
This commit is contained in:
parent
6113f62ad2
commit
6e95c088e4
1 changed files with 7 additions and 0 deletions
|
|
@ -21,6 +21,13 @@ usage() {
|
||||||
MODE="${1#--}"
|
MODE="${1#--}"
|
||||||
case "$MODE" in install|update|destroy) ;; *) usage ;; esac
|
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) ---
|
# --- Load existing env (if any) ---
|
||||||
if [ -f "$BACKUP_DIR/.env" ]; then
|
if [ -f "$BACKUP_DIR/.env" ]; then
|
||||||
set -a; source "$BACKUP_DIR/.env"; set +a
|
set -a; source "$BACKUP_DIR/.env"; set +a
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue