42 lines
1.3 KiB
Bash
42 lines
1.3 KiB
Bash
#!/bin/bash
|
|
set -euo pipefail
|
|
|
|
URL="https://git.jordanwages.com/wagesj45/proxmox-server-setup/raw/branch/main/setup.sh"
|
|
|
|
# if we're not running as root, grab root password (whiptail if available, else tty)
|
|
if [[ $EUID -ne 0 ]]; then
|
|
if command -v whiptail >/dev/null 2>&1; then
|
|
ROOTPW=$(whiptail --title "Authentication Required" \
|
|
--passwordbox "Enter root password to elevate this script:" \
|
|
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
|
|
if command -v curl >/dev/null 2>&1; then
|
|
FETCH_CMD="curl -fsSL \"$URL\" | bash"
|
|
elif command -v wget >/dev/null 2>&1; then
|
|
FETCH_CMD="wget -qO- \"$URL\" | bash"
|
|
else
|
|
# 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
|
|
fi
|
|
|
|
# run the remote script as root
|
|
echo "$ROOTPW" | su - -c "$FETCH_CMD" root
|
|
exit $?
|
|
fi
|
|
|
|
# already root → fetch & exec directly
|
|
if command -v curl >/dev/null 2>&1; then
|
|
curl -fsSL "$URL" | bash
|
|
else
|
|
wget -qO- "$URL" | bash
|
|
fi
|