-
Notifications
You must be signed in to change notification settings - Fork 21
/
myhero-install.sh
executable file
·141 lines (116 loc) · 6.36 KB
/
myhero-install.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
#! /bin/bash
echo
echo "Thank you for using the MyHero Demo Application."
echo "This script will install all of the Microservices needed, "
echo "for a basic installation. "
echo
echo "Press Enter to continue..."
read confirm
echo
[ -z "${MANTL_CONTROL}" ] && echo "Please run 'source myhero_setup' to set Environment Variables" && exit 1;
[ -z "${MANTL_USER}" ] && echo "Please run 'source myhero_setup' to set Environment Variables" && exit 1;
[ -z "${MANTL_PASSWORD}" ] && echo "Please run 'source myhero_setup' to set Environment Variables" && exit 1;
[ -z "${MANTL_DOMAIN}" ] && echo "Please run 'source myhero_setup' to set Environment Variables" && exit 1;
[ -z "${DEPLOYMENT_NAME}" ] && echo "Please run 'source myhero_setup' to set Environment Variables" && exit 1;
set -euo pipefail
echo " "
echo "************************************************************************************************"
echo Checking if MyHero has already been deployed with deployment name \"${DEPLOYMENT_NAME}\"
if python mantl_utils.py applicationexists ${DEPLOYMENT_NAME}/ui; then
echo " Deployment name already used."
echo " Rerun 'source myhero_setup' and choose a new deployment name."
exit 1
else
echo " Deployment name available, continuing."
fi
echo "************************************************************************************************"
# Create Copy of JSON Definitions for Deployment
echo "Creating Marathon Service Definitions for each service."
cp templates/sample-myhero-data.json app_definitions/${DEPLOYMENT_NAME}-data.json
sed -i -e "s/DEPLOYMENTNAME/${DEPLOYMENT_NAME}/g" app_definitions/${DEPLOYMENT_NAME}-data.json
sed -i -e "s/MANTLDOMAIN/${MANTL_DOMAIN}/g" app_definitions/${DEPLOYMENT_NAME}-data.json
sed -i -e "s/TAG/${TAG}/g" app_definitions/${DEPLOYMENT_NAME}-data.json
echo " myhero_data service: app_definitions/${DEPLOYMENT_NAME}-data.json"
cp templates/sample-myhero-mosca.json app_definitions/${DEPLOYMENT_NAME}-mosca.json
sed -i -e "s/DEPLOYMENTNAME/${DEPLOYMENT_NAME}/g" app_definitions/${DEPLOYMENT_NAME}-mosca.json
sed -i -e "s/MANTLDOMAIN/${MANTL_DOMAIN}/g" app_definitions/${DEPLOYMENT_NAME}-mosca.json
sed -i -e "s/TAG/${TAG}/g" app_definitions/${DEPLOYMENT_NAME}-mosca.json
echo " myhero_mosca service: app_definitions/${DEPLOYMENT_NAME}-mosca.json"
cp templates/sample-myhero-app.json app_definitions/${DEPLOYMENT_NAME}-app.json
sed -i -e "s/DEPLOYMENTNAME/${DEPLOYMENT_NAME}/g" app_definitions/${DEPLOYMENT_NAME}-app.json
sed -i -e "s/MANTLDOMAIN/${MANTL_DOMAIN}/g" app_definitions/${DEPLOYMENT_NAME}-app.json
sed -i -e "s/direct/queue/g" app_definitions/${DEPLOYMENT_NAME}-app.json
sed -i -e "s/TAG/${TAG}/g" app_definitions/${DEPLOYMENT_NAME}-app.json
echo " myhero_app service: app_definitions/${DEPLOYMENT_NAME}-app.json"
cp templates/sample-myhero-ernst.json app_definitions/${DEPLOYMENT_NAME}-ernst.json
sed -i -e "s/DEPLOYMENTNAME/${DEPLOYMENT_NAME}/g" app_definitions/${DEPLOYMENT_NAME}-ernst.json
sed -i -e "s/MANTLDOMAIN/${MANTL_DOMAIN}/g" app_definitions/${DEPLOYMENT_NAME}-ernst.json
sed -i -e "s/TAG/${TAG}/g" app_definitions/${DEPLOYMENT_NAME}-ernst.json
echo " myhero_ernst service: app_definitions/${DEPLOYMENT_NAME}-ernst.json"
cp templates/sample-myhero-ui.json app_definitions/${DEPLOYMENT_NAME}-ui.json
sed -i -e "s/DEPLOYMENTNAME/${DEPLOYMENT_NAME}/g" app_definitions/${DEPLOYMENT_NAME}-ui.json
sed -i -e "s/MANTLDOMAIN/${MANTL_DOMAIN}/g" app_definitions/${DEPLOYMENT_NAME}-ui.json
sed -i -e "s/TAG/${TAG}/g" app_definitions/${DEPLOYMENT_NAME}-ui.json
echo " myhero_ui service: app_definitions/${DEPLOYMENT_NAME}-ui.json"
#cp templates/sample-myhero-web.json app_definitions/${DEPLOYMENT_NAME}-web.json
#sed -i -e "s/DEPLOYMENTNAME/${DEPLOYMENT_NAME}/g" app_definitions/${DEPLOYMENT_NAME}-web.json
#sed -i -e "s/MANTLDOMAIN/${MANTL_DOMAIN}/g" app_definitions/${DEPLOYMENT_NAME}-web.json
#sed -i -e "s/TAG/${TAG}/g" app_definitions/${DEPLOYMENT_NAME}-web.json
#echo " myhero_web service: app_definitions/${DEPLOYMENT_NAME}-web.json"
echo " "
echo "************************************************************************************************"
echo Deploying Data Service
curl -k -X POST -u ${MANTL_USER}:${MANTL_PASSWORD} https://${MANTL_CONTROL}/v2/apps \
-o /dev/null \
-H "Content-type: application/json" \
-d @app_definitions/${DEPLOYMENT_NAME}-data.json
echo "************************************************************************************************"
echo
echo Deploying Mosca
curl -k -X POST -u ${MANTL_USER}:${MANTL_PASSWORD} https://${MANTL_CONTROL}/v2/apps \
-o /dev/null \
-H "Content-type: application/json" \
-d @app_definitions/${DEPLOYMENT_NAME}-mosca.json
echo "************************************************************************************************"
echo
echo 'Pausing for 30 seconds initial service startup...'
sleep 30
echo Deploying Application Service
curl -k -X POST -u ${MANTL_USER}:${MANTL_PASSWORD} https://${MANTL_CONTROL}/v2/apps \
-o /dev/null \
-H "Content-type: application/json" \
-d @app_definitions/${DEPLOYMENT_NAME}-app.json
echo "************************************************************************************************"
echo
echo Deploying Ernst Service
curl -k -X POST -u ${MANTL_USER}:${MANTL_PASSWORD} https://${MANTL_CONTROL}/v2/apps \
-o /dev/null \
-H "Content-type: application/json" \
-d @app_definitions/${DEPLOYMENT_NAME}-ernst.json
echo "************************************************************************************************"
echo
echo 'Pausing for 30 seconds API layer startup...'
sleep 30
#echo Deploying Web Service
#curl -k -X POST -u ${MANTL_USER}:${MANTL_PASSWORD} https://${MANTL_CONTROL}/v2/apps \
#-o /dev/null \
#-H "Content-type: application/json" \
#-d @app_definitions/${DEPLOYMENT_NAME}-web.json
#echo "************************************************************************************************"
#echo
echo Deploying UI Service
curl -k -X POST -u ${MANTL_USER}:${MANTL_PASSWORD} https://${MANTL_CONTROL}/v2/apps \
-o /dev/null \
-H "Content-type: application/json" \
-d @app_definitions/${DEPLOYMENT_NAME}-ui.json
echo
echo "************************************************************************************************"
echo
echo Deployed
echo " "
echo "Wait 3-5 minutes for the service to deploy "
echo "and then open the following page in your browser to view the application."
echo " "
echo " http://${DEPLOYMENT_NAME}-ui.${MANTL_DOMAIN} "
echo " "
echo " "