summaryrefslogtreecommitdiffstats
path: root/ipa-server/ipaserver/dsinstance.py
diff options
context:
space:
mode:
authorRob Crittenden <rcritten@redhat.com>2008-01-14 12:43:26 -0500
committerRob Crittenden <rcritten@redhat.com>2008-01-14 12:43:26 -0500
commitc7f3c746ccfd74480064dbe73fbc754548c30927 (patch)
treee0e8296dd50c0f9815f930713a2b3e917cb83bdf /ipa-server/ipaserver/dsinstance.py
parent23ac773ada10867767e779823ab5f66c79b0dc04 (diff)
downloadfreeipa-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/dsinstance.py')
-rw-r--r--ipa-server/ipaserver/dsinstance.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/ipa-server/ipaserver/dsinstance.py b/ipa-server/ipaserver/dsinstance.py
index 0de891fc6..78a847597 100644
--- a/ipa-server/ipaserver/dsinstance.py
+++ b/ipa-server/ipaserver/dsinstance.py
@@ -154,10 +154,14 @@ class DsInstance(service.Service):
self.step("initializing group membership",
self.__init_memberof)
- self.step("configuring directory to start on boot", self.chkconfig_on)
+ self.step("configuring directory to start on boot", self.__enable)
self.start_creation("Configuring directory server:")
+ def __enable(self):
+ self.backup_state("enabled", self.is_enabled())
+ self.chkconfig_on()
+
def __setup_sub_dict(self):
server_root = find_server_root()
self.sub_dict = dict(FQHN=self.host_name, SERVERID=self.serverid,
@@ -166,10 +170,12 @@ class DsInstance(service.Service):
SERVER_ROOT=server_root, DOMAIN=self.domain)
def __create_ds_user(self):
+ user_exists = True
try:
pwd.getpwnam(self.ds_user)
logging.debug("ds user %s exists" % self.ds_user)
except KeyError:
+ user_exists = False
logging.debug("adding ds user %s" % self.ds_user)
args = ["/usr/sbin/useradd", "-c", "DS System User", "-d", "/var/lib/dirsrv", "-M", "-r", "-s", "/sbin/nologin", self.ds_user]
try:
@@ -178,7 +184,12 @@ class DsInstance(service.Service):
except ipautil.CalledProcessError, e:
logging.critical("failed to add user %s" % e)
+ self.backup_state("user", self.ds_user)
+ self.backup_state("user_exists", user_exists)
+
def __create_instance(self):
+ self.backup_state("running", self.is_running())
+ self.backup_state("serverid", self.serverid)
inf_txt = ipautil.template_str(INF_TEMPLATE, self.sub_dict)
logging.debug(inf_txt)
inf_fd = ipautil.write_tmp_file(inf_txt)