1#!/bin/sh 2# 3# $FreeBSD$ 4# 5 6# PROVIDE: ipfs 7# REQUIRE: ipnat 8# BEFORE: netif 9# KEYWORD: nojail shutdown 10 11. /etc/rc.subr 12 13name="ipfs" 14desc="Saves and restores information for NAT and state tables" 15rcvar="ipfs_enable" 16start_cmd="ipfs_start" 17stop_cmd="ipfs_stop" 18start_precmd="ipfs_prestart" 19 20ipfs_prestart() 21{ 22 # Do not continue if either ipnat or ipfilter is not enabled or 23 # if the ipfilter module is not loaded. 24 # 25 if ! checkyesno ipfilter_enable -o ! checkyesno ipnat_enable ; then 26 err 1 "${name} requires either ipfilter or ipnat enabled" 27 fi 28 if ! ${ipfilter_program:-/sbin/ipf} -V | grep -q 'Running: yes' >/dev/null 2>&1; then 29 err 1 "ipfilter module is not loaded" 30 fi 31 return 0 32} 33 34ipfs_start() 35{ 36 if [ -r /var/db/ipf/ipstate.ipf -a -r /var/db/ipf/ipnat.ipf ]; then 37 ${ipfs_program} -R ${rc_flags} 38 rm -f /var/db/ipf/ipstate.ipf /var/db/ipf/ipnat.ipf 39 fi 40} 41 42ipfs_stop() 43{ 44 if [ ! -d /var/db/ipf ]; then 45 mkdir /var/db/ipf 46 chmod 700 /var/db/ipf 47 chown root:wheel /var/db/ipf 48 fi 49 ${ipfs_program} -W ${rc_flags} 50} 51 52load_rc_config $name 53run_rc_command "$1" 54