xref: /freebsd-12.1/libexec/rc/rc.d/pfsync (revision 0696600c)
1*0696600cSBjoern A. Zeeb#!/bin/sh
2*0696600cSBjoern A. Zeeb#
3*0696600cSBjoern A. Zeeb# $FreeBSD$
4*0696600cSBjoern A. Zeeb#
5*0696600cSBjoern A. Zeeb
6*0696600cSBjoern A. Zeeb# PROVIDE: pfsync
7*0696600cSBjoern A. Zeeb# REQUIRE: FILESYSTEMS netif
8*0696600cSBjoern A. Zeeb# KEYWORD: nojailvnet
9*0696600cSBjoern A. Zeeb
10*0696600cSBjoern A. Zeeb. /etc/rc.subr
11*0696600cSBjoern A. Zeeb
12*0696600cSBjoern A. Zeebname="pfsync"
13*0696600cSBjoern A. Zeebdesc="Packet filter state table sychronisation interface"
14*0696600cSBjoern A. Zeebrcvar="pfsync_enable"
15*0696600cSBjoern A. Zeebstart_precmd="pfsync_prestart"
16*0696600cSBjoern A. Zeebstart_cmd="pfsync_start"
17*0696600cSBjoern A. Zeebstop_cmd="pfsync_stop"
18*0696600cSBjoern A. Zeebrequired_modules="pf pfsync"
19*0696600cSBjoern A. Zeeb
20*0696600cSBjoern A. Zeebpfsync_prestart()
21*0696600cSBjoern A. Zeeb{
22*0696600cSBjoern A. Zeeb	case "$pfsync_syncdev" in
23*0696600cSBjoern A. Zeeb	'')
24*0696600cSBjoern A. Zeeb		warn "pfsync_syncdev is not set."
25*0696600cSBjoern A. Zeeb		return 1
26*0696600cSBjoern A. Zeeb		;;
27*0696600cSBjoern A. Zeeb	esac
28*0696600cSBjoern A. Zeeb	return 0
29*0696600cSBjoern A. Zeeb}
30*0696600cSBjoern A. Zeeb
31*0696600cSBjoern A. Zeebpfsync_start()
32*0696600cSBjoern A. Zeeb{
33*0696600cSBjoern A. Zeeb	local _syncpeer
34*0696600cSBjoern A. Zeeb
35*0696600cSBjoern A. Zeeb	echo "Enabling pfsync."
36*0696600cSBjoern A. Zeeb	if [ -n "${pfsync_syncpeer}" ]; then
37*0696600cSBjoern A. Zeeb		_syncpeer="syncpeer ${pfsync_syncpeer}"
38*0696600cSBjoern A. Zeeb	fi
39*0696600cSBjoern A. Zeeb	ifconfig pfsync0 $_syncpeer syncdev $pfsync_syncdev $pfsync_ifconfig up
40*0696600cSBjoern A. Zeeb}
41*0696600cSBjoern A. Zeeb
42*0696600cSBjoern A. Zeebpfsync_stop()
43*0696600cSBjoern A. Zeeb{
44*0696600cSBjoern A. Zeeb	echo "Disabling pfsync."
45*0696600cSBjoern A. Zeeb	ifconfig pfsync0 -syncdev -syncpeer down
46*0696600cSBjoern A. Zeeb}
47*0696600cSBjoern A. Zeeb
48*0696600cSBjoern A. Zeebload_rc_config $name
49*0696600cSBjoern A. Zeebrun_rc_command "$1"
50