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

« back to all changes in this revision

Viewing changes to debian/patches/ntop.init.d.diff

  • 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
 
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
4
 
@@ -13,25 +13,106 @@
5
 
 
6
 
 . $INIT
7
 
 
8
 
+sanity_check() {
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
13
 
+               return 1
14
 
+       fi
15
 
+       if [ -z "$INTERFACES" ] ; then
16
 
+               echo "ERROR: Cannot start ntop since INTERFACES is not defined, check the configuration file $INIT" >&2
17
 
+               return 1
18
 
+       fi
19
 
+       return 0
20
 
+}
21
 
+
22
 
+check_log_dir() {
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"
30
 
+                return 1
31
 
+        elif [ ! -d "$LOGDIR" ] ; then
32
 
+                echo -n "ERR: logging directory $LOGDIR does not exist"
33
 
+                return 1
34
 
+        else
35
 
+                real_log_user=`stat -c %U $LOGDIR`
36
 
+        # An alternative way is to check if the the user can create
37
 
+        # a file there...
38
 
+                if [ "$real_log_user" != "$USER" ] ; then
39
 
+                        echo -n "ERR: logging directory $LOGDIR does not belong
40
 
+to the user $USER"
41
 
+                        return 1
42
 
+                fi
43
 
+        fi
44
 
+        return 0
45
 
+}
46
 
+
47
 
+check_interfaces() {
48
 
+# Check the interface status, abort with error if a configured one is not
49
 
+# available
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..."
55
 
+                       return 1
56
 
+               fi      
57
 
+       done
58
 
+       return 0
59
 
+       } 
60
 
+       return $?
61
 
+}
62
 
+
63
 
+
64
 
+
65
 
 case "$1" in
66
 
 start)
67
 
+  if pidof $DAEMON > /dev/null ; then
68
 
+     echo "Not starting $DESC, it has already been started."
69
 
+     exit 0
70
 
+  fi
71
 
   echo -n "Starting $DESC: "
72
 
+  if ! sanity_check || ! check_log_dir || ! check_interfaces; then
73
 
+       echo " will not start $DESC!"
74
 
+       exit 1
75
 
+  fi
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 \
80
 
   -O $LOGDIR $GETOPT
81
 
-  if ps xa | grep -v grep | grep /usr/sbin/ntop > /dev/null ; then
82
 
+  if pidof $DAEMON > /dev/null ; then
83
 
       echo ntop
84
 
   else
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
88
 
+      sleep 1
89
 
+      if ps xa | grep -v grep | grep $DAEMON > /dev/null ; then
90
 
+       echo ntop
91
 
+      else
92
 
+        echo "ntop not started. Read /usr/share/doc/ntop/README.Debian."
93
 
+       exit 1
94
 
+      fi
95
 
   fi
96
 
   ;;
97
 
 stop)
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
105
 
+      sleep 1 
106
 
+      if ps xa | grep -v grep | grep $DAEMON > /dev/null ; then
107
 
+         echo "Ntop not stopped. Need to kill manually."
108
 
+        exit 1
109
 
+      else 
110
 
+         echo ntop
111
 
+      fi
112
 
   else
113
 
       echo ntop
114
 
   fi
115
 
@@ -42,15 +123,17 @@
116
 
   $0 start
117
 
   ;;
118
 
 reload)
119
 
-  if ps aux | grep -v grep | grep -q '/usr/sbin/ntop' ; then
120
 
+  if pidof $DAEMON > /dev/null ; then
121
 
     $0 stop
122
 
     sleep 2
123
 
     $0 start
124
 
+  else
125
 
+       echo  "Will not reload $DESC (not running)"
126
 
   fi
127
 
   ;;
128
 
 *)
129
 
   N=/etc/init.d/$NAME
130
 
-  echo "Usage: $N {start|stop|restart|force-reload}" >&2
131
 
+  echo "Usage: $N {start|stop|restart|force-reload|reload}" >&2
132
 
   exit 1
133
 
   ;;
134
 
 esac