summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authormukesh.paliwal <mukesh.paliwal1@huawei.com>2021-02-05 12:44:04 +0530
committermukesh.paliwal <mukesh.paliwal1@huawei.com>2021-02-05 12:44:04 +0530
commit36e6d007799eb76a941c7ece38f35860baa8b303 (patch)
tree3cabb652d08674af6585838390f78726cf1c5b7a /scripts
parenta152547937fe212232120131d927156623c24425 (diff)
Split mso-cnf-adapter from the so
Issue-ID: SO-3517 Signed-off-by: mukesh.paliwal <mukesh.paliwal1@huawei.com> Change-Id: I99732559aa259c7a39854409819553d46aa0c080
Diffstat (limited to 'scripts')
-rw-r--r--scripts/.gitattributes5
-rwxr-xr-xscripts/start-app.sh89
-rwxr-xr-xscripts/wait-for.sh85
3 files changed, 179 insertions, 0 deletions
diff --git a/scripts/.gitattributes b/scripts/.gitattributes
new file mode 100644
index 0000000..b905d1d
--- /dev/null
+++ b/scripts/.gitattributes
@@ -0,0 +1,5 @@
+# Default behavior
+* text=auto
+
+# Files to have unix style line endings on checkout
+*.sh text eol=lf \ No newline at end of file
diff --git a/scripts/start-app.sh b/scripts/start-app.sh
new file mode 100755
index 0000000..54ed9ed
--- /dev/null
+++ b/scripts/start-app.sh
@@ -0,0 +1,89 @@
+#!/bin/sh
+#temprary condition
+if [ `id -u` = 0 ]
+then
+ # Install certificates found in the /app/ca-certificates volume, if any.
+
+ needUpdate=FALSE
+
+ for certificate in `ls -1 /app/ca-certificates`; do
+ echo "Installing $certificate in /usr/local/share/ca-certificates"
+ # cp /app/ca-certificates/$certificate /usr/local/share/ca-certificates/$certificate
+ needUpdate=FALSE
+ done
+
+ # Re-exec this script as the 'onap' user.
+ this=`readlink -f $0`
+ # exec su so -c "$this"
+fi
+
+touch /app/app.jar
+
+if [ ! -z "$DB_HOST" -a -z "$DB_PORT" ]; then
+ export DB_PORT=3306
+fi
+
+if [ -z "${CONFIG_PATH}" ]; then
+ export CONFIG_PATH=/app/config/override.yaml
+fi
+
+if [ "${SSL_DEBUG}" = "log" ]; then
+ export SSL_DEBUG="-Djavax.net.debug=all"
+else
+ export SSL_DEBUG=
+fi
+
+# Set java keystore and truststore options, if specified in the environment.
+
+jksargs=
+
+if [ ! -z "${KEYSTORE}" ]; then
+ jksargs="$jksargs -Dmso.load.ssl.client.keystore=true"
+ jksargs="$jksargs -Djavax.net.ssl.keyStore=$KEYSTORE"
+ jksargs="$jksargs -Djavax.net.ssl.keyStorePassword=${KEYSTORE_PASSWORD}"
+fi
+
+if [ ! -z "${TRUSTSTORE}" ]; then
+ jksargs="$jksargs -Djavax.net.ssl.trustStore=${TRUSTSTORE}"
+ jksargs="$jksargs -Djavax.net.ssl.trustStorePassword=${TRUSTSTORE_PASSWORD}"
+fi
+
+if [ -z "${ACTIVE_PROFILE}" ]; then
+ export ACTIVE_PROFILE="basic"
+fi
+
+jvmargs="${JVM_ARGS} -Dspring.profiles.active=${ACTIVE_PROFILE} -Djava.security.egd=file:/dev/./urandom -Dlogs_dir=${LOG_PATH} -Dlogging.config=/app/logback-spring.xml $jksargs -Dspring.config.additional-location=$CONFIG_PATH ${SSL_DEBUG} ${DISABLE_SNI}"
+
+
+read_properties(){
+ while IFS="=" read -r key value; do
+ case "${key}" in
+ '#'*) ;;
+ *)
+ eKey=$(echo $key | tr '[:lower:]' '[:upper:]')
+ export "$eKey"="$value"
+ esac
+ done <<-EOF
+ $1
+ EOF
+}
+
+
+
+if [ -n "${AAF_SSL_CERTS_ENABLED}" ]; then
+read_properties "$(head -n 4 /app/certs/.passphrases)"
+fi
+
+echo "JVM Arguments: ${jvmargs}"
+
+java ${jvmargs} -jar app.jar
+rc=$?
+
+echo "Application exiting with status code $rc"
+
+if [ ! -z "${EXIT_DELAY}" -a "${EXIT_DELAY}" != 0 ]; then
+ echo "Delaying $APP exit for $EXIT_DELAY seconds"
+ sleep $EXIT_DELAY
+fi
+
+exit $rc
diff --git a/scripts/wait-for.sh b/scripts/wait-for.sh
new file mode 100755
index 0000000..2525821
--- /dev/null
+++ b/scripts/wait-for.sh
@@ -0,0 +1,85 @@
+#!/bin/sh
+# https://github.com/Eficode/wait-for.git
+# MIT License
+
+TIMEOUT=15
+QUIET=0
+
+echoerr() {
+ if [ "$QUIET" -ne 1 ]; then printf "%s\n" "$*" 1>&2; fi
+}
+
+usage() {
+ exitcode="$1"
+ cat << USAGE >&2
+Usage:
+ $cmdname host:port [-t timeout] [-- command args]
+ -q | --quiet Do not output any status messages
+ -t TIMEOUT | --timeout=timeout Timeout in seconds, zero for no timeout
+ -- COMMAND ARGS Execute command with args after the test finishes
+USAGE
+ exit "$exitcode"
+}
+
+wait_for() {
+ command="$*"
+ if [ "$QUIET" -ne 1 ]; then echo "$0: probing host $HOST port $PORT"; fi
+ for i in `seq $TIMEOUT` ; do
+ nc -z "$HOST" "$PORT" > /dev/null 2>&1
+ result=$?
+ if [ $result -eq 0 ] ; then
+ if [ "$QUIET" -ne 1 ]; then echo "$0: operation succeeded on try $i"; fi
+ if [ -n "$command" ] ; then
+ if [ "$QUIET" -ne 1 ]; then echo "$0: exec-ing command $command"; fi
+ exec $command
+ fi
+ exit 0
+ fi
+ if [ "$QUIET" -ne 1 ]; then echo "$0: sleeping after try $i"; fi
+ sleep 1
+ done
+ echo "$0: Operation timed out" >&2
+ exit 1
+}
+
+while [ $# -gt 0 ]
+do
+ case "$1" in
+ *:* )
+ HOST=$(printf "%s\n" "$1"| cut -d : -f 1)
+ PORT=$(printf "%s\n" "$1"| cut -d : -f 2)
+ shift 1
+ ;;
+ -q | --quiet)
+ QUIET=1
+ shift 1
+ ;;
+ -t)
+ TIMEOUT="$2"
+ if [ "$TIMEOUT" = "" ]; then break; fi
+ shift 2
+ ;;
+ --timeout=*)
+ TIMEOUT="${1#*=}"
+ shift 1
+ ;;
+ --)
+ shift
+ break
+ ;;
+ --help)
+ usage 0
+ ;;
+ *)
+ echoerr "Unknown argument: $1"
+ usage 1
+ ;;
+ esac
+done
+
+if [ "$HOST" = "" -o "$PORT" = "" ]; then
+ echoerr "Error: you need to provide a host and port to test."
+ usage 2
+fi
+
+wait_for "$@"