Update haos-vm.sh

This commit is contained in:
tteckster 2022-04-16 12:43:35 -04:00 committed by GitHub
parent d49ad57a3c
commit cb0cad67ae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -47,8 +47,6 @@ set -o nounset
set -o pipefail set -o pipefail
shopt -s expand_aliases shopt -s expand_aliases
alias die='EXIT=$? LINE=$LINENO error_exit' alias die='EXIT=$? LINE=$LINENO error_exit'
CM='\xE2\x9C\x94\033'
GN=`echo "\033[1;92m"`
trap die ERR trap die ERR
trap cleanup EXIT trap cleanup EXIT
function error_exit() { function error_exit() {
@ -112,7 +110,7 @@ else
"${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 ${BL}$STORAGE${CL} for Storage Location." msg_ok "Using ${BL}$STORAGE${CL} ${GN}for Storage Location."
VMID=$(pvesh get /cluster/nextid) VMID=$(pvesh get /cluster/nextid)
msg_ok "Container ID is ${BL}$VMID${CL}." msg_ok "Container ID is ${BL}$VMID${CL}."
msg_info "Getting URL for Latest Home Assistant Disk Image" msg_info "Getting URL for Latest Home Assistant Disk Image"
@ -124,7 +122,7 @@ r = requests.get(url).json()
if "message" in r: if "message" in r:
exit() exit()
for release in r: for release in r:
if release["prerelease"]: if release["release"]:
continue continue
for asset in release["assets"]: for asset in release["assets"]:
if asset["name"].find("$RELEASE_TYPE") != -1: if asset["name"].find("$RELEASE_TYPE") != -1:
@ -137,8 +135,6 @@ if [ -z "$URL" ]; then
die "Github has returned an error. A rate limit may have been applied to your connection." die "Github has returned an error. A rate limit may have been applied to your connection."
fi fi
msg_ok "Found URL for Latest Home Assistant Disk Image" msg_ok "Found URL for Latest Home Assistant Disk Image"
msg_info "${BL}${URL}${CL}"
sleep 2
msg_ok "${BL}${URL}${CL}" msg_ok "${BL}${URL}${CL}"
wget -q --show-progress $URL wget -q --show-progress $URL
echo -en "\e[1A\e[0K" echo -en "\e[1A\e[0K"
@ -180,15 +176,15 @@ set +o errtrace
( (
msg_info "Created HAOS VM" msg_info "Created HAOS VM"
msg_info "Adding Serial Port and Configuring Console" msg_info "Adding Serial Port and Configuring Console"
trap ' trap '
warn "Unable to configure serial port. VM is still functional." warn "Unable to configure serial port. VM is still functional."
if [ "$(qm config $VMID | sed -n ''/serial0/p'')" != "" ]; then if [ "$(qm config $VMID | sed -n ''/serial0/p'')" != "" ]; then
qm set $VMID --delete serial0 >/dev/null qm set $VMID --delete serial0 >/dev/null
fi fi
exit exit
' ERR ' ERR
msg_ok "Added Serial Port and Configured Console" msg_ok "Added Serial Port and Configured Console"
if [ "$(command -v kpartx)" = "" ]; then if [ "$(command -v kpartx)" = "" ]; then
msg_info "Installing kpartx" msg_info "Installing kpartx"
apt-get update >/dev/null apt-get update >/dev/null
@ -213,4 +209,4 @@ msg_info "Starting Home Assistant OS (${VM_NAME}) VM"
qm start $VMID qm start $VMID
msg_ok "Started Home Assistant OS (${VM_NAME}) VM" msg_ok "Started Home Assistant OS (${VM_NAME}) VM"
echo -e "${GN} Completed Successfully!${CL} (${VM_NAME}) VM ID is ${BL}${VMID}${CL} \n" msg_ok "Completed Successfully!\n"