From f86c8365a8fdd21edc2383e24ac31b181688fcbb Mon Sep 17 00:00:00 2001 From: Mathieu Baudier Date: Tue, 30 May 2023 13:27:46 +0200 Subject: [PATCH] Improve freed-init --- etc/freed/{ => init}/config.ini | 6 +++++- etc/freed/init/jvm.args | 10 ++++++++++ etc/freed/init/system.properties | 1 + usr/jbin/Makefile | 20 +++++++++++++------ .../src/{FREEdInit.java => freed-init.java} | 11 ++++++++-- usr/jbin/src/test-shebang.java | 16 +++++++++++++++ 6 files changed, 55 insertions(+), 9 deletions(-) rename etc/freed/{ => init}/config.ini (85%) create mode 100644 etc/freed/init/jvm.args create mode 100644 etc/freed/init/system.properties rename usr/jbin/src/{FREEdInit.java => freed-init.java} (68%) create mode 100644 usr/jbin/src/test-shebang.java diff --git a/etc/freed/config.ini b/etc/freed/init/config.ini similarity index 85% rename from etc/freed/config.ini rename to etc/freed/init/config.ini index 3ee3218..bdb2a9a 100644 --- a/etc/freed/config.ini +++ b/etc/freed/init/config.ini @@ -1,4 +1,5 @@ osgi.clean=true +osgi.console=true argeo.osgi.start.2=\ org.eclipse.equinox.http.servlet,\ @@ -21,4 +22,7 @@ argeo.http.port=80 argeo.sshd.port=22 argeo.osgi.sources=\ -a2:///?swt=rap,\ +a2:///?\ +osgi=equinox&\ +log=syslogger&\ +crypto=fips&\ diff --git a/etc/freed/init/jvm.args b/etc/freed/init/jvm.args new file mode 100644 index 0000000..6e7d6a6 --- /dev/null +++ b/etc/freed/init/jvm.args @@ -0,0 +1,10 @@ +-Dosgi.configuration.cascaded=true +-Dosgi.sharedConfiguration.area=/etc/freed/init +-Dosgi.sharedConfiguration.area.readOnly=true +-Dosgi.configuration.area=/var/lib/freed/init/state/ +-Dosgi.instance.area=/var/lib/freed/init/data/ + +-Dorg.osgi.framework.system.packages.extra=sun.security.internal.spec,sun.security.provider,com.sun.net.httpserver,com.sun.jndi.ldap,com.sun.jndi.ldap.sasl,com.sun.jndi.dns,com.sun.security.jgss,com.sun.nio.file,com.sun.nio.sctp +-Dorg.eclipse.equinox.http.jetty.autostart=false + +-cp /usr/local/share/a2/osgi/equinox/org.argeo.tp.osgi/org.eclipse.osgi.3.18.jar:/usr/local/share/a2/org.argeo.cms/org.argeo.init.2.3.jar \ No newline at end of file diff --git a/etc/freed/init/system.properties b/etc/freed/init/system.properties new file mode 100644 index 0000000..5ee8524 --- /dev/null +++ b/etc/freed/init/system.properties @@ -0,0 +1 @@ +log.org.argeo=DEBUG \ No newline at end of file diff --git a/usr/jbin/Makefile b/usr/jbin/Makefile index e748529..94f73a1 100644 --- a/usr/jbin/Makefile +++ b/usr/jbin/Makefile @@ -2,14 +2,22 @@ prefix ?= /usr/local exec_prefix ?= $(prefix) sbindir ?= $(exec_prefix)/sbin +sysconfdir = $(prefix)/etc +srcdir ?= src -all: - cp src/FREEdInit.java src/freed-init - sed -i '1!b;s|//#!|#!|' src/freed-init +EXECUTABLES=$(notdir $(patsubst %.java,%,$(wildcard $(srcdir)/*.java))) +#EXECUTABLES=$(FILE:src/%.java=%) + +all: $(EXECUTABLES) + +%: $(srcdir)/%.java + cp $< $@ + sed -i '1!b;s|//#!|#!|' $@ + chmod a+x $@ clean: - $(RM) src/freed-init + $(RM) $(EXECUTABLES) install: - cp src/freed-init $(DESTDIR)$(sbindir) - chmod u+x $(DESTDIR)$(sbindir)/freed-init + cp -v --preserve=mode freed-init $(DESTDIR)$(sbindir) + cp -v ../../etc/freed/init/* $(DESTDIR)$(sysconfdir)/freed/init diff --git a/usr/jbin/src/FREEdInit.java b/usr/jbin/src/freed-init.java similarity index 68% rename from usr/jbin/src/FREEdInit.java rename to usr/jbin/src/freed-init.java index 75da69a..f9e9cb8 100644 --- a/usr/jbin/src/FREEdInit.java +++ b/usr/jbin/src/freed-init.java @@ -1,19 +1,26 @@ -//#! /usr/bin/java --source 17 -cp /usr/local/share/a2/osgi/equinox/org.argeo.tp.osgi/org.eclipse.osgi.3.18.jar:/usr/local/share/a2/org.argeo.cms/org.argeo.init.2.3.jar -Dosgi.configuration.cascaded=true -Dosgi.sharedConfiguration.area=/etc/freed -Dosgi.sharedConfiguration.area.readOnly=true -Dosgi.configuration.area=/var/lib/freed/state/ -Dosgi.instance.area=/var/lib/freed/data/ -Dorg.osgi.framework.system.packages.extra=sun.security.internal.spec,sun.security.provider,com.sun.net.httpserver,com.sun.jndi.ldap,com.sun.jndi.ldap.sasl,com.sun.jndi.dns,com.sun.security.jgss,com.sun.nio.file,com.sun.nio.sctp -Dorg.eclipse.equinox.http.jetty.autostart=false +//#! /usr/bin/java --source 17 @/etc/freed/init/jvm.args import java.lang.management.ManagementFactory; +import java.util.TreeMap; import org.argeo.init.Service; import jdk.jshell.tool.JavaShellToolBuilder; import sun.misc.Signal; -public class FREEdInit { +class FreedInit { public static void main(String... args) { final long pid = ProcessHandle.current().pid(); System.out.println("FREEd Init daemon starting with pid " + pid + "..."); // System.out.println(System.getProperty("user.dir")); // System.out.println(System.getProperty("user.name")); // System.out.println(System.getProperty("user.home")); + + // System.setProperty("user.dir", "/tmp"); + for (Object key : new TreeMap<>(System.getProperties()).keySet()) { + System.out.println(key + "=" + System.getProperty(key.toString())); + } + System.out.flush(); Signal.handle(new Signal("TERM"), (signal) -> { diff --git a/usr/jbin/src/test-shebang.java b/usr/jbin/src/test-shebang.java new file mode 100644 index 0000000..6332701 --- /dev/null +++ b/usr/jbin/src/test-shebang.java @@ -0,0 +1,16 @@ +//#! /usr/bin/java --source 17 + +//usr/bin/env java --source 17 "$0" "$@" ; exit $? + +import java.util.TreeMap; + +class TestShebang { + public static void main(String... args) { + System.out.println(org.argeo.init.Service.class); + + // System.setProperty("user.dir", "/tmp"); + for (Object key : new TreeMap<>(System.getProperties()).keySet()) { + System.out.println(key + "=" + System.getProperty(key.toString())); + } + } +} -- 2.30.2