From bf345b84989cc9a2984bba4390ebdb349701ed8e Mon Sep 17 00:00:00 2001 From: mbaudier Date: Mon, 6 Nov 2017 16:27:32 +0100 Subject: [PATCH] Improve node RPM packaging --- demo/argeo_node_rap.properties | 2 +- dist/argeo-node/pom.xml | 35 ++++++++++++++++- .../rpm/etc/node/conf.d/app-template.txt | 7 ++++ dist/argeo-node/rpm/etc/node/node.ini | 22 +++++++++++ dist/argeo-node/rpm/etc/node/settings.sh | 3 ++ dist/argeo-node/rpm/usr/sbin/nodectl | 39 +++++++++---------- .../node.policy => usr/share/node/all.policy} | 0 .../rpm/{etc => usr/share}/node/config.ini | 26 +++++++------ 8 files changed, 99 insertions(+), 35 deletions(-) create mode 100644 dist/argeo-node/rpm/etc/node/conf.d/app-template.txt create mode 100644 dist/argeo-node/rpm/etc/node/node.ini create mode 100644 dist/argeo-node/rpm/etc/node/settings.sh rename dist/argeo-node/rpm/{etc/node/node.policy => usr/share/node/all.policy} (100%) rename dist/argeo-node/rpm/{etc => usr/share}/node/config.ini (69%) diff --git a/demo/argeo_node_rap.properties b/demo/argeo_node_rap.properties index 5255b320a..d7149b966 100644 --- a/demo/argeo_node_rap.properties +++ b/demo/argeo_node_rap.properties @@ -21,7 +21,7 @@ org.eclipse.equinox.http.registry,\ java.security.manager= java.security.policy=file:../../all.policy -argeo.node.repo.type=localfs +argeo.node.repo.type=h2 #argeo.node.useradmin.uris=ldap://uid=admin,ou=system:secret@localhost:10389/dc=example,dc=com #argeo.node.useradmin.uris=ldap://uid=admin,ou=system:secret@localhost:10389\ diff --git a/dist/argeo-node/pom.xml b/dist/argeo-node/pom.xml index da4e22949..ecb37395e 100644 --- a/dist/argeo-node/pom.xml +++ b/dist/argeo-node/pom.xml @@ -40,6 +40,23 @@ + + /etc/node/conf.d + root + node + 640 + noreplace + false + + + rpm/etc/node/conf.d + + *.ini + *.txt + + + + /usr/lib/systemd/system root @@ -55,6 +72,22 @@ + + /usr/share/node + root + root + 644 + false + + + rpm/usr/share/node + + config.ini + all.policy + + + + /usr/sbin root @@ -75,7 +108,7 @@ rpm/scripts/preinstall - + argeo-cms-node osgi-boot diff --git a/dist/argeo-node/rpm/etc/node/conf.d/app-template.txt b/dist/argeo-node/rpm/etc/node/conf.d/app-template.txt new file mode 100644 index 000000000..02aac6a82 --- /dev/null +++ b/dist/argeo-node/rpm/etc/node/conf.d/app-template.txt @@ -0,0 +1,7 @@ +# Rename to .ini + +# Backend +#argeo.osgi.start.5.apps=org.argeo.suite.apps + +# UI +#argeo.osgi.start.6.apps=org.argeo.suite.apps.web,org.argeo.suite.workbench.rap diff --git a/dist/argeo-node/rpm/etc/node/node.ini b/dist/argeo-node/rpm/etc/node/node.ini new file mode 100644 index 000000000..f150c4df9 --- /dev/null +++ b/dist/argeo-node/rpm/etc/node/node.ini @@ -0,0 +1,22 @@ +## HTTP server +org.osgi.service.http.port=8080 + +## System management +osgi.console=2323 + +## Standalone +#argeo.node.useradmin.uris=dc=example,dc=com.ldif +#argeo.node.repo.type=h2 + +## Deployed +#argeo.node.useradmin.uris=ldap://cn=Directory%20Manager:argeoargeo@localhost/dc=example,dc=com +#argeo.node.repo.type=postgresql +#argeo.node.repo.dburl=jdbc:postgresql://localhost/node +#argeo.node.repo.dbuser=argeo +#argeo.node.repo.dbpassword=argeo + +## Complex user configuration examples +#argeo.node.useradmin.uris="dc=example,dc=com.ldif dc=example,dc=org.ldif" +#argeo.node.useradmin.uris="ldap://uid=admin,ou=system:secret@localhost:10389\ +#/dc=example,dc=com?userBase=ou=users&groupBase=ou=groups dc=example,dc=org.ldif" + diff --git a/dist/argeo-node/rpm/etc/node/settings.sh b/dist/argeo-node/rpm/etc/node/settings.sh new file mode 100644 index 000000000..8141f0495 --- /dev/null +++ b/dist/argeo-node/rpm/etc/node/settings.sh @@ -0,0 +1,3 @@ +export LANG=en_US.utf8 +JAVA_OPTS="-showversion -Xmx128m" +#JAVA_OPTS="-showversion -Xmx512m -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=7084 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false" diff --git a/dist/argeo-node/rpm/usr/sbin/nodectl b/dist/argeo-node/rpm/usr/sbin/nodectl index 26fe3eeaf..fb1b5802a 100755 --- a/dist/argeo-node/rpm/usr/sbin/nodectl +++ b/dist/argeo-node/rpm/usr/sbin/nodectl @@ -5,16 +5,19 @@ JVM=java # Directories and files CONF_DIR=/etc/$APP +CONF_DIRS=/etc/$APP/conf.d +BASE_POLICY_ALL=/usr/share/$APP/all.policy +BASE_CONFIG_INI=/usr/share/$APP/config.ini EXEC_DIR=/var/lib/$APP DATA_DIR=$EXEC_DIR/data CONF_RW=$EXEC_DIR/state +CONFIG_INI=$CONF_RW/config.ini LOG_DIR=/var/log/$APP LOG_FILE=$LOG_DIR/$APP.log RUN_DIR=/var/run/$APP PID_FILE=$RUN_DIR/$APP.pid -#SHUTDOWN_FILE=$RUN_DIR/$APP.shutdown OSGI_INSTALL_AREA=/usr/share/osgi/boot OSGI_FRAMEWORK=$OSGI_INSTALL_AREA/org.eclipse.osgi.jar @@ -27,29 +30,22 @@ fi RETVAL=0 start() { - if [ -f $PID_FILE ];then - PID=`cat $PID_FILE` - kill -0 $PID &> /dev/null - PID_EXISTS=$? - if [ $PID_EXISTS -eq 0 ]; then - echo $APP already running with pid $PID - RETVAL=1 - return $RETVAL - else - echo Old $APP process with pid $PID is dead, removing $PID_FILE - rm -f $PID_FILE - fi - fi + mkdir -p $CONF_RW + mkdir -p $DATA_DIR + chown -R $APP.APP $EXEC_DIR + + # Merge config files + echo ## Equinox configuration - Generated by /usr/sbin/nodectl > $CONFIG_INI + cat $BASE_CONFIG_INI >> $CONFIG_INI + cat $CONF_DIR/$APP.ini >> $CONFIG_INI + for file in `ls -v $CONF_DIRS/*.ini`; do + echo "\n# $file\n" >> $CONFIG_INI; + cat $file >> $CONFIG_INI + done; -# if [ ! -f $CONF_RW/config.ini ]; then - cp --preserve $CONF_DIR/config.ini $CONF_RW/config.ini -# fi -# touch $SHUTDOWN_FILE cd $EXEC_DIR $JVM \ -Dlog4j.configuration="file:$CONF_DIR/log4j.properties" \ - -Djava.security.manager= \ - -Djava.security.policy="file:$CONF_DIR/node.policy" \ $JAVA_OPTS -jar $OSGI_FRAMEWORK \ -configuration "$CONF_RW" \ -data "$DATA_DIR" @@ -77,7 +73,8 @@ stop() { fi # notifies application by removing the shutdown file - rm -f $SHUTDOWN_FILE +# rm -f $SHUTDOWN_FILE + kill $PID # wait 10 min for application to shutdown, then kill it TIMEOUT=$((10*60)) diff --git a/dist/argeo-node/rpm/etc/node/node.policy b/dist/argeo-node/rpm/usr/share/node/all.policy similarity index 100% rename from dist/argeo-node/rpm/etc/node/node.policy rename to dist/argeo-node/rpm/usr/share/node/all.policy diff --git a/dist/argeo-node/rpm/etc/node/config.ini b/dist/argeo-node/rpm/usr/share/node/config.ini similarity index 69% rename from dist/argeo-node/rpm/etc/node/config.ini rename to dist/argeo-node/rpm/usr/share/node/config.ini index ec75a4f7a..5c54d84e1 100644 --- a/dist/argeo-node/rpm/etc/node/config.ini +++ b/dist/argeo-node/rpm/usr/share/node/config.ini @@ -1,20 +1,14 @@ -argeo.node.repo.type=h2 -org.osgi.service.http.port=8080 -osgi.console=2323 - -# Backend -#argeo.osgi.start.5.apps=org.argeo.suite.apps - -# UI -#argeo.osgi.start.6.apps=org.argeo.suite.apps.web,org.argeo.suite.workbench.rap - -# DO NOT CHANGE BELOW UNLESS YOU KNOW WHAT YOU ARE DOING -osgi.clean=true +# Only Argeo OSGi Boot is explicitly started osgi.bundles=org.argeo.osgi.boot.jar@start +osgi.clean=true + +# Provisioning argeo.osgi.bundles=\ +/etc/node/modules;in=*/*,\ /usr/local/share/osgi;in=**/*.jar,\ /usr/share/osgi;in=**/*.jar +# Required standard bundles to start argeo.osgi.start.2.node=\ org.eclipse.equinox.http.servlet,\ org.eclipse.equinox.http.jetty,\ @@ -22,13 +16,16 @@ org.eclipse.equinox.metatype,\ org.eclipse.equinox.cm,\ org.eclipse.rap.rwt.osgi +# Required CMS bundles to start argeo.osgi.start.3.node=\ org.argeo.cms +# Extension managers argeo.osgi.start.4.node=\ org.eclipse.gemini.blueprint.extender,\ org.eclipse.equinox.http.registry +# Packages provided by the OpenJDK JVM org.osgi.framework.bootdelegation=com.sun.jndi.ldap,\ com.sun.jndi.ldap.sasl,\ com.sun.security.jgss,\ @@ -36,6 +33,11 @@ com.sun.jndi.dns,\ com.sun.nio.file,\ com.sun.nio.sctp +# Security manager +java.security.manager= +java.security.policy=file:/usr/share/node/all.policy + +# Required properties eclipse.ignoreApp=true osgi.noShutdown=true org.eclipse.equinox.http.jetty.autostart=false -- 2.30.2