1 #!/bin/sh 2 # 3 # $NetBSD: ipfilter,v 1.4.4.1 2000/08/09 18:45:22 lukem Exp $ 4 # 5 6 # PROVIDE: ipfilter 7 # REQUIRE: root beforenetlkm mountcritlocal tty 8 9 . /etc/rc.subr 10 11 name="ipfilter" 12 start_precmd="ipfilter_prestart" 13 start_cmd="ipfilter_start" 14 stop_precmd="checkyesno ipfilter && [ -f /etc/ipf.conf ]" 15 stop_cmd="ipfilter_stop" 16 reload_precmd="$stop_precmd" 17 reload_cmd="ipfilter_reload" 18 status_precmd="$stop_precmd" 19 status_cmd="ipfilter_status" 20 extra_commands="reload status" 21 22 ipfilter_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 43 ipfilter_start() 44 { 45 echo "Enabling ipfilter." 46 /sbin/ipf -E -Fa -f /etc/ipf.conf 47 } 48 49 ipfilter_stop() 50 { 51 echo "Disabling ipfilter." 52 /sbin/ipf -D 53 } 54 55 ipfilter_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 66 ipfilter_status() 67 { 68 /sbin/ipf -V 69 } 70 71 load_rc_config $name 72 run_rc_command "$1" 73