53 lines
1.3 KiB
Django/Jinja
53 lines
1.3 KiB
Django/Jinja
#!/usr/local/bin/execlineb -P
|
||
# {{ ansible_managed }}
|
||
|
||
s6-envdir ./env
|
||
multisubstitute {
|
||
importas -i -u NAME NAME
|
||
importas -i -u -s ORDER ORDER
|
||
importas -i -u RAM RAM
|
||
importas -i -u ROM ROM
|
||
importas -i -u CPUS CPUS
|
||
importas -i -u NIC NIC
|
||
importas -i -u COM COM
|
||
importas -i -u PORT PORT
|
||
importas -i -u PASS PASS
|
||
}
|
||
|
||
backtick -n AHCI {
|
||
forx X { $ORDER }
|
||
importas X X
|
||
importas Y $X
|
||
echo -n ,$Y
|
||
}
|
||
importas -i -u AHCI AHCI
|
||
|
||
foreground { if { test -e "/dev/vmm/${NAME}" } bhyvectl --vm="${NAME}" --destroy }
|
||
foreground { /etc/rc.d/netif start "${NIC}" }
|
||
foreground { fdmove -c 1 2 echo "bhyve-${NAME}: Starting VM ${NAME} with ${CPUS} CPUs, ${RAM} RAM, COM on ${COM}, NIC ${NIC} and VNC port ${PORT}." }
|
||
|
||
s6-notifyoncheck -d -w 100 -n 70
|
||
|
||
fdmove -c 2 1
|
||
# Use a static password to make VNC clients happy
|
||
ifelse { test -n "$PASS" } {
|
||
bhyve -c "${CPUS}" -m "${RAM}" -w -A -P -H
|
||
-s "0,amd_hostbridge"
|
||
-s "2:0,ahci${AHCI}"
|
||
-s "3,virtio-net,${NIC}"
|
||
-s "4,virtio-rnd"
|
||
-s "29,fbuf,tcp=[::1]:${PORT},w=800,h=600,password=${PASS}"
|
||
-s "31,lpc"
|
||
-l "com1,/dev/${COM}"
|
||
-l "bootrom,${ROM}"
|
||
"${NAME}"
|
||
}
|
||
bhyve -c "${CPUS}" -m "${RAM}" -w -A -P -H
|
||
-s "0,amd_hostbridge"
|
||
-s "2:0,ahci${AHCI}"
|
||
-s "3,virtio-net,${NIC}"
|
||
-s "4,virtio-rnd"
|
||
-s "31,lpc"
|
||
-l "com1,/dev/${COM}"
|
||
-l "bootrom,${ROM}"
|
||
"${NAME}"
|