private void updateConfigFile() throws EnhancedException { // for SDK cobundles with JDK - see if cobundled JDK exists and use that // checks for jdk7 directory since we only have JDK 7 cobundles if (org.glassfish.installer.util.FileUtils.isFileExist( productRef.getInstallLocation() + File.separator + "jdk7")) { jdkHome = productRef.getInstallLocation() + File.separator + "jdk7"; // on Unix, set executable permissions to jdk7/bin/* and jdk7/jre/bin/* if (!OSUtils.isWindows()) { org.glassfish.installer.util.FileUtils.setAllFilesExecutable( productRef.getInstallLocation() + File.separator + "jdk7" + File.separator + "bin"); org.glassfish.installer.util.FileUtils.setAllFilesExecutable( productRef.getInstallLocation() + File.separator + "jdk7" + File.separator + "jre" + File.separator + "bin"); } } else { // For all installation modes, fetch JAVA_HOME from panel; // on MacOS and AIX use java.home property since panel is skipped try { if (OSUtils.isMac() || OSUtils.isAix()) { jdkHome = System.getProperty("java.home"); } else { jdkHome = ConfigHelper.getStringValue("JDKSelection.directory.SELECTED_JDK"); } } catch (Exception e) { jdkHome = new File(System.getProperty("java.home")).getParent(); if (OSUtils.isMac() || OSUtils.isAix()) { jdkHome = System.getProperty("java.home"); } } } LOGGER.log(Level.INFO, Msg.get("UPDATE_CONFIG_HEADER", null)); LOGGER.log(Level.INFO, Msg.get("JDK_HOME", new String[] {jdkHome})); // write jdkHome value to asenv.bat on Windows, asenv.conf on non-Windows platform... try { FileIOUtils configFile = new FileIOUtils(); configFile.openFile(productRef.getConfigFilePath()); /* Add AS_JAVA to end of buffer and file. */ if (OSUtils.isWindows()) { configFile.appendLine("set AS_JAVA=" + jdkHome); } else { configFile.appendLine("AS_JAVA=" + jdkHome); } configFile.saveFile(); configFile.closeFile(); } catch (Exception ex) { LOGGER.log(Level.FINEST, ex.getMessage()); } }
/* Undo updatetool configuration and post-installation setups.*/ public void unconfigureUpdatetool() throws Exception { /* Try to shutdown the notifer. Don't do this on Mac, the notifier command does not work on Mac, refer to Issue #7348. */ if (!OSUtils.isMac() && !OSUtils.isAix()) { try { String shutdownCommand; if (OSUtils.isWindows()) { shutdownCommand = productRef.getInstallLocation() + "\\updatetool\\bin\\updatetool.exe"; } else { shutdownCommand = productRef.getInstallLocation() + "/updatetool/bin/updatetool"; } String[] shutdownCommandArray = {shutdownCommand, "--notifier", "--shutdown"}; LOGGER.log(Level.INFO, Msg.get("SHUTDOWN_NOTIFIER", null)); ExecuteCommand shutdownExecuteCommand = new ExecuteCommand(shutdownCommandArray); shutdownExecuteCommand.setOutputType(ExecuteCommand.ERRORS | ExecuteCommand.NORMAL); shutdownExecuteCommand.setCollectOutput(true); LOGGER.log( Level.FINEST, shutdownExecuteCommand.expandCommand(shutdownExecuteCommand.getCommand())); shutdownExecuteCommand.execute(); } catch (Exception e) { LOGGER.log(Level.FINEST, e.getMessage()); // Its okay to ignore this for now. } } /* End, conditional code for Mac and Aix. */ /* Now unregister notifer. */ try { String configCommand; if (OSUtils.isWindows()) { configCommand = productRef.getInstallLocation() + "\\updatetool\\bin\\updatetoolconfig.bat"; } else { configCommand = productRef.getInstallLocation() + "/updatetool/bin/updatetoolconfig"; } String[] configCommandArray = {configCommand, "--unregister"}; LOGGER.log(Level.INFO, Msg.get("UNREGISTER_NOTIFIER", null)); ExecuteCommand configExecuteCommand = new ExecuteCommand(configCommandArray); configExecuteCommand.setOutputType(ExecuteCommand.ERRORS | ExecuteCommand.NORMAL); configExecuteCommand.setCollectOutput(true); LOGGER.log( Level.FINEST, configExecuteCommand.expandCommand(configExecuteCommand.getCommand())); configExecuteCommand.execute(); } catch (Exception e) { LOGGER.log(Level.FINEST, e.getMessage()); // Its okay to ignore this for now. } }