summaryrefslogtreecommitdiff
path: root/security/pf/files/pf.sh.sample
blob: 0223f92df05f74e8abd8dc3f1bb3a604eb8a647d (plain) (blame)
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
#!/bin/sh
#
# $FreeBSD$

if ! PREFIX=$(expr $0 : "\(/.*\)/etc/rc\.d/$(basename $0)\$"); then
    echo "$0: Cannot determine the PREFIX" >&2
    echo "Please use the complete pathname." >&2
    exit 1
fi

if [ -z "${source_rc_confs_defined}" ]; then
	if [ -r /etc/defaults/rc.conf ]; then
		. /etc/defaults/rc.conf
		source_rc_confs
	elif [ -r /etc/rc.conf ]; then
		. /etc/rc.conf
	fi
fi

case "$1" in
start)
	case "${pf_enable}" in
	    [Yy][Ee][Ss])
	    echo -n ' pf'
	    kldload ${PREFIX}/modules/pflog.ko
	    kldload ${PREFIX}/modules/pfsync.ko
	    if [ -f ${PREFIX}/modules/pfaltq.ko ]; then
		kldload ${PREFIX}/modules/pfaltq.ko
	    fi
	    ifconfig pflog0 up
	    ifconfig pfsync0 up
	    case "${pf_logd}" in
	    [Yy][Ee][Ss])
		if [ -x ${PREFIX}/sbin/pflogd ]; then
			echo -n ' pflogd'
			${PREFIX}/sbin/pflogd
		fi
	    	;;
	    esac
	    kldload ${PREFIX}/modules/pf.ko
	    if [ -f ${pf_conf:-${PREFIX}/etc/pf.conf} ]; then
		if [ -x ${PREFIX}/sbin/pfctl ]; then
			${PREFIX}/sbin/pfctl -e \
				-f ${pf_conf:-${PREFIX}/etc/pf.conf} \
				${pfctl_flags}
		fi
	    fi
	    ;;
	esac
	;;
stop)
	if [ -x ${PREFIX}/sbin/pfctl ]; then
		${PREFIX}/sbin/pfctl -d
	fi
	killall pflogd
	kldunload pf
	if [ -f ${PREFIX}/modules/pfaltq.ko ]; then
		kldunload pfaltq
	fi
	kldunload pflog
	kldunload pfsync
	;;
*)
	echo "Usage: `basename $0` {start|stop}" >&2
	;;
esac

exit 0