Update haos-vm.sh

This commit is contained in:
tteckster 2022-04-16 16:55:14 -04:00 committed by GitHub
parent e9e9bbd00f
commit 2da1b289f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -51,7 +51,7 @@ function default_settings() {
echo -e "${DGN}Using ID ${BGN}$NEXTID${CL}" echo -e "${DGN}Using ID ${BGN}$NEXTID${CL}"
VM_ID=$NEXTID VM_ID=$NEXTID
echo -e "${DGN}Using Disk Size ${BGN}32GB${CL}" echo -e "${DGN}Using Disk Size ${BGN}32GB${CL}"
DISK_SIZE="32G" DISK_SIZE="32"
echo -e "${DGN}Using ${BGN}2vCPU${CL}" echo -e "${DGN}Using ${BGN}2vCPU${CL}"
CORE_COUNT="2" CORE_COUNT="2"
echo -e "${DGN}Using ${BGN}4096MiB${CL}${GN} RAM${CL}" echo -e "${DGN}Using ${BGN}4096MiB${CL}${GN} RAM${CL}"
@ -75,7 +75,7 @@ header_info
read DISK_SIZE read DISK_SIZE
if [ -z $DISK_SIZE ]; then DISK_SIZE="32"; fi; if [ -z $DISK_SIZE ]; then DISK_SIZE="32"; fi;
if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo "ERROR! DISK SIZE MUST HAVE INTEGER NUMBER!"; exit; fi; if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo "ERROR! DISK SIZE MUST HAVE INTEGER NUMBER!"; exit; fi;
echo -en "${DGN}Set Disk Size To ${BL}$DISK_SIZE${CL}" echo -en "${DGN}Set Disk Size To ${BL}$DISK_SIZEGB${CL}"
echo -e " ${CM}${CL} \r" echo -e " ${CM}${CL} \r"
sleep 1 sleep 1
clear clear
@ -142,7 +142,7 @@ function error_exit() {
local REASON="\e[97m${1:-$DEFAULT}\e[39m" local REASON="\e[97m${1:-$DEFAULT}\e[39m"
local FLAG="\e[91m[ERROR] \e[93m$EXIT@$LINE" local FLAG="\e[91m[ERROR] \e[93m$EXIT@$LINE"
msg "$FLAG $REASON" msg "$FLAG $REASON"
[ ! -z ${VMID-} ] && cleanup_vmid [ ! -z ${VM_ID-} ] && cleanup_vm_id
exit $EXIT exit $EXIT
} }
function warn() { function warn() {
@ -159,12 +159,12 @@ function msg() {
local TEXT="$1" local TEXT="$1"
echo -e "$TEXT" echo -e "$TEXT"
} }
function cleanup_vmid() { function cleanup_vm_id() {
if $(qm status $VMID &>/dev/null); then if $(qm status $VM_ID &>/dev/null); then
if [ "$(qm status $VMID | awk '{print $2}')" == "running" ]; then if [ "$(qm status $VM_ID | awk '{print $2}')" == "running" ]; then
qm stop $VMID qm stop $VM_ID
fi fi
qm destroy $VMID qm destroy $VM_ID
fi fi
} }
function cleanup() { function cleanup() {
@ -289,7 +289,7 @@ msg_ok "Added Serial Port and Configured Console"
mkdir $TEMP_MOUNT mkdir $TEMP_MOUNT
mount $DISK1_PART1_PATH $TEMP_MOUNT mount $DISK1_PART1_PATH $TEMP_MOUNT
sed -i 's/$/ console=ttyS0/' ${TEMP_MOUNT}/cmdline.txt sed -i 's/$/ console=ttyS0/' ${TEMP_MOUNT}/cmdline.txt
qm set $VMID -serial0 socket >/dev/null qm set $VM_ID -serial0 socket >/dev/null
) )
msg_info "Starting Home Assistant OS VM" msg_info "Starting Home Assistant OS VM"
qm start $VM_ID qm start $VM_ID