2022-08-06 15:23:25 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								#!/usr/bin/env bash
 
							 
						 
					
						
							
								
									
										
										
										
											2023-02-07 12:15:22 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-01-01 13:37:29 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								# Copyright (c) 2021-2025 tteck 
							 
						 
					
						
							
								
									
										
										
										
											2023-02-07 12:15:22 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								# Author: tteck (tteckster) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								# License: MIT 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-02 08:48:05 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								# https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE 
							 
						 
					
						
							
								
									
										
										
										
											2023-02-07 12:15:22 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-04-01 10:25:46 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								source  /dev/stdin <<< $( curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/api.func) 
							 
						 
					
						
							
								
									
										
										
										
											2025-02-10 09:13:09 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-01-25 10:42:35 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								function  header_info { 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-22 20:48:20 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								  cat <<"EOF" 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-25 10:42:35 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								                                      ____  _ __  ___                                        
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                                    / __ \( _)   | /  /___  _  __                              
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                                   / /_/ / / /| _/ / __ \|  | /_/                              
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                                  / ____/ / /  / / /_/ />  <                                
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    __  __                       /_/_  /_/_/  /_/\_ ___/_/| _|               __     ____  _____
							 
						 
					
						
							
								
									
										
										
										
											2023-03-22 20:48:20 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								   / / / /___  ____ ___  ___     /   |   __________( _) ____/ /_____ _____  / /_   / __ \/  ___/
							 
						 
					
						
							
								
									
										
										
										
											2023-01-25 10:42:35 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								  / /_/ / __ \/  __ ` __ \/  _ \    / /|  |  / ___/ ___/ / ___/ __/ __ ` / __ \/  __/  / / / /\_ _ \  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								 / __  / /_/ / / / / / /  __/  / ___ | ( __  | __  )  ( __  )  /_/ /_/ / / / / /_   / /_/ /___/ / 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								/_/ /_/\_ ___/_/ /_/ /_/\_ __/  /_/  | _/____/____/_/____/\_ _/\_ _,_/_/ /_/\_ _/   \_ ___//____/  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								                                                                                            
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								EOF
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								clear
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								header_info
							 
						 
					
						
							
								
									
										
										
										
											2025-06-18 22:08:23 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								echo  -e "\n Loading..." 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								GEN_MAC = 02:$( openssl rand -hex 5  |  awk '{print toupper($0)}'  |  sed 's/\(..\)/\1:/g; s/.$//' ) 
							 
						 
					
						
							
								
									
										
										
										
											2025-02-10 09:13:09 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								RANDOM_UUID = " $( cat /proc/sys/kernel/random/uuid) " 
							 
						 
					
						
							
								
									
										
										
										
											2025-06-18 22:08:23 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								VERSIONS = ( stable beta dev) 
							 
						 
					
						
							
								
									
										
										
										
											2025-02-10 09:13:09 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								METHOD = "" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								NSAPP = "pimox-haos-vm" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								var_os = "pimox-haos" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								DISK_SIZE = "32G" 
							 
						 
					
						
							
								
									
										
										
										
											2025-06-18 22:08:23 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								for  version in " ${ VERSIONS [@] } " ;  do 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  eval  " $version = $( curl -fsSL https://raw.githubusercontent.com/home-assistant/version/master/stable.json |  grep '"ova"'  |  cut -d '"'  -f 4) " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								done 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-22 20:48:20 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								YW = $( echo  "\033[33m" ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								BL = $( echo  "\033[36m" ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								RD = $( echo  "\033[01;31m" ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								BGN = $( echo  "\033[4;92m" ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								GN = $( echo  "\033[1;92m" ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								DGN = $( echo  "\033[32m" ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								CL = $( echo  "\033[m" ) 
							 
						 
					
						
							
								
									
										
										
										
											2025-06-18 22:08:23 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								CL = $( echo  "\033[m" ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								BOLD = $( echo  "\033[1m" ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-06 15:23:25 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								BFR = "\\r\\033[K" 
							 
						 
					
						
							
								
									
										
										
										
											2025-06-18 22:08:23 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								HOLD = " " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								TAB = "  " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								CM = " ${ TAB } ✔️ ${ TAB } ${ CL } " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								CROSS = " ${ TAB } ✖️ ${ TAB } ${ CL } " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								INFO = " ${ TAB } 💡 ${ TAB } ${ CL } " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								OS = " ${ TAB } 🖥️ ${ TAB } ${ CL } " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								CONTAINERTYPE = " ${ TAB } 📦 ${ TAB } ${ CL } " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								DISKSIZE = " ${ TAB } 💾 ${ TAB } ${ CL } " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								CPUCORE = " ${ TAB } 🧠 ${ TAB } ${ CL } " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								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
							 
						 
					
						
							
								
									
										
										
										
											2022-08-06 15:23:25 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								trap  cleanup EXIT
							 
						 
					
						
							
								
									
										
										
										
											2025-04-15 15:20:46 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								trap  'post_update_to_api "failed" "INTERRUPTED"'  SIGINT
							 
						 
					
						
							
								
									
										
										
										
											2025-02-10 09:13:09 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								trap  'post_update_to_api "failed" "TERMINATED"'  SIGTERM
							 
						 
					
						
							
								
									
										
										
										
											2025-06-18 22:08:23 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								function  error_handler( )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  local  exit_code = " $? " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  local  line_number = " $1 " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  local  command = " $2 " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  local  error_message = " ${ RD } [ERROR] ${ CL }  in line  ${ RD } $line_number ${ CL } : exit code  ${ RD } $exit_code ${ CL } : while executing command  ${ YW } $command ${ CL } " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  post_update_to_api "failed"  " ${ command } " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  echo  -e " \n $error_message \n " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  cleanup_vmid
							 
						 
					
						
							
								
									
										
										
										
											2022-08-06 15:23:25 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								} 
							 
						 
					
						
							
								
									
										
										
										
											2025-05-07 12:37:46 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								function  get_valid_nextid( )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  local  try_id
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  try_id = $( pvesh get /cluster/nextid) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  while  true;  do 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    if  [  -f " /etc/pve/qemu-server/ ${ try_id } .conf "  ]  ||  [  -f " /etc/pve/lxc/ ${ try_id } .conf "  ] ;  then 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      try_id = $(( try_id +  1 )) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      continue 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    fi 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    if  lvs --noheadings -o lv_name |  grep -qE " (^|[-_]) ${ try_id } ( $|[-_]) " ;  then 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      try_id = $(( try_id +  1 )) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      continue 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    fi 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    break 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  done 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  echo  " $try_id " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-08-06 15:23:25 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								function  cleanup_vmid( )  { 
							 
						 
					
						
							
								
									
										
										
										
											2025-06-18 22:08:23 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								  if  qm status $VMID  & >/dev/null;  then 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    qm stop $VMID  & >/dev/null
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    qm destroy $VMID  & >/dev/null
							 
						 
					
						
							
								
									
										
										
										
											2022-08-06 15:23:25 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  fi 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								} 
							 
						 
					
						
							
								
									
										
										
										
											2025-06-18 22:08:23 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-08-06 15:23:25 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								function  cleanup( )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  popd  >/dev/null
							 
						 
					
						
							
								
									
										
										
										
											2025-06-18 22:08:23 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								  post_update_to_api "done"  "none" 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-06 15:23:25 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  rm -rf $TEMP_DIR 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								} 
							 
						 
					
						
							
								
									
										
										
										
											2025-06-18 22:08:23 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-08-06 15:23:25 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								TEMP_DIR = $( mktemp -d) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								pushd  $TEMP_DIR  >/dev/null
							 
						 
					
						
							
								
									
										
										
										
											2025-06-19 07:29:00 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								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 
							 
						 
					
						
							
								
									
										
										
										
											2025-06-18 22:08:23 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								  :
							 
						 
					
						
							
								
									
										
										
										
											2022-08-06 15:23:25 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								else 
							 
						 
					
						
							
								
									
										
										
										
											2025-06-18 22:08:23 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								  header_info &&  echo  -e " ${ CROSS } ${ RD } User exited script ${ CL } \n "  &&  exit 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-06 15:23:25 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								fi 
							 
						 
					
						
							
								
									
										
										
										
											2025-06-18 22:08:23 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-08-06 15:23:25 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								function  msg_info( )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-22 20:48:20 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								  local  msg = " $1 " 
							 
						 
					
						
							
								
									
										
										
										
											2025-06-18 22:08:23 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								  echo  -ne " ${ TAB } ${ YW } ${ HOLD } ${ msg } ${ HOLD } " 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-06 15:23:25 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								} 
							 
						 
					
						
							
								
									
										
										
										
											2025-06-18 22:08:23 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-08-06 15:23:25 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								function  msg_ok( )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-22 20:48:20 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								  local  msg = " $1 " 
							 
						 
					
						
							
								
									
										
										
										
											2025-06-18 22:08:23 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								  echo  -e " ${ BFR } ${ CM } ${ GN } ${ msg } ${ CL } " 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-06 15:23:25 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								} 
							 
						 
					
						
							
								
									
										
										
										
											2025-06-18 22:08:23 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-29 12:11:55 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								function  msg_error( )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-22 20:48:20 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								  local  msg = " $1 " 
							 
						 
					
						
							
								
									
										
										
										
											2025-06-18 22:08:23 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								  echo  -e " ${ BFR } ${ CROSS } ${ RD } ${ msg } ${ CL } " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								function  check_root( )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  if  [ [  " $( id -u) "  -ne 0  ||  $( ps -o comm =  -p $PPID )  = =  "sudo"  ] ] ;  then 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    clear
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    msg_error "Please run this script as root." 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    echo  -e "\nExiting..." 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    sleep 2 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    exit 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  fi 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-08-06 13:46:07 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								# This function checks the version of Proxmox Virtual Environment (PVE) and exits if the version is not supported. 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
										 
									
								 
							
							
								# Supported: Proxmox VE 8.0.x –   8.9.x and 9.0 (NOT 9.1+) 
							 
						 
					
						
							
								
									
										
										
										
											2025-07-28 11:00:09 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								pve_check( )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  local  PVE_VER
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  PVE_VER = " $( pveversion |  awk -F'/'  '{print $2}'  |  awk -F'-'  '{print $1}' ) " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-08-06 13:46:07 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
										 
									
								 
							
							
								  # Check for Proxmox VE 8.x: allow 8.0–  8.9 
							 
						 
					
						
							
								
									
										
										
										
											2025-07-28 11:00:09 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								  if  [ [  " $PVE_VER "  = ~ ^8\. ( [ 0-9] +)  ] ] ;  then 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    local  MINOR = " ${ BASH_REMATCH [1] } " 
							 
						 
					
						
							
								
									
										
										
										
											2025-08-06 13:46:07 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								    if  ( ( MINOR < 0  ||  MINOR > 9) ) ;  then 
							 
						 
					
						
							
								
									
										
										
										
											2025-07-28 11:00:09 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								      msg_error "This version of Proxmox VE is not supported." 
							 
						 
					
						
							
								
									
										
										
										
											2025-08-06 13:46:07 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
										 
									
								 
							
							
								      msg_error "Supported: Proxmox VE version 8.0 –   8.9" 
							 
						 
					
						
							
								
									
										
										
										
											2025-07-28 11:00:09 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								      exit  1 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    fi 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    return  0 
							 
						 
					
						
							
								
									
										
										
										
											2025-06-18 22:08:23 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								  fi 
							 
						 
					
						
							
								
									
										
										
										
											2025-07-28 11:00:09 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-08-06 13:46:07 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								  # Check for Proxmox VE 9.x: allow ONLY 9.0 
							 
						 
					
						
							
								
									
										
										
										
											2025-07-28 11:00:09 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								  if  [ [  " $PVE_VER "  = ~ ^9\. ( [ 0-9] +)  ] ] ;  then 
							 
						 
					
						
							
								
									
										
										
										
											2025-08-06 13:46:07 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								    local  MINOR = " ${ BASH_REMATCH [1] } " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    if  ( ( MINOR !=  0) ) ;  then 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      msg_error "This version of Proxmox VE is not yet supported." 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      msg_error "Supported: Proxmox VE version 9.0" 
							 
						 
					
						
							
								
									
										
										
										
											2025-07-28 11:00:09 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								      exit  1 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    fi 
							 
						 
					
						
							
								
									
										
										
										
											2025-08-06 13:46:07 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								    return  0 
							 
						 
					
						
							
								
									
										
										
										
											2025-07-28 11:00:09 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								  fi 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  # All other unsupported versions 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  msg_error "This version of Proxmox VE is not supported." 
							 
						 
					
						
							
								
									
										
										
										
											2025-08-06 13:46:07 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
										 
									
								 
							
							
								  msg_error "Supported versions: Proxmox VE 8.0 –   8.x or 9.0" 
							 
						 
					
						
							
								
									
										
										
										
											2025-07-28 11:00:09 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								  exit  1 
							 
						 
					
						
							
								
									
										
										
										
											2025-06-18 22:08:23 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								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..." 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    sleep 2 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    exit 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  fi 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								function  ssh_check( )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  if  command  -v pveversion >/dev/null 2>& 1;  then 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    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  exit-script( )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  clear
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  echo  -e " \n ${ CROSS } ${ RD } User exited script ${ CL } \n " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  exit 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-29 12:11:55 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-08-06 15:23:25 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								function  default_settings( )  { 
							 
						 
					
						
							
								
									
										
										
										
											2025-02-10 09:13:09 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								  METHOD = "default" 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-22 20:48:20 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								  echo  -e " ${ DGN } Using HAOS Version:  ${ BGN } ${ STABLE } ${ CL } " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  BRANCH = ${ STABLE } 
							 
						 
					
						
							
								
									
										
										
										
											2025-05-08 12:57:27 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								  VMID = $( get_valid_nextid) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  echo  -e " ${ DGN } Using Virtual Machine ID:  ${ BGN } $VMID ${ CL } " 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-22 20:48:20 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								  echo  -e " ${ DGN } Using Hostname:  ${ BGN } haos ${ STABLE } ${ CL } " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  HN = haos${ STABLE } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  echo  -e " ${ DGN } Allocated Cores:  ${ BGN } 2 ${ CL } " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  CORE_COUNT = "2" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  echo  -e " ${ DGN } Allocated RAM:  ${ BGN } 4096 ${ CL } " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  RAM_SIZE = "4096" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  echo  -e " ${ DGN } Using Bridge:  ${ BGN } vmbr0 ${ CL } " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  BRG = "vmbr0" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  echo  -e " ${ DGN } Using MAC Address:  ${ BGN } $GEN_MAC ${ CL } " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  MAC = $GEN_MAC 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  echo  -e " ${ DGN } Using VLAN:  ${ BGN } Default ${ CL } " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  VLAN = "" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  echo  -e " ${ DGN } Using Interface MTU Size:  ${ BGN } Default ${ CL } " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  MTU = "" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  echo  -e " ${ DGN } Start VM when completed:  ${ BGN } yes ${ CL } " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  START_VM = "yes" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  echo  -e " ${ BL } Creating a HAOS VM using the above default settings ${ CL } " 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-06 15:23:25 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								function  advanced_settings( )  { 
							 
						 
					
						
							
								
									
										
										
										
											2025-02-10 09:13:09 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								  METHOD = "advanced" 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-09 05:13:17 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								  BRANCH = $( whiptail --backtitle "Proxmox VE Helper Scripts"  --title "HAOS VERSION"  --radiolist "Choose Version"  --cancel-button Exit-Script 10  58  3  \
 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-22 20:48:20 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								    " $STABLE "  "Stable"  ON \
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    " $BETA "  "Beta"  OFF \
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    " $DEV "  "Dev"  OFF \
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    3>& 1  1>& 2  2>& 3) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  exitstatus = $? 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  if  [  $exitstatus  =  0  ] ;  then  echo  -e " ${ DGN } Using HAOS Version:  ${ BGN } $BRANCH ${ CL } " ;  fi 
							 
						 
					
						
							
								
									
										
										
										
											2025-05-08 12:57:27 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								  [  -z " ${ VMID :- } "  ]  &&  VMID = $( get_valid_nextid) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  VMID = $( whiptail --backtitle "Proxmox VE Helper Scripts"  --inputbox "Set Virtual Machine ID"  8  58  $VMID  --title "VIRTUAL MACHINE ID"  --cancel-button Exit-Script 3>& 1  1>& 2  2>& 3) 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-22 20:48:20 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								  exitstatus = $? 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  if  [  -z $VMID  ] ;  then 
							 
						 
					
						
							
								
									
										
										
										
											2025-05-08 12:57:27 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								    VMID = " $VMID " 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-22 20:48:20 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								    echo  -e " ${ DGN } Virtual Machine:  ${ BGN } $VMID ${ CL } " 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-25 10:42:35 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								  else 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-22 20:48:20 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								    if  echo  " $USEDID "  |  egrep -q " $VMID " ;  then 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-25 10:42:35 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								      echo  -e " \n🚨   ${ RD } ID  $VMID  is already in use ${ CL }  \n " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      echo  -e "Exiting Script \n" 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-22 20:48:20 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								      sleep 2 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-25 10:42:35 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								      exit 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-22 20:48:20 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								    else 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      if  [  $exitstatus  =  0  ] ;  then  echo  -e " ${ DGN } Virtual Machine ID:  ${ BGN } $VMID ${ CL } " ;  fi 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    fi 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  fi 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-09 05:13:17 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								  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) 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-22 20:48:20 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								  exitstatus = $? 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  if  [  -z $VM_NAME  ] ;  then 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    HN = " haos ${ BRANCH } " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    echo  -e " ${ DGN } Using Hostname:  ${ BGN } $HN ${ CL } " 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-25 10:42:35 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								  else 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-22 20:48:20 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								    if  [  $exitstatus  =  0  ] ;  then 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      HN = $( echo  ${ VM_NAME ,, }  |  tr -d ' ' ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      echo  -e " ${ DGN } Using Hostname:  ${ BGN } $HN ${ CL } " 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-25 10:42:35 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								    fi 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-22 20:48:20 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								  fi 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-09 05:13:17 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								  CORE_COUNT = $( whiptail --backtitle "Proxmox VE Helper Scripts"  --inputbox "Allocate CPU Cores"  8  58  2  --title "CORE COUNT"  --cancel-button Exit-Script 3>& 1  1>& 2  2>& 3) 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-22 20:48:20 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								  exitstatus = $? 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  if  [  -z $CORE_COUNT  ] ;  then 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    CORE_COUNT = "2" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    echo  -e " ${ DGN } Allocated Cores:  ${ BGN } $CORE_COUNT ${ CL } " 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-25 10:42:35 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								  else 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-22 20:48:20 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								    if  [  $exitstatus  =  0  ] ;  then  echo  -e " ${ DGN } Allocated Cores:  ${ BGN } $CORE_COUNT ${ CL } " ;  fi 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-25 10:42:35 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								  fi 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-09 05:13:17 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								  RAM_SIZE = $( whiptail --backtitle "Proxmox VE Helper Scripts"  --inputbox "Allocate RAM in MiB"  8  58  4096  --title "RAM"  --cancel-button Exit-Script 3>& 1  1>& 2  2>& 3) 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-22 20:48:20 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								  exitstatus = $? 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  if  [  -z $RAM_SIZE  ] ;  then 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    RAM_SIZE = "4096" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    echo  -e " ${ DGN } Allocated RAM:  ${ BGN } $RAM_SIZE ${ CL } " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  else 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    if  [  $exitstatus  =  0  ] ;  then  echo  -e " ${ DGN } Allocated RAM:  ${ BGN } $RAM_SIZE ${ CL } " ;  fi 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  fi 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-09 05:13:17 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								  BRG = $( whiptail --backtitle "Proxmox VE Helper Scripts"  --inputbox "Set a Bridge"  8  58  vmbr0 --title "BRIDGE"  --cancel-button Exit-Script 3>& 1  1>& 2  2>& 3) 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-22 20:48:20 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								  exitstatus = $? 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  if  [  -z $BRG  ] ;  then 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    BRG = "vmbr0" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    echo  -e " ${ DGN } Using Bridge:  ${ BGN } $BRG ${ CL } " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  else 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    if  [  $exitstatus  =  0  ] ;  then  echo  -e " ${ DGN } Using Bridge:  ${ BGN } $BRG ${ CL } " ;  fi 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  fi 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-09 05:13:17 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								  MAC1 = $( whiptail --backtitle "Proxmox VE Helper Scripts"  --inputbox "Set a MAC Address"  8  58  $GEN_MAC  --title "MAC ADDRESS"  --cancel-button Exit-Script 3>& 1  1>& 2  2>& 3) 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-22 20:48:20 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								  exitstatus = $? 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  if  [  -z $MAC1  ] ;  then 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    MAC = " $GEN_MAC " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    echo  -e " ${ DGN } Using MAC Address:  ${ BGN } $MAC ${ CL } " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  else 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    if  [  $exitstatus  =  0  ] ;  then 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      MAC = " $MAC1 " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      echo  -e " ${ DGN } Using MAC Address:  ${ BGN } $MAC1 ${ CL } " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    fi 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  fi 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-09 05:13:17 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								  VLAN1 = $( whiptail --backtitle "Proxmox VE Helper Scripts"  --inputbox "Set a Vlan(leave blank for default)"  8  58  --title "VLAN"  --cancel-button Exit-Script 3>& 1  1>& 2  2>& 3) 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-22 20:48:20 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								  exitstatus = $? 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  if  [  $exitstatus  =  0  ] ;  then 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    if  [  -z $VLAN1  ] ;  then 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      VLAN1 = "Default"  VLAN = "" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      echo  -e " ${ DGN } Using Vlan:  ${ BGN } $VLAN1 ${ CL } " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    else 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      VLAN = " ,tag= $VLAN1 " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      echo  -e " ${ DGN } Using Vlan:  ${ BGN } $VLAN1 ${ CL } " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    fi 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  fi 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-09 05:13:17 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								  MTU1 = $( whiptail --backtitle "Proxmox VE Helper Scripts"  --inputbox "Set Interface MTU Size (leave blank for default)"  8  58  --title "MTU SIZE"  --cancel-button Exit-Script 3>& 1  1>& 2  2>& 3) 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-22 20:48:20 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								  exitstatus = $? 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  if  [  $exitstatus  =  0  ] ;  then 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    if  [  -z $MTU1  ] ;  then 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      MTU1 = "Default"  MTU = "" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      echo  -e " ${ DGN } Using Interface MTU Size:  ${ BGN } $MTU1 ${ CL } " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    else 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      MTU = " ,mtu= $MTU1 " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								      echo  -e " ${ DGN } Using Interface MTU Size:  ${ BGN } $MTU1 ${ CL } " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    fi 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  fi 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-09 05:13:17 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								  if  ( whiptail --backtitle "Proxmox VE Helper Scripts"  --title "START VIRTUAL MACHINE"  --yesno "Start VM when completed?"  10  58) ;  then 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-06 15:23:25 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    echo  -e " ${ DGN } Start VM when completed:  ${ BGN } yes ${ CL } " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    START_VM = "yes" 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-22 20:48:20 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								  else 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-06 15:23:25 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    echo  -e " ${ DGN } Start VM when completed:  ${ BGN } no ${ CL } " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    START_VM = "no" 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-22 20:48:20 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								  fi 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-09 05:13:17 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								  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 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-06 15:23:25 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    echo  -e " ${ RD } Creating a HAOS VM using the above advanced settings ${ CL } " 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-22 20:48:20 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								  else 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    clear
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    header_info
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    echo  -e " ${ RD } Using Advanced Settings ${ CL } " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    advanced_settings
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  fi 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-06 15:23:25 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								} 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-25 10:42:35 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								function  START_SCRIPT( )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-09 05:13:17 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								  if  ( whiptail --backtitle "Proxmox VE Helper Scripts"  --title "SETTINGS"  --yesno "Use Default Settings?"  --no-button Advanced 10  58) ;  then 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-22 20:48:20 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								    clear
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    header_info
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    echo  -e " ${ BL } Using Default Settings ${ CL } " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    default_settings
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  else 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    clear
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    header_info
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    echo  -e " ${ RD } Using Advanced Settings ${ CL } " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    advanced_settings
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  fi 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-06 15:23:25 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								} 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-25 10:42:35 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								ARCH_CHECK
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								START_SCRIPT
							 
						 
					
						
							
								
									
										
										
										
											2025-02-10 09:13:09 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								post_to_api_vm
							 
						 
					
						
							
								
									
										
										
										
											2022-08-06 15:23:25 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								while  read  -r line;  do 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  TAG = $( echo  $line  |  awk '{print $1}' ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  TYPE = $( echo  $line  |  awk '{printf "%-10s", $2}' ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  FREE = $( echo  $line  |  numfmt --field 4-6 --from-unit= K --to= iec --format %.2f |  awk '{printf( "%9sB", $6)}' ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  ITEM = "   Type:  $TYPE  Free:  $FREE   " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  OFFSET = 2 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  if  [ [  $(( ${# ITEM }  +  $OFFSET ))  -gt ${ MSG_MAX_LENGTH :- }  ] ] ;  then 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								    MSG_MAX_LENGTH = $(( ${# ITEM }  +  $OFFSET )) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  fi 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-22 20:48:20 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								  STORAGE_MENU += ( " $TAG "  " $ITEM "  "OFF" ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-06 15:23:25 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								done  < <( pvesm status -content images |  awk 'NR>1' ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-22 20:48:20 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								if  [  $(( ${# STORAGE_MENU [@] }  /  3 ))  -eq 0  ] ;  then 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-06 15:23:25 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  echo  -e "'Disk image' needs to be selected for at least one storage location." 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  die "Unable to detect valid storage location." 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-22 20:48:20 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								elif  [  $(( ${# STORAGE_MENU [@] }  /  3 ))  -eq 1  ] ;  then 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-06 15:23:25 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  STORAGE = ${ STORAGE_MENU [0] } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								else 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  while  [  -z " ${ STORAGE : +x } "  ] ;  do 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-09 05:13:17 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								    STORAGE = $( whiptail --backtitle "Proxmox VE Helper Scripts"  --title "Storage Pools"  --radiolist \
 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-17 02:49:55 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								      "Which storage pool would you like to use for the HAOS VM?\n\n"  \
 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-22 20:48:20 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								      16  $(( $MSG_MAX_LENGTH  +  23 ))  6  \
 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-15 15:20:46 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								      " ${ STORAGE_MENU [@] } "  3>& 1  1>& 2  2>& 3) 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-06 15:23:25 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  done 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								fi 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								msg_ok " Using  ${ CL } ${ BL } $STORAGE ${ CL }   ${ GN } for Storage Location. " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								msg_ok " Virtual Machine ID is  ${ CL } ${ BL } $VMID ${ CL } . " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								msg_info " Getting URL for Home Assistant  ${ BRANCH }  Disk Image " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								URL = https://github.com/home-assistant/operating-system/releases/download/${ BRANCH } /haos_generic-aarch64-${ BRANCH } .qcow2.xz
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								sleep 2 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								msg_ok " ${ CL } ${ BL } ${ URL } ${ CL } " 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-03 16:01:23 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								curl -f#SL -o " $( basename " $URL " ) "  " $URL " 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-06 15:23:25 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								echo  -en "\e[1A\e[0K" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								FILE = $( basename $URL ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								msg_ok " Downloaded  ${ CL } ${ BL } haos_generic-aarch64- ${ BRANCH } .qcow2.xz ${ CL } " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								msg_info "Extracting Disk Image" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								unxz $FILE 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								STORAGE_TYPE = $( pvesm status -storage $STORAGE  |  awk 'NR>1 {print $2}' ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								case  $STORAGE_TYPE  in
							 
						 
					
						
							
								
									
										
										
										
											2023-03-22 20:48:20 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								nfs |  dir) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  DISK_EXT = ".qcow2" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  DISK_REF = " $VMID / " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  DISK_IMPORT = "-format qcow2" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  ; ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-06 15:23:25 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								esac 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								for  i in { 0,1} ;  do 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  disk = " DISK $i " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  eval  DISK${ i } = vm-${ VMID } -disk-${ i } ${ DISK_EXT :- } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  eval  DISK${ i } _REF = ${ STORAGE } :${ DISK_REF :- } ${ !disk } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								done 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								msg_ok "Extracted Disk Image" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								msg_info "Creating HAOS VM" 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-25 10:42:35 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								qm create $VMID  -bios ovmf -cores $CORE_COUNT  -memory $RAM_SIZE  -name $HN  \
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  -net0 virtio,bridge= $BRG ,macaddr= $MAC $VLAN $MTU  -onboot 1  -ostype l26 -scsihw virtio-scsi-pci
							 
						 
					
						
							
								
									
										
										
										
											2022-08-06 15:51:17 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								pvesm alloc $STORAGE  $VMID  $DISK0  64M 1>& /dev/null
							 
						 
					
						
							
								
									
										
										
										
											2022-08-06 15:23:25 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								qm importdisk $VMID  ${ FILE %.* }  $STORAGE  ${ DISK_IMPORT :- }  1>& /dev/null
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								qm set  $VMID  \
 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-06 15:51:17 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								  -efidisk0 ${ DISK0_REF } ,efitype= 4m,size= 64M \
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  -scsi0 ${ DISK1_REF } ,size= 32G >/dev/null
							 
						 
					
						
							
								
									
										
										
										
											2022-08-06 15:23:25 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								qm set  $VMID  \
 
							 
						 
					
						
							
								
									
										
										
										
											2025-06-18 22:08:23 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								  -boot order = scsi0 >/dev/null
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								DESCRIPTION = $( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  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>
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-06-22 21:40:54 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								  <h2 style = 'font-size: 24px; margin: 20px 0;' >Homeassistant VM</h2>
							 
						 
					
						
							
								
									
										
										
										
											2023-11-27 09:48:44 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-06-18 22:08:23 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								  <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/☕-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 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-27 09:48:44 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-08-06 15:23:25 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								msg_ok " Created HAOS VM  ${ CL } ${ BL } ( ${ HN } ) " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								if  [  " $START_VM "  = =  "yes"  ] ;  then 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-22 20:48:20 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								  msg_info "Starting Home Assistant OS VM" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  qm start $VMID 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								  msg_ok "Started Home Assistant OS VM" 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-06 15:23:25 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								fi 
							 
						 
					
						
							
								
									
										
										
										
											2025-02-10 09:13:09 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
								
									
								 
							
							
								post_update_to_api "done"  "none" 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-06 15:23:25 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
								
									
								 
							
							
								msg_ok "Completed Successfully!\n"