summaryrefslogtreecommitdiffstats
path: root/etc/rc.d/pfsync
blob: 8be89282d12030603d57fd42eb443f567e221824 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/bin/sh
#
# $FreeBSD$
#

# PROVIDE: pfsync
# REQUIRE: FILESYSTEMS netif
# KEYWORD: nojail

. /etc/rc.subr

name="pfsync"
rcvar=`set_rcvar`
start_precmd="pfsync_prestart"
start_cmd="pfsync_start"
stop_cmd="pfsync_stop"
required_modules="pf"

pfsync_prestart()
{
	# XXX Currently pfsync cannot be a module as it must register
	# a network protocol in a static kernel table.
	if ! kldstat -q -m pfsync; then
		warn "pfsync(4) must be statically compiled in the kernel."
		return 1
	fi

	case "$pfsync_syncdev" in
	'')
		warn "pfsync_syncdev is not set."
		return 1
		;;
	esac
	return 0
}

pfsync_start()
{
	local _syncpeer

	echo "Enabling pfsync."
	if [ -n "${pfsync_syncpeer}" ]; then
		_syncpeer="syncpeer ${pfsync_syncpeer}"
	fi
	ifconfig pfsync0 $_syncpeer syncdev $pfsync_syncdev $pfsync_ifconfig up
}

pfsync_stop()
{
	echo "Disabling pfsync."
	ifconfig pfsync0 -syncdev down
}

load_rc_config $name
run_rc_command "$1"
OpenPOWER on IntegriCloud