blob: fe4e2485333d8c569d00a4bbe63981cfbe8911f5 [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
11#export JAVA_OPTS="${JAVA_OPTS:--DenableNettyTLS=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}"
12
Jordan Haltermana08cc9e2019-04-08 14:01:59 -070013export JAVA_OPTS=${JAVA_OPTS:--XX:+UseG1GC -XX:MaxGCPauseMillis=200 -Dkaraf.log.console=INFO -Dds.lock.timeout.milliseconds=10000}
Ray Milkeyb32da852018-05-18 15:42:16 -070014
Bob Lantz5e4d49d2016-02-25 02:26:45 -080015set -e # exit on error
16set -u # exit on undefined variable
17
Brian O'Connorea8cb752019-10-09 17:39:28 -070018#
19# Hack: Making docker.host.internal resolvable in Docker for Linux
20# TODO(bocon): this can be removed when this issue is resolved: https://github.com/docker/for-linux/issues/264
21# iproute2 can also be removed from the Dockerfile as a build dep
22#
23# Only run this if we are running in a Docker container
24if awk -F/ '$2 == "docker"' /proc/self/cgroup &>/dev/null; then
25 # Add host.docker.internal to /etc/hosts if it does not resolve
26 getent hosts host.docker.internal > /dev/null || \
27 ip -4 route list match 0/0 | awk '{print $3"\thost.docker.internal"}' >> /etc/hosts
28fi
29
Bob Lantz5e4d49d2016-02-25 02:26:45 -080030# If ONOS_HOME is set, respect its value.
31# If ONOS_HOME is not set (e.g. in the init or service environment),
32# set it based on this script's path.
Brian O'Connora57c2212016-05-06 18:04:15 -070033ONOS_HOME=${ONOS_HOME:-$(cd $(dirname $0)/.. >/dev/null 2>&1 && pwd)}
Ray Milkeyd84f89b2018-08-17 14:54:17 -070034KARAF_ARGS=server
David Bainbridgeff4fb042015-08-17 12:53:29 -070035SYS_APPS=drivers
Thomas Vachuskad4780eb2019-04-18 10:56:59 -070036ONOS_APPS=${ONOS_APPS:-gui2} # Activate GUI2 unless specific apps were named
Jian Li7343bfa2016-01-27 15:42:05 -080037
Bob Lantz5e4d49d2016-02-25 02:26:45 -080038cd $ONOS_HOME
David Bainbridgeff4fb042015-08-17 12:53:29 -070039
40# Parse out arguments destinted for karaf invocation v. arguments that
41# will be processed in line
42while [ $# -gt 0 ]; do
43 case $1 in
44 apps-clean)
45 # Deactivate all applications
46 find ${ONOS_HOME}/apps -name "active" -exec rm \{\} \;
47 ;;
48 *)
49 KARAF_ARGS+=" $1"
50 ;;
51 esac
52 shift
53done
54
55# Activate the system required applications (SYS_APPS) as well as any
56# specified applications in the var ONOS_APPS
57for app in ${SYS_APPS//,/ } ${ONOS_APPS//,/ }; do
Marc De Leenheerf8e02832017-01-17 15:33:11 -080058 if [ -d "${ONOS_HOME}/apps/org.onosproject.$app/" ]; then
59 touch ${ONOS_HOME}/apps/org.onosproject.$app/active
60 elif [ -d "${ONOS_HOME}/apps/$app" ]; then
61 touch ${ONOS_HOME}/apps/$app/active
62 else
63 echo "[WARN] Don't know how to activate $app"
64 fi
David Bainbridgeff4fb042015-08-17 12:53:29 -070065done
66
Ray Milkeyd84f89b2018-08-17 14:54:17 -070067KARAF_ARGS+=" server"
68
Bob Lantz641d5452016-03-04 19:39:17 -080069exec ${ONOS_HOME}/apache-karaf-$KARAF_VERSION/bin/karaf $KARAF_ARGS