]>
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 |
39 | if [ ! -f "$NTOP_DIR/addressQueue.db" ]; then | |
40 | nls "ntop is not initialized. Try \"%s init\" before start." "$0" | |
41 | echo "" | |
6ab1e1ca | 42 | nls "After setting password please press ^C to stop the daemon." |
86295a37 | 43 | exit 6 |
44 | fi | |
35f89074 | 45 | |
46 | # Check if the service is already running? | |
47 | if [ ! -f /var/lock/subsys/ntop ]; then | |
48 | msg_starting ntop | |
6ab1e1ca | 49 | daemon ntop -d -P $NTOP_DIR @/etc/ntop.conf |
35f89074 | 50 | RETVAL=$? |
35f89074 | 51 | [ $RETVAL -eq 0 ] && touch /var/lock/subsys/ntop |
52 | else | |
53 | msg_already_running ntop | |
54 | fi | |
55 | ;; | |
56 | stop) | |
57 | # Stop daemons. | |
58 | if [ -f /var/lock/subsys/ntop ]; then | |
59 | msg_stopping ntop | |
60 | killproc ntop | |
61 | rm -f /var/lock/subsys/ntop >/dev/null 2>&1 | |
62 | else | |
63 | msg_not_running ntop | |
64 | fi | |
65 | ;; | |
66 | restart) | |
67 | $0 stop | |
68 | $0 start | |
69 | ;; | |
70 | reload|force-reload) | |
71 | if [ -f /var/lock/subsys/ntop ]; then | |
72 | msg_reloading ntop | |
73 | killproc ntop -HUP | |
74 | RETVAL=$? | |
86295a37 | 75 | else |
76 | msg_not_running ntop >&2 | |
77 | exit 7 | |
78 | fi | |
79 | ;; | |
35f89074 | 80 | init) |
6ab1e1ca | 81 | ntop -P $NTOP_DIR @/etc/ntop.conf |
35f89074 | 82 | ;; |
83 | status) | |
84 | status ntop | |
85 | exit $? | |
86 | ;; | |
87 | *) | |
88 | msg_usage "$0 {start|stop|restart|reload|force-reload|init|status}" | |
89 | exit 3 | |
90 | esac | |
91 | ||
92 | exit $RETVAL |