From 33407a2ae669ebafd67ca7348d52abfd44e45c09 Mon Sep 17 00:00:00 2001 From: Mathieu Baudier Date: Wed, 25 Mar 2020 06:04:39 +0100 Subject: [PATCH] Replace old scripts with JShell. --- dist/argeo-node/base/bin/argeo-cms | 4 +- dist/argeo-node/base/bin/argeo-cms.js | 6 - dist/argeo-node/base/bin/argeo-cms.jsh | 9 + .../base/etc/argeo/conf.d/app-template.txt | 2 +- dist/argeo-node/base/share/argeo/cms.js | 44 ----- dist/argeo-node/base/share/argeo/cms.jsh | 27 +++ dist/argeo-node/base/share/argeo/config.ini | 5 - dist/argeo-node/pom.xml | 18 +- dist/argeo-node/rpm/scripts/preinstall | 15 -- dist/argeo-node/rpm/usr/share/node/all.policy | 3 - dist/argeo-node/rpm/usr/share/node/config.ini | 38 ----- dist/argeo-node/rpm/usr/share/node/jjs/cms.js | 46 ----- dist/osgi-boot/base/bin/{a2jjs => a2sh} | 2 +- dist/osgi-boot/pom.xml | 49 +----- .../rpm/usr/bin/a2jjs => rpm/usr/bin/a2sh} | 2 +- .../src/main/rpm/etc/osgiboot/all.policy | 3 - .../osgiboot/osgi-service-init-functions.sh | 59 ------- .../rpm/etc/osgiboot/osgi-service-settings.sh | 1 - .../src/main/rpm/usr/sbin/osgi-service | 160 ------------------ 19 files changed, 56 insertions(+), 437 deletions(-) delete mode 100644 dist/argeo-node/base/bin/argeo-cms.js create mode 100644 dist/argeo-node/base/bin/argeo-cms.jsh delete mode 100755 dist/argeo-node/base/share/argeo/cms.js create mode 100755 dist/argeo-node/base/share/argeo/cms.jsh delete mode 100644 dist/argeo-node/rpm/scripts/preinstall delete mode 100644 dist/argeo-node/rpm/usr/share/node/all.policy delete mode 100644 dist/argeo-node/rpm/usr/share/node/config.ini delete mode 100755 dist/argeo-node/rpm/usr/share/node/jjs/cms.js rename dist/osgi-boot/base/bin/{a2jjs => a2sh} (73%) rename dist/osgi-boot/{src/main/rpm/usr/bin/a2jjs => rpm/usr/bin/a2sh} (80%) delete mode 100644 dist/osgi-boot/src/main/rpm/etc/osgiboot/all.policy delete mode 100644 dist/osgi-boot/src/main/rpm/etc/osgiboot/osgi-service-init-functions.sh delete mode 100644 dist/osgi-boot/src/main/rpm/etc/osgiboot/osgi-service-settings.sh delete mode 100644 dist/osgi-boot/src/main/rpm/usr/sbin/osgi-service diff --git a/dist/argeo-node/base/bin/argeo-cms b/dist/argeo-node/base/bin/argeo-cms index a1701a3ba..d93d89984 100755 --- a/dist/argeo-node/base/bin/argeo-cms +++ b/dist/argeo-node/base/bin/argeo-cms @@ -9,10 +9,8 @@ BASE_DIR=$BIN_DIR/.. # Directories and files CONF_DIR=$BASE_DIR/etc/$APP CONF_DIRS=$CONF_DIR/conf.d -#BASE_POLICY_ALL=/usr/share/$APP/all.policy BASE_CONFIG_INI=$BASE_DIR/share/$APP/config.ini -#EXEC_DIR=$BASE_DIR/var/lib/$APP EXEC_DIR=. DATA_DIR=$EXEC_DIR/data CONF_RW=$EXEC_DIR/state @@ -33,7 +31,7 @@ start() { mkdir -p $DATA_DIR # Merge config files - printf "## Equinox configuration - Generated by /usr/sbin/nodectl ##\n\n" > $CONFIG_INI + printf "## Equinox configuration - Generated by argeo-cms ##\n\n" > $CONFIG_INI cat $BASE_CONFIG_INI >> $CONFIG_INI printf "\n##\n## $CONF_DIR/$APP.ini\n##\n\n" >> $CONFIG_INI cat $CONF_DIR/$APP.ini >> $CONFIG_INI diff --git a/dist/argeo-node/base/bin/argeo-cms.js b/dist/argeo-node/base/bin/argeo-cms.js deleted file mode 100644 index 01a12d714..000000000 --- a/dist/argeo-node/base/bin/argeo-cms.js +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/a2jjs -load("share/argeo/cms.js"); -osgi.httpPort = 8080; -//osgi.conf("argeo.node.useradmin.uris", "os:///"); -//osgi.clean = true; -osgi.launch(); diff --git a/dist/argeo-node/base/bin/argeo-cms.jsh b/dist/argeo-node/base/bin/argeo-cms.jsh new file mode 100644 index 000000000..b2212402c --- /dev/null +++ b/dist/argeo-node/base/bin/argeo-cms.jsh @@ -0,0 +1,9 @@ +// Run from base directory with: +// ./bin/a2sh --startup ./share/argeo/cms.jsh ./bin/argeo-cms.jsh + +osgi.setHttpPort(7080); +osgi.conf("argeo.node.useradmin.uris", "os:///"); +osgi.setClean(true); + +// LAUNCH +osgi.launch(); \ No newline at end of file diff --git a/dist/argeo-node/base/etc/argeo/conf.d/app-template.txt b/dist/argeo-node/base/etc/argeo/conf.d/app-template.txt index 02aac6a82..89d582de5 100644 --- a/dist/argeo-node/base/etc/argeo/conf.d/app-template.txt +++ b/dist/argeo-node/base/etc/argeo/conf.d/app-template.txt @@ -4,4 +4,4 @@ #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 +#argeo.osgi.start.6.apps=org.argeo.suite.apps.web,org.argeo.suite.e4.rap diff --git a/dist/argeo-node/base/share/argeo/cms.js b/dist/argeo-node/base/share/argeo/cms.js deleted file mode 100755 index 75353779d..000000000 --- a/dist/argeo-node/base/share/argeo/cms.js +++ /dev/null @@ -1,44 +0,0 @@ -var System = Java.type("java.lang.System"); -var OsgiBuilder = Java.type("org.argeo.osgi.boot.OsgiBuilder"); - -var osgi = new OsgiBuilder(); -// default bundles -osgi.start(2, "org.eclipse.equinox.http.servlet"); -osgi.start(2, "org.eclipse.equinox.http.jetty"); -osgi.start(2, "org.eclipse.equinox.metatype"); -osgi.start(2, "org.eclipse.equinox.cm"); -osgi.start(2, "org.eclipse.equinox.ds"); -osgi.start(2, "org.eclipse.rap.rwt.osgi"); -osgi.start(3, "org.argeo.cms"); -osgi.start(4, "org.argeo.cms.e4.rap"); -// specific properties -osgi.conf("org.eclipse.rap.workbenchAutostart", "false"); -osgi.conf("org.eclipse.equinox.http.jetty.autostart", "false"); -osgi.conf("org.osgi.framework.bootdelegation", "com.sun.jndi.ldap," - + "com.sun.jndi.ldap.sasl," + "com.sun.security.jgss," - + "com.sun.jndi.dns," + "com.sun.nio.file," + "com.sun.nio.sctp"); - -var homeUri = java.nio.file.Paths - .get(java.lang.System.getProperty("user.home")).toUri().toString(); -var execDirUri = java.nio.file.Paths.get( - java.lang.System.getProperty("user.dir")).toUri().toString(); -if (typeof app !== 'undefined') { - if (typeof appHome == 'undefined') { - var appHome = homeUri + "/.a2/var/lib/" + app; - } - if (typeof appConf == 'undefined') { - var appConf = homeUri + "/.a2/etc/" + app; - } - if (typeof policyFile == 'undefined') { - var policyFile = "node.policy"; - } - osgi.conf("osgi.configuration.area", appHome + "/state"); - osgi.conf("osgi.instance.area", appHome + "/data"); - // System.setProperty("java.security.manager", ""); - // System.setProperty("java.security.policy", appConf + "/" + policyFile); - System.setProperty("log4j.configuration", appConf + "/log4j.properties"); -} else { - osgi.conf("osgi.configuration.area", execDirUri + "/state"); - osgi.conf("osgi.instance.area", execDirUri + "/data"); - System.setProperty("log4j.configuration", execDirUri + "etc/argeo/log4j.properties"); -} diff --git a/dist/argeo-node/base/share/argeo/cms.jsh b/dist/argeo-node/base/share/argeo/cms.jsh new file mode 100755 index 000000000..27dd1388c --- /dev/null +++ b/dist/argeo-node/base/share/argeo/cms.jsh @@ -0,0 +1,27 @@ +import java.nio.file.*; +import org.argeo.osgi.boot.*; + +OsgiBuilder osgi = new OsgiBuilder(); + +// default bundles +osgi.start(2, "org.eclipse.equinox.http.servlet"); +osgi.start(2, "org.eclipse.equinox.metatype"); +osgi.start(2, "org.eclipse.equinox.cm"); +osgi.start(2, "org.eclipse.equinox.ds"); +osgi.start(2, "org.eclipse.rap.rwt.osgi"); +osgi.start(3, "org.argeo.cms"); +osgi.start(4, "org.argeo.cms.e4.rap"); + +// specific properties +osgi.conf("org.eclipse.rap.workbenchAutostart", "false"); +osgi.conf("org.eclipse.equinox.http.jetty.autostart", "false"); +osgi.conf("org.osgi.framework.bootdelegation", "com.sun.jndi.ldap," + + "com.sun.jndi.ldap.sasl," + "com.sun.security.jgss," + + "com.sun.jndi.dns," + "com.sun.nio.file," + "com.sun.nio.sctp"); + +String homeUri = Paths.get(System.getProperty("user.home")).toUri().toString(); +String execDirUri = Paths.get(System.getProperty("user.dir")).toUri().toString(); + +osgi.conf("osgi.configuration.area", execDirUri + "/state"); +osgi.conf("osgi.instance.area", execDirUri + "/data"); +System.setProperty("log4j.configuration", execDirUri + "etc/argeo/log4j.properties"); diff --git a/dist/argeo-node/base/share/argeo/config.ini b/dist/argeo-node/base/share/argeo/config.ini index f97810f11..e5cc050c5 100644 --- a/dist/argeo-node/base/share/argeo/config.ini +++ b/dist/argeo-node/base/share/argeo/config.ini @@ -28,15 +28,10 @@ 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 -#org.eclipse.rap.workbenchAutostart=false # Disable some warnings nashorn.option.no.deprecation.warning=true diff --git a/dist/argeo-node/pom.xml b/dist/argeo-node/pom.xml index c4e59a4e8..95998b0f0 100644 --- a/dist/argeo-node/pom.xml +++ b/dist/argeo-node/pom.xml @@ -13,11 +13,26 @@ dist + + org.argeo.commons + org.argeo.dep.cms.client + 2.1.88-SNAPSHOT + + + org.argeo.commons + org.argeo.dep.cms.node + 2.1.88-SNAPSHOT + org.argeo.commons org.argeo.dep.cms.e4.rap 2.1.88-SNAPSHOT + + org.argeo.commons + org.argeo.dep.cms.sdk + 2.1.88-SNAPSHOT + org.argeo.commons osgi-boot @@ -143,9 +158,6 @@ - - - argeo-cms-node osgi-boot diff --git a/dist/argeo-node/rpm/scripts/preinstall b/dist/argeo-node/rpm/scripts/preinstall deleted file mode 100644 index 2e4606555..000000000 --- a/dist/argeo-node/rpm/scripts/preinstall +++ /dev/null @@ -1,15 +0,0 @@ -if [ $1 = "1" ];then - APP=argeo - - # check if user exists - /bin/id $APP 2>/dev/null - if [ $? -ne 0 ];then - echo Create user $APP... - useradd --system --home-dir /var/lib/$APP --shell /bin/bash --user-group --create-home $APP - else - echo User $APP already exists - fi - - mkdir -p /var/lib/$APP/{state,data,indexes} - chown -R $APP.$APP /var/lib/$APP -fi \ No newline at end of file diff --git a/dist/argeo-node/rpm/usr/share/node/all.policy b/dist/argeo-node/rpm/usr/share/node/all.policy deleted file mode 100644 index facb61327..000000000 --- a/dist/argeo-node/rpm/usr/share/node/all.policy +++ /dev/null @@ -1,3 +0,0 @@ -grant { - permission java.security.AllPermission; -}; \ No newline at end of file diff --git a/dist/argeo-node/rpm/usr/share/node/config.ini b/dist/argeo-node/rpm/usr/share/node/config.ini deleted file mode 100644 index ae7a66494..000000000 --- a/dist/argeo-node/rpm/usr/share/node/config.ini +++ /dev/null @@ -1,38 +0,0 @@ -# Only Argeo OSGi Boot is explicitly started -osgi.bundles=org.argeo.osgi.boot@start - -# Required standard bundles to start -argeo.osgi.start.2.node=\ -org.eclipse.equinox.http.servlet,\ -org.eclipse.equinox.http.jetty,\ -org.eclipse.equinox.metatype,\ -org.eclipse.equinox.cm,\ -org.eclipse.equinox.ds,\ -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.argeo.cms.e4.rap - -# Packages provided by the OpenJDK JVM -org.osgi.framework.bootdelegation=com.sun.jndi.ldap,\ -com.sun.jndi.ldap.sasl,\ -com.sun.security.jgss,\ -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 -org.eclipse.rap.workbenchAutostart=false diff --git a/dist/argeo-node/rpm/usr/share/node/jjs/cms.js b/dist/argeo-node/rpm/usr/share/node/jjs/cms.js deleted file mode 100755 index 446747f55..000000000 --- a/dist/argeo-node/rpm/usr/share/node/jjs/cms.js +++ /dev/null @@ -1,46 +0,0 @@ -var System = Java.type("java.lang.System"); -var OsgiBuilder = Java.type("org.argeo.osgi.boot.OsgiBuilder"); - -var osgi = new OsgiBuilder(); -// default bundles -osgi.start(2, "org.eclipse.equinox.http.servlet"); -osgi.start(2, "org.eclipse.equinox.http.jetty"); -osgi.start(2, "org.eclipse.equinox.metatype"); -osgi.start(2, "org.eclipse.equinox.cm"); -osgi.start(2, "org.eclipse.rap.rwt.osgi"); -osgi.start(3, "org.argeo.cms"); -osgi.start(4, "org.eclipse.gemini.blueprint.extender"); -osgi.start(4, "org.eclipse.equinox.http.registry"); -// specific properties -osgi.conf("org.eclipse.rap.workbenchAutostart", "false"); -osgi.conf("org.eclipse.equinox.http.jetty.autostart", "false"); -osgi.conf("org.osgi.framework.bootdelegation", "com.sun.jndi.ldap," - + "com.sun.jndi.ldap.sasl," + "com.sun.security.jgss," - + "com.sun.jndi.dns," + "com.sun.nio.file," + "com.sun.nio.sctp"); - -var homeUri = java.nio.file.Paths - .get(java.lang.System.getProperty("user.home")).toUri().toString(); -if (typeof app !== 'undefined') { - if (typeof appHome == 'undefined') { - var appHome = homeUri + "/.a2/var/lib/" + app; - } - if (typeof appConf == 'undefined') { - var appConf = homeUri + "/.a2/etc/" + app; - } - if (typeof policyFile == 'undefined') { - var policyFile = "node.policy"; - } - osgi.conf("osgi.configuration.area", appHome + "/state"); - osgi.conf("osgi.instance.area", appHome + "/data"); - System.setProperty("java.security.manager", ""); - System.setProperty("java.security.policy", appConf + "/" + policyFile); - System.setProperty("log4j.configuration", appConf + "/log4j.properties"); -} - -function openWorkbench() { - osgi.spring("org.argeo.cms.ui.workbench.rap"); - var appUrl = "http://127.0.0.1:" + osgi.httpPort + "/ui/node"; - $EXEC("chrome --app=" + appUrl); - // shutdown when the window is closed - osgi.shutdown(); -} \ No newline at end of file diff --git a/dist/osgi-boot/base/bin/a2jjs b/dist/osgi-boot/base/bin/a2sh similarity index 73% rename from dist/osgi-boot/base/bin/a2jjs rename to dist/osgi-boot/base/bin/a2sh index 128bcea35..dce546313 100755 --- a/dist/osgi-boot/base/bin/a2jjs +++ b/dist/osgi-boot/base/bin/a2sh @@ -3,4 +3,4 @@ BIN_DIR=`dirname $0` EQUINOX=$BIN_DIR/../share/osgi/boot/org.eclipse.osgi.jar OSGI_BOOT=$BIN_DIR/../share/osgi/boot/org.argeo.osgi.boot.jar -/usr/bin/jjs -cp "$EQUINOX:$OSGI_BOOT" $* +/usr/bin/jshell --class-path "$EQUINOX:$OSGI_BOOT" $* diff --git a/dist/osgi-boot/pom.xml b/dist/osgi-boot/pom.xml index ca76ea1c4..e1ef17a66 100644 --- a/dist/osgi-boot/pom.xml +++ b/dist/osgi-boot/pom.xml @@ -71,38 +71,6 @@ osgi-boot - - /etc/osgiboot - root - root - 644 - noreplace - false - - - src/main/rpm/etc/osgiboot - - *-settings.sh - - - - - - /etc/osgiboot - root - root - 644 - false - - - src/main/rpm/etc/osgiboot - - *.policy - *-functions.sh - - - - /usr/bin root @@ -111,28 +79,13 @@ false - src/main/rpm/usr/sbin + rpm/usr/bin * - - /usr/sbin - root - root - 755 - false - - - src/main/rpm/usr/sbin - - osgi-service - - - - /usr/share/osgi/boot root diff --git a/dist/osgi-boot/src/main/rpm/usr/bin/a2jjs b/dist/osgi-boot/rpm/usr/bin/a2sh similarity index 80% rename from dist/osgi-boot/src/main/rpm/usr/bin/a2jjs rename to dist/osgi-boot/rpm/usr/bin/a2sh index 62762a858..07a27eb4b 100755 --- a/dist/osgi-boot/src/main/rpm/usr/bin/a2jjs +++ b/dist/osgi-boot/rpm/usr/bin/a2sh @@ -10,4 +10,4 @@ fi EQUINOX=$PREFIX/share/osgi/boot/org.eclipse.osgi.jar OSGI_BOOT=$PREFIX/share/osgi/boot/org.argeo.osgi.boot.jar -/usr/bin/jjs -cp "$EQUINOX:$OSGI_BOOT" $* +/usr/bin/jshell --class-path "$EQUINOX:$OSGI_BOOT" $* diff --git a/dist/osgi-boot/src/main/rpm/etc/osgiboot/all.policy b/dist/osgi-boot/src/main/rpm/etc/osgiboot/all.policy deleted file mode 100644 index facb61327..000000000 --- a/dist/osgi-boot/src/main/rpm/etc/osgiboot/all.policy +++ /dev/null @@ -1,3 +0,0 @@ -grant { - permission java.security.AllPermission; -}; \ No newline at end of file diff --git a/dist/osgi-boot/src/main/rpm/etc/osgiboot/osgi-service-init-functions.sh b/dist/osgi-boot/src/main/rpm/etc/osgiboot/osgi-service-init-functions.sh deleted file mode 100644 index ba2351987..000000000 --- a/dist/osgi-boot/src/main/rpm/etc/osgiboot/osgi-service-init-functions.sh +++ /dev/null @@ -1,59 +0,0 @@ -#!/bin/bash - -# Source function library. -. /etc/rc.d/init.d/functions - -RETVAL=0 - -osgi_service_start() { - APP=$1 - # create log and run directories writable by the application user - USER=$APP - GROUP=$APP - RUN_DIR=/var/run/$APP - LOG_DIR=/var/log/$APP - if [ ! -d $LOG_DIR ];then - mkdir -m 0750 $LOG_DIR - chown -R $USER.$GROUP $LOG_DIR - fi - if [ ! -d $RUN_DIR ];then - mkdir -m 0750 $RUN_DIR - chown -R $USER.$GROUP $RUN_DIR - fi - - # call Argeo Commons OSGi utilities as the application user - daemon --user $USER /usr/sbin/osgi-service $APP start - - RETVAL=$? - #action $"Start $APP" /bin/true - if [ $RETVAL -eq 0 ];then - PID=`cat $RUN_DIR/$APP.pid` - action $"Started $APP with pid $PID" /bin/true - else - action $"Could not start $APP" /bin/false - fi - return $RETVAL -} - -osgi_service_stop() { - APP=$1 - USER=$APP - # call Argeo Commons OSGi utilities as the application user - runuser -s /bin/bash $USER -c "/usr/sbin/osgi-service $APP stop" - RETVAL=$? - if [ $RETVAL -eq 0 ];then - action $"Stopped $APP" /bin/true - else - action $"Could not stop $APP" /bin/false - fi - return $RETVAL -} - -osgi_service_status() { - APP=$1 - USER=$APP - # call Argeo Commons OSGi utilities as the application user - runuser -s /bin/bash $USER -c "/usr/sbin/osgi-service $APP status" - RETVAL=$? - return $RETVAL -} diff --git a/dist/osgi-boot/src/main/rpm/etc/osgiboot/osgi-service-settings.sh b/dist/osgi-boot/src/main/rpm/etc/osgiboot/osgi-service-settings.sh deleted file mode 100644 index f5504f811..000000000 --- a/dist/osgi-boot/src/main/rpm/etc/osgiboot/osgi-service-settings.sh +++ /dev/null @@ -1 +0,0 @@ -#JAVA_OPTS=-Xmx256m \ No newline at end of file diff --git a/dist/osgi-boot/src/main/rpm/usr/sbin/osgi-service b/dist/osgi-boot/src/main/rpm/usr/sbin/osgi-service deleted file mode 100644 index 2ce1b61c2..000000000 --- a/dist/osgi-boot/src/main/rpm/usr/sbin/osgi-service +++ /dev/null @@ -1,160 +0,0 @@ -#!/bin/sh - -JVM=java -. /etc/osgiboot/osgi-service-settings.sh - -APP=$1 - -CONF_DIR=/etc/$APP -if [ -f $CONF_DIR/settings.sh ];then - . $CONF_DIR/settings.sh -fi - -LIB_DIR=/usr/share/$APP/lib - -# read/write -EXEC_DIR=/var/lib/$APP -DATA_DIR=$EXEC_DIR/data -CONF_RW=$EXEC_DIR/conf - -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 - -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 - - if [ ! -f $CONF_RW/config.ini ]; then - #echo osgi.configuration.cascaded=true > $CONF_RW/config.ini - #echo osgi.sharedConfiguration.area=$CONF_DIR >> $CONF_RW/config.ini - #echo osgi.sharedConfiguration.area.readOnly=true >> $CONF_RW/config.ini - cp --preserve $CONF_DIR/config.ini $CONF_RW/config.ini - fi - touch $SHUTDOWN_FILE - cd $EXEC_DIR - $JVM \ - -Dargeo.osgi.shutdownFile="$SHUTDOWN_FILE" \ - -Dlog4j.configuration="file:$CONF_DIR/log4j.properties" \ - -Djava.security.manager= \ - -Djava.security.policy="file:/etc/osgiboot/all.policy" \ - $JAVA_OPTS -jar $OSGI_FRAMEWORK \ - -clean \ - -configuration "$CONF_RW" \ - -data "$DATA_DIR" \ - >> $LOG_FILE 2>&1 & - # (above) stderr redirected to stdout, then stdout to log file - # see http://tldp.org/LDP/abs/html/io-redirection.html - PID=$! - echo $PID > $PID_FILE - #echo Started $APP with pid $PID - return $RETVAL -} - -stop() { - if [ -f $PID_FILE ];then - PID=`cat $PID_FILE` - kill -0 $PID &> /dev/null - PID_EXISTS=$? - if [ $PID_EXISTS -ne 0 ]; then - echo Dead $APP process with pid $PID, removing $PID_FILE - rm -f $PID_FILE - RETVAL=1 - return $RETVAL - fi - else - echo $APP is not running - RETVAL=1 - return $RETVAL - fi - - # notifies application by removing the shutdown file - rm -f $SHUTDOWN_FILE - - # wait 5 min for application to shutdown, then kill it - TIMEOUT=$((5*60)) - BEGIN=$(date +%s) - while kill -0 $PID &> /dev/null - do - sleep 1 - NOW=$(date +%s) - DURATION=$(($NOW-$BEGIN)) - if [ $DURATION -gt $TIMEOUT ]; then - kill -9 $PID - echo Forcibly killed $APP with pid $PID - RETVAL=1 - fi - done - - # remove pid file - rm -f $PID_FILE - return $RETVAL - -# timeout is only available in EL6 -# timeout 5m sh << EOF -#while kill -0 $PID &> /dev/null; do sleep 1; done -#EOF -# TIMEOUT_EXIT=$? -# if [ $TIMEOUT_EXIT -eq 124 ];then -# kill -9 $PID -# RETVAL=1 -# echo Killed $APP with pid $PID -# else -# echo Stopped $APP with pid $PID -# fi -# rm -f $PID_FILE -# return $RETVAL -} - -status() { - if [ -f $PID_FILE ];then - PID=`cat $PID_FILE` - else - echo $APP is not running - return $RETVAL - fi - kill -0 $PID &> /dev/null - PID_EXISTS=$? - if [ $PID_EXISTS -eq 0 ]; then - echo $APP is running with pid $PID ... - else - echo No $APP process with pid $PID, removing $PID_FILE - rm -f $PID_FILE - fi - return $RETVAL -} - -# main -case "$2" in - start) - start - ;; - stop) - stop - ;; - status) - status - ;; - *) - echo $"Usage: $0 {start|stop|status}" - exit 1 -esac \ No newline at end of file -- 2.30.2