blob: 0e5fae082ac8c5e489bd4fcb2004790702c8ab29 [file] [log] [blame]
Mandeep Khinda5291ba32017-09-20 16:57:09 +00001#!/bin/bash -x
Mandeep Khindadc2dc862017-09-08 05:20:30 +00002
yurynebdbbd22017-11-28 01:17:36 +02003concat_array() {
4 local arr=("$@")
5 local str=''
6 for i in ${!arr[@]}; do
7 if (( $i > 0 )); then
8 str="${str};"
9 fi
10 str="${str}${arr[$i]}"
11 done
12 echo "$str"
13}
14
Mandeep Khindadc2dc862017-09-08 05:20:30 +000015echo "Validating onap-parameters.yaml has been populated"
16[[ -z "$OPENSTACK_UBUNTU_14_IMAGE" ]] && { echo "Error: OPENSTACK_UBUNTU_14_IMAGE must be set in onap-parameters.yaml"; exit 1; }
17[[ -z "$OPENSTACK_PUBLIC_NET_ID" ]] && { echo "Error: OPENSTACK_PUBLIC_NET_ID must be set in onap-parameters.yaml"; exit 1; }
18[[ -z "$OPENSTACK_OAM_NETWORK_ID" ]] && { echo "Error: OPENSTACK_OAM_NETWORK_ID must be set in onap-parameters.yaml"; exit 1; }
19[[ -z "$OPENSTACK_OAM_SUBNET_ID" ]] && { echo "Error: OPENSTACK_OAM_SUBNET_ID must be set in onap-parameters.yaml"; exit 1; }
20[[ -z "$OPENSTACK_OAM_NETWORK_CIDR" ]] && { echo "Error: OPENSTACK_OAM_NETWORK_CIDR must be set in onap-parameters.yaml"; exit 1; }
21[[ -z "$OPENSTACK_USERNAME" ]] && { echo "Error: OPENSTACK_USERNAME must be set in onap-parameters.yaml"; exit 1; }
Mandeep Khindab53254b2017-09-20 16:39:30 +000022[[ -z "$OPENSTACK_TENANT_ID" ]] && { echo "Error: OPENSTACK_TENANT_ID must be set in onap-parameters.yaml"; exit 1; }
Mandeep Khindadc2dc862017-09-08 05:20:30 +000023[[ -z "$OPENSTACK_API_KEY" ]] && { echo "Error: OPENSTACK_API_KEY must be set in onap-parameters.yaml"; exit 1; }
24[[ -z "$OPENSTACK_REGION" ]] && { echo "Error: OPENSTACK_REGION must be set in onap-parameters.yaml"; exit 1; }
25[[ -z "$OPENSTACK_KEYSTONE_URL" ]] && { echo "Error: OPENSTACK_KEYSTONE_URL must be set in onap-parameters.yaml"; exit 1; }
26[[ -z "$OPENSTACK_FLAVOUR_MEDIUM" ]] && { echo "Error: OPENSTACK_FLAVOUR_MEDIUM must be set in onap-parameters.yaml"; exit 1; }
27[[ -z "$OPENSTACK_SERVICE_TENANT_NAME" ]] && { echo "Error: OPENSTACK_SERVICE_TENANT_NAME must be set in onap-parameters.yaml"; exit 1; }
28[[ -z "$DMAAP_TOPIC" ]] && { echo "Error: DMAAP_TOPIC must be set in onap-parameters.yaml"; exit 1; }
29[[ -z "$DEMO_ARTIFACTS_VERSION" ]] && { echo "Error: DEMO_ARTIFACTS_VERSION must be set in onap-parameters.yaml"; exit 1; }
30[[ -z "$OPENSTACK_TENANT_NAME" ]] && { echo "Error: OPENSTACK_TENANT_NAME must be set in onap-parameters.yaml"; exit 1; }
31
Mike Elliottd17accd2017-08-14 16:21:40 -040032#make NAMESPACE directory
Mandeep Khindadc2dc862017-09-08 05:20:30 +000033echo "Creating $NAMESPACE directory if it doesn't exist"
Mike Elliottd17accd2017-08-14 16:21:40 -040034mkdir -p /config-init/$NAMESPACE/
Mandeep Khindad6ea9872017-06-24 11:49:37 -040035
Mike Elliottd17accd2017-08-14 16:21:40 -040036#unzip the configs in the NAMESPACEs directory ensuring no overwriting of files
Mandeep Khindadc2dc862017-09-08 05:20:30 +000037echo "Installing configuration files"
Mike Elliottd17accd2017-08-14 16:21:40 -040038cp -vnpr /opt/config/src/* /config-init/$NAMESPACE/
Mandeep Khindad6ea9872017-06-24 11:49:37 -040039
40#ensure db directories exist.
Mike Elliottd17accd2017-08-14 16:21:40 -040041mkdir -p /config-init/$NAMESPACE/appc/data/
42mkdir -p /config-init/$NAMESPACE/dcae/pgaas/pgdata/
43mkdir -p /config-init/$NAMESPACE/portal/mariadb/data/
Mandeep Khinda82c63d32017-08-21 16:04:37 -040044mkdir -p /config-init/$NAMESPACE/portal/logs/
Mike Elliottd17accd2017-08-14 16:21:40 -040045mkdir -p /config-init/$NAMESPACE/sdnc/data/
46mkdir -p /config-init/$NAMESPACE/vid/mariadb/data/
47mkdir -p /config-init/$NAMESPACE/sdc/sdc-cs/CS/
Mike Elliottd17accd2017-08-14 16:21:40 -040048mkdir -p /config-init/$NAMESPACE/sdc/logs/ASDC/ASDC-ES/
49mkdir -p /config-init/$NAMESPACE/sdc/logs/ASDC/ASDC-CS/
50mkdir -p /config-init/$NAMESPACE/sdc/logs/ASDC/ASDC-KB/
51mkdir -p /config-init/$NAMESPACE/sdc/logs/ASDC/ASDC-BE/
52mkdir -p /config-init/$NAMESPACE/sdc/logs/ASDC/ASDC-FE/
53mkdir -p /config-init/$NAMESPACE/aai/opt/aai/logroot/
Mandeep Khinda9cd22112017-08-30 14:40:13 +000054mkdir -p /config-init/$NAMESPACE/aai/model-loader/logs/
Mandeep Khinda76092d62017-09-01 02:15:17 +000055mkdir -p /config-init/$NAMESPACE/aai/aai-traversal/logs/
56mkdir -p /config-init/$NAMESPACE/aai/aai-resources/logs/
Mandeep Khinda9cd22112017-08-30 14:40:13 +000057mkdir -p /config-init/$NAMESPACE/aai/sparky-be/logs/
58mkdir -p /config-init/$NAMESPACE/aai/elasticsearch/es-data/
Mandeep Khinda76092d62017-09-01 02:15:17 +000059mkdir -p /config-init/$NAMESPACE/aai/search-data-service/logs/
60mkdir -p /config-init/$NAMESPACE/aai/data-router/logs/
BorislavG66a9a5c2017-09-06 15:12:46 +030061mkdir -p /config-init/$NAMESPACE/mso/mariadb/data
Dusan Rozmanf776f3d2017-09-18 13:07:56 -040062mkdir -p /config-init/$NAMESPACE/clamp/mariadb/data
Itay Hasside2da86d2017-08-24 12:54:42 +000063mkdir -p /config-init/$NAMESPACE/log/elasticsearch/data
gfrabonibe779fa2017-09-19 13:25:30 -040064mkdir -p /config-init/$NAMESPACE/consul/consul-agent-config/bin
65mkdir -p /config-init/$NAMESPACE/consul/consul-agent-config/scripts
66mkdir -p /config-init/$NAMESPACE/consul/consul-server-config
Mandeep Khindad6ea9872017-06-24 11:49:37 -040067
Mandeep Khindadc2dc862017-09-08 05:20:30 +000068echo "Setting permissions to container writeable directories"
Mike Elliottd17accd2017-08-14 16:21:40 -040069chmod -R 777 /config-init/$NAMESPACE/sdc/logs/
Mandeep Khinda82c63d32017-08-21 16:04:37 -040070chmod -R 777 /config-init/$NAMESPACE/portal/logs/
Mike Elliottd17accd2017-08-14 16:21:40 -040071chmod -R 777 /config-init/$NAMESPACE/aai/aai-config/
72chmod -R 777 /config-init/$NAMESPACE/aai/aai-data/
73chmod -R 777 /config-init/$NAMESPACE/aai/opt/aai/logroot/
Mandeep Khinda9cd22112017-08-30 14:40:13 +000074chmod -R 777 /config-init/$NAMESPACE/aai/model-loader/logs/
75chmod -R 777 /config-init/$NAMESPACE/aai/haproxy/log/
76chmod -R 777 /config-init/$NAMESPACE/aai/aai-traversal/logs/
77chmod -R 777 /config-init/$NAMESPACE/aai/aai-resources/logs/
78chmod -R 777 /config-init/$NAMESPACE/aai/sparky-be/logs/
79chmod -R 777 /config-init/$NAMESPACE/aai/elasticsearch/es-data/
Mandeep Khinda76092d62017-09-01 02:15:17 +000080chmod -R 777 /config-init/$NAMESPACE/aai/search-data-service/logs/
81chmod -R 777 /config-init/$NAMESPACE/aai/data-router/logs/
Itay Hasside2da86d2017-08-24 12:54:42 +000082chmod -R 777 /config-init/$NAMESPACE/log/elasticsearch
yurynd0707be2017-09-27 14:54:18 +030083chown -R root:root /config-init/$NAMESPACE/log
Mandeep Khinda76092d62017-09-01 02:15:17 +000084
Mandeep Khindadc2dc862017-09-08 05:20:30 +000085# SDNC/Robot preload files manipulation
86OPENSTACK_OAM_NETWORK_CIDR_PREFIX=`cut -d. -f1-3 <<<"$OPENSTACK_OAM_NETWORK_CIDR"`
Mandeep Khindadc2dc862017-09-08 05:20:30 +000087# MSO post install steps to encrypt openstack password
88MSO_ENCRYPTION_KEY=$(cat /config-init/$NAMESPACE/mso/mso/encryption.key)
BorislavG317f2d52017-11-22 14:02:09 +020089OPENSTACK_API_ENCRYPTED_KEY=`echo -n "$OPENSTACK_API_KEY" | openssl aes-128-ecb -e -K $MSO_ENCRYPTION_KEY -nosalt | xxd -c 256 -p`
Mandeep Khindadc2dc862017-09-08 05:20:30 +000090
yurynebdbbd22017-11-28 01:17:36 +020091echo "Substituting configuration parameters"
92
93# replace the default 'onap' namespace qualification of K8s hostnames within the config files
94SED_NS_PATHS="/config-init/$NAMESPACE/"
95SED_NS_STRINGS=(
BorislavG8bfc6cf2018-02-27 15:04:26 +000096 "s/\.namespace-placeholder/\.${NAMESPACE}/g"
97 "s/kubectl -n namespace-placeholder/kubectl -n ${NAMESPACE}/g"
yurynebdbbd22017-11-28 01:17:36 +020098)
99SED_NS_STRING=$(concat_array "${SED_NS_STRINGS[@]}")
100find $SED_NS_PATHS -type f -exec sed -i -e "${SED_NS_STRING}" {} \;
101
102# set variable parameters
103# ATTENTION: the list of the paths must be verified if more parameters are added!
104SED_CONFIG_PATHS="/config-init/$NAMESPACE/robot/ /config-init/$NAMESPACE/mso/"
105SED_CONFIG_STRINGS=( \
106 "s/UBUNTU_14_IMAGE_NAME_HERE/${OPENSTACK_UBUNTU_14_IMAGE}/g" \
107 "s/OPENSTACK_PUBLIC_NET_ID_HERE/${OPENSTACK_PUBLIC_NET_ID}/g" \
108 "s/OPENSTACK_NETWORK_ID_WITH_ONAP_ROUTE_HERE/${OPENSTACK_OAM_NETWORK_ID}/g" \
109 "s/OPENSTACK_SUBNET_ID_WITH_ONAP_ROUTE_HERE/${OPENSTACK_OAM_SUBNET_ID}/g" \
110 "s,NETWORK_CIDR_WITH_ONAP_ROUTE_HERE,${OPENSTACK_OAM_NETWORK_CIDR},g" \
111 "s/OPENSTACK_USERNAME_HERE/${OPENSTACK_USERNAME}/g" \
112 "s/OPENSTACK_TENANT_ID_HERE/${OPENSTACK_TENANT_ID}/g" \
113 "s/OPENSTACK_PASSWORD_HERE/${OPENSTACK_API_KEY}/g" \
114 "s/OPENSTACK_REGION_HERE/${OPENSTACK_REGION}/g" \
115 "s,OPENSTACK_KEYSTONE_IP_HERE,${OPENSTACK_KEYSTONE_URL},g" \
116 "s/OPENSTACK_FLAVOUR_MEDIUM_HERE/${OPENSTACK_FLAVOUR_MEDIUM}/g" \
117 "s/DMAAP_TOPIC_HERE/${DMAAP_TOPIC}/g" \
118 "s/OPENSTACK_SERVICE_TENANT_NAME_HERE/${OPENSTACK_SERVICE_TENANT_NAME}/g" \
119 "s/DEMO_ARTIFACTS_VERSION_HERE/${DEMO_ARTIFACTS_VERSION}/g" \
120 "s/OPENSTACK_OAM_NETWORK_CIDR_PREFIX_HERE/${OPENSTACK_OAM_NETWORK_CIDR_PREFIX}/g" \
121 "s/OPENSTACK_ENCRYPTED_PASSWORD_HERE/${OPENSTACK_API_ENCRYPTED_KEY}/g" \
122 "s/OPENSTACK_TENANT_NAME_HERE/${OPENSTACK_TENANT_NAME}/g" \
123)
124SED_CONFIG_STRING=$(concat_array "${SED_CONFIG_STRINGS[@]}")
125find $SED_CONFIG_PATHS -type f -exec sed -i -e "${SED_CONFIG_STRING}" {} \;
Mandeep Khindadc2dc862017-09-08 05:20:30 +0000126
Itay Hasside2da86d2017-08-24 12:54:42 +0000127echo "Done!"