| | |
| | | package org.opends.quicksetup.installer.offline; |
| | | |
| | | import java.io.PrintStream; |
| | | import java.io.File; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.logging.Level; |
| | | import java.util.logging.Logger; |
| | | import java.security.KeyStoreException; |
| | | |
| | | import org.opends.quicksetup.ApplicationException; |
| | | import org.opends.quicksetup.ProgressStep; |
| | | import org.opends.quicksetup.Installation; |
| | | import org.opends.quicksetup.SecurityOptions; |
| | | import org.opends.quicksetup.installer.Installer; |
| | | import org.opends.quicksetup.installer.InstallProgressStep; |
| | | import org.opends.quicksetup.util.Utils; |
| | | import org.opends.quicksetup.util.ServerController; |
| | | import org.opends.quicksetup.util.FileManager; |
| | | import org.opends.server.util.CertificateManager; |
| | | |
| | | /** |
| | | * This is an implementation of the Installer class that is used to install |
| | |
| | | System.setErr(err); |
| | | System.setOut(out); |
| | | |
| | | checkAbort(); |
| | | |
| | | setStatus(InstallProgressStep.CONFIGURING_SERVER); |
| | | configureServer(); |
| | | |
| | | checkAbort(); |
| | | |
| | | createData(); |
| | | |
| | | checkAbort(); |
| | | |
| | | writeJavaHome(); |
| | | |
| | | if (Utils.isWindows() && getUserData().getEnableWindowsService()) |
| | |
| | | notifyListeners(getTaskSeparator()); |
| | | setStatus(InstallProgressStep.ENABLING_WINDOWS_SERVICE); |
| | | enableWindowsService(); |
| | | checkAbort(); |
| | | } |
| | | |
| | | if (mustStart()) |
| | |
| | | notifyListeners(getTaskSeparator()); |
| | | setStatus(InstallProgressStep.STARTING_SERVER); |
| | | new ServerController(this).startServer(); |
| | | checkAbort(); |
| | | } |
| | | |
| | | if (mustConfigureReplication()) |
| | |
| | | notifyListeners(getTaskSeparator()); |
| | | |
| | | configureReplication(); |
| | | checkAbort(); |
| | | } |
| | | |
| | | if (mustInitializeSuffixes()) |
| | |
| | | notifyListeners(getTaskSeparator()); |
| | | setStatus(InstallProgressStep.INITIALIZE_REPLICATED_SUFFIXES); |
| | | initializeSuffixes(); |
| | | checkAbort(); |
| | | } |
| | | |
| | | if (mustCreateAds()) |
| | |
| | | notifyListeners(getTaskSeparator()); |
| | | setStatus(InstallProgressStep.CONFIGURING_ADS); |
| | | updateADS(); |
| | | checkAbort(); |
| | | } |
| | | |
| | | if (mustStop()) |
| | |
| | | new ServerController(this).stopServer(); |
| | | } |
| | | |
| | | checkAbort(); |
| | | setStatus(InstallProgressStep.FINISHED_SUCCESSFULLY); |
| | | notifyListeners(null); |
| | | |
| | | } catch (ApplicationException ex) |
| | | { |
| | | notifyListeners(getLineBreak()); |
| | | notifyListenersOfLog(); |
| | | setStatus(InstallProgressStep.FINISHED_WITH_ERROR); |
| | | String html = getFormattedError(ex, true); |
| | | notifyListeners(html); |
| | | LOG.log(Level.SEVERE, "Error installing.", ex); |
| | | if (ApplicationException.Type.CANCEL.equals(ex.getType())) { |
| | | uninstall(); |
| | | setStatus(InstallProgressStep.FINISHED_CANCELED); |
| | | notifyListeners(null); |
| | | } else { |
| | | notifyListeners(getLineBreak()); |
| | | notifyListenersOfLog(); |
| | | setStatus(InstallProgressStep.FINISHED_WITH_ERROR); |
| | | String html = getFormattedError(ex, true); |
| | | notifyListeners(html); |
| | | LOG.log(Level.SEVERE, "Error installing.", ex); |
| | | } |
| | | } |
| | | catch (Throwable t) |
| | | { |
| | |
| | | } |
| | | |
| | | /** |
| | | * Called when the user elects to cancel this operation. |
| | | */ |
| | | protected void uninstall() { |
| | | |
| | | Installation installation = getInstallation(); |
| | | FileManager fm = new FileManager(this); |
| | | |
| | | // Stop the server if necessary |
| | | if (installation.getStatus().isServerRunning()) { |
| | | try { |
| | | new ServerController(installation).stopServer(true); |
| | | } catch (ApplicationException e) { |
| | | LOG.log(Level.INFO, "error stopping server", e); |
| | | } |
| | | } |
| | | |
| | | uninstallServices(); |
| | | |
| | | // Revert to the base configuration |
| | | try { |
| | | File newConfig = fm.copy(installation.getBaseConfigurationFile(), |
| | | installation.getConfigurationDirectory(), |
| | | /*overwrite=*/true); |
| | | fm.rename(newConfig, installation.getCurrentConfigurationFile()); |
| | | |
| | | } catch (ApplicationException ae) { |
| | | LOG.log(Level.INFO, "failed to restore base configuration", ae); |
| | | } |
| | | |
| | | // Cleanup SSL if necessary |
| | | SecurityOptions sec = getUserData().getSecurityOptions(); |
| | | if (sec.getEnableSSL() || sec.getEnableStartTLS()) { |
| | | if (SecurityOptions.CertificateType.SELF_SIGNED_CERTIFICATE.equals( |
| | | sec.getCertificateType())) { |
| | | CertificateManager cm = new CertificateManager( |
| | | getSelfSignedKeystorePath(), |
| | | CertificateManager.KEY_STORE_TYPE_JKS, |
| | | getSelfSignedCertificatePwd()); |
| | | try { |
| | | cm.removeCertificate(SELF_SIGNED_CERT_ALIAS); |
| | | } catch (KeyStoreException e) { |
| | | LOG.log(Level.INFO, "Error deleting self signed certification", e); |
| | | } |
| | | } |
| | | |
| | | File keystore = new File(installation.getConfigurationDirectory(), |
| | | "keystore"); |
| | | if (keystore.exists()) { |
| | | try { |
| | | fm.delete(keystore); |
| | | } catch (ApplicationException e) { |
| | | LOG.log(Level.INFO, "Failed to delete keystore", e); |
| | | } |
| | | } |
| | | |
| | | File keystorePin = new File(installation.getConfigurationDirectory(), |
| | | "keystore.pin"); |
| | | if (keystorePin.exists()) { |
| | | try { |
| | | fm.delete(keystorePin); |
| | | } catch (ApplicationException e) { |
| | | LOG.log(Level.INFO, "Failed to delete keystore.pin", e); |
| | | } |
| | | } |
| | | |
| | | File truststore = new File(installation.getConfigurationDirectory(), |
| | | "truststore"); |
| | | if (truststore.exists()) { |
| | | try { |
| | | fm.delete(truststore); |
| | | } catch (ApplicationException e) { |
| | | LOG.log(Level.INFO, "Failed to delete truststore", e); |
| | | } |
| | | } |
| | | } |
| | | |
| | | // Remove the databases |
| | | try { |
| | | fm.deleteChildren(installation.getDatabasesDirectory()); |
| | | } catch (ApplicationException e) { |
| | | LOG.log(Level.INFO, "Error deleting databases", e); |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | | * Initialize the different map used in this class. |
| | | * |
| | | */ |
| | |
| | | } |
| | | hmRatio.put(InstallProgressStep.FINISHED_SUCCESSFULLY, 100); |
| | | hmRatio.put(InstallProgressStep.FINISHED_WITH_ERROR, 100); |
| | | hmRatio.put(InstallProgressStep.FINISHED_CANCELED, 100); |
| | | } |
| | | |
| | | /** |