-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.sh
executable file
·416 lines (349 loc) · 9.84 KB
/
setup.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
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
# IMPORTANT: Source RVM as a function into local environment.
# Otherwise switching gemsets won't work.
[ -s "$HOME/.rvm/scripts/rvm" ] && . "$HOME/.rvm/scripts/rvm"
#Auto setup
community_setup_path=$PWD
#setup the ruby compatible versions and gemsets
scholar_location=/home/msuser1/workspace/git_scholar/ms_scholar/scholar
identity_ruby_version=ruby-1.9.3-p286
identity_gemset=KK_mupp_cg_identity
community_ruby_version=jruby-1.7.0
community_gemset=KK_mupp_cg_community
# Setup database authentications
database_username=cg_community
database_password=cg_community
# Setup database names accordingls branch
community_database=KK_mupp_cg_community_dev
comment_service_database=KK_mupp_cg_comment_service_dev
lookup_service_database=KK_mupp_cg_lookup_service_dev
message_service_database=KK_mupp_cg_message_service_dev
role_service_database=KK_mupp_cg_role_service_dev
notification_service_database=KK_mupp_cg_notification_service_dev
star_service_database=KK_mupp_cg_star_service_dev
cd $scholar_location
ruby $community_setup_path/change_database.rb $PWD $database_username $database_password $community_database
# Enable shell debugging.
#set -x
echo "*****************************************"
############### cg_identity
rvm use $identity_ruby_version
rvm gemset create $identity_gemset
rvm gemset use $identity_gemset
echo "In " $PWD
echo -e "\n"
rm -rf .rvmrc
cat <<EOF >.rvmrc
rvm use $identity_ruby_version
rvm gemset use $identity_gemset
EOF
rvm rvmrc trust $PWD
cd cg_identity
echo "In " $PWD
echo -e "\n"
echo `rvm current`
ruby $community_setup_path/change_gemfile.rb $PWD
gem install 'gem-dependency_management'
bundle install
git checkout Gemfile
git checkout Gemfile.lock
echo "....................................................."
echo -e "\n"
echo -e "\n"
############### Trunk
cd ..
echo "In " $PWD
echo -e "\n"
gem install foreman
echo `rvm current`
echo "....................................................."
echo -e "\n"
echo -e "\n"
############### cg_community
cd cg_community
rvm use $community_ruby_version
rvm gemset create $community_gemset
rvm gemset use $community_gemset
echo "In " $PWD
echo -e "\n"
rm -rf .rvmrc
cat <<EOF >.rvmrc
rvm use $community_ruby_version
rvm gemset use $community_gemset
EOF
rvm rvmrc trust $PWD
echo -e "\n"
echo "In " $PWD
echo `rvm current`
ruby $community_setup_path/change_gemfile.rb $PWD
gem install 'gem-dependency_management'
bundle install
git checkout Gemfile
git checkout Gemfile.lock
echo "....................................................."
echo -e "\n"
echo -e "\n"
############### services/cg_comment_service
cd ../services/cg_comment_service
echo -e "\n"
echo "In " $PWD
rvm use $identity_ruby_version
rvm gemset create $identity_gemset
rvm gemset use $identity_gemset
rm -rf .rvmrc
cat <<EOF >.rvmrc
rvm use $identity_ruby_version
rvm gemset use $identity_gemset
EOF
rvm rvmrc trust $PWD
echo -e "\n"
echo `rvm current`
ruby $community_setup_path/change_gemfile.rb $PWD
bundle install
git checkout Gemfile
git checkout Gemfile.lock
#Database yaml creation
ruby $community_setup_path/change_database.rb $PWD $database_username $database_password $comment_service_database
bundle exec rake db:create
bundle exec rake db:migrate
rvm wrapper `rvm current` comment_service ruby
echo "....................................................."
echo -e "\n"
echo -e "\n"
############### services/cg_lookup_service
cd ../cg_lookup_service
echo -e "\n"
echo "In " $PWD
rvm use $identity_ruby_version
rvm gemset create $identity_gemset
rvm gemset use $identity_gemset
rm -rf .rvmrc
cat <<EOF >.rvmrc
rvm use $identity_ruby_version
rvm gemset use $identity_gemset
EOF
rvm rvmrc trust $PWD
echo -e "\n"
echo `rvm current`
ruby $community_setup_path/change_gemfile.rb $PWD
bundle install
git checkout Gemfile
git checkout Gemfile.lock
#Database yaml creation
ruby $community_setup_path/change_database.rb $PWD $database_username $database_password $lookup_service_database
bundle exec rake db:create
bundle exec rake db:migrate
rvm wrapper `rvm current` lookup_service ruby
echo "....................................................."
echo -e "\n"
echo -e "\n"
############### services/cg_message_service
cd ../cg_message_service
echo -e "\n"
echo "In " $PWD
rvm use $identity_ruby_version
rvm gemset create $identity_gemset
rvm gemset use $identity_gemset
rm -rf .rvmrc
cat <<EOF >.rvmrc
rvm use $identity_ruby_version
rvm gemset use $identity_gemset
EOF
rvm rvmrc trust $PWD
echo -e "\n"
echo `rvm current`
ruby $community_setup_path/change_gemfile.rb $PWD
bundle install
git checkout Gemfile
git checkout Gemfile.lock
#Database yaml creation
ruby $community_setup_path/change_database.rb $PWD $database_username $database_password $message_service_database
bundle exec rake db:create
bundle exec rake db:migrate
rvm wrapper `rvm current` message_service ruby
echo "....................................................."
echo -e "\n"
echo -e "\n"
############### services/cg_notification_service
cd ../cg_notification_service
echo -e "\n"
echo "In " $PWD
rvm use $identity_ruby_version
rvm gemset create $identity_gemset
rvm gemset use $identity_gemset
rm -rf .rvmrc
cat <<EOF >.rvmrc
rvm use $identity_ruby_version
rvm gemset use $identity_gemset
EOF
rvm rvmrc trust $PWD
echo -e "\n"
echo `rvm current`
ruby $community_setup_path/change_gemfile.rb $PWD
bundle install
git checkout Gemfile
git checkout Gemfile.lock
#Database yaml creation
ruby $community_setup_path/change_database.rb $PWD $database_username $database_password $notification_service_database
bundle exec rake db:create
bundle exec rake db:migrate
rvm wrapper `rvm current` notification_service ruby
echo "....................................................."
echo -e "\n"
echo -e "\n"
############### services/cg_role_service
cd ../cg_role_service
echo -e "\n"
echo "In " $PWD
rvm use $identity_ruby_version
rvm gemset create $identity_gemset
rvm gemset use $identity_gemset
rm -rf .rvmrc
cat <<EOF >.rvmrc
rvm use $identity_ruby_version
rvm gemset use $identity_gemset
EOF
rvm rvmrc trust $PWD
echo -e "\n"
echo `rvm current`
ruby $community_setup_path/change_gemfile.rb $PWD
bundle install
git checkout Gemfile
git checkout Gemfile.lock
#Database yaml creation
ruby $community_setup_path/change_database.rb $PWD $database_username $database_password $role_service_database
bundle exec rake db:create
bundle exec rake db:migrate
rvm wrapper `rvm current` role_service ruby
echo "....................................................."
echo -e "\n"
echo -e "\n"
############### services/faye
cd ../faye
echo -e "\n"
echo "In " $PWD
rvm use $identity_ruby_version
rvm gemset create $identity_gemset
rvm gemset use $identity_gemset
rm -rf .rvmrc
cat <<EOF >.rvmrc
rvm use $identity_ruby_version
rvm gemset use $identity_gemset
EOF
rvm rvmrc trust $PWD
echo -e "\n"
echo `rvm current`
ruby $community_setup_path/change_gemfile.rb $PWD
bundle install
git checkout Gemfile
git checkout Gemfile.lock
rvm wrapper `rvm current` faye ruby
echo "....................................................."
echo -e "\n"
echo -e "\n"
############### services/cg_star_service
cd ../cg_star_service
echo -e "\n"
echo "In " $PWD
rvm use $identity_ruby_version
rvm gemset create $identity_gemset
rvm gemset use $identity_gemset
rm -rf .rvmrc
cat <<EOF >.rvmrc
rvm use $identity_ruby_version
rvm gemset use $identity_gemset
EOF
rvm rvmrc trust $PWD
echo -e "\n"
echo `rvm current`
ruby $community_setup_path/change_gemfile.rb $PWD
bundle install
git checkout Gemfile
git checkout Gemfile.lock
#Database yaml creation
ruby $community_setup_path/change_database.rb $PWD $database_username $database_password $star_service_database
bundle exec rake db:create
bundle exec rake db:migrate
rvm wrapper `rvm current` star_service ruby
echo "....................................................."
echo -e "\n"
echo -e "\n"
#Cg_community build order migrations
echo "community build orders..................................."
cd ../../cg_community
echo 'In' $PWD
enviro='development'
if [ $# -eq 1 ]
then
enviro=$1
echo 'RAILS_ENV='$enviro
fi
ENGINES=$(cat config/build_order)
#Database yaml creation
#link my config/database.yml file to the root/database.yml
if [ -L config/database.yml ]
then
rm config/database.yml
fi
echo 'Sym-linking ../database.yml ./config/database.yml'
ln -s ../../database.yml config/database.yml
bundle exec rake db:create
#For each engine in our build_order
cd ..
echo 'In ' $PWD
ruby ~/workspace/cg_community_setup/link_migrations.rb stage1
cd cg_community
#Back in the application, migrate and seed
RAILS_ENV=$enviro bundle exec rake db:migrate
cd ..
ruby ~/workspace/cg_community_setup/link_migrations.rb stage2
cd cg_community
RAILS_ENV=$enviro bundle exec rake db:migrate
mv db/seeds db/seeds_test
mv db/seeds.rb db/seeds_test.rb
for e in ${ENGINES}; do
#change to engine directory
pushd ../cg_${e} > /dev/null
PWD=$(pwd)
echo 'cd' $PWD
if [ -d db/seeds ]
then
cp -r db/seeds ../cg_community/db
fi
if [ -f db/seeds.rb ]
then
cp db/seeds.rb ../cg_community/db
if [ $enviro != 'test' ]; then
cd ../cg_community
RAILS_ENV=$enviro bundle exec rake db:seed
rm db/seeds.rb
if [ -d db/seeds ]
then
rm -r db/seeds
fi
cd ../cg_${e}
fi
fi
popd > /dev/null
done
mv db/seeds_test.rb db/seeds.rb
mv db/seeds_test db/seeds
if [ $enviro != 'test' ]; then
RAILS_ENV=$enviro bundle exec rake db:seed
fi
#Removing the link files from community migrate directory
find db/migrate/ -lname '*' -exec rm {} \;
#Cg_identity build order migrations
cd ../cg_identity
#link my config/database.yml file to the root/database.yml
if [ -L config/database.yml ]
then
rm config/database.yml
fi
echo 'Sym-linking ../database.yml ./config/database.yml'
ln -s ../../database.yml config/database.yml
bundle exec rake db:create
#Back in the application, migrate and seed
RAILS_ENV=$enviro bundle exec rake db:migrate
if [ $enviro != 'test' ]; then
RAILS_ENV=$enviro bundle exec rake db:seed
fi