Merge pull request #200 from tteck/dev

add options to haos-vm-v3.sh
pull/226/head
tteckster 3 years ago committed by GitHub
commit efab3a14f9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,4 +1,5 @@
#!/usr/bin/env bash #!/usr/bin/env bash
GEN_MAC=$(echo '00 60 2f'$(od -An -N3 -t xC /dev/urandom) | sed -e 's/ /:/g' | tr '[:lower:]' '[:upper:]')
NEXTID=$(pvesh get /cluster/nextid) NEXTID=$(pvesh get /cluster/nextid)
RELEASE=$(curl -sX GET "https://api.github.com/repos/home-assistant/operating-system/releases" | awk '/tag_name/{print $4;exit}' FS='[""]') RELEASE=$(curl -sX GET "https://api.github.com/repos/home-assistant/operating-system/releases" | awk '/tag_name/{print $4;exit}' FS='[""]')
STABLE="7.6" STABLE="7.6"
@ -89,10 +90,16 @@ function default_settings() {
VMID=$NEXTID VMID=$NEXTID
echo -e "${DGN}Using VM Name ${BGN}haos${STABLE}${CL}" echo -e "${DGN}Using VM Name ${BGN}haos${STABLE}${CL}"
VM_NAME=haos${STABLE} VM_NAME=haos${STABLE}
echo -e "${DGN}Using ${BGN}2vCPU${CL}" echo -e "${DGN}Using ${BGN}2${CL}${DGN}vCPU${CL}"
CORE_COUNT="2" CORE_COUNT="2"
echo -e "${DGN}Using ${BGN}4096MiB${CL}" echo -e "${DGN}Using ${BGN}4096${CL}${DGN}MiB RAM${CL}"
RAM_SIZE="4096" 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 Tag ${BGN}NONE${CL}"
VLAN=""
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"
@ -154,7 +161,7 @@ header_info
echo -e "${DGN}Using Version ${BGN}$BRANCH${CL}" echo -e "${DGN}Using Version ${BGN}$BRANCH${CL}"
echo -e "${DGN}Using VM ID ${BGN}$VMID${CL}" echo -e "${DGN}Using VM ID ${BGN}$VMID${CL}"
echo -e "${DGN}Using VM Name ${BGN}$VM_NAME${CL}" echo -e "${DGN}Using VM Name ${BGN}$VM_NAME${CL}"
echo -e "${DGN}Using ${BGN}${CORE_COUNT}vCPU${CL}" echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
echo -e "${YW}Allocate RAM in MiB, or Press [ENTER] for Default: 4096 " echo -e "${YW}Allocate RAM in MiB, or Press [ENTER] for Default: 4096 "
read RAM_SIZE read RAM_SIZE
if [ -z $RAM_SIZE ]; then RAM_SIZE="4096"; fi; if [ -z $RAM_SIZE ]; then RAM_SIZE="4096"; fi;
@ -167,8 +174,60 @@ header_info
echo -e "${DGN}Using Version ${BGN}$BRANCH${CL}" echo -e "${DGN}Using Version ${BGN}$BRANCH${CL}"
echo -e "${DGN}Using VM ID ${BGN}$VMID${CL}" echo -e "${DGN}Using VM ID ${BGN}$VMID${CL}"
echo -e "${DGN}Using VM Name ${BGN}$VM_NAME${CL}" echo -e "${DGN}Using VM Name ${BGN}$VM_NAME${CL}"
echo -e "${DGN}Using ${BGN}${CORE_COUNT}vCPU${CL}" echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
echo -e "${DGN}Using ${BGN}${RAM_SIZE}MiB${CL}" echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
echo -e "${YW}Enter a Bridge, or Press [ENTER] for Default: vmbr0 "
read BRG
if [ -z $BRG ]; then BRG="vmbr0"; fi;
echo -en "${DGN}Set Bridge To ${BL}$BRG${CL}"
echo -e " ${CM}${CL} \n"
sleep 1
clear
header_info
echo -e "${RD}Using Advanced Settings${CL}"
echo -e "${DGN}Using Version ${BGN}$BRANCH${CL}"
echo -e "${DGN}Using VM ID ${BGN}$VMID${CL}"
echo -e "${DGN}Using VM Name ${BGN}$VM_NAME${CL}"
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}"
echo -e "${YW}Enter a Valid MAC Address, or Press [ENTER] for Generated MAC: $GEN_MAC "
read MAC
if [ -z $MAC ]; then MAC=$GEN_MAC; fi;
echo -en "${DGN}Set MAC Address To ${BL}$MAC${CL}"
echo -e " ${CM}${CL} \n"
sleep 1
clear
header_info
echo -e "${RD}Using Advanced Settings${CL}"
echo -e "${DGN}Using Version ${BGN}$BRANCH${CL}"
echo -e "${DGN}Using VM ID ${BGN}$VMID${CL}"
echo -e "${DGN}Using VM Name ${BGN}$VM_NAME${CL}"
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}"
echo -e "${DGN}Using MAC Address ${BGN}$MAC${CL}"
echo -e "${YW}Enter a VLAN Tag, or Press [ENTER] for Default: NONE "
read VLAN1
if [ -z $VLAN1 ]; then VLAN1="NONE" VLAN="";
echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}"
else
VLAN=",tag=$VLAN1"
echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}"
fi;
echo -e " ${CM}${CL} \n"
sleep 1
clear
header_info
echo -e "${RD}Using Advanced Settings${CL}"
echo -e "${DGN}Using Version ${BGN}$BRANCH${CL}"
echo -e "${DGN}Using VM ID ${BGN}$VMID${CL}"
echo -e "${DGN}Using VM Name ${BGN}$VM_NAME${CL}"
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB${CL}"
echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}"
echo -e "${DGN}Using MAC Address ${BGN}$MAC${CL}"
echo -e "${DGN}Using VLAN Tag ${BGN}$VLAN1${CL}"
echo -e "${YW}Start VM when completed, or Press [ENTER] for Default: yes " echo -e "${YW}Start VM when completed, or Press [ENTER] for Default: yes "
read START_VM read START_VM
if [ -z $START_VM ]; then START_VM="yes"; if [ -z $START_VM ]; then START_VM="yes";
@ -183,8 +242,11 @@ header_info
echo -e "${DGN}Using Version ${BGN}$BRANCH${CL}" echo -e "${DGN}Using Version ${BGN}$BRANCH${CL}"
echo -e "${DGN}Using VM ID ${BGN}$VMID${CL}" echo -e "${DGN}Using VM ID ${BGN}$VMID${CL}"
echo -e "${DGN}Using VM Name ${BGN}$VM_NAME${CL}" echo -e "${DGN}Using VM Name ${BGN}$VM_NAME${CL}"
echo -e "${DGN}Using ${BGN}${CORE_COUNT}vCPU${CL}" echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
echo -e "${DGN}Using ${BGN}${RAM_SIZE}MiB${CL}" echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB${CL}"
echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}"
echo -e "${DGN}Using MAC Address ${BGN}$MAC${CL}"
echo -e "${DGN}Using VLAN Tag ${BGN}$VLAN1${CL}"
echo -e "${DGN}Start VM when completed ${BGN}$START_VM${CL}" echo -e "${DGN}Start VM when completed ${BGN}$START_VM${CL}"
read -p "Are these settings correct(y/n)? " -n 1 -r read -p "Are these settings correct(y/n)? " -n 1 -r
@ -257,7 +319,7 @@ done
msg_ok "Extracted Disk Image" msg_ok "Extracted Disk Image"
msg_info "Creating HAOS VM" msg_info "Creating HAOS VM"
qm create $VMID -agent 1 -bios ovmf -cores $CORE_COUNT -memory $RAM_SIZE -name $VM_NAME -net0 virtio,bridge=vmbr0 \ qm create $VMID -agent 1 -bios ovmf -cores $CORE_COUNT -memory $RAM_SIZE -name $VM_NAME -net0 virtio,bridge=$BRG,macaddr=$MAC$VLAN \
-onboot 1 -ostype l26 -scsihw virtio-scsi-pci -onboot 1 -ostype l26 -scsihw virtio-scsi-pci
pvesm alloc $STORAGE $VMID $DISK0 128 1>&/dev/null pvesm alloc $STORAGE $VMID $DISK0 128 1>&/dev/null
qm importdisk $VMID ${FILE%.*} $STORAGE ${IMPORT_OPT:-} 1>&/dev/null qm importdisk $VMID ${FILE%.*} $STORAGE ${IMPORT_OPT:-} 1>&/dev/null

Loading…
Cancel
Save

Powered by BW's shoe-string budget.