summaryrefslogtreecommitdiff
path: root/etc/rc.d/npf
blob: c757d491f584a2733e0b1de3e7e48e0e3782f4ac (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
#!/bin/sh
#
# $NetBSD: npf,v 1.7 2020/09/08 12:52:18 martin Exp $
#
# Public Domain.
#

# PROVIDE: npf
# REQUIRE: root bootconf CRITLOCALMOUNTED tty network
# BEFORE: NETWORKING

$_rc_subr_loaded . /etc/rc.subr

name="npf"
rcvar=$name

config="/etc/npf.conf"

start_cmd="npf_start"
stop_cmd="npf_stop"

reload_cmd="npf_reload"
status_cmd="npf_status"
extra_commands="reload status"

npf_cfg_check()
{
	if [ ! -f ${config} ]; then
		warn "${config} is not readable; failed."
		exit 1
	fi
}

npf_start()
{
	echo "Enabling NPF."
	npf_cfg_check
	/sbin/npfctl reload

	# The npf_boot script has enabled npf already.
	if [ "$autoboot" != "yes" ]; then
		/sbin/npfctl start
	fi
}

npf_stop()
{
	echo "Disabling NPF."
	/sbin/npfctl stop
	/sbin/npfctl flush
}

npf_reload()
{
	echo "Reloading NPF ruleset."
	npf_cfg_check
	/sbin/npfctl reload
}

npf_status()
{
	:
}

load_rc_config $name
run_rc_command "$1"