aboutsummaryrefslogtreecommitdiff
path: root/net-mgmt/darkstat/files/darkstat.in
blob: ff734d79c0a65a100760e085f2a978f07aee6f33 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/bin/sh

# PROVIDE: darkstat
# REQUIRE: LOGIN
# KEYWORD: shutdown

# Add the following lines to /etc/rc.conf to enable `darkstat':
#
# darkstat_enable="YES"
# darkstat_interface="fxp0" # change to suit your configuration
#
# Optional configuration flags:
#
# darkstat_dir="/var/db/darkstat"
# darkstat_pidname="darkstat.pid"
# darkstat_dropuser="nobody"
# darkstat_flags
#
#   - examples: [ --no-promisc ] [ --no-dns ] [ -p port ]
#     [ -b bindaddr ] [ -f filter ] [ -l network/netmask ]
#     [ --daylog filename ] [ --import filename ] [ --export filename ]
#     [ --hosts-max count ] [ --hosts-keep count ] [ --ports-max count ]
#     [ --ports-keep count ] [ --highest-port port ]
#
#   - DON'T pass -i, -r, --chroot, --pidfile, or --user here
#
# Please refer to the darkstat(1) manual page for full documentation.

. /etc/rc.subr

name=darkstat
rcvar=darkstat_enable

command=%%PREFIX%%/sbin/$name
start_precmd=darkstat_prestart

load_rc_config $name
: ${darkstat_enable="NO"}
: ${darkstat_dir="/var/db/darkstat"}
: ${darkstat_pidname="darkstat.pid"}
: ${darkstat_dropuser="nobody"}
pidfile="${darkstat_dir}/${darkstat_pidname}"

darkstat_prestart()
{
	if [ "x${darkstat_interface}" = "x" ]; then
		err 1 "You must define \$darkstat_interface."
	fi
	mkdir -p ${darkstat_dir}
	chown ${darkstat_dropuser} ${darkstat_dir}
	chmod u+wx ${darkstat_dir}
}

darkstat_flags="-i ${darkstat_interface} --chroot ${darkstat_dir} \
--pidfile ${darkstat_pidname} --user ${darkstat_dropuser} \
${darkstat_flags}"

run_rc_command "$1"