diff --git a/ipaclient/install/client.py b/ipaclient/install/client.py index ad03c81fd..2aa8b5f7d 100644 --- a/ipaclient/install/client.py +++ b/ipaclient/install/client.py @@ -266,13 +266,21 @@ def delete_ipa_domain(): "No access to the /etc/sssd/sssd.conf file.") -def is_ipa_client_installed(fstore, on_master=False): +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. """ + fstore = sysrestore.FileStore(paths.IPA_CLIENT_SYSRESTORE) + statestore = sysrestore.StateFile(paths.IPA_CLIENT_SYSRESTORE) + + installed = statestore.get_state('installation', 'complete') + if installed is not None: + return installed + + # Fall back to the old detection installed = ( fstore.has_files() or ( @@ -2086,7 +2094,7 @@ def install_check(options): tasks.check_selinux_status() - if is_ipa_client_installed(fstore, on_master=options.on_master): + if is_ipa_client_installed(on_master=options.on_master): logger.error("IPA client is already configured on this system.") logger.info( "If you want to reinstall the IPA client, uninstall it first " @@ -2598,6 +2606,8 @@ def _install(options): fstore = sysrestore.FileStore(paths.IPA_CLIENT_SYSRESTORE) statestore = sysrestore.StateFile(paths.IPA_CLIENT_SYSRESTORE) + statestore.backup_state('installation', 'complete', False) + if not options.on_master: # Try removing old principals from the keytab purge_host_keytab(cli_realm) @@ -3184,13 +3194,15 @@ def _install(options): configure_nisdomain( options=options, domain=cli_domain, statestore=statestore) + statestore.delete_state('installation', 'complete') + statestore.backup_state('installation', 'complete', True) logger.info('Client configuration complete.') def uninstall_check(options): fstore = sysrestore.FileStore(paths.IPA_CLIENT_SYSRESTORE) - if not is_ipa_client_installed(fstore): + if not is_ipa_client_installed(): if options.on_master: rval = SUCCESS else: @@ -3517,6 +3529,8 @@ def uninstall(options): if fstore.has_files(): logger.error('Some files have not been restored, see %s', paths.SYSRESTORE_INDEX) + + statestore.delete_state('installation', 'complete') has_state = False for module in statestore.modules: logger.error( diff --git a/ipaclient/install/ipa_epn.py b/ipaclient/install/ipa_epn.py index 6e1b00146..666c703e5 100644 --- a/ipaclient/install/ipa_epn.py +++ b/ipaclient/install/ipa_epn.py @@ -42,7 +42,6 @@ from email.utils import make_msgid from ipaclient.install.client import is_ipa_client_installed from ipaplatform.paths import paths from ipalib import api, errors -from ipalib.install import sysrestore from ipapython import admintool, ipaldap from ipapython.dn import DN @@ -255,8 +254,7 @@ class EPN(admintool.AdminTool): def run(self): super(EPN, self).run() - fstore = sysrestore.FileStore(paths.IPA_CLIENT_SYSRESTORE) - if not is_ipa_client_installed(fstore): + if not is_ipa_client_installed(): logger.error("IPA client is not configured on this system.") raise admintool.ScriptError()