summaryrefslogtreecommitdiffstats
path: root/install
diff options
context:
space:
mode:
authorMartin Kosek <mkosek@redhat.com>2011-11-29 09:10:31 +0100
committerMartin Kosek <mkosek@redhat.com>2011-11-29 09:18:03 +0100
commit046147b3a44b793049ee0100d775b8fe5c709999 (patch)
treea00042f986ea5497f9266583d19b750046671e36 /install
parent9cdeabc778c3eaf9e62eee4fc047c2fd1ec58260 (diff)
downloadfreeipa-046147b3a44b793049ee0100d775b8fe5c709999.tar.gz
freeipa-046147b3a44b793049ee0100d775b8fe5c709999.tar.xz
freeipa-046147b3a44b793049ee0100d775b8fe5c709999.zip
Make ipa-server-install clean after itself
ipa-server-install may create some files in the first phase of installation before the actual installation and configuring of services starts. If the installation is interrupted, these files may prevent installing the server again until IPA server is uninstalled. This may be confusing and annoying for the user. This patch safely recovers all known files that could be created in the first phase of the installation. No clean up is done if the actual installation has not started yet or the installation returned success. https://fedorahosted.org/freeipa/ticket/1980
Diffstat (limited to 'install')
-rwxr-xr-xinstall/tools/ipa-server-install45
1 files changed, 36 insertions, 9 deletions
diff --git a/install/tools/ipa-server-install b/install/tools/ipa-server-install
index 26bb8b4b4..57deec64f 100755
--- a/install/tools/ipa-server-install
+++ b/install/tools/ipa-server-install
@@ -66,6 +66,7 @@ from ipapython.ipa_log_manager import *
pw_name = None
uninstalling = False
+installation_cleanup = True
VALID_SUBJECT_ATTRS = ['cn', 'st', 'o', 'ou', 'dnqualifier', 'c',
'serialnumber', 'l', 'title', 'sn', 'givenname',
@@ -522,6 +523,7 @@ def main():
global ds
global pw_name
global uninstalling
+ global installation_cleanup
ds = None
safe_options, options = parse_options()
@@ -535,15 +537,18 @@ def main():
if options.uninstall:
uninstalling = True
standard_logging_setup("/var/log/ipaserver-uninstall.log", debug=options.debug)
+ installation_cleanup = False
else:
standard_logging_setup("/var/log/ipaserver-install.log", debug=options.debug)
print "\nThe log file for this installation can be found in /var/log/ipaserver-install.log"
if not options.external_ca and not options.external_cert_file and is_ipa_configured():
+ installation_cleanup = False
sys.exit("IPA server is already configured on this system.\n"
+ "If you want to reinstall the IPA server please uninstall it first.")
client_fstore = sysrestore.FileStore('/var/lib/ipa-client/sysrestore')
if client_fstore.has_files():
+ installation_cleanup = False
sys.exit("IPA client is already configured on this system.\n"
+ "Please uninstall it first before configuring the IPA server.")
@@ -726,7 +731,17 @@ def main():
domain_name = domain_name.lower()
# Check we have a public IP that is associated with the hostname
- hostaddr = resolve_host(host_name)
+ try:
+ hostaddr = resolve_host(host_name)
+ except HostnameLocalhost:
+ print >> sys.stderr, "The hostname resolves to the localhost address (127.0.0.1/::1)"
+ print >> sys.stderr, "Please change your /etc/hosts file so that the hostname"
+ print >> sys.stderr, "resolves to the ip address of your network interface."
+ print >> sys.stderr, "The KDC service does not listen on localhost"
+ print >> sys.stderr, ""
+ print >> sys.stderr, "Please fix your /etc/hosts file and restart the setup program"
+ sys.exit(1)
+
ip_add_to_hosts = False
if hostaddr is not None:
ip = CheckedIPAddress(hostaddr, match_local=True)
@@ -833,6 +848,10 @@ def main():
dns_forwarders = ()
root_logger.debug("will use dns_forwarders: %s\n" % str(dns_forwarders))
+ # Installation has started. No IPA sysrestore items are restored in case of
+ # failure to enable root cause investigation
+ installation_cleanup = False
+
# Create the management framework config file and finalize api
target_fname = '/etc/ipa/default.conf'
fd = open(target_fname, "w")
@@ -1111,18 +1130,18 @@ def main():
return 0
try:
+ success = True
try:
- sys.exit(main())
+ rval = main()
+ if rval != 0:
+ success = False
+ sys.exit(rval)
except SystemExit, e:
+ if e.code is not None or e.code != 0:
+ success = False
sys.exit(e)
- except HostnameLocalhost:
- print "The hostname resolves to the localhost address (127.0.0.1/::1)"
- print "Please change your /etc/hosts file so that the hostname"
- print "resolves to the ip address of your network interface."
- print "The KDC service does not listen on localhost"
- print ""
- print "Please fix your /etc/hosts file and restart the setup program"
except Exception, e:
+ success = False
if uninstalling:
message = "Unexpected error - see ipaserver-uninstall.log for details:\n %s" % str(e)
else:
@@ -1136,3 +1155,11 @@ try:
finally:
if pw_name and ipautil.file_exists(pw_name):
os.remove(pw_name)
+
+ if not success and installation_cleanup:
+ # Do a cautious clean up as we don't know what failed and what is
+ # the state of the environment
+ try:
+ fstore.restore_file('/etc/hosts')
+ except:
+ pass