Update setup.sh
This commit is contained in:
parent
59af3af67e
commit
00689b0bd4
1 changed files with 4 additions and 4 deletions
8
setup.sh
8
setup.sh
|
@ -14,13 +14,13 @@ DEFAULT_SSH_KEY="ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCoxUu/nC1C03LvxIhCMzyMu7C
|
||||||
# Early root escalation
|
# Early root escalation
|
||||||
###############################################################################
|
###############################################################################
|
||||||
if [[ $EUID -ne 0 ]]; then
|
if [[ $EUID -ne 0 ]]; then
|
||||||
# If script is a file and whiptail exists, prompt via whiptail and re-run file under su
|
# Prompt for root password via whiptail if available
|
||||||
if [[ -f "$0" ]] && command -v whiptail &>/dev/null; then
|
if command -v whiptail &>/dev/null; then
|
||||||
PW=$(whiptail --passwordbox "Root privileges required.
|
PW=$(whiptail --passwordbox "Root privileges required.
|
||||||
Enter root password:" 10 60 3>&1 1>&2 2>&3) || exit 1
|
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
|
else
|
||||||
# Fall back for piped-in scripts
|
|
||||||
echo "Root privileges required; re-running under su..."
|
echo "Root privileges required; re-running under su..."
|
||||||
exec su -c "bash -s -- \"$@\"" root
|
exec su -c "bash -s -- \"$@\"" root
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue