Esempio n. 1
0
  /*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());
    }
  }
Esempio n. 2
0
  /* Create wrappers for asadmin start/stop on Windows.
   * This also should include copyright, that is currently taken from OSUtils.
   */
  private void setupWindowsDomainScripts() {
    LOGGER.log(Level.INFO, Msg.get("SETUP_STARTSTOP_SCRIPTS", null));
    try {
      FileIOUtils startFile = new FileIOUtils();
      startFile.openFile(
          productRef.getInstallLocation() + "\\glassfish\\lib\\asadmin-start-domain.bat");
      startFile.appendLine(GlassFishUtils.windowsCopyRightNoticeText);
      startFile.appendLine("setlocal");
      startFile.appendLine(
          "call \""
              + productRef.getInstallLocation()
              + "\\glassfish\\bin\\asadmin\" start-domain domain1\n");
      startFile.appendLine("pause");
      startFile.appendLine("endlocal");
      startFile.saveFile();
      startFile.closeFile();

      FileIOUtils stopFile = new FileIOUtils();
      stopFile.openFile(
          productRef.getInstallLocation() + "\\glassfish\\lib\\asadmin-stop-domain.bat");
      stopFile.appendLine(GlassFishUtils.windowsCopyRightNoticeText);
      stopFile.appendLine("setlocal");
      stopFile.appendLine(
          "call \""
              + productRef.getInstallLocation()
              + "\\glassfish\\bin\\asadmin\" stop-domain domain1\n");
      stopFile.appendLine("pause");
      stopFile.appendLine("endlocal");
      stopFile.saveFile();
      stopFile.closeFile();
    } catch (Exception ex) {
      LOGGER.log(Level.FINEST, ex.getMessage());
      // OK to ignore this for now.
    }
  }
Esempio n. 3
0
  private void setupUnixDomainScripts() {
    LOGGER.log(Level.INFO, Msg.get("SETUP_STARTSTOP_SCRIPTS", null));
    try {
      FileIOUtils startFile = new FileIOUtils();
      startFile.openFile(productRef.getInstallLocation() + "/glassfish/lib/asadmin-start-domain");
      startFile.appendLine(GlassFishUtils.unixCopyRightNoticeText);
      startFile.appendLine(
          "\"" + productRef.getInstallLocation() + "/glassfish/bin/asadmin\" start-domain domain1");
      startFile.saveFile();
      startFile.closeFile();

      FileIOUtils stopFile = new FileIOUtils();
      stopFile.openFile(productRef.getInstallLocation() + "/glassfish/lib/asadmin-stop-domain");
      stopFile.appendLine(GlassFishUtils.unixCopyRightNoticeText);
      stopFile.appendLine(
          "\"" + productRef.getInstallLocation() + "/glassfish/bin/asadmin\" stop-domain domain1");
      stopFile.saveFile();
      stopFile.closeFile();

      org.glassfish.installer.util.FileUtils.setExecutable(
          new File(productRef.getInstallLocation() + "/glassfish/lib/asadmin-start-domain")
              .getAbsolutePath());
      org.glassfish.installer.util.FileUtils.setExecutable(
          new File(productRef.getInstallLocation() + "/glassfish/lib/asadmin-stop-domain")
              .getAbsolutePath());
    } catch (Exception ex) {
      LOGGER.log(Level.FINEST, ex.getMessage());
    }
  }
Esempio n. 4
0
  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());
    }
  }