File 0023-netconfig-ntp-runtime-add-servers-do-not-try-restart.patch of Package sysconfig.openSUSE_12.1_Update

From 157cda6aab43c319bb7c227ba995be06754c124c Mon Sep 17 00:00:00 2001
From: Marius Tomaschewski <mt@suse.com>
Date: Wed, 26 Sep 2012 18:57:09 +0200
References: bnc#780644
Subject: [PATCH 05/11] netconfig/ntp-runtime: add servers, do not try-restart

ntp try-restart picks up the servers we've written, but its
start may block for a while, so just add servers ourself.
When ntpd is not running (not yet started), the init script
will pickup our servers later.
---
 scripts/netconfig.d/ntp-runtime |   23 +++++++++++++++++++----
 1 Datei geändert, 19 Zeilen hinzugefügt(+), 4 Zeilen entfernt(-)

diff --git a/scripts/netconfig.d/ntp-runtime b/scripts/netconfig.d/ntp-runtime
index 86340e8..88b1baa 100755
--- a/scripts/netconfig.d/ntp-runtime
+++ b/scripts/netconfig.d/ntp-runtime
@@ -232,10 +232,25 @@ fi
 
 # here we should restart services if needed
 
-# try restart ntp; reload is not supported and we need 
-#                  to delete old servers
-if [ -x $r/etc/init.d/ntp ]; then
-        $r/etc/init.d/ntp try-restart >/dev/null 2>&1
+#
+# do not restart  or it may (will) block ifup
+# just try to add the server at runtime ...
+#
+NTP_CONF="/etc/ntp.conf"
+NTPDC_BIN="/usr/sbin/ntpdc"
+
+if [ -n "${NTP_SERVER_LIST[*]}" -a -f "${NTP_CONF}" ] && /etc/init.d/ntp status >/dev/null 2>/dev/null ; then
+    NTP_KEYS=$(awk '/^keys/ { print $2 }' $NTP_CONF)
+    NTP_KEYID=$(awk '/^requestkey[[:blank:]]/ { print $2 }' $NTP_CONF)
+    NTP_PASSWD=$(test -n "$NTP_KEYS" -a -n "$NTP_KEYID" -a -r "$NTP_KEYS" && awk '$0 ~ key { print $3 }' key="^[[:blank:]]*$NTP_KEYID[[:blank:]]" $NTP_KEYS)
+
+    if [ -n "$NTP_KEYS" -a -n "$NTP_PASSWD" ] ; then
+        for server in ${NTP_SERVER_LIST[*]} ; do
+            NTPDC_CMD="keyid $NTP_KEYID\npasswd $NTP_PASSWD\naddserver $server\n"
+            NTPDC_LOG=$(echo -e "${NTPDC_CMD}quit" | $NTPDC_BIN)
+            debug "$PROGNAME add-server: $server"
+        done
+    fi
 fi
 
 exit 0;
-- 
1.7.10.4

openSUSE Build Service is sponsored by