From 130148ade851550a2c1dc418e1d887843ec229be Mon Sep 17 00:00:00 2001
From: Thomas Zimmermann <zimmermann@vdm-design.de>
Date: Mon, 21 Feb 2011 21:19:16 +0100
Subject: [PATCH] shr_ntp: check /etc/default/rcS for UTC value and set hwclock to UTC if requeired

Signed-off-by: Thomas Zimmermann <zimmermann@vdm-design.de>
---
 shr_settings_modules/shr_ntp.py |   23 ++++++++++++++++++++++-
 1 files changed, 22 insertions(+), 1 deletions(-)

diff --git a/shr_settings_modules/shr_ntp.py b/shr_settings_modules/shr_ntp.py
index 6cb2f14..c8c66ce 100644
--- a/shr_settings_modules/shr_ntp.py
+++ b/shr_settings_modules/shr_ntp.py
@@ -17,6 +17,7 @@ except IOError:
 class NTP(module.AbstractModule):
     name = _("NTP settings")
     ntpconf = "/etc/ntp.conf"
+    rcsconf = "/etc/default/rcS"
 
     def GetNTPServer(self):
         server="unknown"
@@ -44,9 +45,29 @@ class NTP(module.AbstractModule):
 
 
     def btClicked(self, obj, *args, **kwargs):
+        utcmode=False
+        try:
+            rcsfile = open(self.rcsconf, "r")
+            while True:
+                line = rcsfile.readline()
+                if line=="": #EOF
+                    break
+
+                li = line.strip('\t\n').split('=')
+                if li[0]=="UTC":
+                    if li[1]=="yes":
+                        utcmode=True
+                    break
+            rcsfile.close()
+        except:
+            print "could not open "+self.ntpconf+" for reading"
+
         self.SetNTPServer(self.NTPserver.entry_get())
         #os.system("ntpclient -s -h "+self.NTPserver.entry_get()+" && hwclock -w")
-        os.system("ntpd  -q -n -p "+self.NTPserver.entry_get()+" && hwclock -w")
+        if utcmode==True:
+            os.system("ntpd  -q -n -p "+self.NTPserver.entry_get()+" && hwclock -uw")
+        else
+            os.system("ntpd  -q -n -p "+self.NTPserver.entry_get()+" && hwclock -w")
 
     def createButton(self):
         self.bt = elementary.Button(self.window)
-- 
1.7.4.1

