Fix Property
[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} = "so-monitoring" ]; then
52         ln -s ${LOG_PATH} MONITORING
53 fi
54
55 if [ ${APP} = "openstack-adapter" ]; then
56         export DISABLE_SNI="-Djsse.enableSNIExtension=false"
57 fi
58
59 if [ "${SSL_DEBUG}" = "log" ]; then
60         export SSL_DEBUG="-Djavax.net.debug=all"
61 else
62         export SSL_DEBUG=
63 fi
64
65 # Set java keystore and truststore options, if specified in the environment.
66
67 jksargs=
68
69 if [ ! -z "${KEYSTORE}" ]; then
70         jksargs="$jksargs -Dmso.load.ssl.client.keystore=true"
71         jksargs="$jksargs -Djavax.net.ssl.keyStore=$KEYSTORE"
72         jksargs="$jksargs -Djavax.net.ssl.keyStorePassword=${KEYSTORE_PASSWORD}"
73 fi
74
75 if [ ! -z "${TRUSTSTORE}" ]; then
76         jksargs="$jksargs -Djavax.net.ssl.trustStore=${TRUSTSTORE}"
77         jksargs="$jksargs -Djavax.net.ssl.trustStorePassword=${TRUSTSTORE_PASSWORD}"
78 fi
79
80 jvmargs="${JVM_ARGS} -Djava.security.egd=file:/dev/./urandom -Dlogs_dir=${LOG_PATH} -Dlogging.config=/app/logback-spring.xml $jksargs -Dspring.config.additional-location=$CONFIG_PATH ${SSL_DEBUG} ${DISABLE_SNI}"
81
82 echo "JVM Arguments: ${jvmargs}"
83
84 java ${jvmargs} -jar app.jar
85 rc=$?
86
87 echo "Application exiting with status code $rc"
88
89 if [ ! -z "${EXIT_DELAY}" -a "${EXIT_DELAY}" != 0 ]; then
90         echo "Delaying $APP exit for $EXIT_DELAY seconds"
91         sleep $EXIT_DELAY
92 fi
93
94 exit $rc