aboutsummaryrefslogtreecommitdiff
path: root/etc/rc.d/bhyve_coeus
blob: 514616def88d08092cfb961a414f174065269a47 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
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"