1
diff -Nru ntop-3.2.old/debian/init ntop-3.2/debian/init
2
--- ntop-3.2.old/debian/init 2006-03-07 17:29:03.000000000 +0100
3
+++ ntop-3.2/debian/init 2006-03-07 18:19:10.000000000 +0100
9
+# Sanity check, we expect USER And INTERFACES to be defined
10
+# (we could also set defaults for them before calling INIT...)
11
+ if [ -z "$USER" ] ; then
12
+ echo -n "ERROR: Cannot start ntop since USER is not defined, check the configuration file $INIT" >&2
15
+ if [ -z "$INTERFACES" ] ; then
16
+ echo "ERROR: Cannot start ntop since INTERFACES is not defined, check the configuration file $INIT" >&2
23
+# Does the logging directory belong to the User running the application
24
+ # If we cannot determine the logdir return without error
25
+ # (we will not check it)
26
+ [ -n "$LOGDIR" ] || return 0
27
+ [ -n "$USER" ] || return 0
28
+ if [ ! -e "$LOGDIR" ] ; then
29
+ echo -n "ERR: logging directory $LOGDIR does not exist"
31
+ elif [ ! -d "$LOGDIR" ] ; then
32
+ echo -n "ERR: logging directory $LOGDIR does not exist"
35
+ real_log_user=`stat -c %U $LOGDIR`
36
+ # An alternative way is to check if the the user can create
38
+ if [ "$real_log_user" != "$USER" ] ; then
39
+ echo -n "ERR: logging directory $LOGDIR does not belong
48
+# Check the interface status, abort with error if a configured one is not
50
+ [ -z "$INTERFACES" ] && return 0
51
+ { echo $INTERFACES | awk -F , '{ for(i=1;i<=NF;i++) print $i }' |
52
+ while read iface ; do
53
+ if ! ifconfig "$iface" | grep -w UP >/dev/null; then
54
+ echo "ERR: interface $iface is DOWN..."
67
+ if pidof $DAEMON > /dev/null ; then
68
+ echo "Not starting $DESC, it has already been started."
71
echo -n "Starting $DESC: "
72
+ if ! sanity_check || ! check_log_dir || ! check_interfaces; then
73
+ echo " will not start $DESC!"
76
start-stop-daemon --start --quiet --name $NAME --exec $DAEMON -- \
77
-d -L -u $USER -P $HOMEDIR --skip-version-check \
78
-a $LOGDIR/access.log -i "$INTERFACES" \
79
-p /etc/ntop/protocol.list \
81
- if ps xa | grep -v grep | grep /usr/sbin/ntop > /dev/null ; then
82
+ if pidof $DAEMON > /dev/null ; then
85
- echo "ntop not started. Read /usr/share/doc/ntop/README.Debian."
86
+ # WARNING: This might introduce a race condition in some (fast) systems
87
+ # Wait for a sec an try again
89
+ if ps xa | grep -v grep | grep $DAEMON > /dev/null ; then
92
+ echo "ntop not started. Read /usr/share/doc/ntop/README.Debian."
98
echo -n "Stopping $DESC: "
99
start-stop-daemon --stop --oknodo --name $NAME --user $USER --retry 9
100
- if ps xa | grep -v grep | grep /usr/sbin/ntop > /dev/null ; then
101
- echo "Ntop not stopped. Need to kill manually."
102
+ if pidof $DAEMON > /dev/null ; then
103
+ # WARNING: This might introduce a race condition in some (fast) systems
104
+ # Wait for a sec an try again
106
+ if ps xa | grep -v grep | grep $DAEMON > /dev/null ; then
107
+ echo "Ntop not stopped. Need to kill manually."
119
- if ps aux | grep -v grep | grep -q '/usr/sbin/ntop' ; then
120
+ if pidof $DAEMON > /dev/null ; then
125
+ echo "Will not reload $DESC (not running)"
130
- echo "Usage: $N {start|stop|restart|force-reload}" >&2
131
+ echo "Usage: $N {start|stop|restart|force-reload|reload}" >&2