forked from redhatdemocentral/ocp-install-demo
-
Notifications
You must be signed in to change notification settings - Fork 2
/
init.sh
executable file
·283 lines (244 loc) · 10.9 KB
/
init.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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
#!/bin/sh
DOCKER_MAJOR_VER=17
DOCKER_MINOR_VER=03
OC_MAJOR_VER="v3"
OC_MINOR_VER=5
OC_MINI_VER=5
OCP_VERSION="$OC_MAJOR_VER.$OC_MINOR_VER"
# sets RAM usage limit for OCP.
VBOX_MEMORY=12288
# wipe screen.
clear
echo
echo "##############################################################"
echo "## ##"
echo "## Setting up your very own ##"
echo "## ##"
echo "## ### #### ##### # # #### # # ##### ##### ##### ##"
echo "## # # # # # ## # # # # # # # ##"
echo "## # # #### ### # # # ### ##### # #### # ##"
echo "## # # # # # ## # # # # # # ##"
echo "## ### # ##### # # #### # # ##### # # ##"
echo "## ##"
echo "## #### ### # # ##### ### ##### # # ##### ##### ##"
echo "## # # # ## # # # # # ## # # # # ##"
echo "## # # # # # # # ##### # # # # ### ##### ##"
echo "## # # # # ## # # # # # ## # # # ##"
echo "## #### ### # # # # # ##### # # ##### # # ##"
echo "## ##"
echo "## #### # ### ##### ##### ### ##### # # ##"
echo "## # # # # # # # # # # # ## ## ##"
echo "## #### # ##### # #### # # ##### # # # ##"
echo "## # # # # # # # # # # # # ##"
echo "## # ##### # # # # ### # # # # ##"
echo "## ##"
echo "## https://github.com/redhatdemocentral/ocp-install-demo ##"
echo "## ##"
echo "##############################################################"
echo
# Ensure VirtualBox available.
#
if [ `uname` == 'Darwin' ]; then
command -v VirtualBox -h >/dev/null 2>&1 || { echo >&2 "VirtualBox is required but not installed yet... download here: https://www.virtualbox.org/wiki/Downloads"; exit 1; }
echo "VirtualBox is installed..."
echo
fi
# Ensure docker engine available.
#
command -v docker -h >/dev/null 2>&1 || { echo >&2 "Docker is required but not installed yet... download here: https://store.docker.com/search?offering=community&type=edition"; exit 1; }
echo "Docker is installed... checking for valid version..."
echo
# Check that docker deamon is setup correctly.
if [ `uname` == 'Darwin' ]; then
# for osX.
docker ps >/dev/null 2>&1
if [ $? -ne 0 ]; then
echo "Docker deamon is not running... please start Docker for osX..."
echo
exit
fi
else
# for Linux versions.
docker ps >/dev/null 2>&1
if [ $? -ne 0 ]; then
echo "Docker deamon is not running... or is running insecurely..."
echo
echo "Check for instructions to run the docker deamon securely in NOTES section of this projects Readme.md file."
echo
exit
fi
fi
echo "Verified the Docker deamon is running..."
echo
# Check docker enging version.
dockerverone=$(docker version -f='{{ .Client.Version }}' | awk -F[=.] '{print $1}')
dockervertwo=$(docker version -f='{{ .Client.Version }}' | awk -F[=.] '{print $2}')
if [ $dockerverone -eq $DOCKER_MAJOR_VER ] && [ $dockervertwo -ge $DOCKER_MINOR_VER ]; then
echo "Valid version of docker engine found... $dockerverone.$dockervertwo"
echo
else
echo "Docker engine version $dockerverone.$dockervertwo found... need $DOCKER_MAJOR_VER.$DOCKER_MINOR_VER, please install: https://store.docker.com/search?offering=community&type=edition"
echo
exit
fi
# Ensure OpenShift command line tools available.
#
command -v oc help >/dev/null 2>&1 || { echo >&2 "OpenShift CLI tooling is required but not installed yet... download here: https://drive.google.com/open?id=0B9WSViV5BZ4aVXV5U3F4LVVmWVk"; exit 1; }
echo "OpenShift command line tools installed... checking for valid version..."
echo
# Check oc version.
verfull=$(oc version | awk '/oc/{print $2}')
verone=$(echo $verfull | awk -F[=.] '{print $1}')
vertwo=$(echo $verfull | awk -F[=.] '{print $2}')
verthree=$(echo $verfull | awk -F[=.] '{print $3}')
# Check version elements, first is a string so using '==', the rest are integers.
if [ $verone == $OC_MAJOR_VER ] && [ $vertwo -eq $OC_MINOR_VER ] && [ $verthree -ge $OC_MINI_VER ]; then
echo "Version of installed OpenShift command line tools correct... $verone.$vertwo.$verthree"
echo
else
echo "Version of installed OpenShift command line tools is $verone.$vertwo.$verthree, must be $OC_MAJOR_VER.$OC_MINOR_VER.$OC_MINI_VER..."
echo
if [ `uname` == 'Darwin' ]; then
echo "Download for Mac here: https://drive.google.com/open?id=0B9WSViV5BZ4aVXV5U3F4LVVmWVk"
exit
else
echo "Download for Linux here: https://drive.google.com/open?id=0B9WSViV5BZ4aVXV5U3F4LVVmWVk"
exit
fi
fi
echo "Setting up OpenShift docker machine..."
echo
docker-machine create --driver virtualbox --virtualbox-cpu-count "4" --virtualbox-memory "$VBOX_MEMORY" --engine-insecure-registry 172.30.0.0/16 --virtualbox-boot2docker-url https://github.com/boot2docker/boot2docker/releases/download/v1.13.1/boot2docker.iso openshift
if [ $? -ne 0 ]; then
echo
echo "Error occurred during openshift docker machine creation..."
echo
echo "Cleaning out existing 'openshift' machine..."
echo
docker-machine rm -f openshift
echo "Setting up new OpenShift docker machine..."
echo
docker-machine create --driver virtualbox --virtualbox-cpu-count "2" --virtualbox-memory "$VBOX_MEMORY" --engine-insecure-registry 172.30.0.0/16 --virtualbox-boot2docker-url https://github.com/boot2docker/boot2docker/releases/download/v1.13.1/boot2docker.iso openshift
if [ $? -ne 0 ]; then
echo
echo "Problem with docker machine creation that I can't resolve, please raise an issue and add error output:"
echo
echo " https://github.com/redhatdemocentral/ocp-install-demo/issues/new"
echo
exit
fi
fi
echo "Installing OCP with cluster up..."
echo
oc cluster up --docker-machine=openshift --image=registry.access.redhat.com/openshift3/ose --version=$OCP_VERSION
if [ $? -ne 0 ]; then
echo
echo "Error occurred during 'oc cluster up' command..."
echo
echo "Cleaning out existing 'openshift' machine..."
echo
docker-machine rm -f openshift
echo "Setting up new OpenShift docker machine..."
echo
docker-machine create --driver virtualbox --virtualbox-cpu-count "2" --virtualbox-memory "$VBOX_MEMORY" --engine-insecure-registry 172.30.0.0/16 --virtualbox-boot2docker-url https://github.com/boot2docker/boot2docker/releases/download/v1.13.1/boot2docker.iso openshift
echo
echo "Trying again to install OCP with cluster up..."
echo
echo "Using osX version of cluster up... installing second try OCP version: $OCP_VERSION"
echo
oc cluster up --docker-machine=openshift --image=registry.access.redhat.com/openshift3/ose --version=$OCP_VERSION
if [ $? -ne 0 ]; then
echo
echo "Problem with installation that I can't resolve, please raise an issue and add error output:"
echo
echo " https://github.com/redhatdemocentral/ocp-install-demo/issues/new"
echo
exit
fi
fi
echo
echo "Logging in as admin user..."
echo
oc login -u system:admin
# capturing OCP IP address from status command.
OCP_IP=$(oc status | awk '/My Project/{print $8}')
echo
echo "Set OCP IP to $OCP_IP..."
echo
# set console environment to openshift container.
eval "$(docker-machine env openshift)"
echo "Updating JBoss image streams..."
echo
oc create -n openshift -f 'https://raw.githubusercontent.com/jboss-openshift/application-templates/master/jboss-image-streams.json'
if [ $? -ne 0 ]; then
echo
echo "Problem with accessing JBoss product streams for OCP..."
echo
echo "Trying again..."
echo
sleep 10
oc create -n openshift -f 'https://raw.githubusercontent.com/jboss-openshift/application-templates/master/jboss-image-streams.json'
if [ $? -ne 0 ]; then
echo "Failed again, exiting, check output messages and network connectivity before running install again..."
echo
docker-machine rm -f openshift
exit
fi
fi
# echo
# echo "Updating Decision Server templates..."
# echo
# oc create -n openshift -f 'https://raw.githubusercontent.com/jboss-openshift/application-templates/master/decisionserver/decisionserver63-basic-s2i.json'
# if [ $? -ne 0 ]; then
# echo
# echo "Problem with accessing JBoss BRMS product streams for OCP..."
# echo
# echo "Trying again..."
# echo
# sleep 10
# oc create -n openshift -f 'https://raw.githubusercontent.com/jboss-openshift/application-templates/master/decisionserver/decisionserver63-basic-s2i.json'
# if [ $? -ne 0 ]; then
# echo "Failed again, exiting, check output messages and network connectivity before running install again..."
# echo
# docker-machine rm -f openshift
# exit
# fi
# fi
echo
echo "Creating Red Hat IoT Demo Project..."
echo
git clone https://github.com/redhat-iot/summit2017
cd summit2017
oc new-project redhat-iot --display-name="Red Hat IoT Demo"
oc policy add-role-to-user view system:serviceaccount:$(oc project -q):default -n $(oc project -q)
./openshift-deploy.sh
#oc create -n openshift -f https://raw.githubusercontent.com/jboss-openshift/application-templates/master/jboss-image-streams.json
oc create -n openshift -f https://raw.githubusercontent.com/openshift/origin/master/examples/image-streams/image-streams-centos7.json
oc policy add-role-to-user admin openshift-dev
oc start-build dashboard --follow
echo
echo "===================================================="
echo "= ="
echo "= Install complete, get ready to rock your Cloud. ="
echo "= Look for information at end of OCP install. ="
echo "= ="
echo "= The server is accessible via web console at: ="
echo "= ="
echo "= $OCP_IP ="
echo "= ="
echo "= Log in as user: openshift-dev ="
echo "= password: devel ="
echo "= ="
echo "= Admin log in as: admin ="
echo "= password: admin ="
echo "= ="
echo "= Now get your Red Hat Demo Central example ="
echo "= projects here: ="
echo "= ="
echo "= https://github.com/redhatdemocentral ="
echo "= ="
echo "= When finished, clean up your demo with: ="
echo "= ="
echo "= $ docker-machine rm -f openshift ="
echo "= ="
echo "===================================================="