From 0bef22e73c45f37eb1f9f91fccb58caf4956c910 Mon Sep 17 00:00:00 2001 From: rodri Date: Wed, 20 Oct 2021 20:22:10 +0000 Subject: correct diagnostic output redirections. re-organize the files to make more sense. --- etc/rc.d/bhyve_coeus | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100755 etc/rc.d/bhyve_coeus (limited to 'etc/rc.d/bhyve_coeus') diff --git a/etc/rc.d/bhyve_coeus b/etc/rc.d/bhyve_coeus new file mode 100755 index 0000000..514616d --- /dev/null +++ b/etc/rc.d/bhyve_coeus @@ -0,0 +1,57 @@ +#!/bin/sh +# +# $AntaresLabs$ +# + +# PROVIDE: bhyve_coeus +# REQUIRE: DAEMON FILESYSTEMS +# KEYWORD: nojail shutdown + +. /etc/rc.subr + +vmname=coeus +name="bhyve_${vmname}" +desc="Bhyve - ${vmname} VM" +rcvar="${name}_enable" +start_cmd="bhyve_start" +stop_cmd="bhyve_stop" +status_cmd="bhyve_status" +extra_commands="status" + +load_rc_config $name +: ${bhyve_coeus_enable:=NO} + +runvm() +{ + local rc=0 + + while [ $rc -eq 0 ];do + /vmm/machine/${vmname}/run + rc=$? + done +} + +bhyve_start() +{ + runvm & +} + +bhyve_status() +{ + local pid=$(ps axo pid,command | egrep "${vmname}.*\\(bhyve\\)" | awk '{print $1}') + + if [ ! -z $pid ];then + echo $name is running with pid $pid. 1>&2 + return 0 + else + echo $name is not running. 1>&2 + fi +} + +bhyve_stop() +{ + local pid=$(ps axo pid,command | egrep "${vmname}.*\\(bhyve\\)" | awk '{print $1}') + kill -TERM $pid +} + +run_rc_command "$1" -- cgit v1.2.3