/* Configure product glassfish */ public void configureGlassfish() throws EnhancedException { // set executable permissions on most used scripts String installDir = productRef.getInstallLocation(); if (!OSUtils.isWindows()) { LOGGER.log(Level.INFO, Msg.get("SETTING_EXECUTE_PERMISSIONS_FOR_GLASSFISH", null)); org.glassfish.installer.util.FileUtils.setAllFilesExecutable(installDir + "/glassfish/bin"); org.glassfish.installer.util.FileUtils.setAllFilesExecutable(installDir + "/bin"); if (org.glassfish.installer.util.FileUtils.isFileExist(installDir + "/mq/bin")) { org.glassfish.installer.util.FileUtils.setAllFilesExecutable(installDir + "/mq/bin"); } } // Update asenv updateConfigFile(); // Unpack all of *pack*ed files. unpackJars(); // create domain startup/shutdown wrapper scripts if (OSUtils.isWindows()) { setupWindowsDomainScripts(); createServerShortCuts(); } else { setupUnixDomainScripts(); } }
/* 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. } }
/*create updatetool wrapper script used by shortcut items */ private void setupUpdateToolScripts() { LOGGER.log(Level.INFO, Msg.get("SETUP_UPDATETOOL_SCRIPT", null)); org.glassfish.installer.util.FileUtils.createDirectory( productRef.getInstallLocation() + File.separator + "updatetool" + File.separator + "lib"); try { if (OSUtils.isWindows()) { FileIOUtils updateToolScript = new FileIOUtils(); updateToolScript.openFile( productRef.getInstallLocation() + "\\updatetool\\lib\\updatetool-start.bat"); updateToolScript.appendLine(GlassFishUtils.windowsCopyRightNoticeText); updateToolScript.appendLine("setlocal"); updateToolScript.appendLine( "cd \"" + productRef.getInstallLocation() + "\\updatetool\\bin\""); updateToolScript.appendLine("call updatetool.exe"); updateToolScript.appendLine("endlocal"); updateToolScript.saveFile(); updateToolScript.closeFile(); } else { FileIOUtils updateToolScript = new FileIOUtils(); updateToolScript.openFile( productRef.getInstallLocation() + "/updatetool/lib/updatetool-start"); updateToolScript.appendLine(GlassFishUtils.unixCopyRightNoticeText); updateToolScript.appendLine( "cd \"" + productRef.getInstallLocation() + "/updatetool/bin\""); updateToolScript.appendLine("./updatetool"); updateToolScript.saveFile(); updateToolScript.closeFile(); org.glassfish.installer.util.FileUtils.setExecutable( productRef.getInstallLocation() + "/updatetool/lib/updatetool-start"); } } catch (Exception ex) { LOGGER.log(Level.FINEST, ex.getMessage()); } }
/* * OI hook to call individual product configurations. */ public ResultReport unConfigure(final PropertySheet propSheet, final boolean validateFlag) { try { if (productRef.getProductName().equals("Domain")) { LOGGER.log(Level.INFO, Msg.get("UNCONFIGURING_GLASSFISH", null)); unconfigureGlassfish(); } if (productRef.getProductName().equals("UpdateTool")) { LOGGER.log(Level.INFO, Msg.get("UNCONFIGURING_UPDATETOOL", null)); unconfigureUpdatetool(); org.glassfish.installer.util.FileUtils.deleteDirectory( new File(productRef.getInstallLocation() + File.separator + "updatetool")); org.glassfish.installer.util.FileUtils.deleteDirectory( new File(productRef.getInstallLocation() + File.separator + "pkg")); } /* Delete the newly created folder, on windows. No incremental uninstallation, so delete everything.*/ String folderName = (String) TemplateProcessor.getInstance().getFromDataModel("PRODUCT_NAME"); if (OSUtils.isWindows()) { WindowsShortcutManager wsShortMgr = new WindowsShortcutManager(); wsShortMgr.deleteFolder(folderName); } } catch (Exception e) { LOGGER.log(Level.FINEST, e.getMessage()); } return new ResultReport( ResultReport.ResultStatus.SUCCESS, "http://www.oracle.com/pls/topic/lookup?ctx=821-2427&id=sjsaseeig", "http://www.oracle.com/pls/topic/lookup?ctx=821-2427&id=sjsaseeig", null, productError); }
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()); } }
/* Run configuration steps for update tool component. */ public void configureUpdatetool() throws Exception { // set execute permissions for UC utilities if (!OSUtils.isWindows()) { LOGGER.log(Level.INFO, Msg.get("SETTING_EXECUTE_PERMISSIONS_FOR_UPDATETOOL", null)); org.glassfish.installer.util.FileUtils.setExecutable( productRef.getInstallLocation() + "/bin/pkg"); org.glassfish.installer.util.FileUtils.setExecutable( productRef.getInstallLocation() + "/bin/updatetool"); } setupUpdateToolScripts(); // check whether to bootstrap at all if (!ConfigHelper.getBooleanValue("UpdateTool.Configuration.BOOTSTRAP_UPDATETOOL")) { LOGGER.log(Level.INFO, Msg.get("SKIPPING_UPDATETOOL_BOOTSTRAP", null)); } else { boolean allowUpdateCheck = ConfigHelper.getBooleanValue("UpdateTool.Configuration.ALLOW_UPDATE_CHECK"); String proxyHost = configData.get("PROXY_HOST"); String proxyPort = configData.get("PROXY_PORT"); // populate bootstrap properties Properties props = new Properties(); if (OSUtils.isWindows()) { props.setProperty("image.path", productRef.getInstallLocation().replace('\\', '/')); } else { props.setProperty("image.path", productRef.getInstallLocation()); } props.setProperty("install.pkg", "true"); if (!OSUtils.isAix()) { props.setProperty("install.updatetool", "true"); } else { props.setProperty("install.updatetool", "false"); } props.setProperty("optin.update.notification", allowUpdateCheck ? "true" : "false"); props.setProperty("optin.usage.reporting", allowUpdateCheck ? "true" : "false"); if ((proxyHost.length() > 0) && (proxyPort.length() > 0)) { props.setProperty("proxy.URL", "http://" + proxyHost + ":" + proxyPort); } LOGGER.log(Level.INFO, Msg.get("BOOTSTRAPPING_UPDATETOOL", null)); LOGGER.log(Level.FINEST, props.toString()); // explicitly refreshing catalogs, workaround for bootstrap issue // proceed to bootstrap if there is an exception try { SystemInfo.initUpdateToolProps(props); Image img = new Image(productRef.getInstallLocation()); img.refreshCatalogs(); } catch (Exception e) { LOGGER.log(Level.FINEST, e.getMessage()); } // invoke bootstrap Bootstrap.main(props, LOGGER); } // Create the required windows start->menu shortcuts for updatetool. if (OSUtils.isWindows()) { createUpdatetoolShortCuts(); } }