Create install.sh
This commit is contained in:
parent
8fb1dff567
commit
c6ddc665de
55
install.sh
Normal file
55
install.sh
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
VMID=$(cat<<EOF | python3
|
||||||
|
import json
|
||||||
|
with open('/etc/pve/.vmlist') as vmlist:
|
||||||
|
vmids = json.load(vmlist)
|
||||||
|
last_vm = sorted(vmids['ids'].keys())[-1:][0]
|
||||||
|
print(int(last_vm)+1) if last_vm else print(100)
|
||||||
|
EOF
|
||||||
|
) && \
|
||||||
|
echo -e "\n\n\n" \
|
||||||
|
"********************************\n" \
|
||||||
|
"* Getting latest HassOS Info *\n" \
|
||||||
|
"********************************\n" && \
|
||||||
|
URL=$(cat<<EOF | python3
|
||||||
|
import requests
|
||||||
|
url = 'https://api.github.com/repos/home-assistant/hassos/releases/latest'
|
||||||
|
r = requests.get(url).json()
|
||||||
|
if 'message' in r:
|
||||||
|
exit()
|
||||||
|
for asset in r['assets']:
|
||||||
|
if asset['name'].endswith('vdi.gz'):
|
||||||
|
print(asset['browser_download_url'])
|
||||||
|
EOF
|
||||||
|
) && \
|
||||||
|
if [ -z "$URL" ]; then
|
||||||
|
echo "Github has returned an error. A rate limit may have been applied to your connection. Please wait a while, then try again."
|
||||||
|
exit 1
|
||||||
|
fi && \
|
||||||
|
echo -e "\n\n\n" \
|
||||||
|
"********************************\n" \
|
||||||
|
"* Downloading HassOS *\n" \
|
||||||
|
"********************************\n" && \
|
||||||
|
wget -q $URL && \
|
||||||
|
FILE=$(basename $URL) && \
|
||||||
|
echo -e "\n\n\n" \
|
||||||
|
"********************************\n" \
|
||||||
|
"* Extracting HassOS *\n" \
|
||||||
|
"********************************\n" && \
|
||||||
|
gunzip -f $FILE && \
|
||||||
|
echo -e "\n\n\n" \
|
||||||
|
"********************************\n" \
|
||||||
|
"* Creating new VM *\n" \
|
||||||
|
"********************************\n" && \
|
||||||
|
qm create $VMID -bios ovmf -bootdisk sata0 -efidisk0 local-lvm:vm-${VMID}-disk-0,size=128K \
|
||||||
|
-name $(sed -e "s/\_//g" -e "s/.vdi.gz//" <<< $FILE) -net0 virtio,bridge=vmbr0 \
|
||||||
|
-onboot 1 -ostype l26 -sata0 local-lvm:vm-${VMID}-disk-1,size=6G \
|
||||||
|
-scsihw virtio-scsi-pci && \
|
||||||
|
pvesm alloc local-lvm $VMID vm-${VMID}-disk-0 128 && \
|
||||||
|
qm importdisk $VMID ${FILE%".gz"} local-lvm && \
|
||||||
|
echo -e "\n\n\n" \
|
||||||
|
"********************************\n" \
|
||||||
|
"* Completed Successfully *\n" \
|
||||||
|
"* New VM ID is $VMID *\n" \
|
||||||
|
"********************************\n"
|
Loading…
Reference in New Issue
Block a user