View | Details | Raw Unified | Return to bug 199150 | Differences between
and this patch

Collapse All | Expand All

(-)etc/rc.d/pflog (-33 / +37 lines)
Lines 24-29 Link Here
24
{
24
{
25
	load_kld pflog || return 1
25
	load_kld pflog || return 1
26
26
27
	# create pflog_dev interface if needed
28
	if ! ifconfig $pflog_dev > /dev/null 2>&1; then
29
		if ! ifconfig $pflog_dev create; then
30
			warn "could not create $pflog_dev."
31
			return 1
32
		fi
33
	fi
34
27
	# set pflog_dev interface to up state
35
	# set pflog_dev interface to up state
28
	if ! ifconfig $pflog_dev up; then
36
	if ! ifconfig $pflog_dev up; then
29
		warn "could not bring up $pflog_dev."
37
		warn "could not bring up $pflog_dev."
Lines 30-53 Link Here
30
		return 1
38
		return 1
31
	fi
39
	fi
32
40
41
	# -p flag requires striping pidfile's leading /var/run and trailing .pid
42
	pidfile=$(echo $pidfile | sed -e 's|/var/run/||' -e 's|.pid$||')
43
33
	# prepare the command line for pflogd
44
	# prepare the command line for pflogd
34
	rc_flags="-f $pflog_logfile -i $pflog_dev $rc_flags"
45
	rc_flags="-p $pidfile -f $pflog_logfile -i $pflog_dev $rc_flags"
35
46
36
	# report we're ready to run pflogd
47
	# report we're ready to run pflogd
37
	return 0
48
	return 0
38
}
49
}
39
50
40
pflog_poststart() {
41
	# Allow child pflogd to settle
42
	sleep 0.10
43
	# More elegant(?) method for getting a unique pid
44
	if [ -f /var/run/pflogd.pid ]; then
45
		mv /var/run/pflogd.pid $pidfile
46
	else
47
		warn "/var/run/pflogd.pid does not exist. Too fast."
48
	fi
49
}
50
51
pflog_poststop()
51
pflog_poststop()
52
{
52
{
53
	if ! ifconfig $pflog_dev down; then
53
	if ! ifconfig $pflog_dev down; then
Lines 70-98 Link Here
70
70
71
load_rc_config $name
71
load_rc_config $name
72
72
73
# Check if spawning multiple pflogd
73
# Check if spawning multiple pflogd and told what to spawn
74
echo "Starting pflogd: $pflog_instances"
74
if [ -n "$2" ]; then
75
if [ "$pflog_instances" ] && [ -n "$pflog_instances" ]; then
75
	# Set required variables
76
	start_postcmd="pflog_poststart"
76
	eval pflog_dev=\$pflog_${2}_dev
77
	eval pflog_logfile=\$pflog_${2}_logfile
78
	eval pflog_flags=\$pflog_${2}_flags
79
	# Check that required vars have non-zero length, warn if not.
80
	if [ -z $pflog_dev ]; then
81
		warn "pflog_dev not set"
82
		continue
83
	fi
84
	if [ -z $pflog_logfile ]; then
85
		warn "pflog_logfile not set"
86
		continue
87
	fi
88
89
	# Provide a unique pidfile name for pflogd -p <pidfile> flag
90
	pidfile="/var/run/pflogd.$2.pid"
91
92
	# Override service name and execute command
93
	export name=$pflog_dev
94
	run_rc_command "$1"
95
# Check if spawning multiple pflogd and not told what to spawn
96
elif [ "$pflog_instances" ] && [ -n "$pflog_instances" ]; then
77
	# Interate through requested instances.
97
	# Interate through requested instances.
78
	for i in $pflog_instances; do
98
	for i in $pflog_instances; do
79
		# Set required variables
99
		/etc/rc.d/pflog $1 $i
80
		eval pflog_dev=\$pflog_${i}_dev
81
		eval pflog_logfile=\$pflog_${i}_logfile
82
		eval pflog_flags=\$pflog_${i}_flags
83
		# Check that required vars have non-zero length, warn if not.
84
		if [ -z $pflog_dev ]; then
85
			warn "pflog_dev not set"
86
			continue
87
		fi
88
		if [ -z $pflog_logfile ]; then
89
			warn "pflog_logfile not set"
90
			continue
91
		fi
92
		# pflogd sets a pidfile, but the name is hardcoded. Concoct a
93
		# unique pidfile name.
94
		pidfile="/var/run/pflogd.$i.pid"
95
		run_rc_command "$1"
96
	done
100
	done
97
else
101
else
98
	# Typical case, spawn single instance only.
102
	# Typical case, spawn single instance only.

Return to bug 199150