]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - libexec/rc/rc.d/ipfs
MFV: xz 5.4.4.
[FreeBSD/FreeBSD.git] / libexec / rc / rc.d / ipfs
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
13 name="ipfs"
14 desc="Saves and restores information for NAT and state tables"
15 rcvar="ipfs_enable"
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 ! ${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
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"