mukesh.paliwal | 36e6d00 | 2021-02-05 12:44:04 +0530 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | #temprary condition |
| 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=FALSE |
| 13 | done |
| 14 | |
| 15 | # Re-exec this script as the 'onap' user. |
| 16 | this=`readlink -f $0` |
| 17 | # exec su so -c "$this" |
| 18 | fi |
| 19 | |
| 20 | touch /app/app.jar |
| 21 | |
| 22 | if [ ! -z "$DB_HOST" -a -z "$DB_PORT" ]; then |
| 23 | export DB_PORT=3306 |
| 24 | fi |
| 25 | |
| 26 | if [ -z "${CONFIG_PATH}" ]; then |
| 27 | export CONFIG_PATH=/app/config/override.yaml |
| 28 | fi |
| 29 | |
| 30 | if [ "${SSL_DEBUG}" = "log" ]; then |
| 31 | export SSL_DEBUG="-Djavax.net.debug=all" |
| 32 | else |
| 33 | export SSL_DEBUG= |
| 34 | fi |
| 35 | |
| 36 | # Set java keystore and truststore options, if specified in the environment. |
| 37 | |
| 38 | jksargs= |
| 39 | |
| 40 | if [ ! -z "${KEYSTORE}" ]; then |
| 41 | jksargs="$jksargs -Dmso.load.ssl.client.keystore=true" |
| 42 | jksargs="$jksargs -Djavax.net.ssl.keyStore=$KEYSTORE" |
| 43 | jksargs="$jksargs -Djavax.net.ssl.keyStorePassword=${KEYSTORE_PASSWORD}" |
| 44 | fi |
| 45 | |
| 46 | if [ ! -z "${TRUSTSTORE}" ]; then |
| 47 | jksargs="$jksargs -Djavax.net.ssl.trustStore=${TRUSTSTORE}" |
| 48 | jksargs="$jksargs -Djavax.net.ssl.trustStorePassword=${TRUSTSTORE_PASSWORD}" |
| 49 | fi |
| 50 | |
| 51 | if [ -z "${ACTIVE_PROFILE}" ]; then |
| 52 | export ACTIVE_PROFILE="basic" |
| 53 | fi |
| 54 | |
| 55 | jvmargs="${JVM_ARGS} -Dspring.profiles.active=${ACTIVE_PROFILE} -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}" |
| 56 | |
| 57 | |
| 58 | read_properties(){ |
| 59 | while IFS="=" read -r key value; do |
| 60 | case "${key}" in |
| 61 | '#'*) ;; |
| 62 | *) |
| 63 | eKey=$(echo $key | tr '[:lower:]' '[:upper:]') |
| 64 | export "$eKey"="$value" |
| 65 | esac |
| 66 | done <<-EOF |
| 67 | $1 |
| 68 | EOF |
| 69 | } |
| 70 | |
| 71 | |
| 72 | |
| 73 | if [ -n "${AAF_SSL_CERTS_ENABLED}" ]; then |
| 74 | read_properties "$(head -n 4 /app/certs/.passphrases)" |
| 75 | fi |
| 76 | |
| 77 | echo "JVM Arguments: ${jvmargs}" |
| 78 | |
| 79 | java ${jvmargs} -jar app.jar |
| 80 | rc=$? |
| 81 | |
| 82 | echo "Application exiting with status code $rc" |
| 83 | |
| 84 | if [ ! -z "${EXIT_DELAY}" -a "${EXIT_DELAY}" != 0 ]; then |
| 85 | echo "Delaying $APP exit for $EXIT_DELAY seconds" |
| 86 | sleep $EXIT_DELAY |
| 87 | fi |
| 88 | |
| 89 | exit $rc |