File rcntop of Package ntop
x
1
2
# Copyright (c) 1995-2005 SUSE Linux Products GmbH
3
#
4
# Author: Remo Behn <ray@suse.de>
5
#
6
# /etc/init.d/ntop
7
#
8
### BEGIN INIT INFO
9
# Provides: ntop
10
# Required-Start: $network
11
# Required-Stop: $network
12
# Default-Start: 3 5
13
# Default-Stop: 0 1 2 6
14
# Short-Description: ntop Network Monitor
15
# Description: Tool for monitoring the network usage.
16
### END INIT INFO
17
PROGRAM=/usr/bin/ntop
18
CONFFILE="/etc/sysconfig/ntop"
19
20
. /etc/rc.status
21
if [ -f $CONFFILE ]; then
22
. $CONFFILE
23
else
24
echo "Config file $CONFFILE not found. "
25
rc_status -s
26
exit 6
27
fi
28
29
function setup_options()
30
{
31
# use default options
32
NTOP_OPTIONS="-P /var/lib/ntop"
33
# define the NTOP_IFACE
34
if [ -n "$NTOPD_IFACE" ]; then
35
NTOP_OPTIONS="$NTOP_OPTIONS -i $NTOPD_IFACE"
36
else
37
rc_failed 6
38
rc_status -v
39
exit 6
40
fi
41
# setup the user to run ntop
42
if [ -n "$NTOP_USER" ]; then
43
NTOP_OPTIONS="$NTOP_OPTIONS -u $NTOP_USER"
44
else
45
rc_failed 6
46
rc_status -v
47
exit 6
48
fi
49
# setup port
50
if [ -n "$NTOPD_PORT" -o -n "$NTOPD_SSL_PORT" ]; then
51
if [ -n "$NTOPD_PORT" ]; then
52
NTOP_OPTIONS="$NTOP_OPTIONS -w $NTOPD_PORT"
53
fi
54
if [ -n "$NTOPD_SSL_PORT" ]; then
55
NTOP_OPTIONS="$NTOP_OPTIONS -W $NTOPD_SSL_PORT"
56
fi
57
else
58
rc_failed 6
59
rc_status -v
60
exit 6
61
fi
62
# use optional
63
test -n "${NTOP_ARGS}" && NTOP_OPTIONS="${NTOP_OPTIONS} ${NTOP_ARGS}"
64
}
65
66
67
68
# The echo return value for success (defined in /etc/rc.config).
69
return=$rc_done
70
case "$1" in
71
start)
72
echo -n "Starting service ntop "
73
##
74
if checkproc /usr/bin/ntop; then
75
echo -e -n "\nntop is already running."
76
rc_status -s
77
exit
78
fi
79
## Start daemon with startproc(8). If this fails
80
## the echo return value is set appropriate.
81
if ! /usr/sbin/passcheck ; then
82
echo -e -n "\nntop admin password is not yet set. "
83
echo -e -n "Run \n\t\033[1mntop -A -u $NTOP_USER\033[m\nmanually "
84
rc_status -u
85
exit
86
else
87
if [ -z $NTOP_OPTIONS ]; then
88
setup_options
89
fi
90
startproc -q $PROGRAM $NTOP_OPTIONS
91
fi
92
93
rc_status -v
94
;;
95
stop)
96
echo -n "Shutting down service ntop "
97
## Stop daemon with killproc(8) and if this fails
98
## set echo the echo return value.
99
100
killproc -TERM $PROGRAM
101
102
rc_status -v
103
;;
104
try-restart)
105
$0 status
106
if test $? = 0; then
107
$0 restart
108
else
109
rc_reset
110
fi
111
rc_status
112
;;
113
restart)
114
$0 stop
115
$0 start
116
rc_status
117
;;
118
reload|force-reload)
119
echo -n "Reload service ntop "
120
killproc -HUP $PROGRAM
121
rc_status -v
122
;;
123
status)
124
echo -n "Checking for service ntop: "
125
## Check status with checkproc(8), if process is running
126
## checkproc will return with exit status 0.
127
128
checkproc $PROGRAM
129
rc_status -v
130
;;
131
*)
132
echo "Usage: $0 {start|stop|restart|reload|force-reload|status|try-restart}"
133
exit 1
134
;;
135
esac
136
rc_exit
137
138