literal name_enable wherever possible, and ${name}_enable when it's not, to prepare for the demise of set_rcvar(). In cases where I had to hand-edit unusual instances also modify formatting slightly to be more uniform (and in some cases, correct). This includes adding some $FreeBSD$ tags, and most importantly moving rcvar= to right after name= so it's clear that one is derived from the other.
53 lines
1.2 KiB
Bash
53 lines
1.2 KiB
Bash
#!/bin/sh
|
|
|
|
# PROVIDE: ourmon
|
|
# REQUIRE: LOGIN
|
|
#
|
|
# Add the follow line to /etc/rc.conf to enable ourmon:
|
|
# ourmon_enable (bool): Set it to "YES" to enable ourmon.
|
|
# Default is "NO".
|
|
# ourmon_flags (str): Flags passed to ourmon-script on startup.
|
|
# Default is "-a 30 -s 256 -f
|
|
# /usr/local/mrourmon/etc/ourmon.conf -i re0 -D /usr/local/mrourmon/tmp"
|
|
#
|
|
# The sysctl variables exist to reduce dropped packets.
|
|
# NOTE: on BSD, you may need a recent version of libpcap for this to work
|
|
# get it from: www.tcpdump.org.
|
|
# On BSD: compare sysctl -a outputs to /var/log/messages, bpf bufsizes should match!
|
|
|
|
|
|
. /etc/rc.subr
|
|
|
|
name="ourmon"
|
|
rcvar=ourmon_enable
|
|
command="%%PREFIX%%/mrourmon/bin/ourmon"
|
|
|
|
load_rc_config $name
|
|
|
|
: ${ourmon_enable="NO"}
|
|
: ${ourmon_flags="-a 30 -s 256 -f /usr/local/mrourmon/etc/ourmon.conf -i re0 -D /usr/local/mrourmon/tmp"}
|
|
|
|
start_cmd=${name}_start
|
|
|
|
ourmon_start () {
|
|
sysctl -w net.bpf_bufsize=8388608
|
|
sysctl -w net.bpf_maxbufsize=8388608
|
|
echo "Starting ourmon."
|
|
${command} ${ourmon_flags}
|
|
}
|
|
|
|
ourmon_stop () {
|
|
echo "Stopping ourmon."
|
|
kill -9 `cat /var/run/ourmon.pid`
|
|
}
|
|
|
|
|
|
ourmon_restart () {
|
|
echo "Restarting ourmon."
|
|
ourmon_stop
|
|
ourmon_start
|
|
}
|
|
|
|
command_args="$ourmon_flags"
|
|
|
|
run_rc_command "$1"
|