]> CyberLeo.Net >> Repos - FreeBSD/releng/8.1.git/blob - etc/rc.d/pfsync
Copy stable/8 to releng/8.1 in preparation for 8.1-RC1.
[FreeBSD/releng/8.1.git] / etc / rc.d / pfsync
1 #!/bin/sh
2 #
3 # $FreeBSD$
4 #
5
6 # PROVIDE: pfsync
7 # REQUIRE: FILESYSTEMS netif
8 # KEYWORD: nojail
9
10 . /etc/rc.subr
11
12 name="pfsync"
13 rcvar=`set_rcvar`
14 start_precmd="pfsync_prestart"
15 start_cmd="pfsync_start"
16 stop_cmd="pfsync_stop"
17 required_modules="pf"
18
19 pfsync_prestart()
20 {
21         # XXX Currently pfsync cannot be a module as it must register
22         # a network protocol in a static kernel table.
23         if ! kldstat -q -m pfsync; then
24                 warn "pfsync(4) must be statically compiled in the kernel."
25                 return 1
26         fi
27
28         case "$pfsync_syncdev" in
29         '')
30                 warn "pfsync_syncdev is not set."
31                 return 1
32                 ;;
33         esac
34         return 0
35 }
36
37 pfsync_start()
38 {
39         local _syncpeer
40
41         echo "Enabling pfsync."
42         if [ -n "${pfsync_syncpeer}" ]; then
43                 _syncpeer="syncpeer ${pfsync_syncpeer}"
44         fi
45         ifconfig pfsync0 $_syncpeer syncdev $pfsync_syncdev $pfsync_ifconfig up
46 }
47
48 pfsync_stop()
49 {
50         echo "Disabling pfsync."
51         ifconfig pfsync0 -syncdev down
52 }
53
54 load_rc_config $name
55 run_rc_command "$1"