From 3afd1b5cdeb8985f7253ca52552bdabce5e6847d Mon Sep 17 00:00:00 2001 From: Mathieu Baudier Date: Mon, 17 Apr 2017 17:53:52 +0200 Subject: [PATCH] Improve packaging --- demo/slc_localrepo.properties | 4 +- dist/slc/pom.xml | 63 +++++++++----- dist/slc/{src/main => }/rpm/etc/init.d/slc | 0 .../{src/main => }/rpm/etc/slc-cl/config.ini | 0 .../main => }/rpm/etc/slc-cl/log4j.properties | 0 .../slc/{src/main => }/rpm/etc/slc/config.ini | 0 .../main => }/rpm/etc/slc/log4j.properties | 0 .../slc/{src/main => rpm}/scripts/postinstall | 0 dist/slc/{src/main => rpm}/scripts/preinstall | 0 dist/slc/{src/main => rpm}/scripts/preremove | 0 dist/slc/{src/main => }/rpm/usr/bin/slc | 6 +- .../rpm/usr/lib/systemd/system/slcd.service | 12 +++ dist/slc/rpm/usr/sbin/slcd | 27 ++++++ .../src/main/rpm/var/lib/slc/.m2/settings.xml | 47 ---------- .../src/org/argeo/slc/cli/SlcMain.java | 87 +++++++++---------- pom.xml | 2 +- 16 files changed, 129 insertions(+), 119 deletions(-) rename dist/slc/{src/main => }/rpm/etc/init.d/slc (100%) rename dist/slc/{src/main => }/rpm/etc/slc-cl/config.ini (100%) rename dist/slc/{src/main => }/rpm/etc/slc-cl/log4j.properties (100%) rename dist/slc/{src/main => }/rpm/etc/slc/config.ini (100%) rename dist/slc/{src/main => }/rpm/etc/slc/log4j.properties (100%) rename dist/slc/{src/main => rpm}/scripts/postinstall (100%) rename dist/slc/{src/main => rpm}/scripts/preinstall (100%) rename dist/slc/{src/main => rpm}/scripts/preremove (100%) rename dist/slc/{src/main => }/rpm/usr/bin/slc (83%) create mode 100644 dist/slc/rpm/usr/lib/systemd/system/slcd.service create mode 100644 dist/slc/rpm/usr/sbin/slcd delete mode 100644 dist/slc/src/main/rpm/var/lib/slc/.m2/settings.xml diff --git a/demo/slc_localrepo.properties b/demo/slc_localrepo.properties index bf1314eef..9e34647a0 100644 --- a/demo/slc_localrepo.properties +++ b/demo/slc_localrepo.properties @@ -23,8 +23,10 @@ org.argeo.tp.factory.extras,\ org.argeo.tp.factory.rcp argeo.node.repo.type=localfs +argeo.node.useradmin.uris=ipa:/// -org.osgi.framework.security=osgi +#org.osgi.framework.security=osgi +java.security.manager= java.security.policy=file:../../all.policy org.osgi.service.http.port=7080 diff --git a/dist/slc/pom.xml b/dist/slc/pom.xml index b96cf8124..938b3503e 100644 --- a/dist/slc/pom.xml +++ b/dist/slc/pom.xml @@ -136,10 +136,34 @@ false - src/main/rpm/usr/bin + rpm/usr/bin + + + + + + + + + + + + + + + + + + + + + + + + /etc/init.d root @@ -148,7 +172,7 @@ false - src/main/rpm/etc/init.d + rpm/etc/init.d @@ -161,7 +185,7 @@ false - src/main/rpm/etc/slc + rpm/etc/slc @@ -173,7 +197,7 @@ false - src/main/rpm/etc/slc-cl + rpm/etc/slc-cl @@ -193,33 +217,32 @@ - - /var/lib/slc/.m2 - slc - slc - 600 - false - - - src/main/rpm/var/lib/slc/.m2 - - - + + + + + + + + + + + + - src/main/scripts/preinstall + rpm/scripts/preinstall - src/main/scripts/postinstall + rpm/scripts/postinstall - src/main/scripts/preremove + rpm/scripts/preremove slc-platform osgi-boot - diff --git a/dist/slc/src/main/rpm/etc/init.d/slc b/dist/slc/rpm/etc/init.d/slc similarity index 100% rename from dist/slc/src/main/rpm/etc/init.d/slc rename to dist/slc/rpm/etc/init.d/slc diff --git a/dist/slc/src/main/rpm/etc/slc-cl/config.ini b/dist/slc/rpm/etc/slc-cl/config.ini similarity index 100% rename from dist/slc/src/main/rpm/etc/slc-cl/config.ini rename to dist/slc/rpm/etc/slc-cl/config.ini diff --git a/dist/slc/src/main/rpm/etc/slc-cl/log4j.properties b/dist/slc/rpm/etc/slc-cl/log4j.properties similarity index 100% rename from dist/slc/src/main/rpm/etc/slc-cl/log4j.properties rename to dist/slc/rpm/etc/slc-cl/log4j.properties diff --git a/dist/slc/src/main/rpm/etc/slc/config.ini b/dist/slc/rpm/etc/slc/config.ini similarity index 100% rename from dist/slc/src/main/rpm/etc/slc/config.ini rename to dist/slc/rpm/etc/slc/config.ini diff --git a/dist/slc/src/main/rpm/etc/slc/log4j.properties b/dist/slc/rpm/etc/slc/log4j.properties similarity index 100% rename from dist/slc/src/main/rpm/etc/slc/log4j.properties rename to dist/slc/rpm/etc/slc/log4j.properties diff --git a/dist/slc/src/main/scripts/postinstall b/dist/slc/rpm/scripts/postinstall similarity index 100% rename from dist/slc/src/main/scripts/postinstall rename to dist/slc/rpm/scripts/postinstall diff --git a/dist/slc/src/main/scripts/preinstall b/dist/slc/rpm/scripts/preinstall similarity index 100% rename from dist/slc/src/main/scripts/preinstall rename to dist/slc/rpm/scripts/preinstall diff --git a/dist/slc/src/main/scripts/preremove b/dist/slc/rpm/scripts/preremove similarity index 100% rename from dist/slc/src/main/scripts/preremove rename to dist/slc/rpm/scripts/preremove diff --git a/dist/slc/src/main/rpm/usr/bin/slc b/dist/slc/rpm/usr/bin/slc similarity index 83% rename from dist/slc/src/main/rpm/usr/bin/slc rename to dist/slc/rpm/usr/bin/slc index 2ffee589f..706b4fa4b 100644 --- a/dist/slc/src/main/rpm/usr/bin/slc +++ b/dist/slc/rpm/usr/bin/slc @@ -1,7 +1,7 @@ #!/bin/sh -JAVA_CMD=/usr/lib/jvm/java-1.8.0/bin/java -JAVA_OPTS="-client -Xmx256m" +JAVA_CMD=java +JAVA_OPTS="-client -Xmx128m" SLC_HOME_DIR=${HOME}/.local/share/slc/ if [ -f $SLC_HOME_DIR/settings.sh ];then @@ -19,7 +19,7 @@ for i in "${OSGI_INSTALL_AREA}"/*.jar $JAVA_CMD $JAVA_OPTS \ "-Dargeo.osgi.bundles=$ARGEO_OSGI_BUNDLES" \ - -Dorg.osgi.framework.security=osgi \ + -Djava.security.manager= \ -Djava.security.policy="file:/etc/osgiboot/all.policy" \ -cp "$CLASSPATH" \ org.argeo.slc.cli.SlcMain "$@" diff --git a/dist/slc/rpm/usr/lib/systemd/system/slcd.service b/dist/slc/rpm/usr/lib/systemd/system/slcd.service new file mode 100644 index 000000000..e74808956 --- /dev/null +++ b/dist/slc/rpm/usr/lib/systemd/system/slcd.service @@ -0,0 +1,12 @@ +[Unit] +Description=Argeo SLC daemon +After=network.target + +[Service] +ExecStart=/usr/sbin/slcd start +ExecStop=/usr/sbin/slcd stop +Type=forking +PIDFile=/var/run/slcd.pid + +[Install] +WantedBy=default.target \ No newline at end of file diff --git a/dist/slc/rpm/usr/sbin/slcd b/dist/slc/rpm/usr/sbin/slcd new file mode 100644 index 000000000..d9561083b --- /dev/null +++ b/dist/slc/rpm/usr/sbin/slcd @@ -0,0 +1,27 @@ +#!/bin/bash + +. /etc/osgiboot/osgi-service-init-functions.sh + +APP=slc + +case "$1" in + start) + osgi_service_start $APP + ;; + stop) + osgi_service_stop $APP + ;; + restart) + osgi_service_stop $APP + osgi_service_start $APP + RETVAL=$? + ;; + status) + osgi_service_status $APP + ;; + *) + echo $"Usage: $0 {start|stop|restart|status}" + exit 1 +esac + +exit $RETVAL diff --git a/dist/slc/src/main/rpm/var/lib/slc/.m2/settings.xml b/dist/slc/src/main/rpm/var/lib/slc/.m2/settings.xml deleted file mode 100644 index 270f6239b..000000000 --- a/dist/slc/src/main/rpm/var/lib/slc/.m2/settings.xml +++ /dev/null @@ -1,47 +0,0 @@ - - - - - slc-repo - SLC Repository - http://localhost:7080/org.argeo.slc.repo.webapp/maven - * - - - - - slc-repo - root - demo - - - localrepo - root - demo - - - localrepo.snapshots - root - demo - - - - diff --git a/org.argeo.slc.launcher/src/org/argeo/slc/cli/SlcMain.java b/org.argeo.slc.launcher/src/org/argeo/slc/cli/SlcMain.java index d7bd977f7..a4bf3cd65 100644 --- a/org.argeo.slc.launcher/src/org/argeo/slc/cli/SlcMain.java +++ b/org.argeo.slc.launcher/src/org/argeo/slc/cli/SlcMain.java @@ -72,14 +72,21 @@ public class SlcMain implements PrivilegedAction { this.confDir = confDir; this.dataDir = dataDir; this.modulesDir = modulesDir; - bundlesToStart.add("org.springframework.osgi.extender"); - bundlesToStart.add("org.argeo.node.repo.jackrabbit"); - bundlesToStart.add("org.argeo.security.dao.os"); - bundlesToStart.add("org.argeo.slc.node.jackrabbit"); + + bundlesToStart.add("org.eclipse.equinox.cm"); + bundlesToStart.add("org.argeo.cms"); + bundlesToStart.add("org.eclipse.gemini.blueprint.extender"); bundlesToStart.add("org.argeo.slc.agent"); bundlesToStart.add("org.argeo.slc.agent.jcr"); - if (args.length == 0) - bundlesToStart.add("org.argeo.slc.support.equinox"); + + // bundlesToStart.add("org.springframework.osgi.extender"); + // bundlesToStart.add("org.argeo.node.repo.jackrabbit"); + // bundlesToStart.add("org.argeo.security.dao.os"); + // bundlesToStart.add("org.argeo.slc.node.jackrabbit"); + // bundlesToStart.add("org.argeo.slc.agent"); + // bundlesToStart.add("org.argeo.slc.agent.jcr"); + // if (args.length == 0) + // bundlesToStart.add("org.argeo.slc.support.equinox"); // bundlesToStart.add("org.argeo.slc.agent.cli"); } @@ -92,12 +99,10 @@ public class SlcMain implements PrivilegedAction { info("## Data : " + dataDir.getCanonicalPath()); // Start Equinox - ServiceLoader ff = ServiceLoader - .load(FrameworkFactory.class); + ServiceLoader ff = ServiceLoader.load(FrameworkFactory.class); FrameworkFactory frameworkFactory = ff.iterator().next(); Map configuration = new HashMap(); - configuration.put("osgi.configuration.area", - confDir.getCanonicalPath()); + configuration.put("osgi.configuration.area", confDir.getCanonicalPath()); configuration.put("osgi.instance.area", dataDir.getCanonicalPath()); // Do clean configuration.put("osgi.clean", "true"); @@ -117,16 +122,13 @@ public class SlcMain implements PrivilegedAction { // working copy modules if (modulesDir.exists()) - osgiBoot.installUrls(osgiBoot.getBundlesUrls(modulesDir - .getCanonicalPath() + ";in=*;ex=.gitignore")); + osgiBoot.installUrls(osgiBoot.getBundlesUrls(modulesDir.getCanonicalPath() + ";in=*;ex=.gitignore")); // system modules if (System.getProperty(OsgiBoot.PROP_ARGEO_OSGI_BUNDLES) != null) - osgiBoot.installUrls(osgiBoot.getBundlesUrls(System - .getProperty(OsgiBoot.PROP_ARGEO_OSGI_BUNDLES))); + osgiBoot.installUrls(osgiBoot.getBundlesUrls(System.getProperty(OsgiBoot.PROP_ARGEO_OSGI_BUNDLES))); else - osgiBoot.installUrls(osgiBoot.getBundlesUrls(System - .getProperty("user.home") + "/.slc/modules/;in=**")); + osgiBoot.installUrls(osgiBoot.getBundlesUrls(System.getProperty("user.home") + "/.slc/modules/;in=**")); // Start runtime osgiBoot.startBundles(bundlesToStart); @@ -134,8 +136,7 @@ public class SlcMain implements PrivilegedAction { // Find SLC Agent ServiceReference sr = null; while (sr == null) { - sr = bundleContext - .getServiceReference("org.argeo.slc.execution.SlcAgentCli"); + sr = bundleContext.getServiceReference("org.argeo.slc.execution.SlcAgentCli"); if (System.currentTimeMillis() - begin > timeout) throw new RuntimeException("Cannot find SLC agent CLI"); Thread.sleep(100); @@ -144,8 +145,7 @@ public class SlcMain implements PrivilegedAction { // Initialization completed long duration = System.currentTimeMillis() - begin; - info("[[ Initialized in " + (duration / 1000) + "s " - + (duration % 1000) + "ms ]]"); + info("[[ Initialized in " + (duration / 1000) + "s " + (duration % 1000) + "ms ]]"); if (args.length == 0) return null;// console mode @@ -153,8 +153,7 @@ public class SlcMain implements PrivilegedAction { // Subject.doAs(Subject.getSubject(AccessController.getContext()), // new AgentCliCall(agentCli)); Class[] parameterTypes = { String[].class }; - Method method = agentCli.getClass().getMethod("process", - parameterTypes); + Method method = agentCli.getClass().getMethod("process", parameterTypes); Object[] methodArgs = { args }; Object ret = method.invoke(agentCli, methodArgs); @@ -184,13 +183,10 @@ public class SlcMain implements PrivilegedAction { File slcDir; Boolean isTransient = false; if (isTransient) { - File tempDir = new File(System.getProperty("java.io.tmpdir") - + "/" + System.getProperty("user.name")); - slcDir = new File(tempDir, "slc-" - + UUID.randomUUID().toString()); + File tempDir = new File(System.getProperty("java.io.tmpdir") + "/" + System.getProperty("user.name")); + slcDir = new File(tempDir, "slc-" + UUID.randomUUID().toString()); slcDir.mkdirs(); - System.setProperty("argeo.node.repo.configuration", - "osgibundle:repository-memory.xml"); + System.setProperty("argeo.node.repo.configuration", "osgibundle:repository-memory.xml"); } else { slcDir = findSlcDir(executionDir); if (slcDir == null) { @@ -211,28 +207,27 @@ public class SlcMain implements PrivilegedAction { File modulesDir = new File(slcDir, "modules"); // JAAS -// File jaasFile = new File(confDir, "jaas.config"); -// if (!jaasFile.exists()) -// copyResource("/org/argeo/slc/cli/jaas.config", jaasFile); -// System.setProperty("java.security.auth.login.config", -// jaasFile.getCanonicalPath()); + // File jaasFile = new File(confDir, "jaas.config"); + // if (!jaasFile.exists()) + // copyResource("/org/argeo/slc/cli/jaas.config", jaasFile); + // System.setProperty("java.security.auth.login.config", + // jaasFile.getCanonicalPath()); // log4j File log4jFile = new File(confDir, "log4j.properties"); if (!log4jFile.exists()) copyResource("/org/argeo/slc/cli/log4j.properties", log4jFile); - System.setProperty("log4j.configuration", - "file://" + log4jFile.getCanonicalPath()); + System.setProperty("log4j.configuration", "file://" + log4jFile.getCanonicalPath()); // Run as a privileged action -// LoginContext lc = new LoginContext(os); -// lc.login(); -// -// Subject subject = Subject.getSubject(AccessController.getContext()); -// Subject.doAs(subject, new SlcMain(args, confDir, dataDir, -// modulesDir)); -SlcMain slcMain = new SlcMain(args, confDir, dataDir, - modulesDir); -slcMain.run(); + // LoginContext lc = new LoginContext(os); + // lc.login(); + // + // Subject subject = + // Subject.getSubject(AccessController.getContext()); + // Subject.doAs(subject, new SlcMain(args, confDir, dataDir, + // modulesDir)); + SlcMain slcMain = new SlcMain(args, confDir, dataDir, modulesDir); + slcMain.run(); if (args.length != 0) System.exit(0); } catch (Exception e) { @@ -277,8 +272,7 @@ slcMain.run(); output.write(buf, 0, length); } } catch (Exception e) { - throw new RuntimeException("Cannot write " + resource + " file to " - + targetFile, e); + throw new RuntimeException("Cannot write " + resource + " file to " + targetFile, e); } finally { try { input.close(); @@ -342,4 +336,3 @@ slcMain.run(); // } // // } - diff --git a/pom.xml b/pom.xml index 1a61a0576..1c1e23b69 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ org.argeo.commons argeo-commons - 2.1.69-SNAPSHOT + 2.1.69 org.argeo.slc argeo-slc -- 2.39.2