~ubuntu-branches/ubuntu/natty/ntop/natty

« back to all changes in this revision

Viewing changes to packages/debian/etc/init.d/ntop

  • Committer: Bazaar Package Importer
  • Author(s): Ludovico Cavedon, Jordan Metzmeier, Ludovico Cavedon
  • Date: 2010-12-15 20:06:19 UTC
  • mfrom: (5.1.5 sid)
  • Revision ID: james.westby@ubuntu.com-20101215200619-0ojz3iak95ihibun
Tags: 3:4.0.3+dfsg1-1
[ Jordan Metzmeier ]
* New upstream release (Closes: #522042)
* Move data files to /usr/share/ntop (Closes: #595450).
* Package architecture independent data in a separate ntop-data package.
* Use debhelper 7.
* Update Standards-Version to 3.9.1.
* Depend on python-mako.
* Do not include ntop.txt in binary packages as it is a copy of the man
  page.
* Do not include NEWS, as it is outdated.
* Switch to package source version 3.0 (quilt).
* Add password creation to debconf
* Changed init script to fix localization problems (thanks to Alejandro
  Varas <alej0varas@gmail.com>, LP: #257466)
* Remove manual update-rc.d calls from postrm and postinst. debhelper adds
  this for us.
* Add pre-depends on adduser for postinst script.
* Fix errors in the manpages: fix-manpage-errors.patch.
* Added fixes for matching active interfaces.
* Added a watch file.

[ Ludovico Cavedon ]
* Remove direct changes to upstream tree, and move them into specific patch
  files:
  - fix-manpage-errors.patch: fix typos in ntop.8.
  - dot-path.patch: fix path of /usr/bin/dot executable
* Add patches:
  - reduce-autogen-purged-files.patch: prevent agutogen.sh from reamoving
  too many files during cleanup.
  - Add build-without-ntop-darwin.patch, to fix compilation without
  ntop_darwin.c.
* No longer add faq.html, as it is not distributed in the upstream tarball.
* Use ${source:Version} in control file. Have ntop-data recommend
  ntop.
* Rename dirs to ntop.dirs and keep only empty directories that need
  to be created.
* Remove var/lib from ntop.install file, as it is empty (keeping it in
  ntop.dirs).
* Update po files.
* Breaks and Replaces instead of Conflitcs for ntop-data.
* Use a longer package description.
* Remove useless configure options from debian/rules.
* Move private shared libraries libraries in /usr/lib/ntop.
* Add change-plugin-dir.patch for adjusting plugin directory.
* Remove development files.
* Use system library for MochiKit.js.
* Rewrite DEP5 copyright file.
* Repackage upstream tarball in order to remove non-DFSG-compliant code. Add
  get-orig-source.sh script and get-orig-source target in debian/rules.
* Add explanation to README.Debian why geolocation is no longer working.
* Add avoid-copy-maxmind-db.patch to prevent copying of Geo*.dat
  files.
* Remove old unused patches.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#! /bin/sh
2
2
#
3
 
# ntop script
4
 
#
5
 
# NOTE: Copy this script in /etc/init.d/ntop
6
 
#
7
 
# Author:
8
 
# Paul Mansfield <paul.mansfield@uk.worldpay.com>
9
 
# Worldpay - 20020218
10
 
#
11
 
# Fixed by L.Deri - May 2007
12
 
#
13
 
 
14
 
set -e
15
 
 
16
 
NAME=ntop
17
 
DAEMON=/usr/local/bin/ntop
18
 
test -x $DAEMON || exit 0
 
3
# (C) 2003-07 - Luca Deri <deri@ntop.org>
 
4
# (C) 2007-08 - Massimo Torquati <torquati@ntop.org>
 
5
#
 
6
 
 
7
. /usr/local/sbin/stop_app.sh
 
8
 
 
9
APPNAME=ntop
 
10
PERSISTENT_DIR=/usr/local/share/ntop
 
11
SPOOL_DIR=$PERSISTENT_DIR/spool
 
12
NTOP_PATH=/usr/local/bin/ntop
 
13
NTOP_CONF=/etc/ntop/ntop.conf
 
14
NTOP_PIDFILE=/var/run/ntop.pid
 
15
 
 
16
# Enable watchdogging
 
17
USERUNSV=1
 
18
RUNSV="/usr/local/bin/runsv"
 
19
RUNSV_PIDFILE="/var/run/runsv.ntop"
 
20
TIMETOWAIT=2
 
21
THRESHOLD=30
 
22
RUNSV_OPT="-p $RUNSV_PIDFILE -s $TIMETOWAIT -S $THRESHOLD -L -- "
 
23
 
 
24
 
 
25
 
 
26
####################
19
27
 
20
28
start_ntop() {
21
 
    echo -n "Starting ntop "
22
 
    $DAEMON -u nobody > /var/log/ntop.out &
23
 
    echo " ...done"
24
 
}
25
 
 
26
 
stop_ntop() {
27
 
    echo -n "Stopping ntop "
28
 
    if test -f /var/run/ntop.pid ; then
29
 
        kill `cat /var/run/ntop.pid`
30
 
        echo -n " killed pid `cat /var/run/ntop.pid`"
31
 
        rm /var/run/ntop.pid
32
 
    fi
33
 
    echo " ...done"
34
 
}
 
29
   if test -f /etc/ntop/ntop.start; then
 
30
       if [ $USERUNSV -eq 1 ]; then
 
31
           ${RUNSV} ${RUNSV_OPT} $NTOP_PATH @$NTOP_CONF > /dev/null &
 
32
       else
 
33
           start-stop-daemon --start --quiet --name $APPNAME --background --exec $NTOP_PATH @$NTOP_CONF > /dev/null
 
34
       fi
 
35
   fi
 
36
 
 
37
   return 0
 
38
}
 
39
 
 
40
####################
 
41
 
 
42
wait_for_deaddaemon () {
 
43
    WAITFORDAEMON=15
 
44
    pid=$1
 
45
    sleep 1
 
46
    if test -n "$pid"
 
47
        then
 
48
        if kill -0 $pid 2>/dev/null
 
49
            then
 
50
            echo -n "."
 
51
            cnt=0
 
52
            while kill -0 $pid 2>/dev/null
 
53
              do
 
54
              cnt=`expr $cnt + 1`
 
55
              if [ $cnt -gt $WAITFORDAEMON ]
 
56
                  then
 
57
                  echo " FAILED."
 
58
                  return 1
 
59
              fi
 
60
              sleep 1
 
61
              echo -n "."
 
62
            done
 
63
        fi
 
64
    fi
 
65
 
 
66
    rm -f $NTOP_PIDFILE
 
67
    return 0
 
68
}
 
69
 
 
70
####################
 
71
 
 
72
stop_ntop() { 
 
73
    if [ $USERUNSV -eq 1 ]; then
 
74
        pid=`cat $NTOP_PIDFILE 2>/dev/null`
 
75
        stop_app -a ntop -r
 
76
        if [ -n $pid ]; then
 
77
            wait_for_deaddaemon $pid
 
78
        fi
 
79
    else
 
80
        if [ -f $NTOP_PIDFILE ]; then
 
81
            pid=`cat $NTOP_PIDFILE 2>/dev/null`
 
82
            if [ -n $pid ]; then
 
83
                kill $pid
 
84
                wait_for_deaddaemon $pid
 
85
            fi
 
86
        fi
 
87
    fi
 
88
}
 
89
 
 
90
####################
 
91
 
 
92
default_ntop() { 
 
93
    if [ ! -d $PERSISTENT_DIR ] && [ ! -h  $PERSISTENT_DIR ]; then
 
94
        mkdir -p $PERSISTENT_DIR/rrd
 
95
        chown -R nobody $PERSISTENT_DIR
 
96
        chmod gou+w $PERSISTENT_DIR
 
97
    fi
 
98
 
 
99
    if [ ! -f $PERSISTENT_DIR/ntop_pw.db ]; then
 
100
        $NTOP_PATH -u nobody -P $PERSISTENT_DIR -Q $SPOOL_DIR --set-admin-password=admin
 
101
    fi
 
102
 
 
103
    if [ ! -d /etc/ntop ]; then
 
104
        mkdir /etc/ntop
 
105
        touch /etc/ntop/ntop.start
 
106
        echo "-P $PERSISTENT_DIR" > $NTOP_CONF
 
107
        echo "-Q $SPOOL_DIR" >> $NTOP_CONF
 
108
        echo "-u nobody" >> $NTOP_CONF
 
109
    fi
 
110
 
 
111
    if [ ! -d $SPOOL_DIR ]; then
 
112
        mkdir -p $SPOOL_DIR
 
113
        chmod gou+w $SPOOL_DIR
 
114
        chown -R nobody $SPOOL_DIR
 
115
    fi
 
116
}
 
117
 
 
118
########
35
119
 
36
120
case "$1" in
37
121
  start)
38
 
    start_ntop
39
 
    ;;
40
 
 
 
122
        echo -n "Starting ntop "
 
123
        default_ntop;
 
124
        start_ntop;
 
125
        echo " Done."
 
126
        ;;
41
127
  stop)
42
 
    stop_ntop
43
 
    ;;
 
128
        echo -n "Stopping ntop "
 
129
        stop_ntop;
 
130
        echo " Done."
 
131
        ;;
 
132
 
 
133
  default)
 
134
        echo -n "Defaulting ntop "
 
135
        default_ntop;
 
136
        echo " Done."
 
137
        ;;
44
138
 
45
139
  restart)
46
 
    stop_ntop
47
 
    start_ntop
48
 
    ;;
49
 
 
50
 
  defaults)
51
 
    $DAEMON -u nobody --set-admin-password=admin
52
 
    ;;
53
 
 
54
 
  *)
55
 
    echo "Usage: /etc/init.d/$NAME {start|stop|restart|install}"
56
 
    exit 1
57
 
    ;;
 
140
        echo -n "Restarting ntop "
 
141
        stop_ntop;
 
142
        start_ntop;
 
143
        echo " Done."
 
144
        ;;
 
145
  launch)
 
146
        if [ -z "$2" ]; then
 
147
            echo "Usage: /etc/init.d/ntop launch <options>"
 
148
            exit 1    
 
149
        fi
 
150
        echo -n "Launching ntop "
 
151
        start-stop-daemon --start --quiet --background --exec $NTOP_PATH -- $2 > /dev/null
 
152
        sleep 3
 
153
        echo " Done."
 
154
        ;;
 
155
 
 
156
    kill)
 
157
        if [ -z "$2" ]; then
 
158
            echo "Usage: /etc/init.d/ntop kill pid"
 
159
            exit 1    
 
160
        fi
 
161
        pid=$2
 
162
        echo -n "Stopping ntop with pid=$pid "
 
163
        rc=`ps xa | awk '{print $1}' | grep $pid | wc -l`
 
164
        if [ $rc -gt 0 ]; then
 
165
            kill -9 $pid > /dev/null
 
166
            wait_for_deaddaemon $pid
 
167
            echo " Done."
 
168
            exit 0
 
169
        else
 
170
            echo 
 
171
            echo "No process with pid=$pid found!!"
 
172
            exit 2
 
173
        fi
 
174
        ;;
 
175
 
 
176
        *)
 
177
        echo "Usage: /etc/init.d/ntop {start|stop|restart|default|launch|kill}"
 
178
        exit 1
58
179
esac
59
180
 
60
 
exit 0
 
 
b'\\ No newline at end of file'
 
181
exit 0