diff options
author | Venkata Harish K Kajur <vk250x@att.com> | 2018-01-30 13:52:34 -0500 |
---|---|---|
committer | Venkata Harish K Kajur <vk250x@att.com> | 2018-02-28 11:36:08 -0500 |
commit | 4f13d6cc64eed0ef75a31ec5f490853267447ab1 (patch) | |
tree | cb7066e12fc39038cc99b74bbeba879c9eb6ca8c /aai-resources/src/main/scripts/common_functions.sh | |
parent | 73539cae6d24e352b84a6411e523da734fbc19e2 (diff) |
Turn ajsc 2 to using ajsc 6 spring boot
Issue-ID: AAI-800
Change-Id: Id174ec5088ddea57f18e605d004c417bee8fbf33
Signed-off-by: Venkata Harish K Kajur <vk250x@att.com>
Diffstat (limited to 'aai-resources/src/main/scripts/common_functions.sh')
-rw-r--r-- | aai-resources/src/main/scripts/common_functions.sh | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/aai-resources/src/main/scripts/common_functions.sh b/aai-resources/src/main/scripts/common_functions.sh new file mode 100644 index 0000000..853941c --- /dev/null +++ b/aai-resources/src/main/scripts/common_functions.sh @@ -0,0 +1,56 @@ +#!/bin/ksh + +# Common functions that can be used throughout multiple scripts +# In order to call these functions, this file needs to be sourced + +# Checks if the user that is currently running is aaiadmin +check_user(){ + + userid=$( id | cut -f2 -d"(" | cut -f1 -d")" ) + + if [ "${userid}" != "aaiadmin" ]; then + echo "You must be aaiadmin to run $0. The id used $userid." + exit 1 + fi +} + +# Sources the profile and sets the project home +source_profile(){ + . /etc/profile.d/aai.sh + PROJECT_HOME=/opt/app/aai-resources +} + +# Runs the spring boot jar based on which main class +# to execute and which logback file to use for that class +execute_spring_jar(){ + + className=$1; + logbackFile=$2; + + shift 2; + + EXECUTABLE_JAR=$(ls ${PROJECT_HOME}/lib/*.jar); + + JAVA_OPTS="${JAVA_PRE_OPTS}"; + JAVA_OPTS="-DAJSC_HOME=$PROJECT_HOME"; + JAVA_OPTS="$JAVA_OPTS -DBUNDLECONFIG_DIR=resources"; + JAVA_OPTS="$JAVA_OPTS -Daai.home=$PROJECT_HOME "; + JAVA_OPTS="$JAVA_OPTS -Dhttps.protocols=TLSv1.1,TLSv1.2"; + JAVA_OPTS="$JAVA_OPTS -Dloader.main=${className}"; + JAVA_OPTS="$JAVA_OPTS -Dlogback.configurationFile=${logbackFile}"; + JAVA_OPTS="${JAVA_OPTS} ${JAVA_POST_OPTS}"; + + ${JAVA_HOME}/bin/java ${JVM_OPTS} ${JAVA_OPTS} -jar ${EXECUTABLE_JAR} "$@" +} + +# Prints the start date and the script that the user called +start_date(){ + echo + echo `date` " Starting $0" +} + +# Prints the end date and the script that the user called +end_date(){ + echo + echo `date` " Done $0" +} |