From 0ae42b28de803bcf024eb9b2a3560b9a0702ce4b Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Wed, 20 Feb 2008 11:03:46 -0500 Subject: Start ntpd first unless we do not want it. Make sure we do sync the clock leaping to the current correct time. This avoids problems with bad dates on certificates, etc.. --- ipa-server/ipaserver/ntpinstance.py | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) (limited to 'ipa-server/ipaserver/ntpinstance.py') diff --git a/ipa-server/ipaserver/ntpinstance.py b/ipa-server/ipaserver/ntpinstance.py index e2765171..53858810 100644 --- a/ipa-server/ipaserver/ntpinstance.py +++ b/ipa-server/ipaserver/ntpinstance.py @@ -35,25 +35,34 @@ class NTPInstance(service.Service): # or we can get our own pool. os = "" if ipautil.file_exists("/etc/fedora-release"): - os = "fedora." + os = "fedora" elif ipautil.file_exists("/etc/redhat-release"): - os = "rhel." + os = "rhel" sub_dict = { } - sub_dict["SERVERA"] = "0.%spool.ntp.org" % os - sub_dict["SERVERB"] = "1.%spool.ntp.org" % os - sub_dict["SERVERC"] = "2.%spool.ntp.org" % os + sub_dict["SERVERA"] = "0.%s.pool.ntp.org" % os + sub_dict["SERVERB"] = "1.%s.pool.ntp.org" % os + sub_dict["SERVERC"] = "2.%s.pool.ntp.org" % os ntp_conf = ipautil.template_file(ipautil.SHARE_DIR + "ntp.conf.server.template", sub_dict) + ntp_sysconf = ipautil.template_file(ipautil.SHARE_DIR + "ntpd.sysconfig.template", {}) sysrestore.backup_file("/etc/ntp.conf") + sysrestore.backup_file("/etc/sysconfig/ntpd") fd = open("/etc/ntp.conf", "w") fd.write(ntp_conf) fd.close() - def __start(self): + fd = open("/etc/sysconfig/ntpd", "w") + fd.write(ntp_sysconf) + fd.close() + + def __stop(self): self.backup_state("running", self.is_running()) + self.stop() + + def __start(self): self.start() def __enable(self): @@ -61,13 +70,14 @@ class NTPInstance(service.Service): self.chkconfig_on() def create_instance(self): - self.step("writing configuration", self.__write_config) # we might consider setting the date manually using ntpd -qg in case # the current time is very far off. - self.step("starting ntpd", self.__start) + self.step("stopping ntpd", self.__stop) + self.step("writing configuration", self.__write_config) self.step("configuring ntpd to start on boot", self.__enable) + self.step("starting ntpd", self.__start) self.start_creation("Configuring ntpd") -- cgit