Fixed whiptail dependency in the bootstrap with a failover.
This commit is contained in:
parent
35a3593ff6
commit
11a4c59e18
1 changed files with 15 additions and 11 deletions
20
bootstrap.sh
20
bootstrap.sh
|
@ -3,17 +3,20 @@ set -euo pipefail
|
||||||
|
|
||||||
URL="https://git.jordanwages.com/wagesj45/proxmox-server-setup/raw/branch/main/setup.sh"
|
URL="https://git.jordanwages.com/wagesj45/proxmox-server-setup/raw/branch/main/setup.sh"
|
||||||
|
|
||||||
# make sure whiptail is available for the password prompt
|
# if we're not running as root, grab root password (whiptail if available, else tty)
|
||||||
if ! command -v whiptail >/dev/null 2>&1; then
|
|
||||||
echo "Error: whiptail is required for this bootstrap." >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# if we're not running as root, grab root password and re-exec via su
|
|
||||||
if [[ $EUID -ne 0 ]]; then
|
if [[ $EUID -ne 0 ]]; then
|
||||||
|
if command -v whiptail >/dev/null 2>&1; then
|
||||||
ROOTPW=$(whiptail --title "Authentication Required" \
|
ROOTPW=$(whiptail --title "Authentication Required" \
|
||||||
--passwordbox "Enter root password to elevate this script:" \
|
--passwordbox "Enter root password to elevate this script:" \
|
||||||
8 60 3>&1 1>&2 2>&3) || exit 1
|
8 60 3>&1 1>&2 2>&3) || exit 1
|
||||||
|
else
|
||||||
|
# Fallback to a simple TTY prompt if whiptail is missing
|
||||||
|
printf "Enter root password to elevate this script: "
|
||||||
|
stty -echo 2>/dev/null || true
|
||||||
|
read -r ROOTPW || exit 1
|
||||||
|
stty echo 2>/dev/null || true
|
||||||
|
printf "\n"
|
||||||
|
fi
|
||||||
|
|
||||||
# choose fetch tool
|
# choose fetch tool
|
||||||
if command -v curl >/dev/null 2>&1; then
|
if command -v curl >/dev/null 2>&1; then
|
||||||
|
@ -21,7 +24,8 @@ if [[ $EUID -ne 0 ]]; then
|
||||||
elif command -v wget >/dev/null 2>&1; then
|
elif command -v wget >/dev/null 2>&1; then
|
||||||
FETCH_CMD="wget -qO- \"$URL\" | bash"
|
FETCH_CMD="wget -qO- \"$URL\" | bash"
|
||||||
else
|
else
|
||||||
whiptail --title "Error" --msgbox "curl or wget not found; install one to continue." 8 60
|
# No network fetch tool available without root; ask user to install one
|
||||||
|
echo "Error: curl or wget is required. Install one and re-run." >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue