diff options
Diffstat (limited to 'sys-freebsd/freebsd-pf/files/pf.initd')
-rwxr-xr-x | sys-freebsd/freebsd-pf/files/pf.initd | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/sys-freebsd/freebsd-pf/files/pf.initd b/sys-freebsd/freebsd-pf/files/pf.initd new file mode 100755 index 0000000..da12019 --- /dev/null +++ b/sys-freebsd/freebsd-pf/files/pf.initd @@ -0,0 +1,50 @@ +#!/sbin/runscript +# Copyright 2006 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: /var/cvsroot/gentoo-x86/sys-freebsd/freebsd-pf/files/pf.initd,v 1.2 2007/02/23 13:51:44 uberlord Exp $ + +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 $? +} |