From 04e9056ec2b6e0360f3f3545fd638ecc17aaad2c Mon Sep 17 00:00:00 2001 From: Rob Crittenden Date: Mon, 3 May 2010 15:21:51 -0400 Subject: Make the installer/uninstaller more aware of its state We have had a state file for quite some time that is used to return the system to its pre-install state. We can use that to determine what has been configured. This patch: - uses the state file to determine if dogtag was installed - prevents someone from trying to re-install an installed server - displays some output when uninstalling - re-arranges the ipa_kpasswd installation so the state is properly saved - removes pkiuser if it was added by the installer - fetches and installs the CA on both masters and clients --- ipaserver/install/cainstance.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'ipaserver/install/cainstance.py') diff --git a/ipaserver/install/cainstance.py b/ipaserver/install/cainstance.py index bb7e00e2e..9e55333db 100644 --- a/ipaserver/install/cainstance.py +++ b/ipaserver/install/cainstance.py @@ -336,6 +336,9 @@ class CADSInstance(service.Service): logging.critical("Failed to restart the directory server. See the installation log for details.") def uninstall(self): + if self.is_configured(): + self.print_msg("Unconfiguring CA directory server") + running = self.restore_state("running") enabled = self.restore_state("enabled") serverid = self.restore_state("serverid") @@ -351,6 +354,7 @@ class CADSInstance(service.Service): if not serverid is None: dsinstance.erase_ds_instance_data(serverid) + self.service_name="pkids" ds_user = self.restore_state("user") user_exists = self.restore_state("user_exists") @@ -1028,6 +1032,13 @@ class CAInstance(service.Service): self.__restart_instance() def uninstall(self): + if self.is_configured(): + self.print_msg("Unconfiguring CA") + + enabled = self.restore_state("enabled") + if not enabled is None and not enabled: + self.chkconfig_off() + try: ipautil.run(["/usr/bin/pkiremove", "-pki_instance_root=/var/lib", "-pki_instance_name=%s" % PKI_INSTANCE_NAME, "--force"]) @@ -1039,6 +1050,14 @@ class CAInstance(service.Service): except ipautil.CalledProcessError, e: pass + pki_user = self.restore_state("user") + user_exists = self.restore_state("user_exists") + if not pki_user is None and not user_exists is None and not user_exists: + try: + ipautil.run(["/usr/sbin/userdel", pki_user]) + except ipautil.CalledProcessError, e: + logging.critical("failed to delete user %s" % e) + if __name__ == "__main__": installutils.standard_logging_setup("install.log", False) cs = CADSInstance() -- cgit