[sdc] - latest code changes
[sdc.git] / sdc-os-chef / sdc-backend / startup.sh
1 #!/bin/sh
2
3 export CHEFNAME=${ENVNAME}
4 # executing chef-solo for configuration
5 cd /root/chef-solo
6 echo "normal['HOST_IP'] = \"${HOST_IP}\"" > /root/chef-solo/cookbooks/sdc-catalog-be/attributes/default.rb
7 chef-solo -c solo.rb -E ${CHEFNAME}
8
9 sed -i '/^set -e/aJAVA_OPTIONS=\" -XX:MaxPermSize=256m -Xmx1500m -Dconfig.home=${JETTY_BASE}\/config -Dlog.home=${JETTY_BASE}\/logs -Dlogback.configurationFile=${JETTY_BASE}\/config\/catalog-be\/logback.xml -Dconfiguration.yaml=${JETTY_BASE}\/config\/catalog-be\/configuration.yaml -Dartifactgenerator.config=${JETTY_BASE}\/config\/catalog-be\/Artifact-Generator.properties\" ' /docker-entrypoint.sh
10 sed -i '/^set -e/aTMPDIR=${JETTY_BASE}\/temp' /docker-entrypoint.sh
11
12 # executiong the jetty
13 cd /var/lib/jetty
14 /docker-entrypoint.sh &
15
16 # add the consumers
17 cd /root/chef-solo
18 python /root/chef-solo/cookbooks/sdc-catalog-be/files/default/consumers.py &
19
20 # add the user
21 python /root/chef-solo/cookbooks/sdc-catalog-be/files/default/user.py &
22
23 # check if BackEnd is up
24 python /root/chef-solo/cookbooks/sdc-normatives/files/default/check_Backend_Health.py
25
26 # executing the normatives
27 cd /root/chef-solo
28 check_normative="/tmp/check_normative.out"
29 curl -s -X GET -H "Content-Type: application/json;charset=UTF-8" -H "USER_ID: jh0003" -H "X-ECOMP-RequestID: cbe744a0-037b-458f-aab5-df6e543c4090" -H "Cache-Control: no-cache" -H "Postman-Token: af08ca1c-302f-1431-404f-ed84246e07c9" "http://${HOST_IP}:8080/sdc2/rest/v1/screen" > ${check_normative}
30
31 echo "normal['HOST_IP'] = \"${HOST_IP}\"" > /root/chef-solo/cookbooks/sdc-normatives/attributes/default.rb
32 resources_len=`cat ${check_normative}| jq '.["resources"]|length'`
33 if [ $resources_len -eq 0 ] ; then
34    chef-solo -c normatives.rb
35 else
36    sed -i "s/import/upgrade/g" normatives.json
37    chef-solo -c normatives.rb
38 fi
39
40 while true; do sleep 2; done
41