a170e30141f6185461eaec93427abbcb5dcb1a35
[policy/api.git] / packages / policy-api-docker / src / main / docker / policy-api.sh
1 #!/usr/bin/env sh
2 #
3 # ============LICENSE_START=======================================================
4 #  Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved.
5 #  Modifications Copyright (C) 2019-2020 Nordix Foundation.
6 #  Modifications Copyright (C) 2022 Bell Canada. All rights reserved.
7 # ================================================================================
8 # Licensed under the Apache License, Version 2.0 (the "License");
9 # you may not use this file except in compliance with the License.
10 # You may obtain a copy of the License at
11 #
12 #      http://www.apache.org/licenses/LICENSE-2.0
13 #
14 # Unless required by applicable law or agreed to in writing, software
15 # distributed under the License is distributed on an "AS IS" BASIS,
16 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 # See the License for the specific language governing permissions and
18 # limitations under the License.
19 #
20 # SPDX-License-Identifier: Apache-2.0
21 # ============LICENSE_END=========================================================
22 #
23
24 JAVA_HOME=/usr/lib/jvm/java-11-openjdk/
25 KEYSTORE="${KEYSTORE:-$POLICY_HOME/etc/ssl/policy-keystore}"
26 TRUSTSTORE="${TRUSTSTORE:-$POLICY_HOME/etc/ssl/policy-truststore}"
27 KEYSTORE_PASSWD="${KEYSTORE_PASSWD:-Pol1cy_0nap}"
28 TRUSTSTORE_PASSWD="${TRUSTSTORE_PASSWD:-Pol1cy_0nap}"
29
30 if [ "$#" -eq 1 ]; then
31     CONFIG_FILE=$1
32 else
33     CONFIG_FILE=${CONFIG_FILE}
34 fi
35
36 if [ -z "$CONFIG_FILE" ]; then
37     CONFIG_FILE="${POLICY_HOME}/etc/apiParameters.yaml"
38 fi
39
40 echo "Policy api config file: $CONFIG_FILE"
41
42 if [ -f "${POLICY_HOME}/etc/mounted/policy-truststore" ]; then
43     echo "overriding policy-truststore"
44     cp -f "${POLICY_HOME}"/etc/mounted/policy-truststore "${TRUSTSTORE}"
45 fi
46
47 if [ -f "${POLICY_HOME}/etc/mounted/policy-keystore" ]; then
48     echo "overriding policy-keystore"
49     cp -f "${POLICY_HOME}"/etc/mounted/policy-keystore "${KEYSTORE}"
50 fi
51
52 if [ -f "${POLICY_HOME}/etc/mounted/logback.xml" ]; then
53     echo "overriding logback.xml"
54     cp -f "${POLICY_HOME}"/etc/mounted/logback.xml "${POLICY_HOME}"/etc/
55 fi
56
57 $JAVA_HOME/bin/java \
58     -Dlogging.config="${POLICY_HOME}/etc/logback.xml" \
59     -Dserver.ssl.key-store="${KEYSTORE}" \
60     -Dserver.ssl.key-store-password="${KEYSTORE_PASSWD}" \
61     -Djavax.net.ssl.trustStore="${TRUSTSTORE}" \
62     -Djavax.net.ssl.trustStorePassword="${TRUSTSTORE_PASSWD}" \
63     -jar /app/api.jar \
64     --spring.config.location="${CONFIG_FILE}"