3 # ============LICENSE_START=======================================================
5 # ================================================================================
6 # Copyright © 2017-2018 AT&T Intellectual Property. 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
12 # http://www.apache.org/licenses/LICENSE-2.0
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 # ============LICENSE_END=========================================================
23 # Common functions that can be used throughout multiple scripts
24 # In order to call these functions, this file needs to be sourced
26 # Checks if the user that is currently running is aaiadmin
29 userid=$( id | cut -f2 -d"(" | cut -f1 -d")" )
31 if [ "${userid}" != "aaiadmin" ]; then
32 echo "You must be aaiadmin to run $0. The id used $userid."
37 # Sources the profile and sets the project home
39 . /etc/profile.d/aai.sh
40 PROJECT_HOME=/opt/app/aai-schema-service
43 # Runs the spring boot jar based on which main class
44 # to execute and which logback file to use for that class
52 EXECUTABLE_JAR=$(ls ${PROJECT_HOME}/lib/*.jar);
54 JAVA_OPTS="${JAVA_PRE_OPTS} -DAJSC_HOME=$PROJECT_HOME";
55 JAVA_OPTS="$JAVA_OPTS -DBUNDLECONFIG_DIR=resources";
56 JAVA_OPTS="$JAVA_OPTS -Daai.home=$PROJECT_HOME ";
57 JAVA_OPTS="$JAVA_OPTS -Dhttps.protocols=TLSv1.1,TLSv1.2";
58 JAVA_OPTS="$JAVA_OPTS -Dloader.main=${className}";
59 JAVA_OPTS="$JAVA_OPTS -Dloader.path=${PROJECT_HOME}/resources";
60 JAVA_OPTS="$JAVA_OPTS -Dlogback.configurationFile=${logbackFile}";
62 export SOURCE_NAME=$(grep '^schema.source.name=' ${PROJECT_HOME}/resources/application.properties | cut -d"=" -f2-);
63 # Needed for the schema ingest library beans
64 eval $(grep '^schema\.' ${PROJECT_HOME}/resources/application.properties | \
65 sed 's/^\(.*\)$/JAVA_OPTS="$JAVA_OPTS -D\1"/g' | \
66 sed 's/${server.local.startpath}/${PROJECT_HOME}\/resources/g'| \
67 sed 's/${schema.source.name}/'${SOURCE_NAME}'/g'\
70 JAVA_OPTS="${JAVA_OPTS} ${JAVA_POST_OPTS}";
72 ${JAVA_HOME}/bin/java ${JVM_OPTS} ${JAVA_OPTS} -jar ${EXECUTABLE_JAR} "$@"
75 # Prints the start date and the script that the user called
78 echo `date` " Starting $0"
81 # Prints the end date and the script that the user called
84 echo `date` " Done $0"
87 # Inserts GEN_DB_WITH_NO_SCHEMA as a paranmter if it isn't there already
88 force_GEN_DB_WITH_NO_SCHEMA () {
91 if [ "$p" == "GEN_DB_WITH_NO_SCHEMA" ]
97 echo "GEN_DB_WITH_NO_SCHEMA $@"