Update haos-vm.sh

This commit is contained in:
tteckster 2022-04-24 13:35:31 -04:00 committed by GitHub
parent 7cf11056c8
commit 503c333750
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 19 deletions

View File

@ -220,39 +220,28 @@ fi
msg_ok "Using ${CL}${BL}$STORAGE${CL} ${GN}for Storage Location." msg_ok "Using ${CL}${BL}$STORAGE${CL} ${GN}for Storage Location."
msg_ok "Container ID is ${CL}${BL}$VMID${CL}." msg_ok "Container ID is ${CL}${BL}$VMID${CL}."
msg_info "Getting URL for Latest Home Assistant Disk Image" msg_info "Getting URL for Latest Home Assistant Disk Image"
RELEASE_TYPE=qcow2
URL=$(cat<<EOF | python3 URL=$(cat<<EOF | python3
import requests import requests
url = "https://api.github.com/repos/home-assistant/operating-system/releases" url = "https://api.github.com/repos/home-assistant/operating-system/releases/latest"
r = requests.get(url).json() r = requests.get(url).json()
if "message" in r: if "message" in r:
exit() exit()
for release in r: for asset in r["assets"]:
if release["prerelease"]: if asset["name"].endswith("qcow2.xz"):
continue print(asset["browser_download_url"])
for asset in release["assets"]:
if asset["name"].find("$RELEASE_TYPE") != -1:
image_url = asset["browser_download_url"]
print(image_url)
exit()
EOF EOF
) )
if [ -z "$URL" ]; then 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, Please try again later."
fi fi
msg_ok "Found URL for Latest Home Assistant Disk Image" msg_ok "Found URL for Latest Home Assistant Disk Image"
msg_ok "${CL}${BL}${URL}${CL}" msg_ok "${CL}${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"
FILE=$(basename $URL) FILE=$(basename $URL)
msg_ok "Downloaded ${CL}${BL}${RELEASE_TYPE}${CL}${GN} Disk Image" msg_ok "Downloaded ${CL}${BL}qcow2${CL}${GN} Disk Image"
msg_info "Extracting Disk Image" msg_info "Extracting Disk Image"
case $FILE in unxz $FILE
*"gz") gunzip -f $FILE ;;
*"zip") gunzip -f -S .zip $FILE ;;
*"xz") xz -d $FILE ;;
*) die "Unable to handle file extension '${FILE##*.}'.";;
esac
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
btrfs|nfs|dir) btrfs|nfs|dir)