blob: 8c69dcc0ebd6565dc38f6d7d5a64be4ffc1924bc (
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
58
59
60
61
62
63
64
65
66
67
68
69
70
|
#!/bin/sh
#
# $FreeBSD$
#
# PROVIDE: vboxnet
# BEFORE: NETWORKING
# REQUIRE: FILESYSTEMS
# KEYWORD: nojail
#
# Add the following lines to /etc/rc.conf.local or /etc/rc.conf
# to enable this service:
#
# vboxnet_enable (bool): Set to NO by default.
# Set it to YES to load network related kernel modules on startup
. /etc/rc.subr
name="vboxnet"
rcvar=vboxnet_enable
start_cmd="vboxnet_start"
stop_cmd="vboxnet_stop"
vboxnet_modules="vboxdrv vboxnetflt:ng_vboxnetflt vboxnetadp"
vboxnet_start()
{
local _k _m
for _m in ${vboxnet_modules}; do
_k=${_m%:*}
_m=${_m#*:}
if ! kldstat -q -m ${_m}; then
if ! kldload ${_k} > /dev/null 2>&1; then
warn "Can't load ${_k} module."
return 1
fi
fi
done
# initialize configured host-only interfaces
LD_LIBRARY_PATH=%%PREFIX%%/lib %%PREFIX%%/bin/VBoxManage list hostonlyifs >/dev/null
}
vboxnet_stop()
{
local _k _m _r
_r=
for _m in ${vboxnet_modules}; do
_r="${_m} ${_r}"
done
for _m in ${_r}; do
_k=${_m%:*}
_m=${_m#*:}
if kldstat -q -m ${_m}; then
if ! kldunload ${_k} > /dev/null 2>&1; then
warn "Can't unload ${_k} module."
return 1
fi
fi
done
}
load_rc_config $name
: ${vboxnet_enable="NO"}
run_rc_command "$1"
|