diff --git a/ansible/roles/bhyve/files/bhyve_netgraph_bridge.bash b/ansible/roles/bhyve/files/bhyve_netgraph_bridge.bash index e93e2bf..bf0a5e6 100644 --- a/ansible/roles/bhyve/files/bhyve_netgraph_bridge.bash +++ b/ansible/roles/bhyve/files/bhyve_netgraph_bridge.bash @@ -35,6 +35,33 @@ if [ "$VERBOSE" = "YES" ]; then set -x fi +############## Setup ######################### + +function cleanup { + for vm in "${vms[@]}"; do + log "Destroying bhyve vm $f" + bhyvectl "--vm=$vm" --destroy + log "Destroyed bhyve vm $f" + done +} +vms=() +for sig in EXIT INT QUIT HUP TERM; do + trap "set +e; cleanup" "$sig" +done + +function die { + local status_code="$1" + shift + (>&2 echo "${@}") + exit "$status_code" +} + +function log { + (>&2 echo "${@}") +} + +############## Program ######################### + function main { local cmd="$1" shift 1 @@ -122,6 +149,7 @@ function start_vm { if [ "$VNC_ENABLE" = "YES" ]; then additional_args+=("-s" "29,fbuf,tcp=$VNC_LISTEN,w=1920,h=1080") fi + vms+=("$name") while true; do set -x set +e @@ -156,9 +184,6 @@ function start_vm { break fi done - - bhyvectl "--vm=$name" --destroy - echo "Destroyed bhyve vm." } function detect_available_link { diff --git a/ansible/roles/poudriere/files/poudboot b/ansible/roles/poudriere/files/poudboot index ff385d3..b6ffc70 100644 --- a/ansible/roles/poudriere/files/poudboot +++ b/ansible/roles/poudriere/files/poudboot @@ -16,9 +16,9 @@ load_rc_config $name : ${poudboot_enable:=YES} command=/usr/sbin/daemon -command_dendrite=poudboot pidfile=/var/run/${name}.pid -command_args="-P $pidfile -u root -f -S -T $name poudboot start" +command_args="-p $pidfile -u root -f -S -T $name poudboot start" +export PATH="${PATH}:/usr/local/bin" run_rc_command "$1"