Package: ntop
Version: 3:3.2-1
Priority: normal
Tags: patch

Ntop package default answer to the 'Which interface do you want to use?'
debconf question is eth0 and set to 'medium' priority. This is usually OK.
However, in a system which does not have 'eth0' (either because the default
interface is different, such as in my system, which I use eth1) or because
there is no eth0 interface this default value will leave a Ntop daemon that
is not able to start (even though the init.d script says otherwise, see my
other patch).

IMHO, the priority should be raised for the ntop debconf question if any of
the defined INTERFACES (or the default, if not defined already) are not
available (i.e. the interface does not exist or is down).

That would ensure that users running with Debconf configured to only show
debconf questions of 'high priority will get to see this and configure Ntop
properly to their system (since the default value, 'eth0' will not be useful
for them)

Please consider the attached patch to fix that behaviour in the config file.

Regards

Javier
diff -Nru ntop-3.2.old/debian/config ntop-3.2/debian/config
--- ntop-3.2.old/debian/config  2006-03-07 17:29:03.000000000 +0100
+++ ntop-3.2/debian/config      2006-03-07 18:14:02.000000000 +0100
@@ -20,6 +20,22 @@
 # Source debconf library
 . /usr/share/debconf/confmodule
 
+check_interfaces() {
+# Check the interface status, abort with error if a configured one is not
+# available
+        [ -z "$INTERFACES" ] && return 0
+        { echo $INTERFACES | awk -F , '{ for(i=1;i<=NF;i++) print $i }' |
+        while read iface ; do
+                if ! ifconfig "$iface" | grep -w UP >/dev/null; then
+                        return 1
+                fi
+        done
+       return 0
+        }
+        return $?
+}
+
+
 if [ -e /etc/ntop/init.cfg ] && [ ! -e /var/lib/ntop/init.cfg ]; then
     cp -a /etc/ntop/init.cfg /etc/ntop/init.cfg.dpkg-old || true
     mv /etc/ntop/init.cfg /var/lib/ntop/init.cfg || true
@@ -32,7 +48,16 @@
   db_set ntop/interfaces $INTERFACES
 fi
 
-db_input medium ntop/interfaces || true
+# Interface default in case /var/lib/ntop/init.cfg does not exist
+[ -z "$INTERFACES" ]  && INTERFACES=eth0
+# Depending on whether the default interface is up or down we set the
+# question priority
+if check_interfaces
+then
+       db_input medium ntop/interfaces || true
+else
+       db_input high ntop/interfaces || true
+fi
 db_go
 db_get ntop/interfaces
 INTERFACES=$RET

Attachment: signature.asc
Description: Digital signature

Reply via email to