Rename asdc-controller docker image
[so.git] / packages / docker / src / main / docker / docker-files / scripts / start-app.sh
1 #!/bin/sh
2
3 if [ `id -u` = 0 ]
4 then
5         # Install certificates found in the /app/ca-certificates volume, if any.
6
7         needUpdate=FALSE
8
9         for certificate in `ls -1 /app/ca-certificates`; do
10                 echo "Installing $certificate in /usr/local/share/ca-certificates"
11                 cp /app/ca-certificates/$certificate /usr/local/share/ca-certificates/$certificate
12                 needUpdate=TRUE
13         done
14
15         if [ $needUpdate = TRUE ]; then
16                 update-ca-certificates --fresh
17         fi
18
19         # Re-exec this script as the 'so' user.
20         this=`readlink -f $0`
21         exec su so -c  "$this"
22 fi
23
24 touch /app/app.jar
25
26 if [ -z "$APP" ]; then
27         echo "CONFIG ERROR: APP environment variable not set"
28         exit 1
29 fi
30
31 if [ ! -z "$DB_HOST" -a -z "$DB_PORT" ]; then
32         export DB_PORT=3306
33 fi
34
35 if [ -z "${CONFIG_PATH}" ]; then
36         export CONFIG_PATH=/app/config/override.yaml
37 fi
38
39 if [ -z "${LOG_PATH}" ]; then
40         export LOG_PATH="logs/${APP}"
41 fi
42
43 if [ ${APP} = "sdc-controller" ]; then
44         ln -s ${LOG_PATH} ASDC
45 fi
46
47 if [ ${APP} = "bpmn-infra" ]; then
48         ln -s ${LOG_PATH} BPMN
49 fi 
50
51 if [ ${APP} = "openstack-adapter" ]; then
52         export DISABLE_SNI="-Djsse.enableSNIExtension=false"
53 fi
54
55 if [ "${SSL_DEBUG}" = "log" ]; then
56         export SSL_DEBUG="-Djavax.net.debug=all"
57 else
58         export SSL_DEBUG=
59 fi
60
61 # Set java keystore and truststore options, if specified in the environment.
62
63 jksargs=
64
65 if [ ! -z "${KEYSTORE}" ]; then
66         jksargs="$jksargs -Dmso.load.ssl.client.keystore=true"
67         jksargs="$jksargs -Djavax.net.ssl.keyStore=$KEYSTORE"
68         jksargs="$jksargs -Djavax.net.ssl.keyStorePassword=${KEYSTORE_PASSWORD}"
69 fi
70
71 if [ ! -z "${TRUSTSTORE}" ]; then
72         jksargs="$jksargs -Djavax.net.ssl.trustStore=${TRUSTSTORE}"
73         jksargs="$jksargs -Djavax.net.ssl.trustStorePassword=${TRUSTSTORE_PASSWORD}"
74 fi
75
76 jvmargs="${JVM_ARGS} -Djava.security.egd=file:/dev/./urandom -Dlogs_dir=${LOG_PATH} -Dlogging.config=/app/logback-spring.xml $jksargs -Dspring.config.location=$CONFIG_PATH ${SSL_DEBUG} ${DISABLE_SNI}"
77
78 echo "JVM Arguments: ${jvmargs}"
79
80 java ${jvmargs} -jar app.jar
81 rc=$?
82
83 echo "Application exiting with status code $rc"
84
85 if [ ! -z "${EXIT_DELAY}" -a "${EXIT_DELAY}" != 0 ]; then
86         echo "Delaying $APP exit for $EXIT_DELAY seconds"
87         sleep $EXIT_DELAY
88 fi
89
90 exit $rc