From a7e8aa65815a4b85fdb16bb779d91db83d7ad2a0 Mon Sep 17 00:00:00 2001 From: wagesj45 Date: Fri, 25 Jul 2025 18:12:14 -0500 Subject: [PATCH] Add bootstrap.sh --- bootstrap.sh | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 bootstrap.sh diff --git a/bootstrap.sh b/bootstrap.sh new file mode 100644 index 0000000..1316122 --- /dev/null +++ b/bootstrap.sh @@ -0,0 +1,38 @@ +#!/bin/bash +set -euo pipefail + +URL="https://git.jordanwages.com/wagesj45/proxmox-server-setup/raw/branch/main/setup.sh" + +# make sure whiptail is available for the password prompt +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 + ROOTPW=$(whiptail --title "Authentication Required" \ + --passwordbox "Enter root password to elevate this script:" \ + 8 60 3>&1 1>&2 2>&3) || exit 1 + + # 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 + whiptail --title "Error" --msgbox "curl or wget not found; install one to continue." 8 60 + 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