Set all cross references of policy/pap
[policy/pap.git] / packages / policy-pap-docker / src / main / docker / policy-pap.sh
1 #!/usr/bin/env sh
2 #
3 # ============LICENSE_START=======================================================
4 #  Copyright (C) 2019-2022 Nordix Foundation.
5 #  Modifications Copyright (C) 2019-2021 AT&T Intellectual Property.
6 #  Modifications Copyright (C) 2021-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 KEYSTORE="${KEYSTORE:-$POLICY_HOME/etc/ssl/policy-keystore}"
25 TRUSTSTORE="${TRUSTSTORE:-$POLICY_HOME/etc/ssl/policy-truststore}"
26 KEYSTORE_PASSWD="${KEYSTORE_PASSWD:-Pol1cy_0nap}"
27 TRUSTSTORE_PASSWD="${TRUSTSTORE_PASSWD:-Pol1cy_0nap}"
28
29 if [ "$#" -ge 1 ]; then
30     CONFIG_FILE=$1
31 else
32     CONFIG_FILE=${CONFIG_FILE}
33 fi
34
35 touch /app/pap.jar
36
37 if [ -z "$CONFIG_FILE" ]; then
38     CONFIG_FILE="${POLICY_HOME}/etc/papParameters.yaml"
39 fi
40
41 echo "Policy pap config file: $CONFIG_FILE"
42
43 if [ -f "${POLICY_HOME}/etc/mounted/policy-truststore" ]; then
44     echo "overriding policy-truststore"
45     cp -f "${POLICY_HOME}"/etc/mounted/policy-truststore "${TRUSTSTORE}"
46 fi
47
48 if [ -f "${POLICY_HOME}/etc/mounted/policy-keystore" ]; then
49     echo "overriding policy-keystore"
50     cp -f "${POLICY_HOME}"/etc/mounted/policy-keystore "${KEYSTORE}"
51 fi
52
53 if [ -f "${POLICY_HOME}/etc/mounted/logback.xml" ]; then
54     echo "overriding logback.xml"
55     cp -f "${POLICY_HOME}"/etc/mounted/logback.xml "${POLICY_HOME}"/etc/
56 fi
57
58 # provide and external PDP group configuration if a groups.json
59 # file is present in the data directory. If none is present,
60 # the PAP will use the PapDb.json resource in the classpath
61 # to load a default group.
62
63 if [ -f "${POLICY_HOME}/etc/mounted/groups.json" ]; then
64     CUSTOM_GROUPS="${POLICY_HOME}/etc/mounted/groups.json"
65 else
66     CUSTOM_GROUPS="PapDb.json"
67 fi
68
69 echo "PDP group configuration file: ${CUSTOM_GROUPS}"
70
71 $JAVA_HOME/bin/java \
72     -Dlogging.config="${POLICY_HOME}/etc/logback.xml" \
73     -Dserver.ssl.key-store="${KEYSTORE}" \
74     -Dserver.ssl.key-store-password="${KEYSTORE_PASSWD}" \
75     -Djavax.net.ssl.trustStore="${TRUSTSTORE}" \
76     -Djavax.net.ssl.trustStorePassword="${TRUSTSTORE_PASSWD}" \
77     -jar /app/pap.jar \
78     --spring.config.location="${CONFIG_FILE}" \
79     --group-config-file="${CUSTOM_GROUPS}"