summaryrefslogtreecommitdiffstats
path: root/aai-traversal/src/main/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'aai-traversal/src/main/scripts')
-rw-r--r--aai-traversal/src/main/scripts/common_functions.sh56
-rw-r--r--aai-traversal/src/main/scripts/deleteNamedQuery.sh18
-rw-r--r--aai-traversal/src/main/scripts/deleteTool.sh4
-rw-r--r--aai-traversal/src/main/scripts/getTool.sh4
-rw-r--r--aai-traversal/src/main/scripts/install/updateQueryData.sh8
-rw-r--r--aai-traversal/src/main/scripts/putTool.sh35
6 files changed, 72 insertions, 53 deletions
diff --git a/aai-traversal/src/main/scripts/common_functions.sh b/aai-traversal/src/main/scripts/common_functions.sh
new file mode 100644
index 0000000..8bd881a
--- /dev/null
+++ b/aai-traversal/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-traversal
+}
+
+# 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/aai-traversal-*SNAPSHOT.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"
+}
diff --git a/aai-traversal/src/main/scripts/deleteNamedQuery.sh b/aai-traversal/src/main/scripts/deleteNamedQuery.sh
index 2d19a9c..43aaae7 100644
--- a/aai-traversal/src/main/scripts/deleteNamedQuery.sh
+++ b/aai-traversal/src/main/scripts/deleteNamedQuery.sh
@@ -22,15 +22,11 @@
#
#
-# This script deletes the named query in bundleconfig/etc/scriptdata/named-query-json directory
+# This script deletes the named query in resources/etc/scriptdata/named-query-json directory
#
PROGNAME=$(basename $0)
-<<<<<<< HEAD
-OUTFILE=$PROJECT_HOME/logs/misc/${PROGNAME}.log.$(date +\%Y-\%m-\%d)
-=======
OUTFILE=/opt/app/aai-traversal/logs/misc/${PROGNAME}.log.$(date +\%Y-\%m-\%d)
->>>>>>> codecloud/release/1802
#OUTFILE=/c/temp/${PROGNAME}.log.$(date +\%Y-\%m-\%d)
TS=$(date "+%Y-%m-%d %H:%M:%S")
@@ -49,23 +45,15 @@ error_exit () {
}
j=0
-<<<<<<< HEAD
-for filepath in `ls $PROJECT_HOME/bundleconfig/etc/scriptdata/named-query-json/*.json|sort -f`
-=======
-for filepath in `ls /opt/app/aai-traversal/bundleconfig/etc/scriptdata/named-query-json/*.json|sort -f`
->>>>>>> codecloud/release/1802
-#for filepath in `ls /c/sources/aai/aaigitnew/bundleconfig-local/etc/scriptdata/named-query-json/*.json|sort -f`
+for filepath in `ls /opt/app/aai-traversal/resources/etc/scriptdata/named-query-json/*.json|sort -f`
+#for filepath in `ls /c/sources/aai/aaigitnew/resources-local/etc/scriptdata/named-query-json/*.json|sort -f`
do
j=$(expr "$j" + 1)
filename=$(basename $filepath)
echo "Begin deleteTool for named-query $filename" | tee -a $OUTFILE
vers=`grep named-query-uuid $filepath|cut -d':' -f2|cut -d'"' -f2`
resource=service-design-and-creation/named-queries/named-query/$vers
-<<<<<<< HEAD
-echo "y" | $PROJECT_HOME/scripts/deleteTool.sh $resource >> $OUTFILE 2>&1 || error_exit "$resource $filepath" $j
-=======
echo "y" | /opt/app/aai-traversal/scripts/deleteTool.sh $resource >> $OUTFILE 2>&1 || error_exit "$resource $filepath" $j
->>>>>>> codecloud/release/1802
echo "End deleteTool for named-query $filename" | tee -a $OUTFILE
done
diff --git a/aai-traversal/src/main/scripts/deleteTool.sh b/aai-traversal/src/main/scripts/deleteTool.sh
index 60c3e1c..8d51437 100644
--- a/aai-traversal/src/main/scripts/deleteTool.sh
+++ b/aai-traversal/src/main/scripts/deleteTool.sh
@@ -50,7 +50,7 @@ fi
. /etc/profile.d/aai.sh
PROJECT_HOME=/opt/app/aai-traversal
-prop_file=$PROJECT_HOME/bundleconfig/etc/appprops/aaiconfig.properties
+prop_file=$PROJECT_HOME/resources/etc/appprops/aaiconfig.properties
log_dir=$PROJECT_HOME/logs/misc
today=$(date +\%Y-\%m-\%d)
@@ -80,7 +80,7 @@ fi
if [ $MISSING_PROP = false ]; then
if [ $USEBASICAUTH = false ]; then
- AUTHSTRING="--cert $PROJECT_HOME/bundleconfig/etc/auth/aaiClientPublicCert.pem --key $PROJECT_HOME/bundleconfig/etc/auth/aaiClientPrivateKey.pem"
+ AUTHSTRING="--cert $PROJECT_HOME/resources/etc/auth/aaiClientPublicCert.pem --key $PROJECT_HOME/resources/etc/auth/aaiClientPrivateKey.pem"
else
AUTHSTRING="-u $CURLUSER:$CURLPASSWORD"
fi
diff --git a/aai-traversal/src/main/scripts/getTool.sh b/aai-traversal/src/main/scripts/getTool.sh
index 39d4e87..df0456f 100644
--- a/aai-traversal/src/main/scripts/getTool.sh
+++ b/aai-traversal/src/main/scripts/getTool.sh
@@ -46,7 +46,7 @@ fi
. /etc/profile.d/aai.sh
PROJECT_HOME=/opt/app/aai-traversal
-prop_file=$PROJECT_HOME/bundleconfig/etc/appprops/aaiconfig.properties
+prop_file=$PROJECT_HOME/resources/etc/appprops/aaiconfig.properties
log_dir=$PROJECT_HOME/logs/misc
today=$(date +\%Y-\%m-\%d)
@@ -76,7 +76,7 @@ fi
if [ $MISSING_PROP = false ]; then
if [ $USEBASICAUTH = false ]; then
- AUTHSTRING="--cert $PROJECT_HOME/bundleconfig/etc/auth/aaiClientPublicCert.pem --key $PROJECT_HOME/bundleconfig/etc/auth/aaiClientPrivateKey.pem"
+ AUTHSTRING="--cert $PROJECT_HOME/resources/etc/auth/aaiClientPublicCert.pem --key $PROJECT_HOME/resources/etc/auth/aaiClientPrivateKey.pem"
else
AUTHSTRING="-u $CURLUSER:$CURLPASSWORD"
fi
diff --git a/aai-traversal/src/main/scripts/install/updateQueryData.sh b/aai-traversal/src/main/scripts/install/updateQueryData.sh
index 3c7f1bf..a5723d0 100644
--- a/aai-traversal/src/main/scripts/install/updateQueryData.sh
+++ b/aai-traversal/src/main/scripts/install/updateQueryData.sh
@@ -41,7 +41,7 @@ error_exit () {
}
j=0
-for filepath in `ls $PROJECT_HOME/bundleconfig/etc/scriptdata/widget-model-json/*.json|sort -f`
+for filepath in `ls $PROJECT_HOME/resources/etc/scriptdata/widget-model-json/*.json|sort -f`
do
j=$(expr "$j" + 1)
filename=$(basename $filepath)
@@ -54,7 +54,7 @@ echo "End putTool for widget $filename" | tee -a $OUTFILE
done
j=0
-for filepath in `ls $PROJECT_HOME/bundleconfig/etc/scriptdata/named-query-json/*.json|sort -f`
+for filepath in `ls $PROJECT_HOME/resources/etc/scriptdata/named-query-json/*.json|sort -f`
do
j=$(expr "$j" + 1)
filename=$(basename $filepath)
@@ -67,7 +67,7 @@ echo "End putTool for named-query $filename" | tee -a $OUTFILE
done
j=0
-for filepath in `ls $PROJECT_HOME/bundleconfig/etc/scriptdata/resource-model-json/*.json|sort -f`
+for filepath in `ls $PROJECT_HOME/resources/etc/scriptdata/resource-model-json/*.json|sort -f`
do
j=$(expr "$j" + 1)
filename=$(basename $filepath)
@@ -80,7 +80,7 @@ echo "End putTool for resource model $filename" | tee -a $OUTFILE
done
j=0
-for filepath in `ls $PROJECT_HOME/bundleconfig/etc/scriptdata/service-model-json/*.json|sort -f`
+for filepath in `ls $PROJECT_HOME/resources/etc/scriptdata/service-model-json/*.json|sort -f`
do
j=$(expr "$j" + 1)
filename=$(basename $filepath)
diff --git a/aai-traversal/src/main/scripts/putTool.sh b/aai-traversal/src/main/scripts/putTool.sh
index be273a2..6630d8f 100644
--- a/aai-traversal/src/main/scripts/putTool.sh
+++ b/aai-traversal/src/main/scripts/putTool.sh
@@ -22,14 +22,9 @@
#
#
-<<<<<<< HEAD
-# The script is called with a resource, filepath and an optional argument to
-# ignore HTTP failure codes which would otherwise indicate a failure.
-=======
# The script is called with a resource, filepath, an optional argument to
# ignore HTTP failure codes which would otherwise indicate a failure,
# and an optional argument to display more data.
->>>>>>> codecloud/release/1802
# It invokes a PUT on the resource with the file using curl
# Uses aaiconfig.properties for authorization type and url. The HTTP response
# code is checked. Responses between 200 and 299 are considered success.
@@ -51,8 +46,6 @@ contains() {
fi
}
-<<<<<<< HEAD
-=======
display_usage() {
cat <<EOF
Usage: $0 [options]
@@ -70,7 +63,6 @@ if [ $# -eq 0 ]; then
exit 1
fi
->>>>>>> codecloud/release/1802
# remove leading slash when present
RESOURCE=`echo $1 | sed "s,^/,,"`
if [ -z $RESOURCE ]; then
@@ -98,12 +90,10 @@ fi
. /etc/profile.d/aai.sh
PROJECT_HOME=/opt/app/aai-traversal
-prop_file=$PROJECT_HOME/bundleconfig/etc/appprops/aaiconfig.properties
+prop_file=$PROJECT_HOME/resources/etc/appprops/aaiconfig.properties
log_dir=$PROJECT_HOME/logs/misc
today=$(date +\%Y-\%m-\%d)
-<<<<<<< HEAD
-=======
RETURNRESPONSE=false
if [ ${#} -ne 2 ]; then
if [ "$3" = "-display" ]; then
@@ -116,7 +106,6 @@ if [ ${#} -ne 3 ]; then
fi
fi
->>>>>>> codecloud/release/1802
MISSING_PROP=false
RESTURL=`grep ^aai.server.url= $prop_file |cut -d'=' -f2 |tr -d "\015"`
if [ -z $RESTURL ]; then
@@ -143,26 +132,19 @@ fi
if [ $MISSING_PROP = false ]; then
if [ $USEBASICAUTH = false ]; then
- AUTHSTRING="--cert $PROJECT_HOME/bundleconfig/etc/auth/aaiClientPublicCert.pem --key $PROJECT_HOME/bundleconfig/etc/auth/aaiClientPrivateKey.pem"
+ AUTHSTRING="--cert $PROJECT_HOME/resources/etc/auth/aaiClientPublicCert.pem --key $PROJECT_HOME/resources/etc/auth/aaiClientPrivateKey.pem"
else
AUTHSTRING="-u $CURLUSER:$CURLPASSWORD"
fi
-<<<<<<< HEAD
- result=`curl --request PUT -sL -w "%{http_code}" -o /dev/null -k $AUTHSTRING -H "X-FromAppId: $XFROMAPPID" -H "X-TransactionId: $XTRANSID" -H "Accept: application/json" -T $JSONFILE $RESTURL$RESOURCE`
- #echo "result is $result."
- RC=0;
- if [ $? -eq 0 ]; then
-=======
-
+
if [ $RETURNRESPONSE = true ]; then
- curl --request PUT -sL -k $AUTHSTRING -H "X-FromAppId: $XFROMAPPID" -H "X-TransactionId: $XTRANSID" -H "Accept: application/json" -T $JSONFILE $RESTURL$RESOURCE | python -mjson.tool
+ curl --request PUT -sL -k $AUTHSTRING -H "Content-Type: application/json" -H "X-FromAppId: $XFROMAPPID" -H "X-TransactionId: $XTRANSID" -H "Accept: application/json" -T $JSONFILE $RESTURL$RESOURCE | python -mjson.tool
RC=$?
else
- result=`curl --request PUT -sL -w "%{http_code}" -o /dev/null -k $AUTHSTRING -H "X-FromAppId: $XFROMAPPID" -H "X-TransactionId: $XTRANSID" -H "Accept: application/json" -T $JSONFILE $RESTURL$RESOURCE`
+ result=`curl --request PUT -sL -w "%{http_code}" -o /dev/null -k $AUTHSTRING -H "Content-Type: application/json" -H "X-FromAppId: $XFROMAPPID" -H "X-TransactionId: $XTRANSID" -H "Accept: application/json" -T $JSONFILE $RESTURL$RESOURCE`
#echo "result is $result."
RC=0;
if [ $? -eq 0 ]; then
->>>>>>> codecloud/release/1802
case $result in
+([0-9])?)
#if [[ "$result" -eq 412 || "$result" -ge 200 && $result -lt 300 ]]
@@ -191,18 +173,11 @@ if [ $MISSING_PROP = false ]; then
;;
esac
-<<<<<<< HEAD
- else
- echo "FAILED to send request to $RESTURL"
- RC=-1
- fi
-=======
else
echo "FAILED to send request to $RESTURL"
RC=-1
fi
fi
->>>>>>> codecloud/release/1802
else
echo "usage: $0 resource file [expected-failure-codes]"
RC=-1