Support for docker-compose in heat environment
[so.git] / packages / docker / src / main / docker / docker-files / scripts / start-app.sh
diff --git a/packages/docker/src/main/docker/docker-files/scripts/start-app.sh b/packages/docker/src/main/docker/docker-files/scripts/start-app.sh
new file mode 100644 (file)
index 0000000..df2e646
--- /dev/null
@@ -0,0 +1,90 @@
+#!/bin/sh
+
+if [ `id -u` = 0 ]
+then
+       # Install certificates found in the /app/ca-certificates volume, if any.
+
+       needUpdate=FALSE
+
+       for certificate in `ls -1 /app/ca-certificates`; do
+               echo "Installing $certificate in /usr/local/share/ca-certificates"
+               cp /app/ca-certificates/$certificate /usr/local/share/ca-certificates/$certificate
+               needUpdate=TRUE
+       done
+
+       if [ $needUpdate = TRUE ]; then
+               update-ca-certificates --fresh
+       fi
+
+       # Re-exec this script as the 'so' user.
+       this=`readlink -f $0`
+       exec su so -c  "$this"
+fi
+
+touch /app/app.jar
+
+if [ -z "$APP" ]; then
+       echo "CONFIG ERROR: APP environment variable not set"
+       exit 1
+fi
+
+if [ ! -z "$DB_HOST" -a -z "$DB_PORT" ]; then
+       export DB_PORT=3306
+fi
+
+if [ -z "${CONFIG_PATH}" ]; then
+       export CONFIG_PATH=/app/config/override.yaml
+fi
+
+if [ -z "${LOG_PATH}" ]; then
+       export LOG_PATH="logs/${APP}"
+fi
+
+if [ ${APP} = "asdc-controller" ]; then
+       ln -s ${LOG_PATH} ASDC
+fi
+
+if [ ${APP} = "bpmn-infra" ]; then
+       ln -s ${LOG_PATH} BPMN
+fi 
+
+if [ ${APP} = "openstack-adapter" ]; then
+       export DISABLE_SNI="-Djsse.enableSNIExtension=false"
+fi
+
+if [ "${SSL_DEBUG}" = "log" ]; then
+       export SSL_DEBUG="-Djavax.net.debug=all"
+else
+       export SSL_DEBUG=
+fi
+
+# Set java keystore and truststore options, if specified in the environment.
+
+jksargs=
+
+if [ ! -z "${KEYSTORE}" ]; then
+       jksargs="$jksargs -Dmso.load.ssl.client.keystore=true"
+       jksargs="$jksargs -Djavax.net.ssl.keyStore=$KEYSTORE"
+       jksargs="$jksargs -Djavax.net.ssl.keyStorePassword=${KEYSTORE_PASSWORD}"
+fi
+
+if [ ! -z "${TRUSTSTORE}" ]; then
+       jksargs="$jksargs -Djavax.net.ssl.trustStore=${TRUSTSTORE}"
+       jksargs="$jksargs -Djavax.net.ssl.trustStorePassword=${TRUSTSTORE_PASSWORD}"
+fi
+
+jvmargs="${JVM_ARGS} -Dlogs_dir=${LOG_PATH} -Dlogging.config=/app/logback-spring.xml $jksargs -Dspring.config.location=$CONFIG_PATH ${SSL_DEBUG} ${DISABLE_SNI}"
+
+echo "JVM Arguments: ${jvmargs}"
+
+java ${jvmargs} -jar app.jar
+rc=$?
+
+echo "Application exiting with status code $rc"
+
+if [ ! -z "${EXIT_DELAY}" -a "${EXIT_DELAY}" != 0 ]; then
+       echo "Delaying $APP exit for $EXIT_DELAY seconds"
+       sleep $EXIT_DELAY
+fi
+
+exit $rc