From a7110d7a32b6eb7131ce47655cb14f693681ab01 Mon Sep 17 00:00:00 2001 From: Tomas Babej Date: Tue, 19 Feb 2013 17:59:50 +0100 Subject: Use default.conf as flag of IPA client being installed When installing / uninstalling IPA client, the checks that determine whether IPA client is installed now take the existence of /etc/ipa/default.conf into consideration. The client will not uninstall unless either something is backed up or /etc/ipa/default.conf file does exist. The client will not install if something is backed up or default.conf file does exist (unless it's installation on master). https://fedorahosted.org/freeipa/ticket/3331 --- ipa-client/ipa-install/ipa-client-install | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'ipa-client') diff --git a/ipa-client/ipa-install/ipa-client-install b/ipa-client/ipa-install/ipa-client-install index 2d32e28ec..308c3f8d0 100755 --- a/ipa-client/ipa-install/ipa-client-install +++ b/ipa-client/ipa-install/ipa-client-install @@ -36,7 +36,9 @@ try: from ipaclient.ipadiscovery import CACERT import ipaclient.ipachangeconf import ipaclient.ntpconf - from ipapython.ipautil import run, user_input, CalledProcessError, file_exists, realm_to_suffix, convert_ldap_error + from ipapython.ipautil import run, user_input, CalledProcessError,\ + file_exists, realm_to_suffix,\ + convert_ldap_error import ipapython.services as ipaservices from ipapython import ipautil from ipapython import sysrestore @@ -281,9 +283,22 @@ def delete_ipa_domain(): root_logger.warning("IPA domain could not be deleted. " "No access to the /etc/sssd/sssd.conf file.") +def is_ipa_client_installed(on_master=False): + """ + Consider IPA client not installed if nothing is backed up + and default.conf file does not exist. If on_master is set to True, + the existence of default.conf file is not taken into consideration, + since it has been already created by ipa-server-install. + """ + + installed = fstore.has_files() or \ + (not on_master and os.path.exists('/etc/ipa/default.conf')) + + return installed + def uninstall(options, env): - if not fstore.has_files(): + if not is_ipa_client_installed(): root_logger.error("IPA client is not configured on this system.") return CLIENT_NOT_CONFIGURED @@ -2326,7 +2341,7 @@ def main(): if options.uninstall: return uninstall(options, env) - if fstore.has_files(): + if is_ipa_client_installed(on_master=options.on_master): root_logger.error("IPA client is already configured on this system.") root_logger.info( "If you want to reinstall the IPA client, uninstall it first " + -- cgit