summaryrefslogtreecommitdiffstats
path: root/ipa-server/ipaserver/dsinstance.py
diff options
context:
space:
mode:
authorMark McLoughlin <markmc@redhat.com>2008-01-11 11:57:36 +0000
committerMark McLoughlin <markmc@redhat.com>2008-01-11 11:57:36 +0000
commit4a162f6fc8d53d959dd23e1138059dd239ff5124 (patch)
tree650d2c3394b728aa694e6da9ea8ded29427ab99c /ipa-server/ipaserver/dsinstance.py
parentc7f3c746ccfd74480064dbe73fbc754548c30927 (diff)
downloadfreeipa-4a162f6fc8d53d959dd23e1138059dd239ff5124.tar.gz
freeipa-4a162f6fc8d53d959dd23e1138059dd239ff5124.tar.xz
freeipa-4a162f6fc8d53d959dd23e1138059dd239ff5124.zip
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 <markmc@redhat.com>
Diffstat (limited to 'ipa-server/ipaserver/dsinstance.py')
-rw-r--r--ipa-server/ipaserver/dsinstance.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/ipa-server/ipaserver/dsinstance.py b/ipa-server/ipaserver/dsinstance.py
index 78a847597..3a71634a4 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()