| #!/bin/bash |
| # ----------------------------------------------------------------------------- |
| # Starts ONOS Apache Karaf container |
| # ----------------------------------------------------------------------------- |
| |
| # uncomment the following line for performance testing |
| # export JAVA_OPTS="${JAVA_OPTS:--Xms16G -Xmx16G -XX:+UseConcMarkSweepGC -XX:+CMSIncrementalMode -XX:+PrintGCDetails -XX:+PrintGCTimeStamps}" |
| |
| # uncomment the following line for Netty TLS encryption |
| # Do modify the keystore location/password and truststore location/password accordingly |
| #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}" |
| |
| export JAVA_OPTS=${JAVA_OPTS:--XX:+UseG1GC -XX:MaxGCPauseMillis=200 -Dkaraf.log.console=INFO -Dds.lock.timeout.milliseconds=10000} |
| |
| set -e # exit on error |
| set -u # exit on undefined variable |
| |
| # |
| # Hack: Making docker.host.internal resolvable in Docker for Linux |
| # TODO(bocon): this can be removed when this issue is resolved: https://github.com/docker/for-linux/issues/264 |
| # iproute2 can also be removed from the Dockerfile as a build dep |
| # |
| # Only run this if we are running in a Docker container |
| if awk -F/ '$2 == "docker"' /proc/self/cgroup &>/dev/null; then |
| # Add host.docker.internal to /etc/hosts if it does not resolve |
| getent hosts host.docker.internal > /dev/null || \ |
| ip -4 route list match 0/0 | awk '{print $3"\thost.docker.internal"}' >> /etc/hosts |
| fi |
| |
| # If ONOS_HOME is set, respect its value. |
| # If ONOS_HOME is not set (e.g. in the init or service environment), |
| # set it based on this script's path. |
| ONOS_HOME=${ONOS_HOME:-$(cd $(dirname $0)/.. >/dev/null 2>&1 && pwd)} |
| KARAF_ARGS=server |
| SYS_APPS=drivers |
| ONOS_APPS=${ONOS_APPS:-gui2} # Activate GUI2 unless specific apps were named |
| |
| cd $ONOS_HOME |
| |
| # Parse out arguments destinted for karaf invocation v. arguments that |
| # will be processed in line |
| while [ $# -gt 0 ]; do |
| case $1 in |
| apps-clean) |
| # Deactivate all applications |
| find ${ONOS_HOME}/apps -name "active" -exec rm \{\} \; |
| ;; |
| *) |
| KARAF_ARGS+=" $1" |
| ;; |
| esac |
| shift |
| done |
| |
| # Activate the system required applications (SYS_APPS) as well as any |
| # specified applications in the var ONOS_APPS |
| for app in ${SYS_APPS//,/ } ${ONOS_APPS//,/ }; do |
| if [ -d "${ONOS_HOME}/apps/org.onosproject.$app/" ]; then |
| touch ${ONOS_HOME}/apps/org.onosproject.$app/active |
| elif [ -d "${ONOS_HOME}/apps/$app" ]; then |
| touch ${ONOS_HOME}/apps/$app/active |
| else |
| echo "[WARN] Don't know how to activate $app" |
| fi |
| done |
| |
| KARAF_ARGS+=" server" |
| |
| exec ${ONOS_HOME}/apache-karaf-$KARAF_VERSION/bin/karaf $KARAF_ARGS |