aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-be/sdc-backend-init/custom-scripts
diff options
context:
space:
mode:
Diffstat (limited to 'catalog-be/sdc-backend-init/custom-scripts')
-rw-r--r--catalog-be/sdc-backend-init/custom-scripts/check_backend.sh48
-rw-r--r--catalog-be/sdc-backend-init/custom-scripts/create_consumer_and_user.sh60
-rw-r--r--catalog-be/sdc-backend-init/custom-scripts/import_normatives.sh65
3 files changed, 173 insertions, 0 deletions
diff --git a/catalog-be/sdc-backend-init/custom-scripts/check_backend.sh b/catalog-be/sdc-backend-init/custom-scripts/check_backend.sh
new file mode 100644
index 0000000000..cf7d6e4053
--- /dev/null
+++ b/catalog-be/sdc-backend-init/custom-scripts/check_backend.sh
@@ -0,0 +1,48 @@
+#!/bin/sh
+
+
+# Set protocol and port based on the HTTP setting
+if [ "$DISABLE_HTTP" = "true" ]; then
+ protocol="https"
+ https_flag="--https"
+ be_port=$BE_HTTPS_PORT
+else
+ protocol="http"
+ https_flag=""
+ be_port=$BE_HTTP_PORT
+fi
+
+# Initialize optional flags as empty strings
+tls_cert=""
+tls_key=""
+tls_key_pw=""
+ca_cert=""
+basic_auth_config=""
+
+# Set TLS configuration flags if using HTTPS
+if [ "$protocol" = "https" ]; then
+ [ -n "$TLS_CERT" ] && tls_cert="--tls_cert $TLS_CERT"
+ [ -n "$TLS_KEY" ] && tls_key="--tls_key $TLS_KEY"
+ [ -n "$TLS_KEY_PW" ] && tls_key_pw="--tls_key_pw $TLS_KEY_PW"
+ [ -n "$CA_CERT" ] && ca_cert="--ca_cert $CA_CERT"
+fi
+
+
+# Check if both username and password are provided
+if [ -n "$BASIC_AUTH_USER" ] && [ -n "$BASIC_AUTH_PASS" ]; then
+ # Create just the Base64-encoded value of "username:password"
+ basic_auth_config="--header $(echo -n "$BASIC_AUTH_USER:$BASIC_AUTH_PASS" | base64)"
+fi
+
+start_time=$(date +"%Y-%m-%d %H:%M:%S")
+echo "[$start_time] Starting sdccheckbackend..."
+
+sdccheckbackend -i $BE_IP -p $be_port $basic_auth_config $https_flag $tls_cert $tls_key $tls_key_pw $ca_cert
+
+end_time=$(date +"%Y-%m-%d %H:%M:%S")
+echo "[$end_time] Finished sdccheckbackend."
+
+start_ts=$(date -d "$start_time" +%s)
+end_ts=$(date -d "$end_time" +%s)
+elapsed=$((end_ts - start_ts))
+echo "Elapsed time: $elapsed seconds"
diff --git a/catalog-be/sdc-backend-init/custom-scripts/create_consumer_and_user.sh b/catalog-be/sdc-backend-init/custom-scripts/create_consumer_and_user.sh
new file mode 100644
index 0000000000..3b7267c356
--- /dev/null
+++ b/catalog-be/sdc-backend-init/custom-scripts/create_consumer_and_user.sh
@@ -0,0 +1,60 @@
+#!/bin/sh
+
+# Set protocol and port based on the HTTP setting
+if [ "$DISABLE_HTTP" = "true" ]; then
+ protocol="https"
+ https_flag="--https"
+ be_port=$BE_HTTPS_PORT
+else
+ protocol="http"
+ https_flag=""
+ be_port=$BE_HTTP_PORT
+fi
+
+basic_auth_config=""
+
+# Check if both username and password are provided
+if [ -n "$BASIC_AUTH_USER" ] && [ -n "$BASIC_AUTH_PASS" ]; then
+ # Create just the Base64-encoded value of "username:password"
+ basic_auth_config="--header $(echo -n "$BASIC_AUTH_USER:$BASIC_AUTH_PASS" | base64)"
+fi
+
+
+tls_cert=""
+tls_key=""
+tls_key_pw=""
+ca_cert=""
+
+if [ "$protocol" = "https" ]; then
+ if [ -n "$TLS_CERT" ]; then
+ tls_cert="--tls_cert $TLS_CERT"
+ fi
+ if [ -n "$TLS_KEY" ]; then
+ tls_key="--tls_key $TLS_KEY"
+ fi
+ if [ -n "$TLS_KEY_PW" ]; then
+ tls_key_pw="--tls_key_pw $TLS_KEY_PW"
+ fi
+ if [ -n "$CA_CERT" ]; then
+ ca_cert="--ca_cert $CA_CERT"
+ fi
+fi
+
+# Execute sdcuserinit command
+start_time=$(date +"%Y-%m-%d %H:%M:%S")
+echo "[$start_time] Starting sdcuserinit..."
+
+sdcuserinit -i $BE_IP -p $be_port $basic_auth_config $user_conf_dir $https_flag $tls_cert $tls_key $tls_key_pw $ca_cert
+echo "sdcuserinit executed successfully."
+
+start_time=$(date +"%Y-%m-%d %H:%M:%S")
+echo "[$start_time] Starting sdcconsumerinit..."
+sdcconsumerinit -i $BE_IP -p $be_port $basic_auth_config $https_flag $tls_cert $tls_key $tls_key_pw $ca_cert
+
+end_time=$(date +"%Y-%m-%d %H:%M:%S")
+echo "[$end_time] Finished sdcuserinit and sdcconsumerinit."
+
+start_ts=$(date -d "$start_time" +%s)
+end_ts=$(date -d "$end_time" +%s)
+elapsed=$((end_ts - start_ts))
+echo "Elapsed time: $elapsed seconds"
diff --git a/catalog-be/sdc-backend-init/custom-scripts/import_normatives.sh b/catalog-be/sdc-backend-init/custom-scripts/import_normatives.sh
new file mode 100644
index 0000000000..e21e1b01b0
--- /dev/null
+++ b/catalog-be/sdc-backend-init/custom-scripts/import_normatives.sh
@@ -0,0 +1,65 @@
+#!/bin/sh
+
+
+# Set protocol and port based on DISABLE_HTTP
+if [ "$DISABLE_HTTP" = "true" ]; then
+ protocol="https"
+ be_port=$BE_HTTPS_PORT
+ param="-i $BE_IP -p $be_port --https"
+
+ # Set TLS flags if certificates are provided
+ if [ -n "$TLS_CERT" ]; then
+ tls_cert="--tls_cert $TLS_CERT"
+ fi
+ if [ -n "$TLS_KEY" ]; then
+ tls_key="--tls_key $TLS_KEY"
+ fi
+ if [ -n "$TLS_KEY_PW" ]; then
+ tls_key_pw="--tls_key_pw $TLS_KEY_PW"
+ fi
+ if [ -n "$CA_CERT" ]; then
+ ca_cert="--ca_cert $CA_CERT"
+ fi
+else
+ protocol="http"
+ be_port="$BE_HTTP_PORT"
+ param="-i $BE_IP -p $be_port"
+fi
+
+# Set basic authentication if enabled
+if [ "$BASIC_AUTH_ENABLED" = "true" ]; then
+ basic_auth_user="${BASIC_AUTH_USER:-}"
+ basic_auth_pass="${BASIC_AUTH_PASS:-}"
+
+ if [ -n "$basic_auth_user" ] && [ -n "$basic_auth_pass" ]; then
+ basic_auth_config="--header $(echo -n "$basic_auth_user:$basic_auth_pass" | base64)"
+ else
+ basic_auth_config=""
+ fi
+else
+ basic_auth_config=""
+fi
+
+# Extract normatives tarball and run the initialization command
+echo "Extracting normatives.tar.gz and initializing SDC..."
+cd /var/tmp/ || exit 1
+cp /home/onap/normatives.tar.gz /var/tmp/
+tar -xvf /var/tmp/normatives.tar.gz
+
+start_time=$(date +"%Y-%m-%d %H:%M:%S")
+echo "[$start_time] Starting sdcinit..."
+
+# Run sdcinit command with the constructed parameters
+cd /var/tmp/normatives/import/tosca || exit 1
+sdcinit $param $basic_auth_config $tls_cert $tls_key $tls_key_pw $ca_cert > "/home/onap/logs/init.log" 2>&1
+
+end_time=$(date +"%Y-%m-%d %H:%M:%S")
+echo "[$end_time] Done sdcinit."
+
+start_ts=$(date -d "$start_time" +%s)
+end_ts=$(date -d "$end_time" +%s)
+elapsed=$((end_ts - start_ts))
+echo "Elapsed time: $elapsed seconds"
+
+echo "SDC initialization Done. Logs can be found at ${ONAP_LOG}/init.log"
+