pf revision 1.5
1#!/bin/sh
2#
3# $NetBSD: pf,v 1.5 2005/08/10 13:52:05 peter Exp $
4#
5
6# PROVIDE: pf
7# REQUIRE: root beforenetlkm mountcritlocal tty
8# BEFORE: network
9
10$_rc_subr_loaded . /etc/rc.subr
11
12name="pf"
13rcvar=$name
14start_precmd="pf_prestart"
15start_cmd="pf_start"
16stop_cmd="pf_stop"
17reload_cmd="pf_reload"
18status_cmd="pf_status"
19extra_commands="reload status"
20
21pf_prestart()
22{
23	if [ ! -f ${pf_rules} ]; then
24		warn "${pf_rules} not readable; pf start aborted."
25
26		# If booting directly to multiuser, send SIGTERM to
27		# the parent (/etc/rc) to abort the boot
28		if [ "$autoboot" = yes ]; then
29			echo "ERROR: ABORTING BOOT (sending SIGTERM to parent)!"
30			kill -TERM $$
31			exit 1
32		fi
33		return 1
34	fi
35	return 0
36}
37
38pf_start()
39{
40	echo "Enabling pf firewall."
41	/sbin/pfctl -q -e 
42	if [ -f ${pf_rules} ]; then
43		/sbin/pfctl -q -f ${pf_rules}
44	else
45		warn "${pf_rules} not found; no pf rules loaded."
46	fi
47}
48
49pf_stop()
50{
51	echo "Disabling pf firewall."
52	/sbin/pfctl -q -Fa -d
53}
54
55pf_reload()
56{
57	echo "Reloading pf rules."
58	if [ -f ${pf_rules} ]; then
59		/sbin/pfctl -q -f ${pf_rules}
60	else
61		warn "${pf_rules} not found; no pf rules loaded."
62	fi
63}
64
65pf_status()
66{
67	/sbin/pfctl -s info
68}
69
70load_rc_config $name
71run_rc_command "$1"
72