Add support for multiple file compressions (#98)
This commit is contained in:
parent
b49feaa906
commit
f6816052bb
14
install.sh
14
install.sh
@ -81,7 +81,7 @@ info "Container ID is $VMID."
|
|||||||
|
|
||||||
# Get latest Home Assistant disk image archive URL
|
# Get latest Home Assistant disk image archive URL
|
||||||
msg "Getting URL for latest Home Assistant disk image..."
|
msg "Getting URL for latest Home Assistant disk image..."
|
||||||
RELEASE_EXT=vmdk.gz
|
RELEASE_TYPE=vmdk
|
||||||
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"
|
||||||
@ -92,7 +92,7 @@ for release in r:
|
|||||||
if release["prerelease"]:
|
if release["prerelease"]:
|
||||||
continue
|
continue
|
||||||
for asset in release["assets"]:
|
for asset in release["assets"]:
|
||||||
if asset["name"].endswith("$RELEASE_EXT"):
|
if asset["name"].find("$RELEASE_TYPE") != -1:
|
||||||
image_url = asset["browser_download_url"]
|
image_url = asset["browser_download_url"]
|
||||||
print(image_url)
|
print(image_url)
|
||||||
exit()
|
exit()
|
||||||
@ -110,7 +110,11 @@ FILE=$(basename $URL)
|
|||||||
|
|
||||||
# Extract Home Assistant disk image
|
# Extract Home Assistant disk image
|
||||||
msg "Extracting disk image..."
|
msg "Extracting disk image..."
|
||||||
gunzip -f $FILE
|
case $FILE in
|
||||||
|
*"gz") gunzip -f $FILE;;
|
||||||
|
*"xz") xz -d $FILE;;
|
||||||
|
*) die "Unable to handle file extension '${FILE##*.}'.";;
|
||||||
|
esac
|
||||||
|
|
||||||
# Create variables for container disk
|
# Create variables for container disk
|
||||||
STORAGE_TYPE=$(pvesm status -storage $STORAGE | awk 'NR>1 {print $2}')
|
STORAGE_TYPE=$(pvesm status -storage $STORAGE | awk 'NR>1 {print $2}')
|
||||||
@ -127,11 +131,11 @@ done
|
|||||||
|
|
||||||
# Create VM
|
# Create VM
|
||||||
msg "Creating VM..."
|
msg "Creating VM..."
|
||||||
VM_NAME=$(sed -e "s/\_//g" -e "s/.${RELEASE_EXT}//" <<< $FILE)
|
VM_NAME=$(sed -e "s/\_//g" -e "s/.${RELEASE_TYPE}.*$//" <<< $FILE)
|
||||||
qm create $VMID -agent 1 -bios ovmf -name $VM_NAME -net0 virtio,bridge=vmbr0 \
|
qm create $VMID -agent 1 -bios ovmf -name $VM_NAME -net0 virtio,bridge=vmbr0 \
|
||||||
-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%".gz"} $STORAGE ${IMPORT_OPT:-} 1>&/dev/null
|
qm importdisk $VMID ${FILE%.*} $STORAGE ${IMPORT_OPT:-} 1>&/dev/null
|
||||||
qm set $VMID \
|
qm set $VMID \
|
||||||
-efidisk0 ${DISK0_REF},size=128K \
|
-efidisk0 ${DISK0_REF},size=128K \
|
||||||
-sata0 ${DISK1_REF},size=6G > /dev/null
|
-sata0 ${DISK1_REF},size=6G > /dev/null
|
||||||
|
Loading…
Reference in New Issue
Block a user