ipfilter revision 1.6
1#!/bin/sh
2#
3# $NetBSD: ipfilter,v 1.6 2000/07/21 01:14:23 lukem Exp $
4#
5
6# PROVIDE: ipfilter
7# REQUIRE: root beforenetlkm mountcritlocal tty
8
9. /etc/rc.subr
10
11name="ipfilter"
12start_precmd="ipfilter_prestart"
13start_cmd="ipfilter_start"
14stop_precmd="checkyesno ipfilter && [ -f /etc/ipf.conf ]"
15stop_cmd="ipfilter_stop"
16reload_precmd="$stop_precmd"
17reload_cmd="ipfilter_reload"
18status_precmd="$stop_precmd"
19status_cmd="ipfilter_status"
20extra_commands="reload status"
21
22ipfilter_prestart()
23{
24	if ! checkyesno ipfilter; then
25		return 1
26	fi
27	if [ ! -f /etc/ipf.conf ]; then
28		warn "/etc/ipf.conf not readable; ipfilter start aborted."
29			#
30			# If booting directly to multiuser, send SIGTERM to
31			# the parent (/etc/rc) to abort the boot
32			#
33		if [ "$autoboot" = yes ]; then
34			echo "ERROR: ABORTING BOOT (sending SIGTERM to parent)!"
35			kill -TERM $$
36			exit 1
37		fi
38		return 1
39	fi
40	return 0
41}
42
43ipfilter_start()
44{
45	echo "Enabling ipfilter."
46	/sbin/ipf -E -Fa -f /etc/ipf.conf
47}
48
49ipfilter_stop()
50{
51	echo "Disabling ipfilter."
52	/sbin/ipf -D
53}
54
55ipfilter_reload()
56{
57	echo "Reloading ipfilter rules."
58	/sbin/ipf -I -Fa -f /etc/ipf.conf
59	if [ $? -eq 0 ]; then
60		/sbin/ipf -s
61	else
62		warn "Reload failed; not swapping to new ruleset."
63	fi
64}
65
66ipfilter_status()
67{
68	/sbin/ipf -V
69}
70
71load_rc_config $name
72run_rc_command "$1"
73