diff options
author | Rob Crittenden <rcritten@redhat.com> | 2008-01-14 12:43:26 -0500 |
---|---|---|
committer | Rob Crittenden <rcritten@redhat.com> | 2008-01-14 12:43:26 -0500 |
commit | c7f3c746ccfd74480064dbe73fbc754548c30927 (patch) | |
tree | e0e8296dd50c0f9815f930713a2b3e917cb83bdf /ipa-server/ipaserver/ntpinstance.py | |
parent | 23ac773ada10867767e779823ab5f66c79b0dc04 (diff) | |
download | freeipa-c7f3c746ccfd74480064dbe73fbc754548c30927.tar.gz freeipa-c7f3c746ccfd74480064dbe73fbc754548c30927.tar.xz freeipa-c7f3c746ccfd74480064dbe73fbc754548c30927.zip |
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 <markmc@redhat.com>
Diffstat (limited to 'ipa-server/ipaserver/ntpinstance.py')
-rw-r--r-- | ipa-server/ipaserver/ntpinstance.py | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/ipa-server/ipaserver/ntpinstance.py b/ipa-server/ipaserver/ntpinstance.py index b321ec075..c40b12b08 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") |