-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbootstrap
executable file
·259 lines (216 loc) · 9.31 KB
/
bootstrap
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
#!/usr/bin/env bash
set -e
#
# This script allows you to install Nubomedia PaaS API. To execute it:
#
# 'curl -fsSkL https://raw.githubusercontent.com/fhg-fokus-nubomedia/bootstrap/master/bootstrap | bash'
export DEBIAN_FRONTEND=noninteractive
_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
_nubomedia_paas_base_repo="https://github.com/fhg-fokus-nubomedia/nubomedia-paas.git"
_tag="develop"
#_tag="tags/1.1"
_base=/opt
_nubomedia_base="${_base}/nubomedia"
_nubomedia_paas="${_nubomedia_base}/nubomedia-paas"
_nubomedia_paas_properties="${_nubomedia_paas}/src/main/resources/application.properties"
_log_folder=/var/log/nubomedia
_user="$(id -un 2>/dev/null || true)"
function checkBinary {
echo -n " * Checking for '$1'..."
if command -v $1 >/dev/null 2>&1; then
echo "OK"
return 0
else
echo >&2 "FAILED."
return 1
fi
}
_ex='sh -c'
if [ "$_user" != 'root' ]; then
if checkBinary sudo; then
_ex='sudo -E sh -c'
elif checkBinary su; then
_ex='su -c'
fi
fi
function createNubomediaBase {
echo "Creating the Nubomedia base folder"
# removing it if exists
#$_ex 'rm -rf '$_nubomedia_base
$_ex 'mkdir -p '$_nubomedia_paas
$_ex 'chown -R '"$_user $_nubomedia_base"
# create log folder and give permission
#$_ex 'rm -rf '$_log_folder
$_ex 'mkdir -p '$_log_folder
$_ex 'chown -R '"$_user $_log_folder"
}
function compileProperties {
export adminPassword
read -p "Enter the admin password of the PaaS Manager [nub0m3d14]: " adminPassword
if [[ "$adminPassword" != "" ]]; then
$_ex 'sed -i "s|paas.security.admin.password=nub0m3d14|paas.security.admin.password=$adminPassword|g" /etc/nubomedia/paas.properties'
fi
export paasPort
read -p "Enter the port of the PaaS Manager [8081]: " paasPort
if [[ "$paasPort" != "" ]]; then
$_ex 'sed -i "s|paas.port=8081|paas.port=$paasPort|g" /etc/nubomedia/paas.properties'
fi
export mysqlUsername
read -p "Enter the username used to authorize against the database [admin]: " mysqlUsername
if [[ "$mysqlUsername" != "" ]]; then
$_ex 'sed -i "s|spring.datasource.username=admin|spring.datasource.username=$mysqlUsername|g" /etc/nubomedia/paas.properties'
fi
export mysqlPassword
read -p "Enter the password used to authorize against the database [changeme]: " mysqlPassword
if [[ "$mysqlPassword" != "" ]]; then
$_ex 'sed -i "s|spring.datasource.password=changeme|spring.datasource.password=$mysqlPassword|g" /etc/nubomedia/paas.properties'
fi
export baseUrl
read -p "Enter the OpenShift url [https://localhost:8443]: " baseUrl
if [[ "$baseUrl" != "" ]]; then
$_ex 'sed -i "s|openshift.baseURL=https://localhost:8443|openshift.baseURL=$baseUrl|g" /etc/nubomedia/paas.properties'
fi
export domainName
read -p "Enter the domain name for the applications [example.com]: " domainName
if [[ "$domainName" != "" ]]; then
$_ex 'sed -i "s|openshift.domainName=example.com|openshift.domainName=$domainName|g" /etc/nubomedia/paas.properties'
fi
export project
read -p "Enter the project name to be used in OpenShift [nubomedia]: " project
if [[ "$project" != "" ]]; then
$_ex 'sed -i "s|openshift.project=nubomedia|openshift.project=$project|g" /etc/nubomedia/paas.properties'
fi
export token
read -p "Enter the token to be used to authorize against OpenShift: " token
if [[ "$token" != "" ]]; then
$_ex 'sed -i "s|openshift.token=token|openshift.token=$token|g" /etc/nubomedia/paas.properties'
fi
export kmsImage
read -p "Enter the name of the image to be used for the KMS instances [kurento-media-server]: " kmsImage
if [[ "$kmsImage" != "" ]]; then
$_ex 'sed -i "s|kms.image=kurento-media-server|kms.image=$kmsImage|g" /etc/nubomedia/paas.properties'
fi
export nfvoIp
read -p "Enter the Orchestrator ip [localhost]: " nfvoIp
if [[ $nfvoIp != "" ]]; then
$_ex 'sed -i "s/nfvo.ip=localhost/nfvo.ip=$nfvoIp/g" /etc/nubomedia/paas.properties'
fi
export nfvoPort
read -p "Enter the Orchestrator port [8080]: " nfvoPort
if [[ $nfvoPort != "" ]]; then
$_ex 'sed -i "s/nfvo.port=8080/nfvo.port=$nfvoPort/g" /etc/nubomedia/paas.properties'
fi
export nfvoUsername
read -p "Enter the Orchestrator username [admin]: " nfvoUsername
if [[ $nfvoUsername != "" ]]; then
$_ex 'sed -i "s/nfvo.username=admin/nfvo.username=$nfvoUsername/g" /etc/nubomedia/paas.properties'
fi
export nfvoPassword
read -p "Enter the password to authorize against the Orchestrator [openbaton]: " nfvoPassword
if [[ $nfvoPassword != "" ]]; then
$_ex 'sed -i "s/nfvo.password=openbaton/nfvo.password=$nfvoPassword/g" /etc/nubomedia/paas.properties'
fi
export vnfmIp
read -p "Enter the IP of the VNFM [localhost]: " vnfmIp
if [[ $vnfmIp != "" ]]; then
$_ex 'sed -i "s/paas.vnfmIP=localhost/paas.vnfmIP=$vnfmIp/g" /etc/nubomedia/paas.properties'
fi
export vnfmPort
read -p "Enter the port of the VNFM [9000]: " vnfmPort
if [[ $vnfmPort != "" ]]; then
$_ex 'sed -i "s/vnfm.port=9000/vnfm.port=$vnfmPort/g" /etc/nubomedia/paas.properties'
fi
export marketplaceIp
read -p "Enter the IP of the marketplace [localhost]: " marketplaceIp
if [[ $marketplaceIp != "" ]]; then
$_ex 'sed -i "s|marketplace.ip=localhost|marketplace.ip=$marketplaceIp|g" /etc/nubomedia/paas.properties'
fi
export marketplacePort
read -p "Enter the port of the marketplace [8082]: " marketplacePort
if [[ $marketplacePort != "" ]]; then
$_ex 'sed -i "s|marketplace.port=8082|marketplace.ip=$marketplacePort|g" /etc/nubomedia/paas.properties'
fi
export authURL
read -p "Enter the Auth URL of the cloud infrastructure [http://localhost:5000/v2.0]: " authURL
if [[ "$authURL" != "" ]]; then
$_ex 'sed -i "s|vim.authURL=http://localhost:5000/v2.0|vim.authURL=$authURL|g" /etc/nubomedia/paas.properties'
fi
export tenantName
read -p "Enter the tenant name to be used in your cloud infrastructure [nubomedia]: " tenantName
if [[ $tenantName != "" ]]; then
$_ex 'sed -i "s/vim.tenant=nubomedia/vim.tenant=$tenantName/g" /etc/nubomedia/paas.properties'
fi
export username
read -p "Enter the username to be used to authorize against your cloud infrastructure (VIM) [nubomedia]: " username
if [[ $username != "" ]]; then
$_ex 'sed -i "s/vim.username=nubomedia/vim.username=$username/g" /etc/nubomedia/paas.properties'
fi
export password
read -p "Enter the password to be used to authorize against your cloud infrastructure (VIM) [changeme]: " password
if [[ $password != "" ]]; then
$_ex 'sed -i "s/vim.password=changeme/vim.password=$password/g" /etc/nubomedia/paas.properties'
fi
export keyPair
read -p "Enter the Key file to be used to login to the VMs via ssh [nubomedia]: " keyPair
if [[ $keyPair != "" ]]; then
$_ex 'sed -i "s/vim.keypair=nubomedia/vim.keypair=$keyPair/g" /etc/nubomedia/paas.properties'
fi
export rabbitMqHost
read -p "Enter the host address where the RabbitMQ server is running [localhost]: " rabbitMqHost
if [[ $rabbitMqHost != "" ]]; then
$_ex 'sed -i "s/rabbitmq.host=localhost/rabbitmq.host=$rabbitMqHost/g" /etc/nubomedia/paas.properties'
fi
export rabbitMqUsername
read -p "Enter the username used to authorize against the RabbitMQ server [admin]: " rabbitMqUsername
if [[ $rabbitMqUsername != "" ]]; then
$_ex 'sed -i "s/rabbitmq.username=admin/rabbitmq.username=$rabbitMqUsername/g" /etc/nubomedia/paas.properties'
fi
export rabbitMqPassword
read -p "Enter the password used to authorize against the RabbitMQ server [openbaton]: " rabbitMqPassword
if [[ $rabbitMqPassword != "" ]]; then
$_ex 'sed -i "s/rabbitmq.password=openbaton/rabbitmq.password=$rabbitMqPassword/g" /etc/nubomedia/paas.properties'
fi
}
function checkoutNubomediaPaaS {
echo "Getting Nubomedia PaaS API..."
createNubomediaBase
git clone --recursive "${_nubomedia_paas_base_repo}" "${_nubomedia_paas}"
pushd "${_nubomedia_paas}"
git checkout ${_tag}
popd
$_ex 'mkdir -p "/etc/nubomedia"'
echo "created properties folder"
$_ex 'cp '"${_nubomedia_paas_properties} /etc/nubomedia/paas.properties"
$_ex 'cp '"${_nubomedia_paas}/resource/cloudrepo-vnfd.json /etc/nubomedia/cloudrepo-vnfd.json"
$_ex 'cp '"${_nubomedia_paas}/resource/nubomedia-nsd.json /etc/nubomedia/nubomedia-nsd.json"
echo "copied properties file, now modifing..."
}
function compileNubomediaPaaS {
echo "compiling the Nubomedia PaaS API"
pushd "${_nubomedia_paas}"
./nubomedia-paas.sh compile
if [ $? -ne 0 ]; then
echo "ERROR: The compilation of the Nubomedia PaaS API failed"
exit 1
fi
popd
}
function startNubomediaPaaS {
echo "starting the Nubomedia PaaS API"
pushd ${_nubomedia_paas}
./nubomedia-paas.sh start
popd
}
function deployNubomediaPaaS {
compileNubomediaPaaS
startNubomediaPaaS
}
function bootstrap {
# checkout Nubomedia PaaS API
checkoutNubomediaPaaS
compileProperties
# deploy and compile Nubomedia PaaS API
deployNubomediaPaaS
echo "Nubomedia PaaS API is up and running now. Check screen -x paas-manager..."
}
bootstrap