summaryrefslogtreecommitdiffstats
path: root/etc/rc.d/ipfs
blob: d9eb62d8c1219651829553eea3b4a08fd12cdbc3 (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
#!/bin/sh
#
# $FreeBSD$
#

# PROVIDE: ipfs
# REQUIRE: ipnat
# BEFORE:  netif
# KEYWORD: nojail shutdown

. /etc/rc.subr

name="ipfs"
rcvar=`set_rcvar`
start_cmd="ipfs_start"
stop_cmd="ipfs_stop"
start_precmd="ipfs_prestart"

ipfs_prestart()
{
	# Do not continue if either ipnat or ipfilter is not enabled or
	# if the ipfilter module is not loaded.
	#
	if ! checkyesno ipfilter_enable -o ! checkyesno ipnat_enable ; then
		err 1  "${name} requires either ipfilter or ipnat enabled"
	fi
	if ! sysctl net.inet.ipf.fr_pass >/dev/null 2>&1; then
		err 1 "ipfilter module is not loaded"
	fi
	return 0
}

ipfs_start()
{
	if [ -r /var/db/ipf/ipstate.ipf -a -r /var/db/ipf/ipnat.ipf ]; then
		${ipfs_program} -R ${rc_flags}
		rm -f /var/db/ipf/ipstate.ipf /var/db/ipf/ipnat.ipf
	fi
}

ipfs_stop()
{
	if [ ! -d /var/db/ipf ]; then
		mkdir /var/db/ipf
		chmod 700 /var/db/ipf
		chown root:wheel /var/db/ipf
	fi
	${ipfs_program} -W ${rc_flags}
}

load_rc_config $name
run_rc_command "$1"
OpenPOWER on IntegriCloud