-
Notifications
You must be signed in to change notification settings - Fork 14
/
devops_tools.sh
1036 lines (1035 loc) · 48.4 KB
/
devops_tools.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
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
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/bin/bash
while [ true ]
do
echo "Author: Anil Kumar Mannem."
#Version : 1.0
#Email : mannemanilkumar@hotmail.com.
#License : Open Source.
#Released on: 07/12/2023.
sudo cat /etc/os-release | grep "Ubuntu" > /dev/null 2>&1
if [ $? -eq 0 ]
then
#echo $USER | grep "root" > /dev/null 2>&1
#if [ $? -eq 0 ]
#then
#tput bold
#echo "***Please execute this script as Normal user.***"
#tput sgr0
#else
echo "Below mentioned tool/Software can be installed individually as per your choice"
tput bold
echo "1) Git 8) Tomcat 15) Exit from this Script"
echo "2) Java 9) Ansible"
echo "3) Maven 10) Terraform"
echo "4) Grafana 11) SonarQube"
echo "5) Docker 12) Prometheus"
echo "6) Jenkins 13) Node_Exporter"
echo "7) Jfrog 14) Kubernetes"
tput sgr0
bold=`tput bold`
nobold=`tput sgr0`
RED='\033[0;31m'
NC='\033[0m' # No Color
echo "For installation of Git tool you can pass the inputs like - ${bold}git / Git / GIT / 1 $nobold(As per your convenience)"
read -p "Now you can install any devops tools/softwares by entering their name(Not case-sensitive) or serial number from the above list:" tool
my_system_ip()
{
host myip.opendns.com resolver1.opendns.com | grep "myip.opendns.com has" | awk '{print $4}'
}
tomcat_version()
{
tomcat_port=`sudo cat /var/lib/tomcat*/conf/server.xml | grep port= | cut -d '=' -f 2 | cut -d '"' -f 2 | head -2 | tail -1` > /dev/null 2>&1
tomcat_ip=`my_system_ip`
tomcat_user=`sudo cat /var/lib/tomcat*/conf/tomcat-users.xml | grep "manager-gui" | grep "username=" | cut -d "=" -f 2 | cut -d '"' -f 2`
tomcat_password=`sudo cat /var/lib/tomcat*/conf/tomcat-users.xml | grep "manager-gui" | grep "password=" | cut -d "=" -f 2 | cut -d '"' -f 2`
version=`curl http://$tomcat_ip:$tomcat_port/manager/html -u ${tomcat_user}:${tomcat_password} | grep "Apache Tomcat" | cut -d ">" -f 3 | cut -d "<" -f 1 | cut -d " " -f 1,2`
echo "Tomcat Server Version is: $version"
}
docker_install()
{
sudo apt-get update
sudo apt-get install ca-certificates curl gnupg -y
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y
}
kubernetes()
{
sudo apt-get update
sudo mkdir -p /etc/apt/keyrings
sudo apt-get install -y apt-transport-https ca-certificates curl
curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.28/deb/Release.key | sudo gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg
echo "deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v1.28/deb/ /" | sudo tee /etc/apt/sources.list.d/kubernetes.list
sudo apt-get update
sudo apt-get install -y kubelet kubeadm kubectl
}
jenkins_timer_130()
{
echo "Please wait process is going on.."
for (( i=1; i<=130; i++ ))
do
echo -n "#"
sleep 1
done
tput cud1
}
jenkins_timer_70()
{
echo "Please wait process is going on.."
for (( i=1; i<=70; i++ ))
do
echo -n "#"
sleep 1
done
tput cud1
}
jenkins_timer_10()
{
echo "Please wait process is going on.."
for (( i=1; i<=10; i++ ))
do
echo -n "#"
sleep 1
done
tput cud1
}
tomcat_timer_5()
{
echo "Please wait process is going on.."
for (( i=1; i<=5; i++ ))
do
echo -n "#"
sleep 1
done
tput cud1
}
tomcat_timer_6()
{
echo "Please wait process is going on.."
for (( i=1; i<=6; i++ ))
do
echo -n "#"
sleep 1
done
tput cud1
}
docker_timer_30()
{
echo "Please wait process is going on.."
for (( i=1; i<=30; i++ ))
do
echo -n "#"
sleep 1
done
tput cud1
}
docker_timer_20()
{
echo "Please wait process is going on.."
for (( i=1; i<=20; i++ ))
do
echo -n "#"
sleep 1
done
tput cud1
}
grafana_timer_10()
{
echo "Please wait process is going on.."
for (( i=1; i<=10; i++ ))
do
echo -n "#"
sleep 1
done
tput cud1
}
sonarqube_timer_30()
{
echo "Please wait process is going on.."
for (( i=1; i<=30; i++ ))
do
echo -n "#"
sleep 1
done
tput cud1
}
node_exporter_timer_5()
{
echo "Please wait process is going on.."
for (( i=1; i<=5; i++ ))
do
echo -n "#"
sleep 1
done
tput cud1
}
node_exporter_timer_40()
{
echo "Please wait process is going on.."
for (( i=1; i<=40; i++ ))
do
echo -n "#"
sleep 1
done
tput cud1
}
prometheus_timer_30()
{
echo "Please wait process is going on.."
for (( i=1; i<=30; i++ ))
do
echo -n "#"
sleep 1
done
tput cud1
}
prometheus_timer_40()
{
echo "Please wait process is going on.."
for (( i=1; i<=40; i++ ))
do
echo -n "#"
sleep 1
done
tput cud1
}
jfrog_timer_54()
{
echo "Please wait process is going on.."
for (( i=1; i<=54; i++ ))
do
echo -n "#"
sleep 1
done
tput cud1
}
jfrog_timer_55()
{
echo "Please wait process is going on.."
for (( i=1; i<=55; i++ ))
do
echo -n "#"
sleep 1
done
tput cud1
}
kubernetes_timer_20()
{
echo "Please wait process is going on.."
for (( i=1; i<=20; i++ ))
do
echo -n "#"
sleep 1
done
tput cud1
}
case $tool in
"tomcat"|"Tomcat"|"TOMCAT"|"8" )
echo "You have entered tomcat"
service=`sudo ls /usr/lib/systemd/system | grep tomcat*`
cd /var/lib/tomcat*/conf > /dev/null 2>&1
if [ $? -eq 0 ]
then
echo "Tomcat-Server was available in your system"
sudo systemctl restart $service
tomcat_ip=`my_system_ip`
tomcat_port=`sudo cat server.xml | grep port= | cut -d '=' -f 2 | cut -d '"' -f 2 | head -2 | tail -1` > /dev/null 2>&1
tomcat_timer_6
sudo curl --connect-timeout 2 http://$tomcat_ip:$tomcat_port | grep tomcat > /dev/null 2>&1
if [ $? -eq 0 ]
then
tput bold
tomcat_version
tput sgr0
echo "Now you can open browser ${bold}http://$tomcat_ip:$tomcat_port $nobold"
echo "Your Tomcat-Server username is $bold'$tomcat_user'$nobold and password is $bold'$tomcat_password'$nobold"
echo "Tomcat is working as expected"
else
tomcat_port=`sudo cat server.xml | grep port= | cut -d '=' -f 2 | cut -d '"' -f 2 | head -2 | tail -1` > /dev/null 2>&1
alloted_port=`sudo cat /lib/systemd/system/jenkins.service | grep "JENKINS_PORT" | cut -d "=" -f 3 | cut -d '"' -f 1`
if [ $tomcat_port == $alloted_port ]
then
echo "$tomcat_port is using by jenkins, so automatically tomcat port will assign to another available port"
sudo sed -i 's/8080/8084/g' /var/lib/tomcat9/conf/server.xml 2>&1
sudo systemctl restart $service
tomcat_timer_6
sudo curl --connect-timeout 2 http://$tomcat_ip:$tomcat_port | grep tomcat > /dev/null 2>&1
if [ $? -eq 0 ]
then
tput bold
tomcat_version
tput sgr0
echo "Now you can open browser ${bold}http://$tomcat_ip:$tomcat_port$nobold"
else
echo "You need to allow the port number ${bold}$tomcat_port$nobold in security groups"
fi
else
echo "You need to allow the port number ${bold}$tomcat_port$nobold in security groups"
fi
fi
else
echo "Now tomcat will be installed"
sudo apt-get update
sudo apt-get install default-jdk -y
sudo apt-get install tomcat9 tomcat9-admin -y
cd ~
wget https://raw.githubusercontent.com/mannem302/download/master/tomcat-users.xml
sudo mv ~/tomcat-users.xml /var/lib/tomcat9/conf/tomcat-users.xml
echo "Tomcat was installed sucessfully and users was configured"
tomcat_port=`sudo cat /var/lib/tomcat*/conf/server.xml | grep port= | cut -d '=' -f 2 | cut -d '"' -f 2 | head -2 | tail -1` > /dev/null 2>&1
tomcat_ip=`my_system_ip`
tomcat_user=`sudo cat /var/lib/tomcat*/conf/tomcat-users.xml | grep "manager-gui" | grep "username=" | cut -d "=" -f 2 | cut -d '"' -f 2`
tomcat_password=`sudo cat /var/lib/tomcat*/conf/tomcat-users.xml | grep "manager-gui" | grep "password=" | cut -d "=" -f 2 | cut -d '"' -f 2`
sudo curl --connect-timeout 2 http://$tomcat_ip:$tomcat_port | grep tomcat > /dev/null 2>&1
if [ $? -eq 0 ]
then
echo "Now you can open browser using the URL ${bold}http://$tomcat_ip:$tomcat_port${nobold}"
echo "Your Tomcat-Server username is $bold'$tomcat_user'$nobold and password is $bold'$tomcat_password'$nobold"
else
sudo curl --connect-timeout 2 http://$tomcat_ip:$tomcat_port | grep tomcat > /dev/null 2>&1
if [ $? -ne 0 ]
then
#echo "You need to allow the port number ${bold}$tomcat_port$nobold in security groups"
alloted_port=`sudo cat /lib/systemd/system/jenkins.service | grep "JENKINS_PORT" | cut -d "=" -f 3 | cut -d '"' -f 1`
if [ $tomcat_port == $alloted_port ]
then
echo " $tomcat_port is using by jenkins, so automatically tomcat port will assign to another available port"
sudo sed -i 's/8080/8084/g' /var/lib/tomcat*/conf/server.xml 2>&1
sudo systemctl restart tomcat9.service
tomcat_timer_6
tomcat_port=`expr $alloted_port + 4`
echo "$tomcat_port is now allocated to tomcat"
sudo curl --connect-timeout 4 http://$tomcat_ip:$tomcat_port | grep tomcat > /dev/null 2>&1
if [ $? -eq 0 ]
then
tput bold
tomcat_version
tput sgr0
echo "Now you can open browser ${bold}http://$tomcat_ip:$tomcat_port$nobold"
echo "Your Tomcat-Server username is $bold'$tomcat_user'$nobold and password is $bold'$tomcat_password'$nobold"
else
echo "You need to allow the port number ${bold}$tomcat_port$nobold in security groups"
fi
else
echo "You need to allow the port number ${bold}$tomcat_port$nobold in security groups"
fi
fi
fi
fi
;;
"maven"|"Maven"|"MAVEN"|"3")
echo "You have entered maven "
mvn --version > /dev/null 2>&1
if [ $? -eq 0 ]
then
echo "Maven is available in your server and it's Version is:"
tput bold
mvn --version
tput sgr0
else
echo "Now maven will be installed"
sudo apt-get update
sudo apt-get install maven -y
echo "Maven was installed sucessfully and it's Version is:"
tput bold
mvn --version
tput sgr0
fi
;;
"git"|"Git"|"GIT"|"1")
echo "You have entered git"
git --version > /dev/null 2>&1
if [ $? -eq 0 ]
then
echo "Git is available in your server and it's Version is:"
tput bold
git --version
tput sgr0
else
echo "Now git will be installed"
sudo apt-get update
sudo apt-get install git -y
echo "Git was installed sucessfully and it's Version is:"
tput bold
git --version
tput sgr0
fi
;;
"java"|"Java"|"JAVA"|"2")
echo "You have entered java "
java --version > /dev/null 2>&1
if [ $? -eq 0 ]
then
echo "Java is available in your server and it's Version is:"
tput bold
java --version
tput sgr0
else
echo "Now java will be installed"
sudo apt-get update
sudo apt-get install openjdk-17-jdk -y
echo "Java was installed sucessfully and it's Version is:"
tput bold
java --version
tput sgr0
fi
;;
"jenkins"|"Jenkins"|"JENKINS"|"6")
echo "You have entered jenkins "
jenkins --version > /dev/null 2>&1
if [ $? -eq 0 ]
then
echo "Jenkins is available in your server and it's Version is:"
tput bold
jenkins --version
tput sgr0
jenkins_ip=`my_system_ip`
jenkins_port=`sudo cat /lib/systemd/system/jenkins.service | grep "JENKINS_PORT" | cut -d "=" -f 3 | cut -d '"' -f 1`
service=`sudo ls /usr/lib/systemd/system | grep jenkins`
sudo systemctl restart $service
jenkins_timer_70
sudo curl --connect-timeout 2 http://$jenkins_ip:$jenkins_port > /dev/null 2>&1
if [ $? -eq 0 ]
then
echo "Open your browser and Enter http://$jenkins_ip and port number is $jenkins_port"
echo "You have to execute like this in your browser ${bold}http://$jenkins_ip:$jenkins_port$nobold "
echo "Jenkins server is working as expected "
else
alloted_port=`sudo cat /var/lib/tomcat*/conf/server.xml | grep port= | cut -d '=' -f 2 | cut -d '"' -f 2 | head -2 | tail -1` > /dev/null 2>&1
jenkins_port=`sudo cat /lib/systemd/system/jenkins.service | grep "JENKINS_PORT" | cut -d "=" -f 3 | cut -d '"' -f 1`
if [ $jenkins_port == $alloted_port ]
then
echo "$jenkins_port is using by tomcat, so automatically jenkins port will assign to another available port"
sudo sed -i 's/8080/8084/g' /lib/systemd/system/jenkins.service 2>&1
sudo systemctl daemon-reload
service=`sudo ls /usr/lib/systemd/system | grep jenkins`
echo "Now $service is restarting please wait.."
sudo systemctl restart $service
jenkins_timer_130
jenkins_port=`sudo cat /lib/systemd/system/jenkins.service | grep "JENKINS_PORT" | cut -d "=" -f 3 | cut -d '"' -f 1`
sudo curl --connect-timeout 2 http://$jenkins_ip:$jenkins_port | grep jenkins > /dev/null 2>&1
if [ $? -eq 0 ]
then
echo "Open your browser and Enter $jenkins_ip and port number is $jenkins_port"
echo "You have to execute like this in your browser ${bold}http://$jenkins_ip:$jenkins_port$nobold "
echo "Jenkins server is working as expected "
else
echo "You need to allow the port number ${bold}$jenkins_port$nobold in security groups"
fi
else
echo "You need to allow the port number ${bold}$jenkins_port$nobold in security groups"
fi
fi
else
echo "Now jenkins will be installed"
sudo wget -O /usr/share/keyrings/jenkins-keyring.asc \
https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key
echo deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc] \
https://pkg.jenkins.io/debian-stable binary/ | sudo tee \
/etc/apt/sources.list.d/jenkins.list > /dev/null
sudo apt-get update
sudo apt-get install openjdk-17-jdk -y
sudo apt-get install jenkins -y
echo "Jenkins was installed sucessfully and it's Version is:"
tput bold
jenkins --version
tput sgr0
jenkins_ip=`my_system_ip`
jenkins_port=`sudo cat /lib/systemd/system/jenkins.service | grep "JENKINS_PORT" | cut -d "=" -f 3 | cut -d '"' -f 1` > /dev/null 2>&1
alloted_port=`sudo cat /var/lib/tomcat*/conf/server.xml | grep port= | cut -d '=' -f 2 | cut -d '"' -f 2 | head -2 | tail -1` > /dev/null 2>&1
jenkins_timer_10
sudo curl --connect-timeout 2 http://$jenkins_ip:$jenkins_port | grep Authentication > /dev/null
if [ $? -ne 0 ] && [ $alloted_port == $jenkins_port ]
then
echo "$jenkins_port to be allowed in security groups or it is using by other services and now $jenkins_port will be changed"
sudo sed -i 's/8080/8084/g' /lib/systemd/system/jenkins.service 2>&1
sudo systemctl daemon-reload
service=`sudo ls /usr/lib/systemd/system | grep jenkins`
sudo systemctl restart $service
jenkins_port1=`expr $alloted_port + 4`
jenkins_port=`sudo cat /lib/systemd/system/jenkins.service | grep "JENKINS_PORT" | cut -d "=" -f 3 | cut -d '"' -f 1` > /dev/null 2>&1
jenkins_timer_130
sudo curl --connect-timeout 4 http://$jenkins_ip:$jenkins_port | grep Authentication > /dev/null 2>&1
if [ $? -eq 0 ]
then
echo "Open your browser and Enter $jenkins_ip and port number is $jenkins_port"
echo "You have to execute like this in your browser ${bold}http://$jenkins_ip:$jenkins_port$nobold "
echo "---------------------------------"
tput bold
sudo cat /var/lib/jenkins/secrets/initialAdminPassword
tput sgr0
echo "---------------------------------"
echo "Copy the above line and paste it in the 'Administrator password' field"
else
echo "You need to allow the port number ${bold}$jenkins_port$nobold in security groups"
fi
else
sudo curl --connect-timeout 4 http://$jenkins_ip:$jenkins_port | grep Authentication > /dev/null 2>&1
if [ $? -eq 0 ]
then
echo "Open your browser and Enter http://$jenkins_ip and port number is $jenkins_port"
echo "You have to execute like this in your browser ${bold}http://$jenkins_ip:$jenkins_port $nobold "
echo "---------------------------------"
tput bold
sudo cat /var/lib/jenkins/secrets/initialAdminPassword
tput sgr0
echo "---------------------------------"
echo "Copy the above displayed password and paste it in the 'Administrator password' field in your browser"
else
echo "You need to allow the port number ${bold}$jenkins_port$nobold in security groups"
fi
fi
fi
;;
"docker"|"Docker"|"DOCKER"|"5")
echo "You have entered docker"
docker --version > /dev/null 2>&1
if [ $? -eq 0 ]
then
docker --version | grep "ubuntu" > /dev/null 2>&1
if [ $? -eq 0 ]
then
echo "In your system Un-official Docker version was available and it's Version is"
tput bold
docker --version
tput sgr0
sleep 2
echo "If you proceed further this un-official Docker version will be un-installed"
echo "But earlier built/pulled images, running/stopped containers will not be deleted"
sleep 2
echo "Now you have only 30 Sec's of time to decide.To move to further process or not"
echo "To cancel Docker installation press $bold ctrl+c $nobold or wait for official Docker version installation"
docker_timer_30
echo "Un-official Docker version is being un-installed and official version will be installed in the next following steps"
for pkg in docker.io docker-doc docker-compose docker-compose-v2 podman-docker containerd runc; do sudo apt-get remove $pkg -y && sudo apt autoremove -y; done
docker_install
docker_timer_20
sudo systemctl restart docker.socket docker.service
echo "Docker was installed sucessfully and it's Version is:"
tput bold
docker --version
tput sgr0
sudo cat /etc/group | grep "docker" | grep "$USER" > /dev/null 2>&1
if [ $? -eq 0 ]
then
echo "$USER is in docker group" > /dev/null 2>&1
else
echo $USER | grep "root" > /dev/null 2>&1
if [ $? -eq 0 ]
then
echo "You can use docker commands normally"
else
sudo usermod -aG docker $USER
echo "$USER is added to docker group and now you neednot to enter 'sudo' everytime for executing docker commands"
echo "Now your instance is being restarted for applying the user changes"
tput smso
echo " For using docker normally, Please wait for 2 Min's and reload the page "
tput rmso
sudo reboot
fi
fi
else
echo "Docker is available in your server and it's Version is:"
tput bold
docker --version
tput sgr0
sudo cat /etc/group | grep "docker" | grep "$USER" > /dev/null 2>&1
if [ $? -eq 0 ]
then
echo "$USER is in docker group" > /dev/null 2>&1
else
echo $USER | grep "root" > /dev/null 2>&1
if [ $? -eq 0 ]
then
echo "You can use docker commands normally"
else
sudo usermod -aG docker $USER
echo "$USER is added to docker group and now you neednot to enter 'sudo' everytime for executing docker commands"
echo "Now your instance is being restarted for applying the user changes"
tput smso
echo "For using docker normally, Please wait for 2 Min's and reload the page "
tput rmso
sudo reboot
fi
fi
fi
else
echo "Now docker will be installed"
docker_install
echo "Docker was installed sucessfully and it's Version is:"
tput bold
docker --version
tput sgr0
echo $USER | grep "root" > /dev/null 2>&1
if [ $? -eq 0 ]
then
echo "You can use docker commands normally"
else
sudo usermod -aG docker $USER
echo "$USER is added to docker group and now you neednot to enter 'sudo' everytime for executing docker commands"
echo "Now your instance is being restarted for applying the user changes"
tput smso
echo " For using docker normally, Please wait for 2 Min's and reload the page "
tput rmso
sudo reboot
fi
fi
;;
"grafana"|"Grafana"|"GRAFANA"|"4")
echo "You have entered grafana "
grafana_ip=`my_system_ip`
cat /usr/share/grafana/VERSION > /dev/null 2>&1
if [ $? -eq 0 ]
then
echo "Grafana is available in your server and it's Version is:"
cat /usr/share/grafana/VERSION
echo
echo "Grafana URL generation under progress"
if [ $? -eq 0 ]
then
grafana_port=`sudo cat /etc/grafana/grafana.ini | grep "http_port" | cut -d "=" -f 2 | head -n 1 | cut -d " " -f 2` > /dev/null 2>&1
sudo systemctl restart grafana-server > /dev/null
grafana_timer_10
curl --connect-timeout 4 http://$grafana_ip:$grafana_port > /dev/null
if [ $? -eq 0 ]
then
echo "Now open your browser and enter the URL: $bold http://$grafana_ip:$grafana_port $nobold"
else
echo "You need to allow the port number $bold $grafana_port$nobold in security groups"
fi
fi
else
echo "Now grafana will be installed"
sudo apt-get update
sudo apt-get install libfontconfig1 -y
wget https://dl.grafana.com/enterprise/release/grafana-enterprise_10.0.3_amd64.deb
sudo dpkg -i grafana-enterprise_10.0.3_amd64.deb
sudo systemctl daemon-reload
sleep 2
sudo systemctl enable grafana-server
sudo systemctl start grafana-server
grafana_timer_10
grafana_port=`sudo cat /etc/grafana/grafana.ini | grep "http_port" | cut -d "=" -f 2 | head -n 1 | cut -d " " -f 2`
echo "Grafana was installed sucessfully and it's Version is:"
tput bold
cat /usr/share/grafana/VERSION
tput sgr0
echo
curl --connect-timeout 5 http://$grafana_ip:$grafana_port > /dev/null
if [ $? -eq 0 ]
then
echo "Now open your browser and enter the URL:$bold http://$grafana_ip:$grafana_port $nobold"
echo "Default Username-$bold admin$nobold and Default Password-$bold admin$nobold"
else
echo "You need to allow the port number$bold $grafana_port$nobold in security groups"
fi
fi
;;
"ansible"|"Ansible"|"ANSIBLE"|"9")
echo "You have entered Ansible "
ansible --version > /dev/null 2>&1
if [ $? -eq 0 ]
then
echo "Ansible is available in your server and it's Version is:"
ansible --version
else
echo "Now ansible will be installed"
sudo apt-get update
sudo apt install software-properties-common -y
sudo add-apt-repository --yes --update ppa:ansible/ansible
sudo apt install ansible -y
echo "Ansible was installed sucessfully and it's Version is:"
ansible --version
fi
;;
"terraform"|"Terraform"|"TERRAFORM"|"10")
echo "You have entered terraform "
terraform -version > /dev/null 2>&1
if [ $? -eq 0 ]
then
echo "Terraform is available in your server and it's Version is:"
tput bold
terraform -version
tput sgr0
else
echo "Now terraform will be installed"
sudo apt-get update
wget -O- https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list
sudo apt update
sudo apt install terraform -y
echo "Terraform was installed sucessfully and it's Version is:"
tput bold
terraform -version
tput sgr0
fi
;;
"sonarqube"|"Sonarqube"|"SONARQUBE"|"11")
echo "You have entered sonarqube"
sonarqube_ip=`my_system_ip`
sudo systemctl status sonar.service > /dev/null 2>&1
if [ $? -eq 0 ]
then
echo "Sonarqube is available in your server"
sudo systemctl restart sonar.service > /dev/null 2>&1
sonarqube_timer_30
sonar_properties=`sudo find / -name "sonar.properties"`
sonarqube_port=`sudo cat $sonar_properties | grep "sonar.web.port" | cut -d "=" -f2`
sudo curl --connect-timeout 4 http://$sonarqube_ip:$sonarqube_port > /dev/null 2>&1
if [ $? -eq 0 ]
then
echo "Now open your browser and enter $bold http://$sonarqube_ip:$sonarqube_port$nobold"
else
echo "You need to allow the port number$bold $sonarqube_port$nobold in security groups"
fi
else
ram_exist=`free -m | grep "Mem" | awk '{print $2}'`
ram_required=3800
if [ $ram_exist -gt $ram_required ]
then
echo "Now sonarqube will be installed"
sudo apt-get update
sudo apt-get install openjdk-17-jdk -y
cd /opt
sudo wget https://binaries.sonarsource.com/Distribution/sonarqube/sonarqube-9.9.0.65466.zip
sudo apt-get install unzip -y > /dev/null 2>&1
sudo unzip sonarqube-9.9.0.65466.zip
sudo mv /opt/sonarqube-9.9.0.65466 /opt/sonarqube
sudo groupadd sonar
sudo useradd -c "user to run SonarQube" -d /opt/sonarqube -g sonar sonar
sudo chown -R sonar:sonar /opt/sonarqube
echo "RUN_AS_USER=sonar" | sudo tee -a /opt/sonarqube/bin/linux-x86-64/sonar.sh > /dev/null 2>&1
echo "sonar ALL=(ALL:ALL) NOPASSWD:ALL" | sudo tee -a /etc/sudoers > /dev/null 2>&1
echo -e " [Unit] \n Description=SonarQube service\n After=syslog.target network.target\n \
After=syslog.target network.target\n [Service]\n Type=forking\n ExecStart=/opt/sonarqube/bin/linux-x86-64/sonar.sh start\n \
ExecStop=/opt/sonarqube/bin/linux-x86-64/sonar.sh stop\n User=sonar\n Group=sonar\n Restart=always\n \
LimitNOFILE=65536\n LimitNPROC=4096\n [Install]\n WantedBy=multi-user.target\n" | sudo tee -a /etc/systemd/system/sonar.service > /dev/null 2>&1
sudo systemctl start sonar > /dev/null 2>&1
sudo systemctl status sonar > /dev/null 2>&1
sudo systemctl enable sonar > /dev/null 2>&1
sonarqube_port=`sudo cat /opt/sonarqube/conf/sonar.properties | grep "sonar.web.port" | cut -d "=" -f2`
sonarqube_timer_30
curl --connect-timeout 4 http://$sonarqube_ip:$sonarqube_port > /dev/null 2>&1
if [ $? -eq 0 ]
then
echo "Sonarqube was installed sucessfully and you can browse using following URL"
echo "${bold}http://$sonarqube_ip:$sonarqube_port$nobold"
echo "Default Username-${bold}admin$nobold and Password-${bold}admin${nobold}"
else
echo "You need to allow the port number$bold $sonarqube_port$nobold in security groups"
fi
else
echo "${bold}It requires minimum 4GB server, please launch t2.meduim in AWS or equivalent in Azure$nobold"
fi
fi
;;
"node_exporter"|"Node_exporter"|"NODE_EXPORTER"|"13")
echo "You have entered node_exporter "
node_exporter_ip=`my_system_ip`
systemctl status node_exporter > /dev/null 2>&1
if [ $? -eq 0 ]
then
echo "Node_exporter is available in your server"
sudo systemctl restart node_exporter.service > /dev/null 2>&1
node_exporter_timer_5
node_exporter_port=`journalctl -eu node_exporter | grep "Listening on" | head -n 1 |cut -d ":" -f10`
node_exporter_timer_40
sudo curl --connect-timeout 4 http://$node_exporter_ip:$node_exporter_port > /dev/null 2>&1
if [ $? -eq 0 ]
then
node_version=`curl http://$node_exporter_ip:$node_exporter_port | grep "version=" | cut -d "=" -f2 | cut -d "," -f 1`
echo "Node_exporter version:- $bold$node_version$nobold"
echo "Now open your browser and enter $bold http://$node_exporter_ip:$node_exporter_port$nobold"
else
echo "You need to allow the port number$bold $node_exporter_port$nobold in security groups"
fi
else
echo "Now node_exporter will be installed"
sudo apt-get update
cd /tmp
curl -s https://api.github.com/repos/prometheus/node_exporter/releases/latest | grep browser_download_url | grep linux-amd64 | cut -d '"' -f 4 | wget -qi -
tar -xvzf node_exporter-*.*.*.linux-amd64.tar.gz
sudo mv node_exporter-*.linux-amd64 /opt/node_exporter
echo -e "[Unit]\n Description=Prometheus Node Exporter\n Documentation=https://github.com/prometheus/node_exporter\n\
After=network-online.target\n [Service]\n User=root\n EnvironmentFile=/etc/default/node_exporter\n \
ExecStart=/opt/node_exporter/node_exporter $OPTIONS \n Restart=on-failure\n RestartSec=5\n [Install]\n \
WantedBy=multi-user.target\n " | sudo tee -a /etc/systemd/system/node_exporter.service > /dev/null 2>&1
sudo systemctl daemon-reload > /dev/null 2>&1
node_exporter_timer_5
echo "OPTIONS=''" | sudo tee -a /etc/default/node_exporter > /dev/null 2>&1
sudo systemctl enable node_exporter
sudo systemctl start node_exporter > /dev/null 2>&1
node_exporter_timer_40
node_exporter_port=`journalctl -eu node_exporter | grep "Listening on" | head -n 1 |cut -d ":" -f10`
sudo curl --connect-timeout 4 http://$node_exporter_ip:$node_exporter_port > /dev/null 2>&1
if [ $? -eq 0 ]
then
node_version=`curl http://$node_exporter_ip:$node_exporter_port | grep "version=" | cut -d "=" -f2 | cut -d "," -f 1`
echo "Node_exporter version:-$bold$node_version$nobold"
echo "Node_exporter was installed sucessfully and you can browse using following URL"
echo "${bold}http://$node_exporter_ip:$node_exporter_port$nobold"
else
echo "You need to allow the port number$bold $node_exporter_port$nobold in security groups"
fi
fi
;;
"prometheus"|"Prometheus"|"PROMETHEUS"|"12")
echo "You have entered Prometheus "
prometheus_ip=`my_system_ip`
prometheus --version > /dev/null 2>&1
if [ $? -eq 0 ]
then
version=`prometheus --version | grep "version" | head -1 | cut -d " " -f 3` > /dev/null 2>&1
echo "Prometheus is available in your server and it's Version is:"
echo "Prometheus- $version"
sudo systemctl restart prometheus.service > /dev/null 2>&1
prometheus_timer_30
prometheus_port=`journalctl -eu prometheus | grep "Listening on" | head -n 1 |cut -d ":" -f10`
sudo curl --connect-timeout 4 http://$prometheus_ip:$prometheus_port > /dev/null 2>&1
if [ $? -eq 0 ]
then
echo "Prometheus was installed sucessfully and you can browse using following URL"
echo "${bold}http://$prometheus_ip:$prometheus_port$nobold"
else
echo "You need to allow the port number$bold $prometheus_port$nobold in security groups"
fi
else
echo "Now Prometheus will be installed"
sudo apt-get update
sudo groupadd --system prometheus
sudo useradd -s /sbin/nologin --system -g prometheus prometheus
sudo mkdir /var/lib/prometheus
for i in rules rules.d files_sd; do sudo mkdir -p /etc/prometheus/${i}; done
cd /tmp
curl -s https://api.github.com/repos/prometheus/prometheus/releases/latest | grep browser_download_url | grep linux-amd64 | cut -d '"' -f 4 | wget -qi -
tar xvfz prometheus-*.*.*.linux-amd64.tar.gz
cd prometheus*/
sudo mv prometheus promtool /usr/local/bin/
sudo mv prometheus.yml /etc/prometheus/prometheus.yml
sudo mv consoles/ console_libraries/ /etc/prometheus/
cd $HOME
wget https://raw.githubusercontent.com/mannem302/download/main/prometheus.service
sudo mv prometheus.service /etc/systemd/system/prometheus.service > /dev/null 2>&1
for i in rules rules.d files_sd; do sudo chown -R prometheus:prometheus /etc/prometheus/${i}; done
for i in rules rules.d files_sd; do sudo chmod -R 775 /etc/prometheus/${i}; done
sudo chown -R prometheus:prometheus /var/lib/prometheus/
sudo systemctl daemon-reload
sleep 4
sudo systemctl start prometheus.service > /dev/null 2>&1
sudo systemctl enable prometheus.service
version=`prometheus --version | grep "version" | head -1 | cut -d " " -f 3` > /dev/null 2>&1
echo "Prometheus was installed sucessfully and it's Version is:"
echo "Prometheus- ${bold}$version$nobold"
prometheus_port=`journalctl -eu prometheus | grep "Listening on" | head -n 1 |cut -d ":" -f10`
prometheus_timer_40
sudo curl --connect-timeout 4 http://$prometheus_ip:$prometheus_port > /dev/null 2>&1
if [ $? -eq 0 ]
then
echo "Prometheus was installed sucessfully and you can browse using following URL"
echo "$bold http://$prometheus_ip:$prometheus_port$nobold"
else
echo "You need to allow the port number$bold $prometheus_port$nobold in security groups"
fi
fi
;;
"jfrog"|"Jfrog"|"JFROG"|"7")
echo "You have entered Jfrog"
jfrog_ip=`my_system_ip`
sudo systemctl status artifactory.service > /dev/null 2>&1
if [ $? -eq 0 ]
then
echo "Jfrog is available in your server"
sudo systemctl restart artifactory.service > /dev/null 2>&1
jfrog_timer_55
jfrog_port=8081
sudo curl --connect-timeout 4 http://$jfrog_ip:$jfrog_port > /dev/null 2>&1
if [ $? -eq 0 ]
then
echo "Now open your browser and enter $bold http://$jfrog_ip:$jfrog_port$nobold"
else
echo "You need to allow the port number$bold $jfrog_port & 8082$nobold in security groups"
fi
else
ram_exist=`free -m | grep "Mem" | awk '{print $2}'`
ram_required=3800
if [ $ram_exist -gt $ram_required ]
then
echo "Now Jfrog will be installed"
sudo apt-get update
cd /opt
sudo wget https://releases.jfrog.io/artifactory/bintray-artifactory/org/artifactory/oss/jfrog-artifactory-oss/7.71.5/jfrog-artifactory-oss-7.71.5-linux.tar.gz
sudo sudo tar -xvzf jfrog-artifactory-oss*
sudo mv /opt/artifactory-oss-* /opt/artifactory
sudo rm -rf jfrog-artifactory-oss*
sudo groupadd jfrog
sudo useradd -c "user to run Jfrog" -d /opt/artifactory -g jfrog jfrog
sudo chown -R jfrog:jfrog /opt/artifactory
echo "jfrog ALL=(ALL:ALL) NOPASSWD:ALL" | sudo tee -a /etc/sudoers > /dev/null 2>&1
echo -e " [Unit] \n Description=Artifactory service\n After=syslog.target network.target\n \
After=syslog.target network.target\n [Service]\n Type=forking\n ExecStart=/opt/artifactory/app/bin/artifactory.sh start\n \
ExecStop=/opt/artifactory/app/bin/artifactory.sh stop\n User=jfrog\n Group=jfrog\n Restart=always\n \
[Install]\n WantedBy=multi-user.target\n" | sudo tee /etc/systemd/system/artifactory.service > /dev/null 2>&1
sudo systemctl start artifactory.service > /dev/null 2>&1
sudo systemctl status artifactory.service > /dev/null 2>&1
sudo systemctl enable artifactory.service > /dev/null 2>&1
jfrog_port=`sudo cat /opt/artifactory/app/artifactory/tomcat/conf/server.xml | grep "Connector" | cut -d "=" -f 2 | cut -d '"' -f 2| head -1`
jfrog_timer_55
curl --connect-timeout 4 http://$jfrog_ip:$jfrog_port > /dev/null 2>&1
if [ $? -eq 0 ]
then
echo "Jfrog was installed sucessfully and you can browse using following URL"
echo "${bold}http://$jfrog_ip:$jfrog_port$nobold"
echo "Default Username-${bold}admin$nobold and Password-${bold}password${nobold}"
else
echo "You need to allow the port number$bold $jfrog_port & 8082$nobold in security groups"
fi
else
echo "${bold}It requires minimum 4GB server, please launch t2.meduim in AWS or equivalent in Azure$nobold"
fi
fi
;;
"kubernetes"|"Kubernetes"|"KUBERNETES"|"14")
echo "You have entered kubernetes"
kubectl version > /dev/null 2>&1
if [ $? -eq 0 ]
then
echo "Kubernetes is available in your server and it's Version is:"
version=`kubectl version | head -1`
echo "${bold}$version$nobold"
else
ubuntu_version=`sudo cat /etc/os-release | grep 'PRETTY_NAME="Ubuntu' | awk {'print $2'}`
supported_version=20.04.6
if [ $ubuntu_version == $supported_version ]
then
echo $USER | grep "root" > /dev/null 2>&1
if [ $? -ne 0 ]
then
echo "${bold}***To proceed the kubernetes cluster setup you have to switch to root user.***$nobold"
else
echo "${bold}Based on your selection kubernetes master or worker node will be configured$nobold "
echo "Please enter the option${bold} master$nobold or ${bold}worker${nobold}"
read -p "You are setting up ${bold}Kubernetes$nobold - " decision
if [ $decision == master ] || [ $decision == Master ] || [ $decision == MASTER ]
then
ram_exist=`free -m | grep "Mem" | awk '{print $2}'`
ram_required=3800
if [ $ram_exist -gt $ram_required ]
then
docker --version > /dev/null 2>&1
if [ $? -eq 0 ]
then
sed -i 's/cri//g' /etc/containerd/config.toml
systemctl restart containerd
echo "Now kubernetes master will be configured"
kubernetes
kubeadm init | tail -2 | tee join_token
sleep 2
export KUBECONFIG=/etc/kubernetes/admin.conf
sleep 2
kubectl apply -f https://github.com/weaveworks/weave/releases/download/v2.8.1/weave-daemonset-k8s.yaml
sleep 1
#echo "Please copy the token and paste in worker node to configure cluster setup"
echo "Kubernetes was installed sucessfully and it's Version is:"
version=`kubectl version | head -1`
echo "$version"
export KUBECONFIG=/etc/kubernetes/admin.conf
touch as_root_user
echo "export KUBECONFIG=/etc/kubernetes/admin.conf" >as_root_user
sudo wget https://raw.githubusercontent.com/mannem302/download/main/as_normal_user
kubernetes_timer_20
echo "Kubernetes master status getting ready, please wait ..."
kubectl get nodes
echo "Kubernetes master node is ready and now you can add worker nodes by using generated token"
echo "If you want to check the node status, please execute the below command"
echo "export KUBECONFIG=/etc/kubernetes/admin.conf"
else
echo "Now container runtime will be installed"
docker_install
sed -i 's/cri//g' /etc/containerd/config.toml
systemctl restart containerd
echo "Now kubernetes master will be configured"
kubernetes
kubeadm init | tail -2 | tee join_token
sleep 2
export KUBECONFIG=/etc/kubernetes/admin.conf
kubectl apply -f https://github.com/weaveworks/weave/releases/download/v2.8.1/weave-daemonset-k8s.yaml
sleep 1
echo "Please copy the token and paste in worker node to configure cluster setup"
echo "Kubernetes was installed sucessfully and it's Version is:"
version=`kubectl version | head -1`
echo "$version"
export KUBECONFIG=/etc/kubernetes/admin.conf
touch as_root_user
echo "export KUBECONFIG=/etc/kubernetes/admin.conf" >as_root_user
sudo wget https://raw.githubusercontent.com/mannem302/download/main/as_normal_user
kubernetes_timer_20
echo "Kubernetes master status getting ready, please wait ..."
kubectl get nodes
echo "Kubernetes master node is ready and now you can add worker nodes by using generated token"
echo "Generated token and to be executed commands was saved in $HOME directory"
echo "If you want to check node status, please execute the below command"
echo "${bold}export KUBECONFIG=/etc/kubernetes/admin.conf$nobold"
fi
else
cat /proc/version | grep "aws" > /dev/null 2>&1
if [ $? -eq 0 ]
then
echo "${bold}Please launch t2.medium instance$nobold"
else
echo "${bold}Please launch standard_B2s virtual machine$nobold"
fi
fi
else
echo "Now kubernetes worker setup going on"
docker --version > /dev/null 2>&1
if [ $? -eq 0 ]
then
sed -i 's/cri//g' /etc/containerd/config.toml
systemctl restart containerd
kubernetes
else
echo "Now container runtime will be installed"
docker_install
sed -i 's/cri//g' /etc/containerd/config.toml