Testing has shown that an environment var there isn't working well.
Reason is that the call -> ifup -> hook isn't transferring environment.

But checking for alternatives made this even better.

ifup makes all options in e/n/i or ifup -o available (prepended with IF_
and uppercased) to called scripts.
That way one can not only disable per call, but also per device in e/n/i.

So the behavior will be like:

 1. default it is running on ifup (old default)

 2. one can set a global disable in the config file

 3. one disable per device in the devices e/n/i stanza via disable_ntpdate 1
 4. one can disable it per call via -o option setting -o disable_ntpdate=1

The following patch reflects that improvement


Christian Ehrhardt
Software Engineer, Ubuntu Server
Canonical Ltd
commit 79f5e2bd41f8d23269364c93cf4dad97957b759f
Author: Christian Ehrhardt <[email protected]>
Date:   Mon Jul 4 14:30:26 2016 +0200

    d/ntpdate-debian allow disabling the call to ntpdate
    
    Done via setting in /etc/default/ntpdate and environment variable
    (LP: #1206164).
    
    So the behavior will be like:
    1. default it is running on ifup (old default)
    2. one can set a global disable in the config file
    3. one disable per device in the devices e/n/i stanza via "disable_ntpdate 1"
    4. one can disable it per call via -o option setting -o disable_ntpdate=1

diff --git a/debian/ntpdate-debian b/debian/ntpdate-debian
index 4f5b17b..f4be2c4 100644
--- a/debian/ntpdate-debian
+++ b/debian/ntpdate-debian
@@ -6,6 +6,8 @@ if [ -r /etc/default/ntpdate ]; then
 	. /etc/default/ntpdate
 fi
 
+[ "${IF_DISABLE_NTPDATE:-0}" != "0" -o "${NTPDATE_IFUP_DISABLE}" != "0" ] && exit 0
+
 if [ "$NTPDATE_USE_NTP_CONF" = yes ]; then
 	for f in /etc/ntp.conf /etc/openntpd/ntpd.conf; do
 		if [ -r "$f" ]; then
diff --git a/debian/ntpdate.default b/debian/ntpdate.default
index f239b18..8d98440 100644
--- a/debian/ntpdate.default
+++ b/debian/ntpdate.default
@@ -5,6 +5,13 @@
 # so you only have to keep it in one place.
 NTPDATE_USE_NTP_CONF=yes
 
+# Set to 1 to disable the automated ntpdate-debian call triggered on ifup
+# For more fine granular control this can also be disabled per device by
+# adding "disable_ntpdate 1" to its stanza in /etc/network/interfaces.
+# Furthermore it can be disabled per ifup call with by adding 
+# "-o disable_ntpdate=1" to it.
+NTPDATE_IFUP_DISABLE="0"
+
 # List of NTP servers to use  (Separate multiple servers with spaces.)
 # Not used if NTPDATE_USE_NTP_CONF is yes.
 NTPSERVERS="ntp.ubuntu.com"

Reply via email to