ansible/roles/bhyve-s6/templates/bhyve/run.j2

54 lines
1.3 KiB
Django/Jinja
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/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}"