3 # ########################################################################
4 # Copyright 2019-2021 AT&T Intellectual Property. All rights reserved
5 # Modifications Copyright (C) 2024 Nordix Foundation.
7 # Licensed under the Apache License, Version 2.0 (the "License");
8 # you may not use this file except in compliance with the License.
9 # You may obtain a copy of the License at
11 # http://www.apache.org/licenses/LICENSE-2.0
13 # Unless required by applicable law or agreed to in writing, software
14 # distributed under the License is distributed on an "AS IS" BASIS,
15 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 # See the License for the specific language governing permissions and
17 # limitations under the License.
18 # ########################################################################
22 if [ "${DEBUG}" = "y" ]; then
27 if [ -f "${POLICY_INSTALL_INIT}"/settings.xml ]; then
28 if ! cmp -s "${POLICY_INSTALL_INIT}"/settings.xml "${POLICY_HOME}"/etc/m2/settings.xml; then
29 echo "overriding settings.xml"
30 cp -f "${POLICY_INSTALL_INIT}"/settings.xml "${POLICY_HOME}"/etc/m2
34 if [ -f "${POLICY_INSTALL_INIT}"/standalone-settings.xml ]; then
35 if ! cmp -s "${POLICY_INSTALL_INIT}"/standalone-settings.xml "${POLICY_HOME}"/etc/m2/standalone-settings.xml; then
36 echo "overriding standalone-settings.xml"
37 cp -f "${POLICY_INSTALL_INIT}"/standalone-settings.xml "${POLICY_HOME}"/etc/m2
42 function systemConfs {
43 if [ "${DEBUG}" = "y" ]; then
44 echo "-- systemConfs --"
50 if ! ls "${POLICY_INSTALL_INIT}"/*.conf > /dev/null 2>&1; then
54 for c in $(ls "${POLICY_INSTALL_INIT}"/*.conf 2> /dev/null); do
55 echo "adding system conf file: ${c}"
56 cp -f "${c}" "${POLICY_HOME}"/etc/profile.d/
57 confName="$(basename "${c}")"
58 sed -i -e "s/ *= */=/" -e "s/=\([^\"\']*$\)/='\1'/" "${POLICY_HOME}/etc/profile.d/${confName}"
61 source "${POLICY_HOME}"/etc/profile.d/env.sh
65 if [ "${DEBUG}" = "y" ]; then
70 if ! ls "${POLICY_INSTALL_INIT}"/features*.zip > /dev/null 2>&1; then
74 source "${POLICY_HOME}"/etc/profile.d/env.sh
76 for f in $(ls "${POLICY_INSTALL_INIT}"/features*.zip 2> /dev/null); do
77 echo "installing feature: ${f}"
78 "${POLICY_HOME}"/bin/features install "${f}"
83 if [ "${DEBUG}" = "y" ]; then
88 local scriptExtSuffix=${1:-"sh"}
90 if ! ls "${POLICY_INSTALL_INIT}"/*."${scriptExtSuffix}" > /dev/null 2>&1; then
94 source "${POLICY_HOME}"/etc/profile.d/env.sh
96 for s in $(ls "${POLICY_INSTALL_INIT}"/*."${scriptExtSuffix}" 2> /dev/null); do
97 echo "executing script: ${s}"
103 if [ "${DEBUG}" = "y" ]; then
104 echo "-- security --"
108 if [ -f "${POLICY_INSTALL_INIT}"/policy-keystore ]; then
109 if ! cmp -s "${POLICY_INSTALL_INIT}"/policy-keystore "${POLICY_HOME}"/etc/ssl/policy-keystore; then
110 echo "overriding policy-keystore"
111 cp -f "${POLICY_INSTALL_INIT}"/policy-keystore "${POLICY_HOME}"/etc/ssl
115 if [ -f "${POLICY_INSTALL_INIT}"/policy-truststore ]; then
116 if ! cmp -s "${POLICY_INSTALL_INIT}"/policy-truststore "${POLICY_HOME}"/etc/ssl/policy-truststore; then
117 echo "overriding policy-truststore"
118 cp -f "${POLICY_INSTALL_INIT}"/policy-truststore "${POLICY_HOME}"/etc/ssl
123 function serverConfig {
124 if [ "${DEBUG}" = "y" ]; then
125 echo "-- serverConfig --"
129 local configExtSuffix=${1:-"properties"}
131 if ! ls "${POLICY_INSTALL_INIT}"/*."${configExtSuffix}" > /dev/null 2>&1; then
135 for p in $(ls "${POLICY_INSTALL_INIT}"/*."${configExtSuffix}" 2> /dev/null); do
136 echo "configuration ${configExtSuffix}: ${p}"
137 cp -f "${p}" "${POLICY_HOME}"/config
142 if [ "${DEBUG}" = "y" ]; then
147 if [ -z "${SQL_HOST}" ]; then
151 if [ -z "${SQL_PORT}" ]; then
155 echo "Waiting for ${SQL_HOST}:${SQL_PORT} ..."
156 timeout 120 sh -c 'until nc -vz -w 20 "${SQL_HOST}" "${SQL_PORT}"; do echo -n "."; sleep 1; done'
158 "${POLICY_HOME}"/bin/db-migrator -s ALL -o upgrade
162 if [ "${DEBUG}" = "y" ]; then
172 source "${POLICY_HOME}"/etc/profile.d/env.sh
180 if [ "${DEBUG}" = "y" ]; then
189 serverConfig "properties"
196 if [ "${DEBUG}" = "y" ]; then
201 source "${POLICY_HOME}"/etc/profile.d/env.sh
206 if [ "${DEBUG}" = "y" ]; then
207 echo "-- configure --"
216 if [ "${DEBUG}" = "y" ]; then
227 function dockerBoot {
228 if [ "${DEBUG}" = "y" ]; then
229 echo "-- dockerBoot --"
237 source "${POLICY_HOME}"/etc/profile.d/env.sh
241 if [ "${DEBUG}" = "y" ]; then
247 case "${operation}" in