This repository has been archived by the owner on Feb 15, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
/
init.sh
executable file
·224 lines (207 loc) · 8.44 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
#!/bin/sh
DEMO="CDK Install Demo"
AUTHORS="Andrew Block, Eric D. Schabell"
PROJECT="[email protected]:redhatdemocentral/cdk-install-demo.git"
PRODUCT="Container Development Kit"
CDK_HOME=./target
SRC_DIR=./installs
SUPPORT_DIR=./support
PRJ_DIR=./projects
CDK_PLUGINS_DIR=$CDK_HOME/cdk/plugins
CDK=cdk-2.2.0.zip
CDK_DOWNLOAD_LINK="http://developers.redhat.com/download-manager/file/cdk-2.2.0.zip"
OSX_BOX=rhel-cdk-kubernetes-7.2-29.x86_64.vagrant-virtualbox.box
LINUX_BOX=rhel-cdk-kubernetes-7.2-29.x86_64.vagrant-libvirt.box
VAGRANTFILE=VagrantFile-rhel-ose
CDK_BOX_VERSION=cdkv2
VERSION=2.2.0
# wipe screen.
clear
echo
echo "#######################################################################"
echo "## ##"
echo "## Setting up the ${DEMO} ##"
echo "## ##"
echo "## ##"
echo "## #### ### # # ##### ### ##### # # ##### #### ##"
echo "## # # # ## # # # # # ## # # # # ##"
echo "## # # # # # # # ##### # # # # ### #### ##"
echo "## # # # # ## # # # # # ## # # # ##"
echo "## ### ### # # # # # ##### # # ##### # # ##"
echo "## ##"
echo "## #### ##### # # # # ##### ##### ##"
echo "## # # # # # # # # # ##"
echo "## # # ### # # ### # # ##"
echo "## # # # # # # # # # ##"
echo "## #### ##### # # # ##### # ##"
echo "## ##"
echo "## ##"
echo "## brought to you by ${AUTHORS} ##"
echo "## ##"
echo "## ${PROJECT} ##"
echo "## ##"
echo "#######################################################################"
echo
# Ensure Vagrant avaiable.
#
command -v vagrant -v >/dev/null 2>&1 || { echo >&2 "Vagrant is required but not installed yet... download here: https://www.vagrantup.com/downloads.html"; exit 1; }
echo "Vagrant is installed..."
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... downlaod here: https://www.virtualbox.org/wiki/Downloads"; exit 1; }
echo "VirtualBox is installed..."
echo
fi
# Ensure CDK downloaded.
#
if [ -r $SRC_DIR/$CDK ] || [ -L $SRC_DIR/$CDK ]; then
echo Product sources are present...
echo
else
echo Need to download $CDK package from the Customer Portal
echo $CDK_DOWNLOAD_LINK
echo and place it in the $SRC_DIR directory to proceed...
echo
exit
fi
# Ensure correct Vagrant box downloaded.
#
if [ `uname` == 'Darwin' ]; then
# OSX Vagrant box.
if [ -r $SRC_DIR/$OSX_BOX ] || [ -L $SRC_DIR/$OSX_BOX ]; then
echo OSX Vagrant box present...
echo
else
echo Need to download $OSX_BOX from the Customer Portal
echo $CDK_DOWNLOAD_LINK
echo and place it in the $SRC_DIR directory to proceed...
echo
exit
fi
else
# Linux Vagrant box.
if [ -r $SRC_DIR/$LINUX_BOX ] || [ -L $SRC_DIR/$LINUX_BOX ]; then
echo Linux Vagrant box present...
echo
else
echo Need to download $LINUX_BOX from the Customer Portal
echo $CDK_DOWNLOAD_LINK
echo and place it in the $SRC_DIR directory to proceed...
echo
exit
fi
fi
# Remove the old insallation, if it exists.
#
if [ -x $CDK_HOME ]; then
echo " - removing existing installation..."
echo
rm -rf $CDK_HOME
fi
# Run installation.
#
echo "Setting up installation now..."
echo
mkdir $CDK_HOME
unzip -q $SRC_DIR/$CDK -d $CDK_HOME
# Add memory adjusted Vagrantfile for OSE image.
#
echo "Copying over VagrantFile for Red Hat Demo Central project sizings..."
echo
cp $SUPPORT_DIR/$VAGRANTFILE $CDK_HOME/cdk/components/rhel/rhel-ose/Vagrantfile
echo "Installing provided Vagrant plugins..."
echo
cd $CDK_PLUGINS_DIR
vagrant plugin install *.gem
echo
echo "Checking that plugins installed, looking for:"
echo
echo " -> vagrant-registration"
echo " -> vagrant-service-manager"
echo " -> vagrant-sshfs"
echo
vagrant plugin list
# determine which Vagrant box to add.
#
cd ../../../
if [ `uname` == 'Darwin' ]; then
# OSX Vagrant box.
echo
echo "Adding the RHEL Vagrant box..."
echo
vagrant box add $CDK_BOX_VERSION $SRC_DIR/$OSX_BOX
else
# Linux Vagrant box.
#
echo
echo "Adding the libvirt Vagrant box..."
echo
vagrant box add $CDK_BOX_VERSION $SRC_DIR/$LINUX_BOX
fi
if [ $? -ne 0 ]; then
echo
echo "Detected a previous installation of this demo..."
echo
echo "Cleaning out previous Vagrant box $CDK_BOX_VERSION entry..."
echo
vagrant box remove $CDK_BOX_VERSION
echo
echo "Cleanup done, re-trying the installation."
echo
if [ `uname` == 'Darwin' ]; then
# OSX Vagrant box.
echo
echo "Adding the RHEL Vagrant box..."
echo
vagrant box add --name $CDK_BOX_VERSION $SRC_DIR/$OSX_BOX
else
# Linux Vagrant box.
echo
echo "Adding the libvirt Vagrant box..."
echo
vagrant box add --name $CDK_BOX_VERSION $SRC_DIR/$LINUX_BOX
fi
fi
echo
echo "Checking that $CDK_BOX_VERSION is listed..."
echo
vagrant box list
echo
echo "========================================================================="
echo "= ="
echo "= Now you can start up pre-defined Vagrant boxes using the provided ="
echo "= Vagrant files or you can initialze an empty box and create your own ="
echo "= Vagrant file. ="
echo "= ="
echo "= For example, using a provided Vagrant file means going to its ="
echo "= directory and start a RHEL CDK Vagrant box. ="
echo "= ="
echo "= Two Vagrant files are provided with the CDK for uses cases ="
echo "= described below as we show you how to start each below. ="
echo "= ="
echo "= ="
echo "= 1. OpenShift Enterprise (rhel-ose): ="
echo "= ="
echo "= $ cd ./target/cdk/components/rhel/rhel-ose; vagrant up ="
echo "= ="
echo "= ="
echo "= 2. Single-node Kubernetes setup (rhel-k8s-singlenode-setup): ="
echo "= ="
echo "= $ cd ./target/cdk/components/rhel/misc/rhel-k8s-singlenode-setup ="
echo "= ="
echo "= $ vagrant up ="
echo "= ="
echo "= ="
echo "= Finally, initialize a Vagrant box for using your own Vagrant file: ="
echo "= ="
echo "= $ mkdir ./target/mycdkv2 ="
echo "= $ cd ./target/mycdkv2 ="
echo "= $ vagrant init cdkv2 ="
echo "= $ vagrant up ="
echo "= ="
echo "= This completes the $DEMO setup. ="
echo "= ="
echo "========================================================================="
echo