From c7f3c746ccfd74480064dbe73fbc754548c30927 Mon Sep 17 00:00:00 2001 From: Rob Crittenden Date: Mon, 14 Jan 2008 12:43:26 -0500 Subject: Backup system state in ipa-server-install This patch adds a sysrestore module which allows ipa-server-install code to backup any system state so that it can be restored again with e.g. ipa-server-install --uninstall. The idea is that any files ipa-server-install modifies gets backed up to /var/cache/ipa/sysrestore/ while any "meta" state, like whether a service is enabled with chkconfig, is saved to /var/cache/ipa/sysrestore.state. Signed-off-by: Mark McLoughlin --- ipa-server/ipaserver/ntpinstance.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'ipa-server/ipaserver/ntpinstance.py') diff --git a/ipa-server/ipaserver/ntpinstance.py b/ipa-server/ipaserver/ntpinstance.py index b321ec07..c40b12b0 100644 --- a/ipa-server/ipaserver/ntpinstance.py +++ b/ipa-server/ipaserver/ntpinstance.py @@ -20,6 +20,7 @@ import shutil import service +import sysrestore from ipa import ipautil class NTPInstance(service.Service): @@ -45,19 +46,27 @@ class NTPInstance(service.Service): ntp_conf = ipautil.template_file(ipautil.SHARE_DIR + "ntp.conf.server.template", sub_dict) - shutil.copy("/etc/ntp.conf", "/etc/ntp.conf.ipasave") + sysrestore.backup_file("/etc/ntp.conf") fd = open("/etc/ntp.conf", "w") fd.write(ntp_conf) fd.close() + def __start(self): + self.backup_state("running", self.is_running()) + self.start() + + def __enable(self): + self.backup_state("enabled", self.is_enabled()) + 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("configuring ntpd to start on boot", self.chkconfig_on) + self.step("starting ntpd", self.__start) + self.step("configuring ntpd to start on boot", self.__enable) self.start_creation("Configuring ntpd") -- cgit