Update setup.sh

This commit is contained in:
Jordan Wages 2025-07-25 15:34:41 -05:00
parent 59af3af67e
commit 00689b0bd4

View file

@ -14,13 +14,13 @@ DEFAULT_SSH_KEY="ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCoxUu/nC1C03LvxIhCMzyMu7C
# Early root escalation
###############################################################################
if [[ $EUID -ne 0 ]]; then
# If script is a file and whiptail exists, prompt via whiptail and re-run file under su
if [[ -f "$0" ]] && command -v whiptail &>/dev/null; then
# Prompt for root password via whiptail if available
if command -v whiptail &>/dev/null; then
PW=$(whiptail --passwordbox "Root privileges required.
Enter root password:" 10 60 3>&1 1>&2 2>&3) || exit 1
exec su root -c "$0 $*" <<<"$PW"
# Re-exec under su using stdin for piped or file-based scripts
exec su root -c "bash -s -- \"$@\"" <<<"$PW"
else
# Fall back for piped-in scripts
echo "Root privileges required; re-running under su..."
exec su -c "bash -s -- \"$@\"" root
fi