]>
Commit | Line | Data |
---|---|---|
35f89074 | 1 | #!/bin/sh |
2 | # | |
86295a37 | 3 | # ntop This shell script takes care of starting and stopping ntop |
35f89074 | 4 | # |
5 | # chkconfig: 345 96 24 | |
6 | # description: Network monitoring tool. | |
7 | # | |
8 | ||
9 | # Source function library | |
10 | . /etc/rc.d/init.d/functions | |
11 | ||
12 | # Get network config | |
13 | . /etc/sysconfig/network | |
14 | ||
15 | ||
16 | # Get service config - may override defaults | |
17 | [ -f /etc/sysconfig/ntop ] && . /etc/sysconfig/ntop | |
18 | ||
19 | # Check that networking is up. | |
20 | if is_yes "${NETWORKING}"; then | |
21 | if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then | |
22 | msg_network_down ntop | |
23 | exit 1 | |
24 | fi | |
25 | else | |
26 | exit 0 | |
27 | fi | |
28 | ||
6ab1e1ca JB |
29 | if [ -z "$NTOP_DIR" ]; then |
30 | nls "NTOP_DIR not set in /etc/sysconfig/ntop" | |
31 | exit 6 | |
32 | fi | |
33 | ||
35f89074 | 34 | RETVAL=0 |
35 | # See how we were called. | |
36 | case "$1" in | |
37 | start) | |
86295a37 | 38 | # Check if ntop is initialized |
0a1e280c | 39 | if [ ! -f "$NTOP_DIR/ntop_pw.db" ]; then |
642cc90c | 40 | nls "ntop is not initialized. Try '%s init' before start." /etc/rc.d/init.d/ntop |
86295a37 | 41 | exit 6 |
42 | fi | |
35f89074 | 43 | |
44 | # Check if the service is already running? | |
45 | if [ ! -f /var/lock/subsys/ntop ]; then | |
46 | msg_starting ntop | |
af056c53 | 47 | daemon ntop @/etc/ntop.conf -d -P $NTOP_DIR |
35f89074 | 48 | RETVAL=$? |
35f89074 | 49 | [ $RETVAL -eq 0 ] && touch /var/lock/subsys/ntop |
50 | else | |
51 | msg_already_running ntop | |
52 | fi | |
53 | ;; | |
54 | stop) | |
55 | # Stop daemons. | |
56 | if [ -f /var/lock/subsys/ntop ]; then | |
57 | msg_stopping ntop | |
58 | killproc ntop | |
59 | rm -f /var/lock/subsys/ntop >/dev/null 2>&1 | |
60 | else | |
61 | msg_not_running ntop | |
abba7ae8 | 62 | fi |
35f89074 | 63 | ;; |
64 | restart) | |
65 | $0 stop | |
66 | $0 start | |
67 | ;; | |
68 | reload|force-reload) | |
69 | if [ -f /var/lock/subsys/ntop ]; then | |
70 | msg_reloading ntop | |
71 | killproc ntop -HUP | |
72 | RETVAL=$? | |
86295a37 | 73 | else |
74 | msg_not_running ntop >&2 | |
75 | exit 7 | |
76 | fi | |
77 | ;; | |
35f89074 | 78 | init) |
1f70e9b9 | 79 | ntop -P $NTOP_DIR @/etc/ntop.conf -A |
35f89074 | 80 | ;; |
81 | status) | |
82 | status ntop | |
83 | exit $? | |
84 | ;; | |
85 | *) | |
86 | msg_usage "$0 {start|stop|restart|reload|force-reload|init|status}" | |
87 | exit 3 | |
88 | esac | |
89 | ||
90 | exit $RETVAL |