-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathodoctl
More file actions
executable file
·902 lines (875 loc) · 38.2 KB
/
odoctl
File metadata and controls
executable file
·902 lines (875 loc) · 38.2 KB
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
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
#!/bin/bash
#set -ex
COMPOSE_YAML='docker-compose.yaml'
COMPOSE_PROJECT='odo'
DOCKER_COMPOSE="docker-compose --compatibility -f ${COMPOSE_YAML} -p ${COMPOSE_PROJECT}"
COMPOSE_CONFIG=$(cat ${COMPOSE_YAML})
LDAP_DOMAIN=$(echo $COMPOSE_CONFIG | awk -F 'container_name: odo-ldap-openldap' '{print $2}' | awk -F 'SLAPD_DOMAIN: ' '{print $2}' | awk '{print $1}')
LDAP_ADMIN="cn=admin,dc=$(echo $LDAP_DOMAIN | sed 's/\./,dc=/g')"
LDAP_PASSWD=$(echo $COMPOSE_CONFIG | awk -F 'container_name: odo-ldap-openldap' '{print $2}' | awk -F 'SLAPD_PASSWORD: ' '{print $2}' | awk '{print $1}')
PG_USER=$(echo $COMPOSE_CONFIG | awk -F 'container_name: odo-pg' '{print $2}' | awk -F 'POSTGRES_USER: ' '{print $2}' | awk '{print $1}')
PG_PASSWD=$(echo $COMPOSE_CONFIG | awk -F 'container_name: odo-pg' '{print $2}' | awk -F 'POSTGRES_PASSWORD: ' '{print $2}' | awk '{print $1}')
COMPOSE_CMD="${1-''}"
COMPOSE_SVC="${2-''}"
PRODUCT_ID="${3}"
ODO_HOME=$PWD
ODO_INIT_PG='yes'
ODO_INIT_LDAP='yes'
ODO_INIT_JENKINS='yes'
ODO_INIT_SONAR='yes'
ODO_INIT_JIRA='yes'
ODO_INIT_CONF='yes'
ODO_INIT_GITLAB='yes'
ODO_INIT_HARBOR='yes'
ODO_INIT_RANCHER='yes'
ODO_INIT_JMS='yes'
COOKIES=".odo_cookies"
CURL="curl -s -v --location -c ${COOKIES} -b ${COOKIES}"
## Common Function
function log_error() {
echo -e "\033[33;1m$@ \033[0m"
exit 1
}
function log_fail() {
echo -e "\033[31;1m[FAIL] Whoops! Looks like we have some trouble ...\033[0m"
echo -e "$@"
exit 1
}
function chmod_dir() {
dir_name=$1
while true; do
sleep 1
[[ -d ${dir_name} ]] && break
done
chmod -R 777 ${dir_name}
}
## ODO Document
function help_doc_cmd() {
cat <<EOF
$0 <COMMAND>:
start - Up container(s) to start service(s) and init them
start_no_init - Up container(s) to start service(s)
stop - Stop container(s) to stop service(s)
down - Down all services
restart - Restart container(s) to restart service(s)
list - List container(s)
license - Generate JIRA/Confluence/Plugin license
cleanup - Cleanup all containers and dirs
EOF
exit 1
}
function help_doc_svc() {
cat <<EOF
$0 ${COMPOSE_CMD} <SERVICE>:
all - All Services
ldap - OpenLDAP, PhpLDAPAdmin and Self Service Password
pg - PostgresQL
jira - Jira Software
conf - Confluence
sonar - SonarQube Community Edition
jenkins - Jenkins
gitlab - GitLab Community Edition
harbor - Harbor
rancher - Rancher
jms - JumpServer
portal - DevOps Portal
EOF
exit 1
}
function help_doc_license() {
cat <<EOF
$0 ${COMPOSE_CMD} <PRODUCT>:
jira - Generate JIRA software license
jira_plugin - Generate JIRA plugin license
conf - Generate Confluence server license
conf_plugin - Generate Confluence plugin license
jenkins - Get Jenkins initialAdminPassword
EOF
exit 1
}
function help_doc_license_pid() {
cat <<EOF
$0 ${COMPOSE_CMD} ${COMPOSE_SVC} <PRODUCT_ID>:
PRODUCT_ID is REQUIRED
+-------------+------------+------------------------------------+
| PRODUCT | PRODUCT_ID | WHERE |
+-------------+------------+------------------------------------+
| jira_plugin | plugin ID | JIRA application detail page |
+-------------+------------+------------------------------------+
| conf | server ID | Confluence installation page |
+-------------+------------+------------------------------------+
| conf_plugin | plugin ID | Confluence application detail page |
+-------------+------------+------------------------------------+
EOF
exit 0
}
## ODO Basic Function
function check_env() {
[[ "$(uname)" == "Linux" ]] || log_error "Only support Linux OS"
[[ -f /etc/selinux/config ]] && {
[[ "$(getenforce)" == "Enforcing" ]] && setenforce 0
sed -i 's/^SELINUX=.*/SELINUX=disabled/' /etc/selinux/config
}
for _tool in "docker" "docker-compose" "curl"; do
output=$(${_tool} --version 2>&1) || {
echo -e "\033[33;1m${_tool} is required in this machine \033[0m"
echo "${output}"
exit 1
}
done
}
function check_odo_cli() {
echo "start start_no_init stop down restart list license cleanup" | grep -qw "${COMPOSE_CMD}" || help_doc_cmd
if [[ "${COMPOSE_CMD}" == "license" ]]; then
echo "jira jira_plugin conf conf_plugin jenkins" | grep -qw "${COMPOSE_SVC}" || help_doc_license
[[ "${COMPOSE_SVC}" == "jira" ]] && return 0
[[ "${COMPOSE_SVC}" == "jenkins" ]] && return 0
[[ -z "${PRODUCT_ID}" ]] && help_doc_license_pid
elif [[ "${COMPOSE_CMD}" == "list" ]]; then
return 0
elif [[ "${COMPOSE_CMD}" == "cleanup" ]]; then
return 0
elif [[ "${COMPOSE_CMD}" == "down" ]]; then
return 0
else
echo "all ldap pg jira conf sonar jenkins gitlab rancher jms portal harbor" | grep -qw "${COMPOSE_SVC}" || help_doc_svc
fi
return 0
}
function check_odo_svc() {
if [[ "${COMPOSE_SVC}" == "all" ]]; then
COMPOSE_SVC=""
elif [[ "${COMPOSE_SVC}" == "ldap" ]]; then
COMPOSE_SVC="odo-ldap-openldap odo-ldap-phpldapadmin odo-ldap-ssp"
else
[[ "${COMPOSE_CMD}" == "license" ]] || COMPOSE_SVC="odo-${COMPOSE_SVC}"
fi
}
function check_odo_exist() {
[[ -d odo-pg ]] && ODO_INIT_PG='no'
[[ -d odo-ldap/db ]] && ODO_INIT_LDAP='no'
[[ -d odo-jenkins ]] && ODO_INIT_JENKINS='no'
[[ -d odo-sonar/data ]] && ODO_INIT_SONAR='no'
[[ -d odo-jira ]] && ODO_INIT_JIRA='no'
[[ -d odo-conf ]] && ODO_INIT_CONF='no'
[[ -d odo-gitlab/config ]] && ODO_INIT_GITLAB='no'
[[ -f odo-harbor/docker-compose.yml ]] && ODO_INIT_HARBOR='no'
[[ -d odo-rancher ]] && ODO_INIT_RANCHER='no'
[[ -d odo-jms/data ]] && ODO_INIT_JMS='no'
return 0
}
# Usage: get_odo_service_port container_name
function get_odo_service_port() {
echo ${COMPOSE_CONFIG} | awk -F "container_name: $1" '{print $2}' | awk -F 'ports: - ' '{print $2}' | awk -F ':' '{print $1}'
return 0
}
## ODO Init Service Function
function set_host_for_sonar() {
[[ "${ODO_INIT_SONAR}" == "yes" ]] || return 0
[[ "$(uname)" == "Linux" ]] && {
sysctl -w vm.max_map_count=262144
sysctl -w fs.file-max=65535
ulimit -n 65535
ulimit -u 4095
}
}
function init_odo_pg() {
[[ "${ODO_INIT_PG}" == "yes" ]] || return 0
echo "Waiting for PostgresQL running ..."
chmod_dir odo-pg
while true; do
sleep 1
docker exec -it odo-pg psql -U postgres -l && break
done
db_list=$(docker exec -it odo-pg psql -U postgres -l)
for db_name in jira conf sonar; do
echo "Check and init DB for ${db_name}"
echo "${db_list}" | grep $db_name || docker exec -it odo-pg createdb -U postgres $db_name
done
echo "Complete to init DB"
docker exec -it odo-pg psql -U postgres -l
}
function init_odo_ldap() {
[[ "${ODO_INIT_LDAP}" == "yes" ]] || return 0
phpldapadmin_url=$(grep ODO_PHPLADPADMIN_URL docker-compose.yaml | awk '{print $NF}')
[[ "${phpldapadmin_url}" == "" ]] && phpldapadmin_url="http://localhost:$(get_odo_service_port odo-ldap-phpldapadmin)"
phpldapadmin_index_url="${phpldapadmin_url}/htdocs/index.php"
phpldapadmin_cmd_url="${phpldapadmin_url}/htdocs/cmd.php"
_curl_output=".ldapcontent"
echo "Access LDAP: ${phpldapadmin_index_url}"
while true; do
sleep 2
rm -rf ${COOKIES}
output=$($CURL -X GET "$phpldapadmin_index_url" -o ${_curl_output} 2>&1)
echo "$output" | grep HTTP | grep 200 && break
done
echo "Login LDAP: ${phpldapadmin_cmd_url}"
output=$($CURL -X POST "$phpldapadmin_cmd_url" \
-H 'Accept: */*' \
-H 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'cmd=login' \
--data-urlencode 'server_id=1' \
--data-urlencode 'nodecode[login_pass]=1' \
--data-urlencode "login=${LDAP_ADMIN}" \
--data-urlencode "login_pass=${LDAP_PASSWD}" \
--data-urlencode 'submit=Authenticate' \
-o ${_curl_output} 2>&1)
echo "$output" | grep HTTP | grep 200 || log_fail "$output"
echo "Import LDAP: ${phpldapadmin_cmd_url}"
output=$($CURL -X POST "$phpldapadmin_cmd_url" \
-H 'Accept: */*' \
-H 'Content-Type: multipart/form-data' \
--form 'server_id=1' \
--form 'cmd=import' \
--form "ldif=$(cat odo-ldap/odo_users.ldif)" \
-o ${_curl_output} 2>&1)
echo "$output" | grep HTTP | grep 200 || log_fail "$output"
rm -rf ${_curl_output}
rm -rf ${COOKIES}
return 0
}
function init_odo_sonar() {
[[ "${ODO_INIT_SONAR}" == "yes" ]] || return 0
chmod_dir odo-sonar
sonar_url=$(grep ODO_SONAR_URL docker-compose.yaml | awk '{print $NF}')
[[ "${sonar_url}" == "" ]] && sonar_url="http://localhost:$(get_odo_service_port odo-sonar)}"
sonar_status_url="${sonar_url}/api/system/status"
sonar_login_url="${sonar_url}/api/authentication/login"
sonar_plugin_url="${sonar_url}/api/plugins/install"
sonar_restart_url="${sonar_url}/api/system/restart"
echo "Waiting for SonarQube[${sonar_url}] running ..."
while true; do
sleep 2
rm -rf ${COOKIES}
$CURL -X GET ${sonar_status_url} 2>&1 | grep HTTP | grep 200 && break
done
echo "Login SonarQube[${sonar_login_url}] ..."
while true; do
sleep 2
rm -rf ${COOKIES}
output=$($CURL -X POST ${sonar_login_url} \
-H 'Accept: application/json' \
-H 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode "login=admin" \
--data-urlencode "password=admin" \
2>&1)
echo "${output}" | grep HTTP | grep 200 && {
sonar_token=$(echo "${output}" | grep ' Set-Cookie:' | grep 'XSRF-TOKEN=' | awk -F 'XSRF-TOKEN=' '{print $2}' | awk -F ';' '{print $1}')
[[ -z "${sonar_token}" ]] && exit 1
echo "${sonar_token}"
break
}
done
echo "Install LDAP plugin: ${sonar_plugin_url}"
output=$($CURL -X POST ${sonar_plugin_url} \
-H 'Accept: application/json' \
-H 'Content-Type: application/x-www-form-urlencoded' \
-H "X-XSRF-TOKEN: ${sonar_token}" \
--data-urlencode 'key=ldap' \
2>&1)
echo "${output}" | grep HTTP | grep 204 || log_fail "${output}"
echo "Update sonar.properties to enable LDAP"
sed -i 's/#sonar.security.realm=LDAP/sonar.security.realm=LDAP/' odo-sonar/sonar.properties
echo "Restart sonar: ${sonar_restart_url}"
output=$($CURL -X POST ${sonar_restart_url} \
-H 'Accept: application/json' \
-H 'Content-Type: application/x-www-form-urlencoded' \
-H "X-XSRF-TOKEN: ${sonar_token}" \
2>&1)
echo "${output}" | grep HTTP | grep 200 || log_fail "$output"
rm -rf ${COOKIES}
docker restart odo-sonar
return 0
}
function init_odo_jenkins() {
[[ "${ODO_INIT_JENKINS}" == "yes" ]] || return 0
chmod_dir odo-jenkins
return 0
## Need more debug
jenkins_url=$(grep ODO_JENKINS_URL docker-compose.yaml | awk '{print $NF}')
[[ "${jenkins_url}" == "" ]] && jenkins_url="http://localhost:$(get_odo_service_port odo-jenkins)"
jenkins_login_url="${jenkins_url}/login"
jenkins_security_url="${jenkins_url}/j_acegi_security_check"
jenkins_plugin_url="${jenkins_url}/pluginManager/installPlugins"
jenkins_restart_url="${jenkins_url}/updateCenter/safeRestart"
echo "Waiting for Jenkins[${jenkins_login_url}] running ..."
while true; do
sleep 2
rm -rf ${COOKIES}
output=$($CURL -X GET "${jenkins_login_url}" 2>&1)
echo "${output}" | grep HTTP | grep -E '200|302' && break
done
echo "Unlock Jenkins: ${jenkins_security_url}"
j_password=$(docker exec -it odo-jenkins sh -c 'cat /var/jenkins_home/secrets/initialAdminPassword' | sed 's/\r//g')
j_crumb=$(echo "$output" | grep '"Jenkins-Crumb"' | awk -F '"Jenkins-Crumb"' '{print $2}' | awk -F '"' '{print $2}')
output=$($CURL -X POST "${jenkins_security_url}" \
-H 'Accept: */*' \
-H 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'from=/' \
--data-urlencode 'j_username=admin' \
--data-urlencode "j_password=${j_password}" \
--data-urlencode "Jenkins-Crumb=${j_crumb}" \
--data-urlencode "json={\"from\":\"\",\"j_username\":\"admin\",\"j_password\":\"${j_password}\",\"\$redact\":\"j_password\",\"Jenkins-Crumb\":\"${j_crumb}\"}" \
2>&1)
echo "${output}" | grep HTTP | grep 200 || log_fail "${output}"
echo "Install Plugins: ${jenkins_plugin_url}"
j_crumb=$(echo "$output" | grep '"Jenkins-Crumb"' | awk -F '"Jenkins-Crumb"' '{print $2}' | awk -F '"' '{print $2}')
output=$($CURL -X POST "${jenkins_security_url}" \
-H 'Accept: */*' \
-H 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode "Jenkins-Crumb=${j_crumb}" \
--data-urlencode 'dynamicLoad=true' \
--data-urlencode 'plugins=["cloudbees-folder","antisamy-markup-formatter","build-timeout","credentials-binding","timestamper","ws-cleanup","workflow-aggregator","pipeline-stage-view","git","subversion","ssh-slaves","matrix-auth","pam-auth","ldap","email-ext","mailer","localization-zh-cn","htmlpublisher","gitlab-plugin","git-parameter","authorize-project","publish-over-ssh","emailext-template","ssh"]' \
2>&1)
echo "${output}" | grep HTTP | grep 200 || log_fail "${output}"
echo "Restart Jenkins: ${jenkins_restart_url}"
j_crumb=$(echo "$output" | grep '"Jenkins-Crumb"' | awk -F '"Jenkins-Crumb"' '{print $2}' | awk -F '"' '{print $2}')
output=$($CURL -X POST "${jenkins_restart_url}" \
-H 'Accept: */*' \
-H 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode "Jenkins-Crumb=${j_crumb}" \
2>&1)
echo "${output}" | grep HTTP | grep 200 || log_fail "${output}"
return 0
}
function init_odo_jira() {
[[ "${ODO_INIT_JIRA}" == "yes" ]] || return 0
jira_url=$(grep ODO_JIRA_URL docker-compose.yaml | awk '{print $NF}')
[[ "${jira_url}" == "" ]] && jira_url="http://localhost:$(get_odo_service_port odo-jira)"
jira_mode_url="${jira_url}/secure/SetupMode.jspa"
jira_db_url="${jira_url}/secure/SetupDatabase.jspa"
jira_app_url="${jira_url}/secure/SetupApplicationProperties.jspa"
jira_license_url="${jira_url}/secure/SetupLicense.jspa"
jira_admin_url="${jira_url}/secure/SetupAdminAccount.jspa"
jira_mail_url="${jira_url}/secure/SetupMailNotifications.jspa"
echo "Waiting for Jira Software[${jira_url}] running ..."
while true; do
sleep 2
rm -rf ${COOKIES}
output=$($CURL -X GET "${jira_url}" 2>&1)
echo "${output}" | grep HTTP | grep -E '200|302' && {
atl_token=$(echo "${output}" | grep 'Set-Cookie: ' | awk -F 'Set-Cookie: ' '{print $NF}' | awk -F 'atlassian.xsrf.token=' '{print $2}' | awk -F ';' '{print $1}')
echo "${atl_token}"
[[ -z "${atl_token}" ]] || break
}
done
echo "Setup Mode: ${jira_mode_url}"
output=$($CURL -X POST ${jira_mode_url} \
-H 'Accept: */*' \
-H 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'setupOption=classic' \
--data-urlencode "atl_token=${atl_token}" \
2>&1)
echo "${output}" | grep HTTP | grep -E '200|302' || log_fail "$output"
echo "Setup Database: ${jira_db_url}"
get_atl_token=$(echo "${output}" | grep 'Set-Cookie: ' | awk -F 'Set-Cookie: ' '{print $NF}' | awk -F 'atlassian.xsrf.token=' '{print $2}' | awk -F ';' '{print $1}')
[[ -z "$get_atl_token" ]] || atl_token=$get_atl_token
output=$($CURL -X POST ${jira_db_url} \
-H 'Accept: */*' \
-H 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'databaseOption=external' \
--data-urlencode 'databaseType=postgres72' \
--data-urlencode 'jdbcHostname=odo-pg' \
--data-urlencode 'jdbcPort=5432' \
--data-urlencode 'jdbcDatabase=jira' \
--data-urlencode 'jdbcSid=' \
--data-urlencode "jdbcUsername=${PG_USER}" \
--data-urlencode "jdbcPassword=${PG_PASSWD}" \
--data-urlencode 'schemaName=public' \
--data-urlencode "atl_token=${atl_token}" \
2>&1)
echo "${output}" | grep HTTP | grep -E '200|302' || log_fail "$output"
echo "Setup Application Properties: ${jira_app_url}"
get_atl_token=$(echo "${output}" | grep 'Set-Cookie: ' | awk -F 'Set-Cookie: ' '{print $NF}' | awk -F 'atlassian.xsrf.token=' '{print $2}' | awk -F ';' '{print $1}')
[[ -z "$get_atl_token" ]] || atl_token=$get_atl_token
output=$($CURL -X POST ${jira_url}/secure/SetupApplicationProperties.jspa \
-H 'Accept: */*' \
-H 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'title=Jira' \
--data-urlencode 'mode=private' \
--data-urlencode "baseURL=${jira_url}" \
--data-urlencode 'nextStep=true' \
--data-urlencode "atl_token=${atl_token}" \
2>&1)
echo "${output}" | grep HTTP | grep -E '200|302' || log_fail "$output"
echo "Generate Jira Software License"
jira_license=$(docker exec -it odo-jira getJiraLicense | tail -9)
echo "${jira_license}"
echo "Setup Jira Software License: ${jira_license_url}"
get_atl_token=$(echo "${output}" | grep 'Set-Cookie: ' | awk -F 'Set-Cookie: ' '{print $NF}' | awk -F 'atlassian.xsrf.token=' '{print $2}' | awk -F ';' '{print $1}')
[[ -z "$get_atl_token" ]] || atl_token=$get_atl_token
output=$($CURL -X POST "${jira_url}/secure/SetupLicense!validateLicense.jspa" \
-H 'Accept: */*' \
-H 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode "licenseToValidate=${jira_license}" \
2>&1)
echo "${output}" | grep HTTP | grep -E '200|302' || log_fail "$output"
get_atl_token=$(echo "${output}" | grep 'Set-Cookie: ' | awk -F 'Set-Cookie: ' '{print $NF}' | awk -F 'atlassian.xsrf.token=' '{print $2}' | awk -F ';' '{print $1}')
[[ -z "$get_atl_token" ]] || atl_token=$get_atl_token
output=$($CURL -X POST ${jira_license_url} \
-H 'Accept: */*' \
-H 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode "setupLicenseKey=${jira_license}" \
--data-urlencode "atl_token=${atl_token}" \
2>&1)
echo "${output}" | grep HTTP | grep -E '200|302' || log_fail "$output"
echo "Setup Admin Account: ${jira_admin_url}"
get_atl_token=$(echo "${output}" | grep 'Set-Cookie: ' | awk -F 'Set-Cookie: ' '{print $NF}' | awk -F 'atlassian.xsrf.token=' '{print $2}' | awk -F ';' '{print $1}')
[[ -z "$get_atl_token" ]] || atl_token=$get_atl_token
output=$($CURL -X POST ${jira_admin_url} \
-H 'Accept: */*' \
-H 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode "fullname=admin" \
--data-urlencode "email=admin@${LDAP_DOMAIN}" \
--data-urlencode "username=admin" \
--data-urlencode "password=${LDAP_PASSWD}" \
--data-urlencode "confirm=${LDAP_PASSWD}" \
--data-urlencode "atl_token=${atl_token}" \
2>&1)
echo "${output}" | grep HTTP | grep -E '200|302' || log_fail "$output"
echo "Setup Mail Notifications: ${jira_mail_url}"
get_atl_token=$(echo "${output}" | grep 'Set-Cookie: ' | awk -F 'Set-Cookie: ' '{print $NF}' | awk -F 'atlassian.xsrf.token=' '{print $2}' | awk -F ';' '{print $1}')
[[ -z "$get_atl_token" ]] || atl_token=$get_atl_token
output=$($CURL -X POST ${jira_mail_url} \
-H 'Accept: */*' \
-H 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode "analytics-enabled=" \
--data-urlencode "noemail=true" \
--data-urlencode "name=admin" \
--data-urlencode "from=opendevops" \
--data-urlencode "prefix=[Jira]" \
--data-urlencode "mailservertype=smtp" \
--data-urlencode "serverProvider=custom" \
--data-urlencode "serverName=" \
--data-urlencode "protocol=smtp" \
--data-urlencode "port=" \
--data-urlencode "timeout=10000" \
--data-urlencode "username=" \
--data-urlencode "password=" \
--data-urlencode "jndiLocation=" \
--data-urlencode "type=smtp" \
--data-urlencode "testingMailConnection=false" \
--data-urlencode "atl_token=${atl_token}" \
2>&1)
echo "${output}" | grep HTTP | grep -E '200|302' || log_fail "$output"
rm -rf ${COOKIES}
return 0
}
function init_odo_conf() {
[[ "${ODO_INIT_CONF}" == "yes" ]] || return 0
conf_url=$(grep ODO_CONF_URL docker-compose.yaml | awk '{print $NF}')
[[ "${conf_url}" == "" ]] && conf_url="http://localhost:$(get_odo_service_port odo-conf)"
conf_start_url="${conf_url}/setup/dosetupstart.action"
conf_bundle_url="${conf_url}/setup/doselectbundle.action"
conf_license_url="${conf_url}/setup/dosetuplicense.action"
conf_dbchoice_url="${conf_url}/setup/setupdbchoice.action"
conf_dbtest_url="${conf_url}/setup/setupstandarddb-testconnection.action"
conf_dbtype_url="${conf_url}/setup/setupdbtype.action"
conf_data_url="${conf_url}/setup/setupdata.action"
conf_user_url="${conf_url}/setup/setupusermanagementchoice.action"
conf_admin_url="${conf_url}/setup/setupadministrator.action"
echo "Waiting for Confluence Server[${conf_url}] running ..."
while true
do
sleep 2
rm -rf ${COOKIES}
output=$($CURL -X GET ${conf_url}/setup/setupstart.action 2>&1)
echo "${output}" | grep HTTP | grep -E '302|200' && {
atl_token=$(echo "${output}" | grep Location | awk -F 'atl_token=' '{print $2}' | sed 's/\r//g')
[[ -z "$atl_token" ]] || break
}
done
echo "Start Setup Confluence: ${conf_start_url}"
output=$($CURL -X GET "${conf_start_url}?setupType=custom&atl_token=${atl_token}" 2>&1)
echo "$output" | grep HTTP | grep -E '302|200' || log_fail "$output"
echo "Select Bundle: ${conf_bundle_url}"
output=$($CURL -X POST ${conf_bundle_url} \
-H 'Accept: */*' \
-H 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'pluginKeys=' \
--data-urlencode 'setup-next-button=Next' \
--data-urlencode "atl_token=${atl_token}" \
2>&1)
echo "$output" | grep HTTP | grep -E '200|302' || log_fail "$output"
echo "Get server ID: ${conf_url}/setup/setuplicense.action"
output=$($CURL -X GET ${conf_url}/setup/setuplicense.action 2>&1)
echo "$output" | grep HTTP | grep -E '200|302' || log_error "$output"
conf_server_id=$(echo "$output"| grep 'name="serverId"' | awk -F 'value=' '{print $2}' | awk -F '"' '{print $2}')
echo "${conf_server_id}"
echo "Generate conf license"
conf_license=$(docker exec -it odo-conf getConfLicense ${conf_server_id} | tail -8)
echo "$conf_license"
echo "Setup license: ${conf_license_url}"
output=$($CURL -X POST ${conf_license_url} \
-H 'Accept: */*' \
-H 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode "selectedPluginKeys=" \
--data-urlencode "confLicenseString=${conf_license}" \
--data-urlencode "setupTypeCustom=next" \
--data-urlencode "atl_token=${atl_token}" \
2>&1)
echo "$output" | grep HTTP | grep -E '200|302' || log_fail "$output"
echo "Choice DB: ${conf_dbchoice_url}"
output=$($CURL -X POST ${conf_dbchoice_url} \
-H 'Accept: */*' \
-H 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode "thisNodeClustered=false" \
--data-urlencode "dbChoice=custom" \
--data-urlencode "setup-next-button=Next" \
--data-urlencode "atl_token=${atl_token}" \
2>&1)
echo "$output" | grep HTTP | grep -E '200|302' || log_fail "$output"
echo "Test DB: ${conf_dbtest_url}"
output=$($CURL -X POST ${conf_dbtest_url} \
-H 'Accept: */*' \
-H 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode "dbConfigInfo.databaseType=postgresql" \
--data-urlencode "dbConfigInfo.simple=false" \
--data-urlencode "dbConfigInfo.databaseUrl=jdbc:postgresql://odo-pg:5432/conf" \
--data-urlencode "dbConfigInfo.hostname=" \
--data-urlencode "dbConfigInfo.port=" \
--data-urlencode "dbConfigInfo.databaseName=" \
--data-urlencode "dbConfigInfo.serviceName=" \
--data-urlencode "dbConfigInfo.userName=${PG_USER}" \
--data-urlencode "dbConfigInfo.password=${PG_PASSWD}" \
--data-urlencode "dbConfigInfo.instanceName=" \
--data-urlencode "database=" \
--data-urlencode "atl_token=${atl_token}" \
2>&1)
echo "$output" | grep HTTP | grep -E '200|302' || log_fail "$output"
echo "Setup DB: ${conf_dbtype_url}"
output=$($CURL -X POST ${conf_dbtype_url} \
-H 'Accept: */*' \
-H 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode "dbConfigInfo.databaseType=postgresql" \
--data-urlencode "dbConfigInfo.simple=false" \
--data-urlencode "dbConfigInfo.databaseUrl=jdbc:postgresql://odo-pg:5432/conf" \
--data-urlencode "dbConfigInfo.hostname=" \
--data-urlencode "dbConfigInfo.port=" \
--data-urlencode "dbConfigInfo.databaseName=" \
--data-urlencode "dbConfigInfo.serviceName=" \
--data-urlencode "dbConfigInfo.userName=${PG_USER}" \
--data-urlencode "dbConfigInfo.password=${PG_PASSWD}" \
--data-urlencode "dbConfigInfo.instanceName=" \
--data-urlencode "database=" \
--data-urlencode "atl_token=${atl_token}" \
2>&1)
echo "$output" | grep HTTP | grep -E '200|302' || log_fail "$output"
echo "Setup Data: ${conf_data_url}"
output=$($CURL -X POST ${conf_data_url} \
-H 'Accept: */*' \
-H 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode "dbchoiceSelect=Empty+Site" \
--data-urlencode "contentChoice=blank" \
--data-urlencode "atl_token=${atl_token}" \
2>&1)
echo "$output" | grep HTTP | grep -E '200|302' || log_fail "$output"
echo "Setup User Management: ${conf_user_url}"
output=$($CURL -X POST ${conf_user_url} \
-H 'Accept: */*' \
-H 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode "userManagementChoice=internal" \
--data-urlencode "internal=Manage+users+and+groups+within+Confluence" \
--data-urlencode "atl_token=${atl_token}" \
2>&1)
echo "$output" | grep HTTP | grep -E '200|302' || log_fail "$output"
echo "Setup Administrator: ${conf_admin_url}"
output=$($CURL -X POST ${conf_admin_url} \
-H 'Accept: */*' \
-H 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode "username=admin" \
--data-urlencode "fullName=admin" \
--data-urlencode "email=admin@${LDAP_DOMAIN}" \
--data-urlencode "password=${LDAP_PASSWD}" \
--data-urlencode "confirm=${LDAP_PASSWD}" \
--data-urlencode "step-next-button=Next" \
--data-urlencode "atl_token=${atl_token}" \
2>&1)
echo "$output" | grep HTTP | grep -E '200|302' || log_fail "$output"
rm -rf ${COOKIES}
return 0
}
function init_odo_gitlab() {
[[ "${ODO_INIT_GITLAB}" == "yes" ]] || return 0
gitlab_url=$(grep ODO_GITLAB_URL docker-compose.yaml | awk '{print $NF}')
[[ "${gitlab_url}" == "" ]] && gitlab_url="http://localhost:$(get_odo_service_port odo-gitlab)"
gitlab_passwd_url="${gitlab_url}/users/password"
gitlab_login_url="${gitlab_url}/users/sign_in"
gitlab_setting_url="${gitlab_url}/admin/application_settings/general"
echo "Waiting for GitLab[${gitlab_url}] running ..."
while true
do
sleep 2
rm -rf ${COOKIES}
output=$($CURL -X GET ${gitlab_url} 2>&1)
echo "${output}" | grep HTTP | grep -E '302|200' && {
reset_password_token=$(echo "${output}" | \
grep Location | \
grep 'reset_password_token' | \
awk -F 'reset_password_token=' '{print $2}' | \
sed 's/\r//g')
auth_token=$(echo "$output" | \
grep 'name="authenticity_token"' | \
awk -F 'name="authenticity_token"' '{print $2}' | \
awk -F 'value="' '{print $2}' | \
awk -F '"' '{print $1}')
[[ -z "$reset_password_token" ]] || {
[[ -z "$auth_token" ]] || {
echo "Auth Token: $auth_token"
break
}
}
}
done
echo "Reset GitLab password: ${gitlab_passwd_url}"
output=$($CURL -X POST ${gitlab_passwd_url} \
-H 'Accept: */*' \
-H 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode "_method=put" \
--data-urlencode "authenticity_token=${auth_token}" \
--data-urlencode "user[reset_password_token]=${reset_password_token}" \
--data-urlencode "user[password]=${LDAP_PASSWD}" \
--data-urlencode "user[password_confirmation]=${LDAP_PASSWD}" \
2>&1)
echo "$output" | grep HTTP | grep -E '200|302' || log_fail "$output"
echo "Login GitLab: ${gitlab_login_url}"
output=$($CURL -X GET ${gitlab_login_url} 2>&1)
echo "${output}" | grep HTTP | grep -E '302|200' && {
auth_token=$(echo "$output" | \
grep 'action="/users/sign_in"' -A 5 | \
grep 'name="authenticity_token"' | \
awk -F 'name="authenticity_token"' '{print $2}' | \
awk -F 'value="' '{print $2}' | \
awk -F '"' '{print $1}')
echo "Auth Token: $auth_token"
}
output=$($CURL -X POST ${gitlab_login_url} \
-H 'Accept: */*' \
-H 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode "authenticity_token=${auth_token}" \
--data-urlencode "user[login]=root" \
--data-urlencode "user[password]=${LDAP_PASSWD}" \
--data-urlencode "user[remember_me]=0" \
2>&1)
echo "$output" | grep HTTP | grep -E '200|302' || log_fail "$output"
echo "Disable GitLab Sign Up: ${gitlab_setting_url}"
output=$($CURL -X GET ${gitlab_setting_url} 2>&1)
echo "${output}" | grep HTTP | grep -E '302|200' && {
auth_token=$(echo "$output" | \
grep -A 5 'general#js-signup-settings' | \
grep 'name="authenticity_token"' | \
awk -F 'name="authenticity_token"' '{print $2}' | \
awk -F 'value="' '{print $2}' | \
awk -F '"' '{print $1}')
echo "Auth Token: $auth_token"
}
output=$($CURL -X POST ${gitlab_setting_url} \
-H 'Accept: */*' \
-H 'Content-Type: multipart/form-data' \
--form "_method=patch" \
--form "authenticity_token=${auth_token}" \
--form "application_setting[signup_enabled]=0" \
--form "application_setting[send_user_confirmation_mail]=0" \
--form "application_setting[minimum_password_length]=8" \
--form "application_setting[domain_whitelist_raw]=" \
--form "application_setting[domain_blacklist_enabled]=0" \
--form "blacklist_type=raw" \
--form "application_setting[domain_blacklist_raw]=" \
--form "application_setting[email_restrictions_enabled]=0" \
--form "application_setting[email_restrictions]=" \
--form "application_setting[after_sign_up_text]=" \
2>&1)
echo "$output" | grep HTTP | grep -E '200|302' || log_fail "$output"
rm -rf ${COOKIES}
echo "Modity config file to enable LDAP"
_ldap_base="ou=users,dc=$(echo $LDAP_DOMAIN | sed 's/\./,dc=/g')"
cat <<EOF >> odo-gitlab/config/gitlab.rb
#### ODO LDAP Configuration
gitlab_rails['ldap_enabled'] = true
gitlab_rails['ldap_servers'] = YAML.load <<-'EOS'
main:
label: 'LDAP'
host: 'odo-ldap-openldap'
port: 389
uid: 'cn'
bind_dn: '$LDAP_ADMIN'
password: '${LDAP_PASSWD}'
encryption: 'plain'
verify_certificates: true
smartcard_auth: false
active_directory: false
allow_username_or_email_login: true
lowercase_usernames: false
base: '$_ldap_base'
user_filter: ''
attributes:
username: ['cn']
email: ['mail']
name: 'displayName'
EOS
EOF
echo "Restart GitLab"
docker restart odo-gitlab
return 0
}
function init_odo_harbor() {
if [[ "${ODO_INIT_HARBOR}" == "yes" ]]; then
harbor_url=$(grep ODO_HARBOR_URL docker-compose.yaml | awk '{print $NF}')
harbor_host=$(echo ${harbor_url} | awk -F '://' '{print $2}' | awk -F ':' '{print $1}')
harbor_port=$(echo ${harbor_url} | awk -F '://' '{print $2}' | awk -F ':' '{print $2}')
[[ -z "$harbor_port" ]] && harbor_port=80
echo "Waiting for Harbor installer ready ..."
while true
do
sleep 1
[[ -f odo-harbor/harbor.yml.tmpl ]] && break
done
cd odo-harbor || log_fail "Cannot change dir to odo-harbor"
echo "Update harbor.yml"
cp harbor.yml.tmpl harbor.yml
sed -i "s#^hostname: .*#hostname: ${harbor_host}#" harbor.yml
sed -i "s#port: 80#port: ${harbor_port}#" harbor.yml
sed -i 's/^https:/# https:/' harbor.yml
sed -i 's/port: 443/# port: 443/' harbor.yml
sed -i 's/certificate:/# certificate:/' harbor.yml
sed -i 's/private_key:/# private_key:/' harbor.yml
sed -i "s#^harbor_admin_password: .*#harbor_admin_password: ${LDAP_PASSWD}#" harbor.yml
sed -i "s#^data_volume: .*#data_volume: ${ODO_HOME}/odo-harbor/data#" harbor.yml
sed -i "s#location: .*#location: ${ODO_HOME}/odo-harbor/log#" harbor.yml
echo "Start to install Harbor ..."
./install.sh --with-chartmuseum
else
cd odo-harbor || log_fail "Cannot change dir to odo-harbor"
docker-compose up -d
fi
cd $ODO_HOME
return 0
}
function init_odo_rancher() {
[[ "${ODO_INIT_RANCHER}" == "yes" ]] || return 0
return 0
}
function init_odo_jms() {
[[ "${ODO_INIT_JMS}" == "yes" ]] || return 0
return 0
}
## Main
check_env
check_odo_cli
check_odo_svc
check_odo_exist
if [[ "${COMPOSE_CMD}" == "start" ]]; then
# Set host before UP containers
if [[ "${COMPOSE_SVC}" == "" ]]; then
set_host_for_sonar
else
echo "${COMPOSE_SVC}" | grep -q "sonar" && set_host_for_sonar
fi
# Pull images
${DOCKER_COMPOSE} pull ${COMPOSE_SVC}
# UP service container
${DOCKER_COMPOSE} up -d ${COMPOSE_SVC}
# if start all odo-svc, need init them
if [[ "${COMPOSE_SVC}" == "" ]]; then
init_odo_ldap
init_odo_pg
init_odo_jenkins
init_odo_sonar
init_odo_jira
init_odo_conf
init_odo_gitlab
init_odo_rancher
init_odo_harbor
init_odo_jms
# if start the odo-svc, check and init it
else
echo "${COMPOSE_SVC}" | grep -q "ldap" && init_odo_ldap
echo "${COMPOSE_SVC}" | grep -q "pg" && init_odo_pg
echo "${COMPOSE_SVC}" | grep -q "jenkins" && init_odo_jenkins
echo "${COMPOSE_SVC}" | grep -q "sonar" && init_odo_sonar
echo "${COMPOSE_SVC}" | grep -q "jira" && init_odo_jira
echo "${COMPOSE_SVC}" | grep -q "conf" && init_odo_conf
echo "${COMPOSE_SVC}" | grep -q "gitlab" && init_odo_gitlab
echo "${COMPOSE_SVC}" | grep -q "rancher" && init_odo_rancher
echo "${COMPOSE_SVC}" | grep -q "harbor" && init_odo_harbor
echo "${COMPOSE_SVC}" | grep -q "jms" && init_odo_jms
fi
sleep 2
${DOCKER_COMPOSE} ps
# Emm......
elif [[ "${COMPOSE_CMD}" == "start_no_init" ]]; then
if [[ "${COMPOSE_SVC}" == "" ]]; then
set_host_for_sonar
else
echo "${COMPOSE_SVC}" | grep -q "sonar" && set_host_for_sonar
fi
${DOCKER_COMPOSE} pull ${COMPOSE_SVC}
${DOCKER_COMPOSE} up -d ${COMPOSE_SVC}
if [[ "${COMPOSE_SVC}" == "" ]]; then
[[ "${ODO_INIT_PG}" == "yes" ]] && chmod_dir odo-pg
[[ "${ODO_INIT_JENKINS}" == "yes" ]] && chmod_dir odo-jenkins
[[ "${ODO_INIT_SONAR}" == "yes" ]] && chmod_dir odo-sonar
else
echo "${COMPOSE_SVC}" | grep -q "pg" && [[ "${ODO_INIT_PG}" == "yes" ]] && chmod_dir odo-pg
echo "${COMPOSE_SVC}" | grep -q "jenkins" && [[ "${ODO_INIT_JENKINS}" == "yes" ]] && chmod_dir odo-jenkins
echo "${COMPOSE_SVC}" | grep -q "sonar" && [[ "${ODO_INIT_SONAR}" == "yes" ]] && chmod_dir odo-sonar
fi
sleep 2
${DOCKER_COMPOSE} ps
# Stop the container
elif [[ "${COMPOSE_CMD}" == "stop" ]]; then
${DOCKER_COMPOSE} stop ${COMPOSE_SVC}
sleep 2
${DOCKER_COMPOSE} ps
# Restart the container
elif [[ "${COMPOSE_CMD}" == "restart" ]]; then
${DOCKER_COMPOSE} restart ${COMPOSE_SVC}
sleep 2
${DOCKER_COMPOSE} ps
# List all containers
elif [[ "${COMPOSE_CMD}" == "list" ]]; then
${DOCKER_COMPOSE} ps
# Down all containers
elif [[ "${COMPOSE_CMD}" == "down" ]]; then
${DOCKER_COMPOSE} down -v
sleep 2
${DOCKER_COMPOSE} ps
# Generate license or get initial password
elif [[ "${COMPOSE_CMD}" == "license" ]]; then
if [[ "${COMPOSE_SVC}" == "jira" ]]; then
docker ps | grep -q odo-jira || log_error "Seems there is no Jira Software in this server"
docker exec -it odo-jira getJiraLicense
elif [[ "${COMPOSE_SVC}" == "jira_plugin" ]]; then
docker ps | grep -q odo-jira || log_error "Seems there is no Jira Software in this server"
docker exec -it odo-jira getPluginLicense ${PRODUCT_ID}
elif [[ "${COMPOSE_SVC}" == "conf" ]]; then
docker ps | grep -q odo-conf || log_error "Seems there is no Confluence in this server"
docker exec -it odo-conf getConfLicense ${PRODUCT_ID}
elif [[ "${COMPOSE_SVC}" == "conf_plugin" ]]; then
docker ps | grep -q odo-conf || log_error "Seems there is no Confluence in this server"
docker exec -it odo-conf getPluginLicense ${PRODUCT_ID}
elif [[ "${COMPOSE_SVC}" == "jenkins" ]]; then
docker ps | grep -q odo-jenkins || log_error "Seems there is no Jenkins in this server"
docker exec -it odo-jenkins sh -c 'cat /var/jenkins_home/secrets/initialAdminPassword'
fi
# Cleanup all
elif [[ "${COMPOSE_CMD}" == "cleanup" ]]; then
echo -en "\033[31;1m [ DANGER ] \033[0m"
echo -e "\033[33;1mThis action will wipe all ODO data\033[0m"
echo -en "\033[33;1mDo you really wanna to this? \033[0m"
read -p "[y/N] " _CLEANUP
[[ "${_CLEANUP,,}" == 'y' ]] || log_error "Abort cleanup"
${DOCKER_COMPOSE} down
sleep 2
${DOCKER_COMPOSE} ps
# Remove generated dirs
[[ -f .gitignore ]] && {
for clean_dir in $(grep 'odo-' .gitignore | grep -v '#'); do
rm -rf ${clean_dir}
done
}
# Check and disable sonar LDAP config
sed -i 's/^sonar.security.realm=LDAP/#sonar.security.realm=LDAP/' odo-sonar/sonar.properties
# Remove cookie file
rm -rf ${COOKIES}
fi