blob: b0ef25f14dd3ff263c700b64a99d13dc4e47a2fb [file] [log] [blame]
tom4d0c6632014-09-15 23:27:01 -07001#!/bin/bash
Pavlin Radoslavov91413792014-10-15 11:00:32 -07002# -----------------------------------------------------------------------------
tom4d0c6632014-09-15 23:27:01 -07003# Starts ONOS Apache Karaf container
Pavlin Radoslavov91413792014-10-15 11:00:32 -07004# -----------------------------------------------------------------------------
tom4d0c6632014-09-15 23:27:01 -07005
Brian O'Connor9362d882015-03-10 11:56:35 -07006# uncomment the following line for performance testing
Jian Libf7598f2018-03-20 17:30:40 +09007# export JAVA_OPTS="${JAVA_OPTS:--Xms16G -Xmx16G -XX:+UseConcMarkSweepGC -XX:+CMSIncrementalMode -XX:+PrintGCDetails -XX:+PrintGCTimeStamps}"
tom5c255702014-09-18 06:57:39 -07008
JunHuy Lam39eb4292015-06-26 17:24:23 +09009# uncomment the following line for Netty TLS encryption
10# Do modify the keystore location/password and truststore location/password accordingly
Lakshya Thakur5de46cd2020-08-14 19:32:07 +053011#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 Lam39eb4292015-06-26 17:24:23 +090012
Bob Lantz5e4d49d2016-02-25 02:26:45 -080013# 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'Connora57c2212016-05-06 18:04:15 -070016ONOS_HOME=${ONOS_HOME:-$(cd $(dirname $0)/.. >/dev/null 2>&1 && pwd)}
pierventreb418e112021-05-04 16:48:36 +020017
18JAVA_OPTS="${JAVA_OPTS:--XX:+UseG1GC -XX:MaxGCPauseMillis=200 -Dkaraf.log.console=INFO -Dds.lock.timeout.milliseconds=10000}"
19if [ ! -z "$ONOS_YOURKIT" ]; then
20 JAVA_OPTS+=" -agentpath:$ONOS_HOME/libyjpagent.so=listen=all"
21fi
22export JAVA_OPTS=${JAVA_OPTS}
23
24set -e # exit on error
25set -u # exit on undefined variable
26
Ray Milkeyd84f89b2018-08-17 14:54:17 -070027KARAF_ARGS=server
David Bainbridgeff4fb042015-08-17 12:53:29 -070028SYS_APPS=drivers
Thomas Vachuskad4780eb2019-04-18 10:56:59 -070029ONOS_APPS=${ONOS_APPS:-gui2} # Activate GUI2 unless specific apps were named
Jian Li7343bfa2016-01-27 15:42:05 -080030
Bob Lantz5e4d49d2016-02-25 02:26:45 -080031cd $ONOS_HOME
David Bainbridgeff4fb042015-08-17 12:53:29 -070032
33# Parse out arguments destinted for karaf invocation v. arguments that
34# will be processed in line
35while [ $# -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
46done
47
48# Activate the system required applications (SYS_APPS) as well as any
49# specified applications in the var ONOS_APPS
50for app in ${SYS_APPS//,/ } ${ONOS_APPS//,/ }; do
Marc De Leenheerf8e02832017-01-17 15:33:11 -080051 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 Bainbridgeff4fb042015-08-17 12:53:29 -070058done
59
Ray Milkeyd84f89b2018-08-17 14:54:17 -070060KARAF_ARGS+=" server"
61
Bob Lantz641d5452016-03-04 19:39:17 -080062exec ${ONOS_HOME}/apache-karaf-$KARAF_VERSION/bin/karaf $KARAF_ARGS