]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - etc/rc.d/ipfs
Pull in /etc/rc.conf.d/network so that ifconfig_<if> variables can be
[FreeBSD/FreeBSD.git] / etc / rc.d / ipfs
1 #!/bin/sh
2 #
3 # $NetBSD: ipfs,v 1.3 2002/02/11 13:55:42 lukem Exp $
4 # $FreeBSD$
5 #
6
7 # PROVIDE: ipfs
8 # REQUIRE: ipnat
9 # BEFORE:  netif
10 # KEYWORD: nojail shutdown
11
12 . /etc/rc.subr
13
14 name="ipfs"
15 rcvar=`set_rcvar`
16 start_cmd="ipfs_start"
17 stop_cmd="ipfs_stop"
18 start_precmd="ipfs_prestart"
19
20 ipfs_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 ! sysctl net.inet.ipf.fr_pass >/dev/null 2>&1; then
29                 err 1 "ipfilter module is not loaded"
30         fi
31         return 0
32 }
33
34 ipfs_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
42 ipfs_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
52 load_rc_config $name
53 run_rc_command "$1"