nextwks.sh: auto-escalate to root via sudo instead of erroring out
This commit is contained in:
parent
6e95c088e4
commit
d23b6c2909
1 changed files with 3 additions and 4 deletions
|
|
@ -21,11 +21,10 @@ usage() {
|
||||||
MODE="${1#--}"
|
MODE="${1#--}"
|
||||||
case "$MODE" in install|update|destroy) ;; *) usage ;; esac
|
case "$MODE" in install|update|destroy) ;; *) usage ;; esac
|
||||||
|
|
||||||
# --- Must be root ---
|
# --- Auto-escalate to root if not already ---
|
||||||
if [ "$(id -u)" -ne 0 ]; then
|
if [ "$(id -u)" -ne 0 ]; then
|
||||||
echo "ERROR: This script must be run as root (use sudo)."
|
echo "[*] Escalating to root..."
|
||||||
echo " sudo bash ~/nextwks.sh --$MODE"
|
exec sudo bash "$(realpath "$0")" "$@"
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# --- Load existing env (if any) ---
|
# --- Load existing env (if any) ---
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue