Revert pimox

This commit is contained in:
Sam Heinz
2025-08-09 09:11:51 +10:00
committed by GitHub
parent b85ffd648a
commit 186c0d494c

View File

@@ -23,65 +23,49 @@ EOF
} }
clear clear
header_info header_info
echo -e "\n Loading..." echo -e "Loading..."
GEN_MAC=02:$(openssl rand -hex 5 | awk '{print toupper($0)}' | sed 's/\(..\)/\1:/g; s/.$//')
RANDOM_UUID="$(cat /proc/sys/kernel/random/uuid)" RANDOM_UUID="$(cat /proc/sys/kernel/random/uuid)"
VERSIONS=(stable beta dev)
METHOD="" METHOD=""
NSAPP="pimox-haos-vm" NSAPP="pimox-haos-vm"
var_os="pimox-haos" var_os="pimox-haos"
var_version=" "
DISK_SIZE="32G" DISK_SIZE="32G"
GEN_MAC=$(echo '00 60 2f'$(od -An -N3 -t xC /dev/urandom) | sed -e 's/ /:/g' | tr '[:lower:]' '[:upper:]')
for version in "${VERSIONS[@]}"; do USEDID=$(pvesh get /cluster/resources --type vm --output-format yaml | egrep -i 'vmid' | awk '{print substr($2, 1, length($2)-0) }')
eval "$version=$(curl -fsSL https://raw.githubusercontent.com/home-assistant/version/master/stable.json | grep '"ova"' | cut -d '"' -f 4)" STABLE=$(curl -fsSL https://raw.githubusercontent.com/home-assistant/version/master/stable.json | grep "ova" | awk '{print substr($2, 2, length($2)-3) }')
done BETA=$(curl -fsSL https://raw.githubusercontent.com/home-assistant/version/master/beta.json | grep "ova" | awk '{print substr($2, 2, length($2)-3) }')
DEV=$(curl -fsSL https://raw.githubusercontent.com/home-assistant/version/master/dev.json | grep "ova" | awk '{print substr($2, 2, length($2)-3) }')
YW=$(echo "\033[33m") YW=$(echo "\033[33m")
BL=$(echo "\033[36m") BL=$(echo "\033[36m")
HA=$(echo "\033[1;34m")
RD=$(echo "\033[01;31m") RD=$(echo "\033[01;31m")
BGN=$(echo "\033[4;92m") BGN=$(echo "\033[4;92m")
GN=$(echo "\033[1;92m") GN=$(echo "\033[1;92m")
DGN=$(echo "\033[32m") DGN=$(echo "\033[32m")
CL=$(echo "\033[m") CL=$(echo "\033[m")
CL=$(echo "\033[m")
BOLD=$(echo "\033[1m")
BFR="\\r\\033[K" BFR="\\r\\033[K"
HOLD=" " HOLD="-"
TAB=" " CM="${GN}${CL}"
CROSS="${RD}${CL}"
CM="${TAB}✔️${TAB}${CL}" set -o errexit
CROSS="${TAB}✖️${TAB}${CL}" set -o errtrace
INFO="${TAB}💡${TAB}${CL}" set -o nounset
OS="${TAB}🖥️${TAB}${CL}" set -o pipefail
CONTAINERTYPE="${TAB}📦${TAB}${CL}" shopt -s expand_aliases
DISKSIZE="${TAB}💾${TAB}${CL}" alias die='EXIT=$? LINE=$LINENO error_exit'
CPUCORE="${TAB}🧠${TAB}${CL}" trap die ERR
RAMSIZE="${TAB}🛠️${TAB}${CL}"
CONTAINERID="${TAB}🆔${TAB}${CL}"
HOSTNAME="${TAB}🏠${TAB}${CL}"
BRIDGE="${TAB}🌉${TAB}${CL}"
GATEWAY="${TAB}🌐${TAB}${CL}"
DEFAULT="${TAB}⚙️${TAB}${CL}"
MACADDRESS="${TAB}🔗${TAB}${CL}"
VLANTAG="${TAB}🏷️${TAB}${CL}"
CREATING="${TAB}🚀${TAB}${CL}"
ADVANCED="${TAB}🧩${TAB}${CL}"
CLOUD="${TAB}☁️${TAB}${CL}"
THIN="discard=on,ssd=1,"
set -e
trap 'error_handler $LINENO "$BASH_COMMAND"' ERR
trap cleanup EXIT trap cleanup EXIT
trap 'post_update_to_api "failed" "INTERRUPTED"' SIGINT trap 'post_update_to_api "failed" "INTERRUPTED"' SIGINT
trap 'post_update_to_api "failed" "TERMINATED"' SIGTERM trap 'post_update_to_api "failed" "TERMINATED"' SIGTERM
function error_handler() { function error_exit() {
local exit_code="$?" trap - ERR
local line_number="$1" local reason="Unknown failure occurred."
local command="$2" local msg="${1:-$reason}"
local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" local flag="${RD}ERROR ${CL}$EXIT@$LINE"
post_update_to_api "failed" "${command}" post_update_to_api "failed" "unknown"
echo -e "\n$error_message\n" echo -e "$flag $msg" 1>&2
cleanup_vmid [ ! -z ${VMID-} ] && cleanup_vmid
exit $EXIT
} }
function get_valid_nextid() { function get_valid_nextid() {
@@ -102,111 +86,51 @@ function get_valid_nextid() {
} }
function cleanup_vmid() { function cleanup_vmid() {
if qm status $VMID &>/dev/null; then if $(qm status $VMID &>/dev/null); then
qm stop $VMID &>/dev/null if [ "$(qm status $VMID | awk '{print $2}')" == "running" ]; then
qm destroy $VMID &>/dev/null qm stop $VMID
fi
qm destroy $VMID
fi fi
} }
function cleanup() { function cleanup() {
popd >/dev/null popd >/dev/null
post_update_to_api "done" "none"
rm -rf $TEMP_DIR rm -rf $TEMP_DIR
} }
TEMP_DIR=$(mktemp -d) TEMP_DIR=$(mktemp -d)
pushd $TEMP_DIR >/dev/null pushd $TEMP_DIR >/dev/null
if whiptail --backtitle "Proxmox VE Helper Scripts" --title "Pimox Homeassistant OS VM" --yesno "This will create a New Pimox Homeassistant OS VM. Proceed?" 10 58; then if ! command -v whiptail &>/dev/null; then
: echo "Installing whiptail..."
else apt-get update &>/dev/null
header_info && echo -e "${CROSS}${RD}User exited script${CL}\n" && exit apt-get install -y whiptail &>/dev/null
fi fi
if (whiptail --backtitle "Proxmox VE Helper Scripts" --title "PiMox HAOS VM" --yesno "This will create a New PiMox HAOS VM. Proceed?" 10 58); then
function msg_info() { echo "User selected Yes"
local msg="$1" else
echo -ne "${TAB}${YW}${HOLD}${msg}${HOLD}"
}
function msg_ok() {
local msg="$1"
echo -e "${BFR}${CM}${GN}${msg}${CL}"
}
function msg_error() {
local msg="$1"
echo -e "${BFR}${CROSS}${RD}${msg}${CL}"
}
function check_root() {
if [[ "$(id -u)" -ne 0 || $(ps -o comm= -p $PPID) == "sudo" ]]; then
clear clear
msg_error "Please run this script as root." echo -e "⚠ User exited script \n"
echo -e "\nExiting..."
sleep 2
exit exit
fi fi
} function ARCH_CHECK() {
ARCH=$(dpkg --print-architecture)
pve_check() { if [[ "$ARCH" == "amd64" ]]; then
local PVE_VER echo -e "\n ❌ This script only works with PiMox! \n"
PVE_VER="$(pveversion | awk -F'/' '{print $2}' | awk -F'-' '{print $1}')"
# Check for Proxmox VE 8.x
if [[ "$PVE_VER" =~ ^8\.([0-9]+) ]]; then
local MINOR="${BASH_REMATCH[1]}"
if ((MINOR < 1 || MINOR > 4)); then
msg_error "This version of Proxmox VE is not supported."
echo -e "Required: Proxmox VE version 8.1 8.4"
exit 1
fi
return 0
fi
# Check for Proxmox VE 9.x (Beta) — require confirmation
if [[ "$PVE_VER" =~ ^9\.([0-9]+) ]]; then
if whiptail --title "Proxmox 9.x Detected (Beta)" \
--yesno "You are using Proxmox VE $PVE_VER, which is currently in Beta state.\n\nThis version is experimentally supported.\n\nDo you want to proceed anyway?" 12 70; then
msg_ok "Confirmed: Continuing with Proxmox VE $PVE_VER"
return 0
else
msg_error "Aborted by user: Proxmox VE 9.x was not confirmed."
exit 1
fi
fi
# All other unsupported versions
msg_error "This version of Proxmox VE is not supported."
echo -e "Supported versions: Proxmox VE 8.1 8.4 or 9.x (Beta, with confirmation)"
exit 1
}
function arch_check() {
if [ "$(dpkg --print-architecture)" != "amd64" ]; then
echo -e "\n ${INFO}${YWB}This script will not work with PiMox! \n"
echo -e "\n ${YWB}Visit https://github.com/asylumexp/Proxmox for ARM64 support. \n"
echo -e "Exiting..." echo -e "Exiting..."
sleep 2 sleep 2
exit exit
fi fi
} }
function msg_info() {
function ssh_check() { local msg="$1"
if command -v pveversion >/dev/null 2>&1; then echo -ne " ${HOLD} ${YW}${msg}..."
if [ -n "${SSH_CLIENT:+x}" ]; then
if whiptail --backtitle "Proxmox VE Helper Scripts" --defaultno --title "SSH DETECTED" --yesno "It's suggested to use the Proxmox shell instead of SSH, since SSH can create issues while gathering variables. Would you like to proceed with using SSH?" 10 62; then
echo "you've been warned"
else
clear
exit
fi
fi
fi
} }
function msg_ok() {
function exit-script() { local msg="$1"
clear echo -e "${BFR} ${CM} ${GN}${msg}${CL}"
echo -e "\n${CROSS}${RD}User exited script${CL}\n" }
exit function msg_error() {
local msg="$1"
echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}"
} }
function default_settings() { function default_settings() {
@@ -258,10 +182,10 @@ function advanced_settings() {
if [ $exitstatus = 0 ]; then echo -e "${DGN}Virtual Machine ID: ${BGN}$VMID${CL}"; fi if [ $exitstatus = 0 ]; then echo -e "${DGN}Virtual Machine ID: ${BGN}$VMID${CL}"; fi
fi fi
fi fi
VM_NAME=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set Hostname" 8 58 haosStable --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3) VM_NAME=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set Hostname" 8 58 haos${BRANCH} --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
exitstatus=$? exitstatus=$?
if [ -z $VM_NAME ]; then if [ -z $VM_NAME ]; then
HN="haosStable" HN="haos${BRANCH}"
echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}" echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
else else
if [ $exitstatus = 0 ]; then if [ $exitstatus = 0 ]; then
@@ -333,7 +257,7 @@ function advanced_settings() {
echo -e "${DGN}Start VM when completed: ${BGN}no${CL}" echo -e "${DGN}Start VM when completed: ${BGN}no${CL}"
START_VM="no" START_VM="no"
fi fi
if (whiptail --backtitle "Proxmox VE Helper Scripts" --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create HAOS Stable VM?" --no-button Do-Over 10 58); then if (whiptail --backtitle "Proxmox VE Helper Scripts" --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create HAOS ${BRANCH} VM?" --no-button Do-Over 10 58); then
echo -e "${RD}Creating a HAOS VM using the above advanced settings${CL}" echo -e "${RD}Creating a HAOS VM using the above advanced settings${CL}"
else else
clear clear
@@ -355,7 +279,7 @@ function START_SCRIPT() {
advanced_settings advanced_settings
fi fi
} }
ARCH_CHECK
START_SCRIPT START_SCRIPT
post_to_api_vm post_to_api_vm
while read -r line; do while read -r line; do
@@ -384,14 +308,14 @@ else
fi fi
msg_ok "Using ${CL}${BL}$STORAGE${CL} ${GN}for Storage Location." msg_ok "Using ${CL}${BL}$STORAGE${CL} ${GN}for Storage Location."
msg_ok "Virtual Machine ID is ${CL}${BL}$VMID${CL}." msg_ok "Virtual Machine ID is ${CL}${BL}$VMID${CL}."
msg_info "Getting URL for Home Assistant Stable Disk Image" msg_info "Getting URL for Home Assistant ${BRANCH} Disk Image"
URL=https://github.com/home-assistant/operating-system/releases/download/16.0/haos_generic-aarch64-16.0.qcow2.xz URL=https://github.com/home-assistant/operating-system/releases/download/${BRANCH}/haos_generic-aarch64-${BRANCH}.qcow2.xz
sleep 2 sleep 2
msg_ok "${CL}${BL}${URL}${CL}" msg_ok "${CL}${BL}${URL}${CL}"
curl -f#SL -o "$(basename "$URL")" "$URL" curl -f#SL -o "$(basename "$URL")" "$URL"
echo -en "\e[1A\e[0K" echo -en "\e[1A\e[0K"
FILE=$(basename $URL) FILE=$(basename $URL)
msg_ok "Downloaded ${CL}${BL}haos_generic-aarch64-16.0.qcow2.xz${CL}" msg_ok "Downloaded ${CL}${BL}haos_generic-aarch64-${BRANCH}.qcow2.xz${CL}"
msg_info "Extracting Disk Image" msg_info "Extracting Disk Image"
unxz $FILE unxz $FILE
STORAGE_TYPE=$(pvesm status -storage $STORAGE | awk 'NR>1 {print $2}') STORAGE_TYPE=$(pvesm status -storage $STORAGE | awk 'NR>1 {print $2}')
@@ -417,47 +341,13 @@ qm set $VMID \
-efidisk0 ${DISK0_REF},efitype=4m,size=64M \ -efidisk0 ${DISK0_REF},efitype=4m,size=64M \
-scsi0 ${DISK1_REF},size=32G >/dev/null -scsi0 ${DISK1_REF},size=32G >/dev/null
qm set $VMID \ qm set $VMID \
-boot order=scsi0 >/dev/null -boot order=scsi0 \
-description "<div align='center'><a href='https://Helper-Scripts.com'><img src='https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/images/logo-81x112.png'/></a>
DESCRIPTION=$( # Home Assistant OS
cat <<EOF
<div align='center'>
<a href='https://Helper-Scripts.com' target='_blank' rel='noopener noreferrer'>
<img src='https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/images/logo-81x112.png' alt='Logo' style='width:81px;height:112px;'/>
</a>
<h2 style='font-size: 24px; margin: 20px 0;'>Homeassistant VM</h2>
<p style='margin: 16px 0;'>
<a href='https://ko-fi.com/community_scripts' target='_blank' rel='noopener noreferrer'>
<img src='https://img.shields.io/badge/&#x2615;-Buy us a coffee-blue' alt='spend Coffee' />
</a>
</p>
<span style='margin: 0 10px;'>
<i class="fa fa-github fa-fw" style="color: #f5f5f5;"></i>
<a href='https://github.com/community-scripts/ProxmoxVE' target='_blank' rel='noopener noreferrer' style='text-decoration: none; color: #00617f;'>GitHub</a>
</span>
<span style='margin: 0 10px;'>
<i class="fa fa-comments fa-fw" style="color: #f5f5f5;"></i>
<a href='https://github.com/community-scripts/ProxmoxVE/discussions' target='_blank' rel='noopener noreferrer' style='text-decoration: none; color: #00617f;'>Discussions</a>
</span>
<span style='margin: 0 10px;'>
<i class="fa fa-exclamation-circle fa-fw" style="color: #f5f5f5;"></i>
<a href='https://github.com/community-scripts/ProxmoxVE/issues' target='_blank' rel='noopener noreferrer' style='text-decoration: none; color: #00617f;'>Issues</a>
</span>
</div>
EOF
)
qm set "$VMID" -description "$DESCRIPTION" >/dev/null
if [ -n "$DISK_SIZE" ]; then
msg_info "Resizing disk to $DISK_SIZE GB"
qm resize $VMID scsi0 ${DISK_SIZE} >/dev/null
else
msg_info "Using default disk size of $DEFAULT_DISK_SIZE GB"
qm resize $VMID scsi0 ${DEFAULT_DISK_SIZE} >/dev/null
fi
<a href='https://ko-fi.com/D1D7EP4GF'><img src='https://img.shields.io/badge/&#x2615;-Buy me a coffee-blue' /></a>
</div>" >/dev/null
msg_ok "Created HAOS VM ${CL}${BL}(${HN})" msg_ok "Created HAOS VM ${CL}${BL}(${HN})"
if [ "$START_VM" == "yes" ]; then if [ "$START_VM" == "yes" ]; then
msg_info "Starting Home Assistant OS VM" msg_info "Starting Home Assistant OS VM"