|
1 | | -#!/bin/sh |
2 | | - |
| 1 | +#!/bin/bash |
| 2 | +# |
| 3 | +# Copyright (c) 2025 Eurotech and/or its affiliates and others |
| 4 | +# |
| 5 | +# This program and the accompanying materials are made |
| 6 | +# available under the terms of the Eclipse Public License 2.0 |
| 7 | +# which is available at https://www.eclipse.org/legal/epl-2.0/ |
| 8 | +# |
| 9 | +# SPDX-License-Identifier: EPL-2.0 |
| 10 | +# |
| 11 | +# Contributors: |
| 12 | +# Eurotech |
| 13 | +# |
| 14 | +# Kura should be installed to the \${kura.install.dir} directory. |
3 | 15 | export PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/opt/jvm/bin:/usr/java/bin:$PATH |
4 | 16 | export MALLOC_ARENA_MAX=1 |
5 | 17 |
|
| 18 | +KURA_RUNNING=$(pgrep -f ".*java.*org\.eclipse\.equinox\..*") |
| 19 | + |
| 20 | +if [ -n "$KURA_RUNNING" ] ; then |
| 21 | + echo "Failed to start Kura. It is already running ..." |
| 22 | + exit 1 |
| 23 | +fi |
| 24 | + |
6 | 25 | DIR=$(cd $(dirname $0)/..; pwd) |
7 | | -cd $DIR |
| 26 | +cd "$DIR" || exit 1 |
| 27 | + |
| 28 | +IS_DEBUG_MODE="false" |
| 29 | +IS_DETACHED_MODE="false" |
| 30 | + |
| 31 | +while [[ $# -gt 0 ]]; do |
| 32 | + key="$1" |
| 33 | + |
| 34 | + case $key in |
| 35 | + -d | --detached) |
| 36 | + IS_DETACHED_MODE="true" |
| 37 | + ;; |
| 38 | + -x | --debug) |
| 39 | + IS_DEBUG_MODE="true" |
| 40 | + ;; |
| 41 | + -h | --help) |
| 42 | + echo |
| 43 | + echo "Options:" |
| 44 | + echo " -d | --detached run Kura in detached mode" |
| 45 | + echo " -x | --debug run Kura in debug mode" |
| 46 | + exit 0 |
| 47 | + ;; |
| 48 | + *) |
| 49 | + echo "Unknown option." |
| 50 | + exit 1 |
| 51 | + ;; |
| 52 | + esac |
| 53 | + shift # past argument or value |
| 54 | +done |
8 | 55 |
|
9 | 56 | # set up the configuration area |
10 | 57 | mkdir -p /tmp/.kura/configuration |
11 | 58 | \${DIR}/bin/gen_config_ini.sh \${DIR}/framework/config.ini \${DIR}/plugins > /tmp/.kura/configuration/config.ini |
12 | 59 |
|
13 | | -KURA_RUNNING=`ps ax | grep java | grep "org.eclipse.equinox"` |
14 | | - |
15 | | -if [ -z "$KURA_RUNNING" ] ; then |
16 | | - exec java -Xms${kura.mem.size} -Xmx${kura.mem.size} \ |
17 | | - -XX:+IgnoreUnrecognizedVMOptions \ |
18 | | - --add-opens java.base/java.lang=ALL-UNNAMED \ |
19 | | - --add-opens java.base/java.util=ALL-UNNAMED \ |
20 | | - --add-modules=ALL-SYSTEM \ |
21 | | - -Dkura.os.version=${kura.os.version} \ |
22 | | - -Dkura.arch=${kura.arch} \ |
23 | | - -Dtarget.device=${target.device} \ |
24 | | - -Dorg.eclipse.kura.core.crypto.secretKey="$KURA_CRYPTO_SECRET_KEY" \ |
25 | | - -Declipse.ignoreApp=true \ |
26 | | - -Dkura.home=\${DIR} \ |
27 | | - -Dkura.configuration=file:\${DIR}/framework/kura.properties \ |
28 | | - -Dkura.custom.configuration=file:\${DIR}/user/kura_custom.properties \ |
29 | | - -Ddpa.configuration=\${DIR}/packages/dpa.properties \ |
30 | | - -Dlog4j.configurationFile=file:\${DIR}/log4j/log4j.xml \ |
31 | | - -Dlog4j2.disable.jmx=true \ |
32 | | - -Djava.security.policy=\${DIR}/framework/jdk.dio.policy \ |
33 | | - -Djdk.dio.registry=\${DIR}/framework/jdk.dio.properties \ |
34 | | - -Djdk.tls.trustNameService=true \ |
35 | | - -Dosgi.console \ |
36 | | - -Declipse.consoleLog=true \ |
37 | | - -jar \${DIR}/plugins/org.eclipse.equinox.launcher-${org.eclipse.equinox.launcher.version}.jar \ |
38 | | - -configuration /tmp/.kura/configuration |
| 60 | +if [[ -n "${KURA_DEBUG_MODE}" && "${KURA_DEBUG_MODE}" == "true" ]]; then |
| 61 | + IS_DEBUG_MODE="true" |
| 62 | +fi |
| 63 | + |
| 64 | +DEBUG_OPTS="" |
| 65 | +if [[ $IS_DEBUG_MODE == "true" ]]; then |
| 66 | + DEBUG_OPTS="-Xdebug \ |
| 67 | + -Xrunjdwp:server=y,transport=dt_socket,address=*:8000,suspend=n \ |
| 68 | + -Xlog:gc=info:file=/var/log/kura-gc.log:time:filecount=10,filesize=10m \ |
| 69 | + -XX:+HeapDumpOnOutOfMemoryError \ |
| 70 | + -XX:HeapDumpPath=/var/log/kura-heapdump.hprof \ |
| 71 | + -XX:ErrorFile=/var/log/kura-error.log" |
| 72 | +fi |
| 73 | + |
| 74 | +KURA_LAUNCH_COMMAND="exec java" |
| 75 | + |
| 76 | +if [[ $IS_DETACHED_MODE == "true" ]]; then |
| 77 | + KURA_LAUNCH_COMMAND="nohup java" |
| 78 | +fi |
| 79 | + |
| 80 | +KURA_CMD="${KURA_LAUNCH_COMMAND} -Xms${kura.mem.size} -Xmx${kura.mem.size} \ |
| 81 | + $DEBUG_OPTS \ |
| 82 | + -XX:+IgnoreUnrecognizedVMOptions \ |
| 83 | + --add-opens java.base/java.lang=ALL-UNNAMED \ |
| 84 | + --add-opens java.base/java.util=ALL-UNNAMED \ |
| 85 | + --add-modules=ALL-SYSTEM \ |
| 86 | + -Dkura.os.version=${kura.os.version} \ |
| 87 | + -Dkura.arch=${kura.arch} \ |
| 88 | + -Dtarget.device=${target.device} \ |
| 89 | + -Declipse.ignoreApp=true \ |
| 90 | + -Dkura.home=\${DIR} \ |
| 91 | + -Dkura.configuration=file:\${DIR}/framework/kura.properties \ |
| 92 | + -Dkura.custom.configuration=file:\${DIR}/user/kura_custom.properties \ |
| 93 | + -Ddpa.configuration=\${DIR}/packages/dpa.properties \ |
| 94 | + -Dlog4j.configurationFile=file:\${DIR}/log4j/log4j.xml \ |
| 95 | + -Dlog4j2.disable.jmx=true \ |
| 96 | + -Djava.security.policy=\${DIR}/framework/jdk.dio.policy \ |
| 97 | + -Djdk.dio.registry=\${DIR}/framework/jdk.dio.properties \ |
| 98 | + -Djdk.tls.trustNameService=true \ |
| 99 | + -Declipse.consoleLog=true \ |
| 100 | + -jar \${DIR}/plugins/org.eclipse.equinox.launcher-${org.eclipse.equinox.launcher.version}.jar \ |
| 101 | + -configuration /tmp/.kura/configuration" |
| 102 | + |
| 103 | +if [[ $IS_DETACHED_MODE == "true" ]]; then |
| 104 | + eval "$KURA_CMD &" |
| 105 | + |
| 106 | + #Save the PID |
| 107 | + KURA_PID=$! |
| 108 | + echo "Kura Started (pid=$KURA_PID) ..." |
| 109 | + echo $KURA_PID > /var/run/kura.pid |
39 | 110 | else |
40 | | - echo "Failed to start Kura. It is already running ..." |
| 111 | + eval "$KURA_CMD" |
41 | 112 | fi |
0 commit comments