blob: 7b8c2c298e1bbe253d9e0d28f1e1d4acefc91cc0 (
plain)
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
|
#!/sbin/runscript
# Copyright 1999-2006 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/net-analyzer/darkstat/files/darkstat-init,v 1.4 2007/02/01 21:35:33 jokey Exp $
IF=${SVCNAME##*.}
if [[ -n "${IF}" && ${SVCNAME} != "darkstat" ]] ; then
PIDFILE=/var/run/darkstat.${IF}.pid
else
PIDFILE=/var/run/darkstat.pid
fi
depend() {
need net
}
chkconfig() {
if [[ -n "${IF}" && ${SVCNAME} != "darkstat" ]] ; then
if [[ ! -f "/etc/conf.d/darkstat.${IF}" ]]; then
eerror "/etc/conf.d/darkstat.${IF} does not exist. Please, create."
return 1
fi
INTERFACE=${IF}
else
if [[ ! -f "/etc/conf.d/darkstat" ]]; then
eerror "/etc/conf.d/darkstat does not exist. Please, create."
return 1
fi
fi
if [[ -z "${INTERFACE}" ]]; then
ewarn "No interface specified. Trying to use eth0."
INTERFACE="eth0"
fi
DARKSTAT_OPTS="-i ${INTERFACE}"
[[ -n "${PORT}" ]] && DARKSTAT_OPTS="${DARKSTAT_OPTS} -p ${PORT}"
[[ -n "${ADDRESS}" ]] && DARKSTAT_OPTS="${DARKSTAT_OPTS} -b ${ADDRESS}"
[[ -n "${FILTER}" ]] && DARKSTAT_OPTS="${DARKSTAT_OPTS} -f ${FILTER}"
return 0
}
start() {
chkconfig || return 1
ebegin "Starting darkstat on ${INTERFACE}"
# Remove --background option for debugging.
start-stop-daemon --start --exec /usr/sbin/darkstat --pidfile ${PIDFILE} --make-pidfile --background -- ${DARKSTAT_OPTS}
eend $?
}
stop() {
ebegin "Stopping darkstat on ${INTERFACE}"
start-stop-daemon --stop --quiet --retry 5 --pidfile ${PIDFILE}
eend $?
}
|