mirror of https://github.com/tteck/Proxmox.git
Update and rename pimox-haos-vm-v5.sh to pimox-haos-vm.sh
Code refactoring
This commit is contained in:
parent
a17e8372be
commit
f789ec15e7
|
@ -6,13 +6,13 @@
|
||||||
# https://github.com/tteck/Proxmox/raw/main/LICENSE
|
# https://github.com/tteck/Proxmox/raw/main/LICENSE
|
||||||
|
|
||||||
function header_info {
|
function header_info {
|
||||||
cat <<"EOF"
|
cat <<"EOF"
|
||||||
____ _ __ ___
|
____ _ __ ___
|
||||||
/ __ \(_) |/ /___ _ __
|
/ __ \(_) |/ /___ _ __
|
||||||
/ /_/ / / /|_/ / __ \| |/_/
|
/ /_/ / / /|_/ / __ \| |/_/
|
||||||
/ ____/ / / / / /_/ /> <
|
/ ____/ / / / / /_/ /> <
|
||||||
__ __ /_/_ /_/_/ /_/\____/_/|_| __ ____ _____
|
__ __ /_/_ /_/_/ /_/\____/_/|_| __ ____ _____
|
||||||
/ / / /___ ____ ___ ___ / | __________(_)____/ /_____ _____v5/ /_ / __ \/ ___/
|
/ / / /___ ____ ___ ___ / | __________(_)____/ /_____ _____ / /_ / __ \/ ___/
|
||||||
/ /_/ / __ \/ __ `__ \/ _ \ / /| | / ___/ ___/ / ___/ __/ __ `/ __ \/ __/ / / / /\__ \
|
/ /_/ / __ \/ __ `__ \/ _ \ / /| | / ___/ ___/ / ___/ __/ __ `/ __ \/ __/ / / / /\__ \
|
||||||
/ __ / /_/ / / / / / / __/ / ___ |(__ |__ ) (__ ) /_/ /_/ / / / / /_ / /_/ /___/ /
|
/ __ / /_/ / / / / / / __/ / ___ |(__ |__ ) (__ ) /_/ /_/ / / / / /_ / /_/ /___/ /
|
||||||
/_/ /_/\____/_/ /_/ /_/\___/ /_/ |_/____/____/_/____/\__/\__,_/_/ /_/\__/ \____//____/
|
/_/ /_/\____/_/ /_/ /_/\___/ /_/ |_/____/____/_/____/\__/\__,_/_/ /_/\__/ \____//____/
|
||||||
|
@ -28,14 +28,14 @@ NEXTID=$(pvesh get /cluster/nextid)
|
||||||
STABLE=$(curl -s https://raw.githubusercontent.com/home-assistant/version/master/stable.json | grep "ova" | awk '{print substr($2, 2, length($2)-3) }')
|
STABLE=$(curl -s https://raw.githubusercontent.com/home-assistant/version/master/stable.json | grep "ova" | awk '{print substr($2, 2, length($2)-3) }')
|
||||||
BETA=$(curl -s https://raw.githubusercontent.com/home-assistant/version/master/beta.json | grep "ova" | awk '{print substr($2, 2, length($2)-3) }')
|
BETA=$(curl -s https://raw.githubusercontent.com/home-assistant/version/master/beta.json | grep "ova" | awk '{print substr($2, 2, length($2)-3) }')
|
||||||
DEV=$(curl -s https://raw.githubusercontent.com/home-assistant/version/master/dev.json | grep "ova" | awk '{print substr($2, 2, length($2)-3) }')
|
DEV=$(curl -s https://raw.githubusercontent.com/home-assistant/version/master/dev.json | grep "ova" | awk '{print substr($2, 2, length($2)-3) }')
|
||||||
YW=`echo "\033[33m"`
|
YW=$(echo "\033[33m")
|
||||||
BL=`echo "\033[36m"`
|
BL=$(echo "\033[36m")
|
||||||
HA=`echo "\033[1;34m"`
|
HA=$(echo "\033[1;34m")
|
||||||
RD=`echo "\033[01;31m"`
|
RD=$(echo "\033[01;31m")
|
||||||
BGN=`echo "\033[4;92m"`
|
BGN=$(echo "\033[4;92m")
|
||||||
GN=`echo "\033[1;92m"`
|
GN=$(echo "\033[1;92m")
|
||||||
DGN=`echo "\033[32m"`
|
DGN=$(echo "\033[32m")
|
||||||
CL=`echo "\033[m"`
|
CL=$(echo "\033[m")
|
||||||
BFR="\\r\\033[K"
|
BFR="\\r\\033[K"
|
||||||
HOLD="-"
|
HOLD="-"
|
||||||
CM="${GN}✓${CL}"
|
CM="${GN}✓${CL}"
|
||||||
|
@ -72,20 +72,20 @@ function cleanup() {
|
||||||
TEMP_DIR=$(mktemp -d)
|
TEMP_DIR=$(mktemp -d)
|
||||||
pushd $TEMP_DIR >/dev/null
|
pushd $TEMP_DIR >/dev/null
|
||||||
if (whiptail --title "PiMox HAOS VM" --yesno "This will create a New PiMox HAOS VM. Proceed?" 10 58); then
|
if (whiptail --title "PiMox HAOS VM" --yesno "This will create a New PiMox HAOS VM. Proceed?" 10 58); then
|
||||||
echo "User selected Yes"
|
echo "User selected Yes"
|
||||||
else
|
else
|
||||||
clear
|
clear
|
||||||
echo -e "⚠ User exited script \n"
|
echo -e "⚠ User exited script \n"
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
function PVE_CHECK() {
|
function PVE_CHECK() {
|
||||||
if [ `pveversion | grep "pve-manager/7.2\|7.3" | wc -l` -ne 1 ]; then
|
if [ $(pveversion | grep "pve-manager/7.2\|7.3" | wc -l) -ne 1 ]; then
|
||||||
echo "⚠ This version of Proxmox Virtual Environment is not supported"
|
echo "⚠ This version of Proxmox Virtual Environment is not supported"
|
||||||
echo "Requires PVE Version: =>7.2"
|
echo "Requires PVE Version: =>7.2"
|
||||||
echo "Exiting..."
|
echo "Exiting..."
|
||||||
sleep 2
|
sleep 2
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
function ARCH_CHECK() {
|
function ARCH_CHECK() {
|
||||||
ARCH=$(dpkg --print-architecture)
|
ARCH=$(dpkg --print-architecture)
|
||||||
|
@ -97,142 +97,160 @@ function ARCH_CHECK() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
function msg_info() {
|
function msg_info() {
|
||||||
local msg="$1"
|
local msg="$1"
|
||||||
echo -ne " ${HOLD} ${YW}${msg}..."
|
echo -ne " ${HOLD} ${YW}${msg}..."
|
||||||
}
|
}
|
||||||
function msg_ok() {
|
function msg_ok() {
|
||||||
local msg="$1"
|
local msg="$1"
|
||||||
echo -e "${BFR} ${CM} ${GN}${msg}${CL}"
|
echo -e "${BFR} ${CM} ${GN}${msg}${CL}"
|
||||||
}
|
}
|
||||||
function msg_error() {
|
function msg_error() {
|
||||||
local msg="$1"
|
local msg="$1"
|
||||||
echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}"
|
echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}"
|
||||||
}
|
}
|
||||||
|
|
||||||
function default_settings() {
|
function default_settings() {
|
||||||
echo -e "${DGN}Using HAOS Version: ${BGN}${STABLE}${CL}"
|
echo -e "${DGN}Using HAOS Version: ${BGN}${STABLE}${CL}"
|
||||||
BRANCH=${STABLE}
|
BRANCH=${STABLE}
|
||||||
echo -e "${DGN}Using Virtual Machine ID: ${BGN}$NEXTID${CL}"
|
echo -e "${DGN}Using Virtual Machine ID: ${BGN}$NEXTID${CL}"
|
||||||
VMID=$NEXTID
|
VMID=$NEXTID
|
||||||
echo -e "${DGN}Using Hostname: ${BGN}haos${STABLE}${CL}"
|
echo -e "${DGN}Using Hostname: ${BGN}haos${STABLE}${CL}"
|
||||||
HN=haos${STABLE}
|
HN=haos${STABLE}
|
||||||
echo -e "${DGN}Allocated Cores: ${BGN}2${CL}"
|
echo -e "${DGN}Allocated Cores: ${BGN}2${CL}"
|
||||||
CORE_COUNT="2"
|
CORE_COUNT="2"
|
||||||
echo -e "${DGN}Allocated RAM: ${BGN}4096${CL}"
|
echo -e "${DGN}Allocated RAM: ${BGN}4096${CL}"
|
||||||
RAM_SIZE="4096"
|
RAM_SIZE="4096"
|
||||||
echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}"
|
echo -e "${DGN}Using Bridge: ${BGN}vmbr0${CL}"
|
||||||
BRG="vmbr0"
|
BRG="vmbr0"
|
||||||
echo -e "${DGN}Using MAC Address: ${BGN}$GEN_MAC${CL}"
|
echo -e "${DGN}Using MAC Address: ${BGN}$GEN_MAC${CL}"
|
||||||
MAC=$GEN_MAC
|
MAC=$GEN_MAC
|
||||||
echo -e "${DGN}Using VLAN: ${BGN}Default${CL}"
|
echo -e "${DGN}Using VLAN: ${BGN}Default${CL}"
|
||||||
VLAN=""
|
VLAN=""
|
||||||
echo -e "${DGN}Using Interface MTU Size: ${BGN}Default${CL}"
|
echo -e "${DGN}Using Interface MTU Size: ${BGN}Default${CL}"
|
||||||
MTU=""
|
MTU=""
|
||||||
echo -e "${DGN}Start VM when completed: ${BGN}yes${CL}"
|
echo -e "${DGN}Start VM when completed: ${BGN}yes${CL}"
|
||||||
START_VM="yes"
|
START_VM="yes"
|
||||||
echo -e "${BL}Creating a HAOS VM using the above default settings${CL}"
|
echo -e "${BL}Creating a HAOS VM using the above default settings${CL}"
|
||||||
}
|
}
|
||||||
function advanced_settings() {
|
function advanced_settings() {
|
||||||
BRANCH=$(whiptail --title "HAOS VERSION" --radiolist "Choose Version" --cancel-button Exit-Script 10 58 3 \
|
BRANCH=$(whiptail --title "HAOS VERSION" --radiolist "Choose Version" --cancel-button Exit-Script 10 58 3 \
|
||||||
"$STABLE" "Stable" ON \
|
"$STABLE" "Stable" ON \
|
||||||
"$BETA" "Beta" OFF \
|
"$BETA" "Beta" OFF \
|
||||||
"$DEV" "Dev" OFF \
|
"$DEV" "Dev" OFF \
|
||||||
3>&1 1>&2 2>&3)
|
3>&1 1>&2 2>&3)
|
||||||
exitstatus=$?
|
exitstatus=$?
|
||||||
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using HAOS Version: ${BGN}$BRANCH${CL}"; fi
|
if [ $exitstatus = 0 ]; then echo -e "${DGN}Using HAOS Version: ${BGN}$BRANCH${CL}"; fi
|
||||||
VMID=$(whiptail --inputbox "Set Virtual Machine ID" 8 58 $NEXTID --title "VIRTUAL MACHINE ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
|
VMID=$(whiptail --inputbox "Set Virtual Machine ID" 8 58 $NEXTID --title "VIRTUAL MACHINE ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
|
||||||
exitstatus=$?
|
exitstatus=$?
|
||||||
if [ -z $VMID ]; then VMID="$NEXTID"; echo -e "${DGN}Virtual Machine: ${BGN}$VMID${CL}";
|
if [ -z $VMID ]; then
|
||||||
|
VMID="$NEXTID"
|
||||||
|
echo -e "${DGN}Virtual Machine: ${BGN}$VMID${CL}"
|
||||||
else
|
else
|
||||||
if echo "$USEDID" | egrep -q "$VMID"
|
if echo "$USEDID" | egrep -q "$VMID"; then
|
||||||
then
|
|
||||||
echo -e "\n🚨 ${RD}ID $VMID is already in use${CL} \n"
|
echo -e "\n🚨 ${RD}ID $VMID is already in use${CL} \n"
|
||||||
echo -e "Exiting Script \n"
|
echo -e "Exiting Script \n"
|
||||||
sleep 2;
|
sleep 2
|
||||||
exit
|
exit
|
||||||
else
|
else
|
||||||
if [ $exitstatus = 0 ]; then echo -e "${DGN}Virtual Machine ID: ${BGN}$VMID${CL}"; fi;
|
if [ $exitstatus = 0 ]; then echo -e "${DGN}Virtual Machine ID: ${BGN}$VMID${CL}"; fi
|
||||||
fi
|
fi
|
||||||
fi
|
|
||||||
VM_NAME=$(whiptail --inputbox "Set Hostname" 8 58 haos${BRANCH} --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
|
|
||||||
exitstatus=$?
|
|
||||||
if [ -z $VM_NAME ]; then HN="haos${BRANCH}"; echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}";
|
|
||||||
else
|
|
||||||
if [ $exitstatus = 0 ]; then HN=$(echo ${VM_NAME,,} | tr -d ' '); echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"; fi;
|
|
||||||
fi
|
|
||||||
CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 2 --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
|
|
||||||
exitstatus=$?
|
|
||||||
if [ -z $CORE_COUNT ]; then CORE_COUNT="2"; echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}";
|
|
||||||
else
|
|
||||||
if [ $exitstatus = 0 ]; then echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}"; fi;
|
|
||||||
fi
|
|
||||||
RAM_SIZE=$(whiptail --inputbox "Allocate RAM in MiB" 8 58 4096 --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
|
|
||||||
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
|
|
||||||
BRG=$(whiptail --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
|
|
||||||
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
|
|
||||||
MAC1=$(whiptail --inputbox "Set a MAC Address" 8 58 $GEN_MAC --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
|
|
||||||
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
|
|
||||||
VLAN1=$(whiptail --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
|
|
||||||
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
|
|
||||||
MTU1=$(whiptail --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
|
|
||||||
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
|
||||||
fi
|
VM_NAME=$(whiptail --inputbox "Set Hostname" 8 58 haos${BRANCH} --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
|
||||||
if (whiptail --title "START VIRTUAL MACHINE" --yesno "Start VM when completed?" 10 58); then
|
exitstatus=$?
|
||||||
|
if [ -z $VM_NAME ]; then
|
||||||
|
HN="haos${BRANCH}"
|
||||||
|
echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
|
||||||
|
else
|
||||||
|
if [ $exitstatus = 0 ]; then
|
||||||
|
HN=$(echo ${VM_NAME,,} | tr -d ' ')
|
||||||
|
echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
CORE_COUNT=$(whiptail --inputbox "Allocate CPU Cores" 8 58 2 --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
|
||||||
|
exitstatus=$?
|
||||||
|
if [ -z $CORE_COUNT ]; then
|
||||||
|
CORE_COUNT="2"
|
||||||
|
echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}"
|
||||||
|
else
|
||||||
|
if [ $exitstatus = 0 ]; then echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}"; fi
|
||||||
|
fi
|
||||||
|
RAM_SIZE=$(whiptail --inputbox "Allocate RAM in MiB" 8 58 4096 --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
|
||||||
|
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
|
||||||
|
BRG=$(whiptail --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
|
||||||
|
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
|
||||||
|
MAC1=$(whiptail --inputbox "Set a MAC Address" 8 58 $GEN_MAC --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
|
||||||
|
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
|
||||||
|
VLAN1=$(whiptail --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
|
||||||
|
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
|
||||||
|
MTU1=$(whiptail --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
|
||||||
|
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
|
||||||
|
if (whiptail --title "START VIRTUAL MACHINE" --yesno "Start VM when completed?" 10 58); then
|
||||||
echo -e "${DGN}Start VM when completed: ${BGN}yes${CL}"
|
echo -e "${DGN}Start VM when completed: ${BGN}yes${CL}"
|
||||||
START_VM="yes"
|
START_VM="yes"
|
||||||
else
|
else
|
||||||
echo -e "${DGN}Start VM when completed: ${BGN}no${CL}"
|
echo -e "${DGN}Start VM when completed: ${BGN}no${CL}"
|
||||||
START_VM="no"
|
START_VM="no"
|
||||||
fi
|
fi
|
||||||
if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create HAOS ${BRANCH} VM?" --no-button Do-Over 10 58); then
|
if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create HAOS ${BRANCH} VM?" --no-button Do-Over 10 58); then
|
||||||
echo -e "${RD}Creating a HAOS VM using the above advanced settings${CL}"
|
echo -e "${RD}Creating a HAOS VM using the above advanced settings${CL}"
|
||||||
else
|
else
|
||||||
clear
|
clear
|
||||||
header_info
|
header_info
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
echo -e "${RD}Using Advanced Settings${CL}"
|
||||||
advanced_settings
|
advanced_settings
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
function START_SCRIPT() {
|
function START_SCRIPT() {
|
||||||
if (whiptail --title "SETTINGS" --yesno "Use Default Settings?" --no-button Advanced 10 58); then
|
if (whiptail --title "SETTINGS" --yesno "Use Default Settings?" --no-button Advanced 10 58); then
|
||||||
clear
|
clear
|
||||||
header_info
|
header_info
|
||||||
echo -e "${BL}Using Default Settings${CL}"
|
echo -e "${BL}Using Default Settings${CL}"
|
||||||
default_settings
|
default_settings
|
||||||
else
|
else
|
||||||
clear
|
clear
|
||||||
header_info
|
header_info
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
echo -e "${RD}Using Advanced Settings${CL}"
|
||||||
advanced_settings
|
advanced_settings
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
ARCH_CHECK
|
ARCH_CHECK
|
||||||
PVE_CHECK
|
PVE_CHECK
|
||||||
|
@ -246,19 +264,19 @@ while read -r line; do
|
||||||
if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then
|
if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then
|
||||||
MSG_MAX_LENGTH=$((${#ITEM} + $OFFSET))
|
MSG_MAX_LENGTH=$((${#ITEM} + $OFFSET))
|
||||||
fi
|
fi
|
||||||
STORAGE_MENU+=( "$TAG" "$ITEM" "OFF" )
|
STORAGE_MENU+=("$TAG" "$ITEM" "OFF")
|
||||||
done < <(pvesm status -content images | awk 'NR>1')
|
done < <(pvesm status -content images | awk 'NR>1')
|
||||||
if [ $((${#STORAGE_MENU[@]}/3)) -eq 0 ]; then
|
if [ $((${#STORAGE_MENU[@]} / 3)) -eq 0 ]; then
|
||||||
echo -e "'Disk image' needs to be selected for at least one storage location."
|
echo -e "'Disk image' needs to be selected for at least one storage location."
|
||||||
die "Unable to detect valid storage location."
|
die "Unable to detect valid storage location."
|
||||||
elif [ $((${#STORAGE_MENU[@]}/3)) -eq 1 ]; then
|
elif [ $((${#STORAGE_MENU[@]} / 3)) -eq 1 ]; then
|
||||||
STORAGE=${STORAGE_MENU[0]}
|
STORAGE=${STORAGE_MENU[0]}
|
||||||
else
|
else
|
||||||
while [ -z "${STORAGE:+x}" ]; do
|
while [ -z "${STORAGE:+x}" ]; do
|
||||||
STORAGE=$(whiptail --title "Storage Pools" --radiolist \
|
STORAGE=$(whiptail --title "Storage Pools" --radiolist \
|
||||||
"Which storage pool you would like to use for the HAOS VM?\n\n" \
|
"Which storage pool you would like to use for the HAOS VM?\n\n" \
|
||||||
16 $(($MSG_MAX_LENGTH + 23)) 6 \
|
16 $(($MSG_MAX_LENGTH + 23)) 6 \
|
||||||
"${STORAGE_MENU[@]}" 3>&1 1>&2 2>&3) || exit
|
"${STORAGE_MENU[@]}" 3>&1 1>&2 2>&3) || exit
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
msg_ok "Using ${CL}${BL}$STORAGE${CL} ${GN}for Storage Location."
|
msg_ok "Using ${CL}${BL}$STORAGE${CL} ${GN}for Storage Location."
|
||||||
|
@ -275,10 +293,11 @@ msg_info "Extracting Disk Image"
|
||||||
unxz $FILE
|
unxz $FILE
|
||||||
STORAGE_TYPE=$(pvesm status -storage $STORAGE | awk 'NR>1 {print $2}')
|
STORAGE_TYPE=$(pvesm status -storage $STORAGE | awk 'NR>1 {print $2}')
|
||||||
case $STORAGE_TYPE in
|
case $STORAGE_TYPE in
|
||||||
nfs|dir)
|
nfs | dir)
|
||||||
DISK_EXT=".qcow2"
|
DISK_EXT=".qcow2"
|
||||||
DISK_REF="$VMID/"
|
DISK_REF="$VMID/"
|
||||||
DISK_IMPORT="-format qcow2"
|
DISK_IMPORT="-format qcow2"
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
for i in {0,1}; do
|
for i in {0,1}; do
|
||||||
disk="DISK$i"
|
disk="DISK$i"
|
||||||
|
@ -301,8 +320,8 @@ qm set $VMID -description "# PiMox HAOS
|
||||||
[](https://ko-fi.com/D1D7EP4GF)" >/dev/null
|
[](https://ko-fi.com/D1D7EP4GF)" >/dev/null
|
||||||
msg_ok "Created HAOS VM ${CL}${BL}(${HN})"
|
msg_ok "Created HAOS VM ${CL}${BL}(${HN})"
|
||||||
if [ "$START_VM" == "yes" ]; then
|
if [ "$START_VM" == "yes" ]; then
|
||||||
msg_info "Starting Home Assistant OS VM"
|
msg_info "Starting Home Assistant OS VM"
|
||||||
qm start $VMID
|
qm start $VMID
|
||||||
msg_ok "Started Home Assistant OS VM"
|
msg_ok "Started Home Assistant OS VM"
|
||||||
fi
|
fi
|
||||||
msg_ok "Completed Successfully!\n"
|
msg_ok "Completed Successfully!\n"
|
Loading…
Reference in New Issue