[java-idp-jetty-base] 10/18: IDP-2297 Explore extending the Plugin and Module Infrastructure to allow Jetty installation

Rod Widdowson rdw at steadingsoftware.com
Tue Oct 15 15:14:57 UTC 2024


This is an automated email from the git hooks/post-receive script.

rdw pushed a commit to branch dev/IDP-2297
in repository java-idp-jetty-base.

View the commit online:
http://git.shibboleth.net/view/?p=java-idp-jetty-base.git;a=commit;h=8e2762c4ec6ecb11ed8a316ce02d734ff15a9ada

commit 8e2762c4ec6ecb11ed8a316ce02d734ff15a9ada
Author: Rod Widdowson <rdw at steadingsoftware.com>
AuthorDate: Sat Aug 10 16:45:17 2024 +0100

    IDP-2297 Explore extending the Plugin and Module Infrastructure to allow Jetty installation
    
    https://shibboleth.atlassian.net/browse/IDP-2297
    
    * Move logging into idp home
    * Add a bat file (windows only) to create an environmental variable for
      idp.home with unix diectory separatora
---
 .../idp/plugin/jettybase/JettyBaseModule.java       | 21 ++++++++++++++++++++-
 .../idp/plugin/jettybase/module/runjetty.bat        |  7 ++++++-
 .../idp/plugin/jettybase/module/runjetty.sh         |  2 +-
 3 files changed, 27 insertions(+), 3 deletions(-)

diff --git a/jetty-base-impl/src/main/java/net/shibboleth/idp/plugin/jettybase/JettyBaseModule.java b/jetty-base-impl/src/main/java/net/shibboleth/idp/plugin/jettybase/JettyBaseModule.java
index 6103e9f..be7b83b 100644
--- a/jetty-base-impl/src/main/java/net/shibboleth/idp/plugin/jettybase/JettyBaseModule.java
+++ b/jetty-base-impl/src/main/java/net/shibboleth/idp/plugin/jettybase/JettyBaseModule.java
@@ -13,13 +13,16 @@
  */
 package net.shibboleth.idp.plugin.jettybase;
 
+import java.io.File;
 import java.io.IOException;
+import java.io.PrintStream;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.util.Map;
 
 import javax.annotation.Nonnull;
 
+import org.apache.commons.lang3.SystemUtils;
 import org.slf4j.Logger;
 
 import net.shibboleth.idp.Version;
@@ -49,13 +52,29 @@ public class JettyBaseModule extends PluginIdPModule {
         final Path jettyBase = idpHome.resolve("jetty-base");
         log.debug("Creating directories (if needed): 'credentials', 'logs', 'static', 'tmp' below {}", jettyBase);
         try {
-            Files.createDirectories(jettyBase.resolve("logs"));
             Files.createDirectories(idpHome.resolve("static"));
             Files.createDirectories(jettyBase.resolve("tmp"));
         } catch (final IOException e) {
             log.error("Create Directory failed", e);
             throw new ModuleException(e);
         }
+        if (SystemUtils.IS_OS_WINDOWS) {
+            final File jettyHelper = idpHome.resolve("bin").resolve("Jetty-helper.bat").toFile();
+            if (!jettyHelper.exists()) {
+                try {
+                    final String idpHomeString = idpHome.toFile().getCanonicalPath().replace('\\', '/');
+                    try (final PrintStream stream = new PrintStream(jettyHelper)) {
+                        stream.println("@echo off\n\nREM Helper to set up the UNIX delimited IDP_HOME\n\n");
+                        stream.printf("IDP_HOME_UNIX=%s\n", idpHomeString);
+                    }
+                }
+                catch (IOException e) {
+                    log.error("Could not write bin\\jetty-helper.bat", e);
+                    throw new ModuleException("Could not write bin\\jetty-helper.bat", e);
+                }
+            }
+        }
+
         return result;
     }
 }
diff --git a/jetty-base-impl/src/main/resources/net/shibboleth/idp/plugin/jettybase/module/runjetty.bat b/jetty-base-impl/src/main/resources/net/shibboleth/idp/plugin/jettybase/module/runjetty.bat
index 99fd3dd..3944ed0 100644
--- a/jetty-base-impl/src/main/resources/net/shibboleth/idp/plugin/jettybase/module/runjetty.bat
+++ b/jetty-base-impl/src/main/resources/net/shibboleth/idp/plugin/jettybase/module/runjetty.bat
@@ -18,6 +18,11 @@ if not defined JAVACMD (
 
 set IDP_HOME_WINDOWS=%~dp0..
 
+REM setup IDP_HOME_UNIX
+%~dp0/jetty-helper.bat
+
+echo %IDP_HOME_UNIX%
+
 if not defined JETTY_HOME {
    set JETTY_HOME=%IDP_HOME_WINDOWS%\jetty-home
 }
@@ -38,7 +43,7 @@ if not exist "%JETTY_BASE%\start.d" (
 
 set JVM_ARGS=-Didp.home="%IDP_HOME%" -Djdk.tls.ephemeralDHKeySize=2048 -Dorg.eclipse.jetty.util.log.class=org.eclipse.jetty.util.log.Slf4jLog -Djava.io.tmpdir="%JETTY_BASE%/tmp" -XX:+UseG1GC
 
-SET JETTY_ARGS=jetty.base="%JETTY_BASE%" jetty.logging.dir="%JETTY_BASE%\logs"
+SET JETTY_ARGS=jetty.base="%JETTY_BASE%" jetty.logging.dir="%IDP_HOME_WINDOWS%\logs"
 
 %JAVACMD% -jar "%JETTY_HOME%/start.jar" %JVM_ARGS% %JETTY_ARGS%
 
diff --git a/jetty-base-impl/src/main/resources/net/shibboleth/idp/plugin/jettybase/module/runjetty.sh b/jetty-base-impl/src/main/resources/net/shibboleth/idp/plugin/jettybase/module/runjetty.sh
index 03e7f7b..46f925f 100644
--- a/jetty-base-impl/src/main/resources/net/shibboleth/idp/plugin/jettybase/module/runjetty.sh
+++ b/jetty-base-impl/src/main/resources/net/shibboleth/idp/plugin/jettybase/module/runjetty.sh
@@ -43,7 +43,7 @@ fi
 
 JVM_ARGS="-Didp.home=$IDP_HOME -Djdk.tls.ephemeralDHKeySize=2048 -Dorg.eclipse.jetty.util.log.class=org.eclipse.jetty.util.log.Slf4jLog -Djava.io.tmpdir=$JETTY_BASE/tmp -XX:+UseG1GC"
 
-JETTY_ARGS="jetty.base=$JETTY_BASE jetty.logging.dir=$JETTY_BASE/logs"
+JETTY_ARGS="jetty.base=$JETTY_BASE jetty.logging.dir=$IDP_HOME/logs"
 
 $JAVACMD '-jar' $JETTY_HOME/start.jar  $JVM_ARGS   $JETTY_ARGS 
 

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list