From 4a162f6fc8d53d959dd23e1138059dd239ff5124 Mon Sep 17 00:00:00 2001 From: Mark McLoughlin Date: Fri, 11 Jan 2008 11:57:36 +0000 Subject: Add ipa-server-install --uninstall Add a --uninstall option to ipa-server-install which tries to restore the system to the way it was before ipa-server-install was run using the state backed up through sysrestore.py. Signed-off-by: Mark McLoughlin --- ipa-server/ipaserver/dsinstance.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'ipa-server/ipaserver/dsinstance.py') diff --git a/ipa-server/ipaserver/dsinstance.py b/ipa-server/ipaserver/dsinstance.py index 78a84759..3a71634a 100644 --- a/ipa-server/ipaserver/dsinstance.py +++ b/ipa-server/ipaserver/dsinstance.py @@ -333,3 +333,28 @@ class DsInstance(service.Service): print "Unable to set admin password", e logging.debug("Unable to set admin password %s" % e) + def uninstall(self): + running = self.restore_state("running") + enabled = self.restore_state("enabled") + + if not running is None: + self.stop() + + if not enabled is None and not enabled: + self.chkconfig_off() + + serverid = self.restore_state("serverid") + if not serverid is None: + erase_ds_instance_data(serverid) + + ds_user = self.restore_state("user") + user_exists = self.restore_state("user_exists") + + if not ds_user is None and not user_exists is None and not user_exists: + try: + ipautil.run(["/usr/sbin/userdel", ds_user]) + except ipautil.CalledProcessError, e: + logging.critical("failed to delete user %s" % e) + + if self.restore_state("running"): + self.start() -- cgit