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
|
@ -12,7 +12,7 @@ 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) }')
|
||||
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) }')
|
||||
YW=`echo "\033[33m"`
|
||||
BL=`echo "\033[36m"`
|
||||
HA=`echo "\033[1;34m"`
|
||||
RD=`echo "\033[01;31m"`
|
||||
BGN=`echo "\033[4;92m"`
|
||||
GN=`echo "\033[1;92m"`
|
||||
DGN=`echo "\033[32m"`
|
||||
CL=`echo "\033[m"`
|
||||
YW=$(echo "\033[33m")
|
||||
BL=$(echo "\033[36m")
|
||||
HA=$(echo "\033[1;34m")
|
||||
RD=$(echo "\033[01;31m")
|
||||
BGN=$(echo "\033[4;92m")
|
||||
GN=$(echo "\033[1;92m")
|
||||
DGN=$(echo "\033[32m")
|
||||
CL=$(echo "\033[m")
|
||||
BFR="\\r\\033[K"
|
||||
HOLD="-"
|
||||
CM="${GN}✓${CL}"
|
||||
|
@ -79,7 +79,7 @@ else
|
|||
exit
|
||||
fi
|
||||
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 "Requires PVE Version: =>7.2"
|
||||
echo "Exiting..."
|
||||
|
@ -142,52 +142,70 @@ exitstatus=$?
|
|||
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)
|
||||
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
|
||||
if echo "$USEDID" | egrep -q "$VMID"
|
||||
then
|
||||
if echo "$USEDID" | egrep -q "$VMID"; then
|
||||
echo -e "\n🚨 ${RD}ID $VMID is already in use${CL} \n"
|
||||
echo -e "Exiting Script \n"
|
||||
sleep 2;
|
||||
sleep 2
|
||||
exit
|
||||
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
|
||||
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}";
|
||||
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;
|
||||
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}";
|
||||
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;
|
||||
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}";
|
||||
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;
|
||||
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}";
|
||||
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;
|
||||
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}";
|
||||
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
|
||||
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="";
|
||||
if [ -z $VLAN1 ]; then
|
||||
VLAN1="Default" VLAN=""
|
||||
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
|
||||
else
|
||||
VLAN=",tag=$VLAN1"
|
||||
|
@ -279,6 +297,7 @@ case $STORAGE_TYPE in
|
|||
DISK_EXT=".qcow2"
|
||||
DISK_REF="$VMID/"
|
||||
DISK_IMPORT="-format qcow2"
|
||||
;;
|
||||
esac
|
||||
for i in {0,1}; do
|
||||
disk="DISK$i"
|
Loading…
Reference in New Issue