tom | 4d0c663 | 2014-09-15 23:27:01 -0700 | [diff] [blame] | 1 | #!/bin/bash |
Pavlin Radoslavov | 9141379 | 2014-10-15 11:00:32 -0700 | [diff] [blame] | 2 | # ----------------------------------------------------------------------------- |
tom | 4d0c663 | 2014-09-15 23:27:01 -0700 | [diff] [blame] | 3 | # Starts ONOS Apache Karaf container |
Pavlin Radoslavov | 9141379 | 2014-10-15 11:00:32 -0700 | [diff] [blame] | 4 | # ----------------------------------------------------------------------------- |
tom | 4d0c663 | 2014-09-15 23:27:01 -0700 | [diff] [blame] | 5 | |
Brian O'Connor | 9362d88 | 2015-03-10 11:56:35 -0700 | [diff] [blame] | 6 | # uncomment the following line for performance testing |
Jian Li | bf7598f | 2018-03-20 17:30:40 +0900 | [diff] [blame] | 7 | # export JAVA_OPTS="${JAVA_OPTS:--Xms16G -Xmx16G -XX:+UseConcMarkSweepGC -XX:+CMSIncrementalMode -XX:+PrintGCDetails -XX:+PrintGCTimeStamps}" |
tom | 5c25570 | 2014-09-18 06:57:39 -0700 | [diff] [blame] | 8 | |
JunHuy Lam | 39eb429 | 2015-06-26 17:24:23 +0900 | [diff] [blame] | 9 | # uncomment the following line for Netty TLS encryption |
| 10 | # Do modify the keystore location/password and truststore location/password accordingly |
Lakshya Thakur | 5de46cd | 2020-08-14 19:32:07 +0530 | [diff] [blame] | 11 | #export JAVA_OPTS="${JAVA_OPTS:--Dio.atomix.enableNettyTLS=true -Djavax.net.ssl.keyStore=/home/ubuntu/onos.jks -Djavax.net.ssl.keyStorePassword=222222 -Djavax.net.ssl.trustStore=/home/ubuntu/onos.jks -Djavax.net.ssl.trustStorePassword=222222}" |
JunHuy Lam | 39eb429 | 2015-06-26 17:24:23 +0900 | [diff] [blame] | 12 | |
Bob Lantz | 5e4d49d | 2016-02-25 02:26:45 -0800 | [diff] [blame] | 13 | # If ONOS_HOME is set, respect its value. |
| 14 | # If ONOS_HOME is not set (e.g. in the init or service environment), |
| 15 | # set it based on this script's path. |
Brian O'Connor | a57c221 | 2016-05-06 18:04:15 -0700 | [diff] [blame] | 16 | ONOS_HOME=${ONOS_HOME:-$(cd $(dirname $0)/.. >/dev/null 2>&1 && pwd)} |
pierventre | 59d88b5 | 2021-05-04 16:48:36 +0200 | [diff] [blame^] | 17 | |
| 18 | JAVA_OPTS="${JAVA_OPTS:--XX:+UseG1GC -XX:MaxGCPauseMillis=200 -Dkaraf.log.console=INFO -Dds.lock.timeout.milliseconds=10000}" |
| 19 | if [ ! -z "$ONOS_YOURKIT" ]; then |
| 20 | JAVA_OPTS+=" -agentpath:$ONOS_HOME/libyjpagent.so=listen=all" |
| 21 | fi |
| 22 | export JAVA_OPTS=${JAVA_OPTS} |
| 23 | |
| 24 | set -e # exit on error |
| 25 | set -u # exit on undefined variable |
| 26 | |
Ray Milkey | d84f89b | 2018-08-17 14:54:17 -0700 | [diff] [blame] | 27 | KARAF_ARGS=server |
David Bainbridge | ff4fb04 | 2015-08-17 12:53:29 -0700 | [diff] [blame] | 28 | SYS_APPS=drivers |
Thomas Vachuska | d4780eb | 2019-04-18 10:56:59 -0700 | [diff] [blame] | 29 | ONOS_APPS=${ONOS_APPS:-gui2} # Activate GUI2 unless specific apps were named |
Jian Li | 7343bfa | 2016-01-27 15:42:05 -0800 | [diff] [blame] | 30 | |
Bob Lantz | 5e4d49d | 2016-02-25 02:26:45 -0800 | [diff] [blame] | 31 | cd $ONOS_HOME |
David Bainbridge | ff4fb04 | 2015-08-17 12:53:29 -0700 | [diff] [blame] | 32 | |
| 33 | # Parse out arguments destinted for karaf invocation v. arguments that |
| 34 | # will be processed in line |
| 35 | while [ $# -gt 0 ]; do |
| 36 | case $1 in |
| 37 | apps-clean) |
| 38 | # Deactivate all applications |
| 39 | find ${ONOS_HOME}/apps -name "active" -exec rm \{\} \; |
| 40 | ;; |
| 41 | *) |
| 42 | KARAF_ARGS+=" $1" |
| 43 | ;; |
| 44 | esac |
| 45 | shift |
| 46 | done |
| 47 | |
| 48 | # Activate the system required applications (SYS_APPS) as well as any |
| 49 | # specified applications in the var ONOS_APPS |
| 50 | for app in ${SYS_APPS//,/ } ${ONOS_APPS//,/ }; do |
Marc De Leenheer | f8e0283 | 2017-01-17 15:33:11 -0800 | [diff] [blame] | 51 | if [ -d "${ONOS_HOME}/apps/org.onosproject.$app/" ]; then |
| 52 | touch ${ONOS_HOME}/apps/org.onosproject.$app/active |
| 53 | elif [ -d "${ONOS_HOME}/apps/$app" ]; then |
| 54 | touch ${ONOS_HOME}/apps/$app/active |
| 55 | else |
| 56 | echo "[WARN] Don't know how to activate $app" |
| 57 | fi |
David Bainbridge | ff4fb04 | 2015-08-17 12:53:29 -0700 | [diff] [blame] | 58 | done |
| 59 | |
Ray Milkey | d84f89b | 2018-08-17 14:54:17 -0700 | [diff] [blame] | 60 | KARAF_ARGS+=" server" |
| 61 | |
Bob Lantz | 641d545 | 2016-03-04 19:39:17 -0800 | [diff] [blame] | 62 | exec ${ONOS_HOME}/apache-karaf-$KARAF_VERSION/bin/karaf $KARAF_ARGS |