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