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
This commit is contained in:
Tomas Babej 2013-02-19 17:59:50 +01:00 committed by Martin Kosek
parent 42300eb55b
commit a7110d7a32

View File

@ -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 " +