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; 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 71-79
Link Here
|
71 |
load_rc_config $name |
71 |
load_rc_config $name |
72 |
|
72 |
|
73 |
# Check if spawning multiple pflogd |
73 |
# Check if spawning multiple pflogd |
74 |
echo "Starting pflogd: $pflog_instances" |
|
|
75 |
if [ "$pflog_instances" ] && [ -n "$pflog_instances" ]; then |
74 |
if [ "$pflog_instances" ] && [ -n "$pflog_instances" ]; then |
76 |
start_postcmd="pflog_poststart" |
|
|
77 |
# Interate through requested instances. |
75 |
# Interate through requested instances. |
78 |
for i in $pflog_instances; do |
76 |
for i in $pflog_instances; do |
79 |
# Set required variables |
77 |
# Set required variables |
Lines 89-98
Link Here
|
89 |
warn "pflog_logfile not set" |
87 |
warn "pflog_logfile not set" |
90 |
continue |
88 |
continue |
91 |
fi |
89 |
fi |
92 |
# pflogd sets a pidfile, but the name is hardcoded. Concoct a |
90 |
|
93 |
# unique pidfile name. |
91 |
# Provide a unique pidfile name for pflogd -p <pidfile> flag |
94 |
pidfile="/var/run/pflogd.$i.pid" |
92 |
pidfile="/var/run/pflogd.$i.pid" |
|
|
93 |
|
94 |
# Override service name and execute command |
95 |
name=$pflog_dev |
95 |
run_rc_command "$1" |
96 |
run_rc_command "$1" |
|
|
97 |
#_rc_restart_done=false |
96 |
done |
98 |
done |
97 |
else |
99 |
else |
98 |
# Typical case, spawn single instance only. |
100 |
# Typical case, spawn single instance only. |