summaryrefslogtreecommitdiffstats
path: root/etc/rc.d/pflog
diff options
context:
space:
mode:
authoryar <yar@FreeBSD.org>2005-10-02 15:54:26 +0000
committeryar <yar@FreeBSD.org>2005-10-02 15:54:26 +0000
commit470062ac3bc0d8f6085200b852e97a10dac25606 (patch)
tree51bb1741bb0e213fd12f3c2cd9b2213f7375710e /etc/rc.d/pflog
parentf97f0f5c5cbe20d8d7f8d73450e9abfb911286c4 (diff)
downloadFreeBSD-src-470062ac3bc0d8f6085200b852e97a10dac25606.zip
FreeBSD-src-470062ac3bc0d8f6085200b852e97a10dac25606.tar.gz
Use rc.subr(8) appropriately:
- utilize default methods instead of rolling local ones; - avoid to specify BEFORE conditions we don't really need (pflog will be REQUIRE'd by pf); - omit extra decoration from warning messages, warn() will decorate them sufficiently.
Diffstat (limited to 'etc/rc.d/pflog')
-rw-r--r--etc/rc.d/pflog67
1 files changed, 23 insertions, 44 deletions
diff --git a/etc/rc.d/pflog b/etc/rc.d/pflog
index 859bde7..0e5b499 100644
--- a/etc/rc.d/pflog
+++ b/etc/rc.d/pflog
@@ -5,81 +5,60 @@
# PROVIDE: pflog
# REQUIRE: root mountcritlocal netif cleanvar
-# BEFORE: DAEMON LOGIN
# KEYWORD: nojail
. /etc/rc.subr
name="pflog"
rcvar=`set_rcvar`
-load_rc_config $name
-stop_precmd="test -x ${pflog_program}"
+command="/sbin/pflogd"
+pidfile="/var/run/pflogd.pid"
start_precmd="pflog_prestart"
-start_cmd="pflog_start"
-stop_cmd="pflog_stop"
-resync_precmd="$stop_precmd"
+stop_postcmd="pflog_poststop"
+extra_commands="reload resync"
+
+# for backward compatibility
resync_cmd="pflog_resync"
-status_precmd="$stop_precmd"
-status_cmd="pflog_status"
-extra_commands="resync status"
pflog_prestart()
{
# load pflog kernel module if needed
if ! kldstat -q -m pflog; then
if kldload pf; then
- info 'pflog module loaded.'
+ info 'pf module loaded.'
else
- err 1 'pflog module failed to load.'
+ warn 'pf module failed to load.'
+ return 1
fi
fi
# set pflog0 interface to up state
if ! ifconfig pflog0 up; then
- warn 'pflog: COULD NOT SET UP pflog0'
- fi
-
- # check for pflogd binary
- if [ ! -x "${pflog_program:-/sbin/pflogd}" ]
- then
- warn 'pflog: NO PFLOGD BINARY FOUND'
+ warn 'could not not bring up pflog0.'
return 1
fi
-}
-pflog_start()
-{
- echo -n "Enabling pflogd"
- if ! ${pflog_program:-/sbin/pflogd} ${pflog_flags} \
- -f ${pflog_logfile:-/var/log/pflog}; then
- echo " failed!"
- else
- echo "."
- fi
-}
+ # prepare the command line for pflogd
+ rc_flags="-f $pflog_logfile $rc_flags"
-pflog_stop()
-{
- if [ -r /var/run/pflogd.pid ]; then
- echo "Stopping pflogd."
- kill `cat /var/run/pflogd.pid`
- fi
+ # report we're ready to run pflogd
+ return 0
}
-pflog_resync()
+pflog_poststop()
{
- if [ -r /var/run/pflogd.pid ]; then
- kill -SIGHUP `cat /var/run/pflogd.pid`
+ if ! ifconfig pflog0 down; then
+ warn 'could not bring down pflog0.'
+ return 1
fi
+ return 0
}
-pflog_status()
+# for backward compatibility
+pflog_resync()
{
- if [ -r /var/run/pflogd.pid ]; then
- ps -p `cat /var/run/pflogd.pid` | tail -n 1
- else
- echo 'pflogd not running.'
- fi
+ run_rc_command reload
}
+load_rc_config $name
run_rc_command "$1"
OpenPOWER on IntegriCloud