summaryrefslogtreecommitdiff
blob: e8f3d92c096e6e1d346a11d13c09d8979d998a02 (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
#!/sbin/runscript
# Copyright 2006 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Id$

depend() {
	need net
}

checkconfig() {
	if ! [ -c /dev/pf ]; then
		ewarn "Pseudo-device /dev/pf not found."
	
		ebegin "Loading pf module"
		if ! kldload pf; then
			eerror "Unable to load pf module."
			eend 1
			return 1
		fi
		eend $?

		if ! [ -c /dev/pf ]; then
			eerror "Pseudo-device /dev/pf still not found."
			return 1
		fi
	fi

	return 0
}

start() {
	checkconfig || return 1

	einfo "Starting firewall"
	
	if [ -r "${PF_RULES_FILE}" ]; then
		einfo "Loading firewall rules"
		/sbin/pfctl -qe -f ${PF_RULES_FILE:-/etc/pf.conf} ${PF_OPTS}
	else
		/sbin/pfctl -qe ${PF_OPTS}
	fi
	
	eend $?
}

stop() {
	einfo "Stopping firewall"
	/sbin/pfctl -qd || retval=1
	eend $?
}