4
# Required-Start: $remote_fs $network
5
# Required-Stop: $remote_fs
6
# Default-Start: 2 3 4 5
8
# Short-Description: netflow capture daemon
9
# Description: nfcapd is the netflow capture daemon of the nfdump tools.
12
# Author: Erik Wenzel <erik@debian.org>
16
# PATH should only include /usr/* if it runs after the mountnfs.sh script
17
PATH=/sbin:/usr/sbin:/bin:/usr/bin
18
DESC="netflow capture daemon"
21
DATA_BASE_DIR="/var/cache/nfdump"
22
PIDFILE=/var/run/$NAME.pid
23
DAEMON_ARGS="-D -l $DATA_BASE_DIR -P $PIDFILE"
24
SCRIPTNAME=/etc/init.d/nfdump
26
# Exit if the package is not installed
27
[ -x "$DAEMON" ] || exit 0
29
# Read configuration variable file if it is present
30
[ -r /etc/default/nfdump ] && . /etc/default/nfdump
32
# Load the VERBOSE setting and other rcS variables
35
# Define LSB log_* functions.
36
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
37
. /lib/lsb/init-functions
40
# Function that starts the daemon/service
44
# Don't start daemon in this mode. Defined in /etc/default/nfdump
45
if [ x"$nfcapd_start" = xno ]
47
[ "$VERBOSE" != no ] && log_warning_msg "nfdump daemon not enabled in /etc/default/nfdump, not starting..."
51
# 0 if daemon has been started
52
# 1 if daemon was already running
53
# 2 if daemon could not be started
54
start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \
56
start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \
59
# Add code here, if necessary, that waits for the process to be ready
60
# to handle requests from services started subsequently which depend
61
# on this one. As a last resort, sleep for some time.
65
# Function that stops the daemon/service
70
# 0 if daemon has been stopped
71
# 1 if daemon was already stopped
72
# 2 if daemon could not be stopped
73
# other if a failure occurred
74
start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME
76
[ "$RETVAL" = 2 ] && return 2
77
# Wait for children to finish too if this is a daemon that forks
78
# and if the daemon is only ever run from this initscript.
79
# If the above conditions are not satisfied then add some other code
80
# that waits for the process to drop all resources that could be
81
# needed by services started subsequently. A last resort is to
82
# sleep for some time.
84
# Disabled second call, because is kills nfsen controlled nfcapd
85
#start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
86
#[ "$?" = 2 ] && return 2
87
# Many daemons don't delete their pidfiles when they exit.
93
# Function that sends a SIGHUP to the daemon/service
97
# If the daemon can reload its configuration without
98
# restarting (for example, when it is sent a SIGHUP),
99
# then implement that here.
101
start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAME
107
[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
110
0|1) [ q"$VERBOSE" != qno ] && log_end_msg 0 ;;
111
2) [ p"$VERBOSE" != pno ] && log_end_msg 1 ;;
115
[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
118
0|1) [ "r$VERBOSE" != rno ] && log_end_msg 0 ;;
119
2) [ "s$VERBOSE" != sno ] && log_end_msg 1 ;;
122
#reload|force-reload)
124
# If do_reload() is not implemented then leave this commented out
125
# and leave 'force-reload' as an alias for 'restart'.
127
#log_daemon_msg "Reloading $DESC" "$NAME"
131
restart|force-reload)
133
# If the "reload" option is implemented then remove the
134
# 'force-reload' alias
136
log_daemon_msg "Restarting $DESC" "$NAME"
142
0|1) log_end_msg 0 ;;
143
*) log_end_msg 1 ;; # Failed to start
153
#echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
154
echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2