-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinstall-xema.sh
More file actions
executable file
·1209 lines (927 loc) · 30.5 KB
/
Copy pathinstall-xema.sh
File metadata and controls
executable file
·1209 lines (927 loc) · 30.5 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
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
# https://stackoverflow.com/questions/3466166/how-to-check-if-running-in-cygwin-mac-or-linux
# https://stackoverflow.com/questions/17336915/return-value-in-a-bash-function
# https://www.gnu.org/software/bash/manual/html_node/Bash-Variables.html#index-FUNCNAME
# https://www.redhat.com/sysadmin/arguments-options-bash-scripts
# Define the support matrix in a central place
function define_support_matrix() {
# Define arrays for each configuration
# Format: distro|hostsys|kernel|version|installable|supported|details
SUPPORT_MATRIX=(
"Ubuntu|Linux|Linux|20|no|no"
"Ubuntu|Linux|Linux|22|yes|yes"
"Ubuntu|Linux|Linux|24|yes|no"
"Ubuntu|Linux|Linux|25|yes|no"
"Ubuntu|Linux|Linux|26|yes|no"
"CentOS|Linux|Linux|4|no|no"
"Ubuntu|WSL|Linux|25|yes|no"
)
}
function set_colors() {
red=$(tput setaf 1)
green=$(tput setaf 2)
reset=$(tput sgr0)
}
function dep() {
i=$depth
while [[ $i -gt 0 ]]; do
echo -n " "
let "i-=1"
done
echo -n ""
}
function lineno1() {
lineno="...........1."${BASH_LINENO[1]}
echo -n ${lineno:(-5)}
}
function lineno2() {
# space is not working, so, using . to pad
lineno="...........2."${BASH_LINENO[2]}
echo -n ${lineno:(-5)}
}
function lineno3() {
lineno="...........3."${BASH_LINENO[3]}
echo -n ${lineno:(-5)}
}
function header() {
logger+=$(lineno1)".H.: "$(dep)${FUNCNAME[1]}$'()\n'
let "depth++"
}
function footer() {
let "depth--"
logger+=$(lineno1)".F.: "$(dep)${FUNCNAME[1]}"() completed. "$1$'\n'
}
log() {
logger+=$(lineno1)".L.: "$(dep)$1$'\n'
# echo "DEBUG: $1"
}
# variable: $hostsys $kernel
function detect_host() {
header
unameOut="$(uname -sro)"
log "uname -sro: ""${green}$unameOut${reset}"
case "${unameOut}" in
Darwin*) hostsys="Mac" ;;
Linux*Microsoft* | Linux*microsoft*) hostsys="WSL" ;;
Linux*) hostsys="Linux" ;;
CYGWIN* | MINGW*) hostsys="Windows" ;;
*) hostsys="Unknown" ;;
esac
case "${unameOut}" in
Darwin*) kernel="OS X" ;;
Linux*) kernel="Linux" ;;
CYGWIN* | MINGW*) kernel="Windows" ;;
*) kernel="Unknown" ;;
esac
footer hostsys="$hostsys",kernel="$kernel"
}
# variable $oever
function detect_ubuntu_version() {
header
lsbOut="$(lsb_release -rs)"
log "lsb_release -rs: ""${green}$lsbOut${reset}"
case "${lsbOut}" in
18.*) oever="18" ;;
20.*) oever="20" ;;
22.*) oever="22" ;;
24.*) oever="24" ;;
25.*) oever="25" ;;
26.*) oever="26" ;;
# 24.*) oever="24" ;;
*) oever="Unknown" ;;
esac
footer oever="$oever"
}
# variable $oever
function detect_centos_version() {
header
log "${red}Not implemented${reset}"
footer
}
# variable $distro
function detect_distro() {
header
if [[ $(lsb_release -is) = *Ubuntu* ]]; then
log "lsb_release -is: "${green}$(lsb_release -is)${reset}
distro="Ubuntu"
detect_ubuntu_version
elif [[ $(cat /etc/os-release | grep "^NAME=") = *CentOS* ]]; then
distro="CentOS"
detect_centos_version
else
distro="Unknown"
fi
footer distro="$distro"
}
# variable $supported, $installable
function check_support_matrix() {
header
supported="no"
installable="no"
log "${red}$hostsys $kernel $distro $oever${reset}"
# Call the common function to define the support matrix
define_support_matrix
# Check the current configuration against the matrix
for config in "${SUPPORT_MATRIX[@]}"; do
# More compatible way to split the string
OLD_IFS="$IFS"
IFS="|"
set -- $config
conf_distro="$1"
conf_hostsys="$2"
conf_kernel="$3"
conf_version="$4"
conf_installable="$5"
conf_supported="$6"
IFS="$OLD_IFS"
if [[ $distro == "$conf_distro" && $hostsys == "$conf_hostsys" && $kernel == "$conf_kernel" && $oever == "$conf_version" ]]; then
installable="$conf_installable"
supported="$conf_supported"
break
fi
done
footer installable="$installable",supported="$supported"
}
function print_support_matrix() {
header
# Call the common function to define the support matrix
define_support_matrix
# Table header
printf "+------------------+----------+----------+----------+\n"
printf "| %-16s | %-8s | %-8s | %-8s |\n" "Environment" "Version" "Install" "Support"
printf "+------------------+----------+----------+----------+\n"
# Loop through the support matrix to print each configuration
for config in "${SUPPORT_MATRIX[@]}"; do
# More compatible way to split the string
OLD_IFS="$IFS"
IFS="|"
set -- $config
conf_distro="$1"
conf_hostsys="$2"
conf_kernel="$3"
conf_version="$4"
conf_installable="$5"
conf_supported="$6"
IFS="$OLD_IFS"
# Format the install and support status with fixed column width
if [[ $conf_installable == "yes" ]]; then
install_mark=" ${green}✅${reset} "
else
install_mark=" ${red}❌${reset} "
fi
if [[ $conf_supported == "yes" ]]; then
support_mark=" ${green}✅${reset} "
else
support_mark=" ${red}❌${reset} "
fi
# Print the row with fixed column widths
printf "| %-16s | %-8s | %-8s | %-8s |\n" "$conf_distro ($conf_hostsys)" "$conf_version" "$install_mark" "$support_mark"
done
# Footer line
printf "+------------------+----------+----------+----------+\n"
footer
}
# variable $installed
function install_tools_and_binaries() {
header
installed="no"
log "-> xema_capable_operating_environment"
xema_capable_operating_environment
if [[ $installable == "yes" ]]; then
log "-> install_tools"
echo "${green}Installing tools ...${reset}"
install_tools
log "-> install_dependencies"
echo "${green}Installing dependencies ...${reset}"
install_dependencies
log "-> install_xema_fastagi"
echo "${green}Installing Xema FastAGI ...${reset}"
install_xema_fastagi
log "-> install_xema_astermq"
echo "${green}Installing Xema AsterMQ ...${reset}"
install_xema_astermq
log "-> install_xema_simplecdr"
echo "${green}Installing Xema SimpleCdr ...${reset}"
install_xema_simplecdr
log "-> install_xema_bff"
echo "${green}Installing Xema BFF ...${reset}"
install_xema_bff
log "-> install_xema_tracer"
echo "${green}Installing Xema Tracer ...${reset}"
install_xema_tracer
log "-> install_xema_sipper"
echo "${green}Installing Xema Sipper ...${reset}"
install_xema_sipper
log "-> install_xema_missingcdrs"
echo "${green}Installing Xema MissingCdrs ...${reset}"
install_xema_missingcdrs
log "-> install_xema_ava"
echo "${green}Installing Xema Ava ...${reset}"
install_xema_ava
log "-> install_xema_binary"
echo "${green}Installing Xema Manager ...${reset}"
install_xema_binary
installed="yes"
fi
footer installed="$installed"
}
function xema_capable_operating_environment() {
header
log "-> detect_host"
detect_host
if [[ ! $kernel = *Linux* ]]; then
echo "${red}$kernel Environment is not supported.${reset}"
else
log "-> detect_distro and version"
detect_distro
# detect_distro also calls version detection
if [[ ! $distro = *Ubuntu* ]]; then
echo "${red}$distro Linux Distribution is not supported.${reset}"
else
log "-> check_support_matrix"
check_support_matrix
if [[ $installable == "yes" && $supported == "no" ]]; then
log "-> print_support_matrix"
print_support_matrix
echo "${red}Unsupported configuration.${reset} $hostsys $kernel $distro $oever"
echo "${red}!!! Install at your own risk !!! ${reset}"
elif [[ $installable == "no" ]]; then
echo "${red}!!! Unable to install !!! ${reset}"
echo "${red}Unsupported configuration.${reset} $hostsys $kernel $distro $oever"
fi
if [[ $installable == "yes" ]]; then
# echo "${green}"
echo -e "Distro: " $distro
echo -e "Version: " $oever
if [[ $supported == "yes" ]]; then echo -e "Support: ${green}✅${reset}"; fi
if [[ $supported == "no" ]]; then echo -e "Support: ${red}❌${reset}"; fi
# echo "${reset}"
fi
fi
fi
footer
}
function install_tools() {
header
if [ "$distro" == "Ubuntu" ]; then
apt $apt_quiet update
apt $apt_quiet install -y curl wget unzip at sngrep libpcap0.8
# apt $apt_quiet install -y git sipsak linphone-cli
fi
if [ "$distro" == "CentOS" ]; then
echo "${red}$LINENO: Not implemented${reset}"
fi
if [ "$distro" == "Unknown" ]; then
echo "${red}$LINENO: $distro OS${reset}"
fi
footer
}
function install_dependencies() {
header
if [ "$distro" == "Ubuntu" ]; then
ubuntu_dependencies
ubuntu_dotnet
fi
if [ "$distro" == "CentOS" ]; then
centos_dependencies
centos_dotnet
fi
if [ "$distro" == "Unknown" ]; then
echo "${red}$LINENO: $distro OS${reset}"
fi
footer
}
# ubuntu dependencies
function ubuntu_dependencies() {
header
which asterisk >/dev/null
if [ "$?" -ne "0" ]; then
apt $apt_quiet install -y asterisk
systemctl start asterisk
fi
which nginx >/dev/null
if [ "$?" -ne "0" ]; then
apt $apt_quiet install -y nginx
systemctl start nginx
fi
which rabbitmq-server >/dev/null
if [ "$?" -ne "0" ]; then
apt $apt_quiet install -y rabbitmq-server
systemctl start rabbitmq-server
fi
which redis-server >/dev/null
if [ "$?" -ne "0" ]; then
apt $apt_quiet install -y redis-server
systemctl start redis-server
fi
which prometheus >/dev/null
if [ "$?" -ne "0" ]; then
apt $apt_quiet install -y prometheus
systemctl start prometheus
fi
install_mariadb="no"
which mysql >/dev/null
if [ "$?" -ne "0" ]; then
# apt $apt_quiet install -y mariadb-server
install_mariadb="yes"
fi
mysql -e "show databases" >/dev/null
if [ "$?" -ne "0" ]; then
install_mariadb="yes"
fi
if [ "$install_mariadb" == "yes" ]; then
apt $apt_quiet install -y mariadb-server
systemctl start mariadb
fi
footer
}
# ubuntu dotnet
function ubuntu_dotnet() {
header
if [ "$oever" == "18" ]; then
wget -q https://packages.microsoft.com/config/ubuntu/18.04/packages-microsoft-prod.deb -O /tmp/packages-microsoft-prod.deb
dpkg -i /tmp/packages-microsoft-prod.deb
add-apt-repository -y universe
elif [ "$oever" == "20" ]; then
echo "${red}$LINENO: Not implemented${reset}"
elif [ "$oever" == "22" ]; then
add-apt-repository -y ppa:dotnet/backports
apt update
apt $apt_quiet install -y aspnetcore-runtime-10.0
elif [ "$oever" == "24" ] || [ "$oever" == "25" ] || [ "$oever" == "26" ]; then
apt $apt_quiet install -y aspnetcore-runtime-10.0
else
echo "${red}$LINENO: Not implemented${reset}"
fi
footer
}
# centos dependencies
function centos_dependencies() {
header
echo "${red}$LINENO: Not implemented${reset}"
footer
}
# centos dotnet
function centos_dotnet() {
header
echo "${red}$LINENO: Not implemented${reset}"
footer
}
function install_xema_fastagi() {
header
mkdir -p /var/lib/xema/fastagi
rm -rf /tmp/fastagi.zip
if [ "$channel" == "dev" ]; then
release_tag="dev"
else
release_tag="v2.0"
fi
if [ "$distro" == "Ubuntu" ]; then
wget -q --show-progress https://github.com/xema-in/manager/releases/download/$release_tag/FastAGI.zip -O /tmp/fastagi.zip
unzip -qo /tmp/fastagi.zip -d /var/lib/xema/fastagi
fi
footer
}
function install_xema_astermq() {
header
mkdir -p /var/lib/xema/astermq
rm -rf /tmp/astermq.zip
if [ "$channel" == "dev" ]; then
release_tag="dev"
else
release_tag="v2.0"
fi
if [ "$distro" == "Ubuntu" ]; then
wget -q --show-progress https://github.com/xema-in/manager/releases/download/$release_tag/AsterMQ.zip -O /tmp/astermq.zip
unzip -qo /tmp/astermq.zip -d /var/lib/xema/astermq
fi
footer
}
function install_xema_simplecdr() {
header
mkdir -p /var/lib/xema/simplecdr
rm -rf /tmp/simplecdr.zip
if [ "$channel" == "dev" ]; then
release_tag="dev"
else
release_tag="v2.0"
fi
if [ "$distro" == "Ubuntu" ]; then
wget -q --show-progress https://github.com/xema-in/manager/releases/download/$release_tag/SimpleCdr.zip -O /tmp/simplecdr.zip
unzip -qo /tmp/simplecdr.zip -d /var/lib/xema/simplecdr
fi
footer
}
function install_xema_bff() {
header
mkdir -p /var/lib/xema/bff
rm -rf /tmp/bff.zip
if [ "$channel" == "dev" ]; then
release_tag="dev"
else
release_tag="v2.0"
fi
if [ "$distro" == "Ubuntu" ]; then
wget -q --show-progress https://github.com/xema-in/manager/releases/download/$release_tag/Bff.zip -O /tmp/bff.zip
unzip -qo /tmp/bff.zip -d /var/lib/xema/bff
fi
footer
}
function install_xema_tracer() {
header
mkdir -p /var/lib/xema/tracer
rm -rf /tmp/tracer.zip
if [ "$channel" == "dev" ]; then
release_tag="dev"
else
release_tag="v2.0"
fi
if [ "$distro" == "Ubuntu" ]; then
wget -q --show-progress https://github.com/xema-in/manager/releases/download/$release_tag/Tracer.zip -O /tmp/tracer.zip
unzip -qo /tmp/tracer.zip -d /var/lib/xema/tracer
fi
footer
}
function install_xema_sipper() {
header
mkdir -p /var/lib/xema/sipper
rm -rf /tmp/sipper.zip
if [ "$channel" == "dev" ]; then
release_tag="dev"
else
release_tag="v2.0"
fi
if [ "$distro" == "Ubuntu" ]; then
wget -q --show-progress https://github.com/xema-in/manager/releases/download/$release_tag/Sipper.zip -O /tmp/sipper.zip
unzip -qo /tmp/sipper.zip -d /var/lib/xema/sipper
fi
footer
}
function install_xema_missingcdrs() {
header
mkdir -p /var/lib/xema/import
rm -rf /tmp/missingcdrs.zip
if [ "$channel" == "dev" ]; then
release_tag="dev"
else
release_tag="v2.0"
fi
if [ "$distro" == "Ubuntu" ]; then
wget -q --show-progress https://github.com/xema-in/manager/releases/download/$release_tag/MissingCdrs.zip -O /tmp/missingcdrs.zip
unzip -qo /tmp/missingcdrs.zip -d /var/lib/xema/import
fi
footer
}
function install_xema_ava() {
header
mkdir -p /var/lib/xema/ava
rm -rf /tmp/ava.zip
if [ "$channel" == "dev" ]; then
release_tag="dev"
else
release_tag="v2.0"
fi
if [ "$distro" == "Ubuntu" ]; then
wget -q --show-progress https://github.com/xema-in/manager/releases/download/$release_tag/Ava.zip -O /tmp/ava.zip
unzip -qo /tmp/ava.zip -d /var/lib/xema/ava
fi
footer
}
function install_xema_binary() {
header
backup_existing_installation
if [ "$channel" == "release" ]; then
log "-> install_xema_prod_channel"
install_xema_prod_channel
fi
if [ "$channel" == "dev" ]; then
log "-> install_xema_dev_channel"
install_xema_dev_channel
fi
add_default_settings
footer
}
function backup_existing_installation() {
header
mkdir -p /var/lib/xema/manager
cp -r /var/lib/xema/manager /var/lib/xema/manager.$(date '+%Y%m%d.%H')
rm -rf /tmp/manager.zip
rm -f /tmp/appsettings.json
cp -f /var/lib/xema/manager/appsettings.json /tmp/appsettings.json
footer
}
# https://github.com/xema-in/manager/releases/download/v2.0/Manager.zip
function install_xema_prod_channel() {
header
echo "Installing from ${green}$channel${reset} channel ..."
if [ "$distro" == "Ubuntu" ]; then
wget -q --show-progress https://github.com/xema-in/manager/releases/download/v2.0/Manager.zip -O /tmp/manager.zip
unzip -qo /tmp/manager.zip -d /var/lib/xema/manager
fi
if [ "$distro" == "CentOS" ]; then
echo "${red}$LINENO: Not implemented${reset}"
fi
if [ "$distro" == "Unknown" ]; then
echo "${red}$LINENO: $distro OS${reset}"
fi
footer
}
# https://github.com/xema-in/manager/releases/download/dev/Manager.zip
function install_xema_dev_channel() {
header
echo "Installing from ${green}$channel${reset} channel ..."
if [ "$distro" == "Ubuntu" ]; then
wget -q --show-progress https://github.com/xema-in/manager/releases/download/dev/Manager.zip -O /tmp/manager.zip
unzip -qo /tmp/manager.zip -d /var/lib/xema/manager
fi
if [ "$distro" == "CentOS" ]; then
echo "${red}$LINENO: Not implemented${reset}"
fi
if [ "$distro" == "Unknown" ]; then
echo "${red}$LINENO: $distro OS${reset}"
fi
footer
}
function add_default_settings() {
header
cp -f /tmp/appsettings.json /var/lib/xema/manager/appsettings.json
# cp -n /var/lib/xema/manager/appsettings.default.json /var/lib/xema/manager/appsettings.json
cp --update=none /var/lib/xema/manager/appsettings.default.json /var/lib/xema/manager/appsettings.json
footer
}
# variable $configured
function configure_components() {
header
configured="no"
if [[ $installed == "yes" ]]; then
log "-> configure_firewall"
configure_firewall
log "-> configure_nginx"
configure_nginx
log "-> configure_asterisk"
configure_asterisk
log "-> configure_mysql"
configure_mysql
log "-> configure_logrotate"
configure_logrotate
log "-> configure_prometheus"
configure_prometheus
log "-> configure_xema_service"
configure_xema_service
log "-> configure_admin_access"
configure_admin_access
configured="yes"
fi
footer configured="$configured"
}
function configure_firewall() {
header
# Ubuntu: ufw
# CentOS: firewalld
if [ "$distro" == "Ubuntu" ]; then
ufw disable
fi
if [ "$distro" == "CentOS" ]; then
systemctl stop firewalld
systemctl disable firewalld
systemctl mask --now firewalld
fi
if [ "$distro" == "Unknown" ]; then
echo "${red}$LINENO: $distro OS${reset}"
fi
footer
}
function configure_nginx() {
header
generate_self_signed_ssl
if [ "$distro" == "Ubuntu" ]; then
wget -q https://raw.githubusercontent.com/xema-in/install/master/deps/xema.nginx -O /tmp/xema.nginx
cp /tmp/xema.nginx /etc/nginx/sites-available/xema.nginx
ls /etc/nginx/sites-enabled/xema.nginx
if [ "$?" -ne "0" ]; then
ln -s /etc/nginx/sites-available/xema.nginx /etc/nginx/sites-enabled/xema.nginx
fi
ls /etc/nginx/sites-enabled/default
if [ "$?" -eq "0" ]; then
rm /etc/nginx/sites-enabled/default
fi
nginx -s reload
fi
if [ "$distro" == "CentOS" ]; then
wget -q https://raw.githubusercontent.com/xema-in/install/master/deps/xema.nginx -O /tmp/xema.nginx
cp /tmp/xema.nginx /etc/nginx/conf.d/xema.conf
nginx -s reload
fi
if [ "$distro" == "Unknown" ]; then
echo "${red}$LINENO: $distro OS${reset}"
fi
footer
}
function generate_self_signed_ssl() {
header
if [ "$distro" == "Ubuntu" ]; then
ls /etc/ssl/private/key.pem
if [ "$?" -ne "0" ]; then
openssl req -x509 -nodes -days 3650 -newkey rsa:2048 -keyout /etc/ssl/private/key.pem -out /etc/ssl/certs/certificate.pem -subj "/CN=xema-manager"
fi
fi
if [ "$distro" == "CentOS" ]; then
echo "${red}$LINENO: Not implemented${reset}"
fi
if [ "$distro" == "Unknown" ]; then
echo "${red}$LINENO: $distro OS${reset}"
fi
footer
}
function configure_asterisk() {
header
# if [ "$distro" == "Ubuntu" ]; then
# echo "${red}$LINENO: Not implemented${reset}"
# fi
if [ "$distro" == "CentOS" ]; then
echo "${red}$LINENO: Not implemented${reset}"
fi
if [ "$distro" == "Unknown" ]; then
echo "${red}$LINENO: $distro OS${reset}"
fi
footer
}
function configure_mysql() {
header
mysql -u root -e "CREATE USER IF NOT EXISTS 'xema'@'localhost' IDENTIFIED BY 'xema';GRANT ALL PRIVILEGES ON *.* TO 'xema'@'localhost';FLUSH PRIVILEGES;"
# if [ "$distro" == "Ubuntu" ]; then
# echo "${red}$LINENO: Not implemented${reset}"
# fi
# if [ "$distro" == "CentOS" ]; then
# echo "${red}$LINENO: Not implemented${reset}"
# fi
# if [ "$distro" == "Unknown" ]; then
# echo "${red}$LINENO: $distro OS${reset}"
# fi
footer
}
function configure_logrotate() {
header
if [ "$distro" == "Ubuntu" ]; then
wget -q https://raw.githubusercontent.com/xema-in/install/master/deps/asterisk-master-csv -O /tmp/asterisk-master-csv
cp /tmp/asterisk-master-csv /etc/logrotate.d/asterisk-master-csv
fi
if [ "$distro" == "CentOS" ]; then
echo "${red}$LINENO: Not implemented${reset}"
fi
if [ "$distro" == "Unknown" ]; then
echo "${red}$LINENO: $distro OS${reset}"
fi
footer
}
function configure_prometheus() {
header
if [ "$distro" == "Ubuntu" ]; then
wget -q https://raw.githubusercontent.com/xema-in/install/master/deps/prometheus.yml -O /tmp/prometheus.yml
cp /tmp/prometheus.yml /etc/prometheus/prometheus.yml
wget -q https://raw.githubusercontent.com/xema-in/install/master/deps/target-xema.json -O /tmp/target-xema.json
cp /tmp/target-xema.json /etc/prometheus/target-xema.json
fi
if [ "$distro" == "CentOS" ]; then
echo "${red}$LINENO: Not implemented${reset}"
fi
if [ "$distro" == "Unknown" ]; then
echo "${red}$LINENO: $distro OS${reset}"
fi
footer
}
function configure_xema_service() {
header
if [[ $hostsys == "WSL" && $kernel == "Linux" ]]; then
# wsl
ls /etc/init.d/xema-manager
if [ "$?" -ne "0" ]; then
wget -q https://raw.githubusercontent.com/xema-in/install/master/deps/xema-manager -O /tmp/xema-manager
cp /tmp/xema-manager /etc/init.d/xema-manager
chmod +x /etc/init.d/xema-manager
update-rc.d xema-manager defaults
fi
elif [[ $hostsys == "Linux" && $kernel == "Linux" ]]; then
# Ubuntu, CentOS
# systemctl list-dependencies xema-manager.service
wget -q https://raw.githubusercontent.com/xema-in/install/master/deps/xema-manager.service -O /tmp/xema-manager.service
cp /tmp/xema-manager.service /lib/systemd/system/xema-manager.service
ls /etc/systemd/system/multi-user.target.wants/xema-manager.service
if [ "$?" -ne "0" ]; then
ln -s /lib/systemd/system/xema-manager.service /etc/systemd/system/multi-user.target.wants/xema-manager.service
fi
systemctl daemon-reload
systemctl enable xema-manager.service
wget -q https://raw.githubusercontent.com/xema-in/install/master/deps/xema-fastagi.service -O /tmp/xema-fastagi.service
cp /tmp/xema-fastagi.service /lib/systemd/system/xema-fastagi.service
ls /etc/systemd/system/multi-user.target.wants/xema-fastagi.service
if [ "$?" -ne "0" ]; then
ln -s /lib/systemd/system/xema-fastagi.service /etc/systemd/system/multi-user.target.wants/xema-fastagi.service
fi
systemctl daemon-reload
systemctl enable xema-fastagi.service
wget -q https://raw.githubusercontent.com/xema-in/install/master/deps/xema-astermq.service -O /tmp/xema-astermq.service
cp /tmp/xema-astermq.service /lib/systemd/system/xema-astermq.service
ls /etc/systemd/system/multi-user.target.wants/xema-astermq.service
if [ "$?" -ne "0" ]; then
ln -s /lib/systemd/system/xema-astermq.service /etc/systemd/system/multi-user.target.wants/xema-astermq.service
fi
systemctl daemon-reload
systemctl enable xema-astermq.service
wget -q https://raw.githubusercontent.com/xema-in/install/master/deps/xema-simplecdr.service -O /tmp/xema-simplecdr.service
cp /tmp/xema-simplecdr.service /lib/systemd/system/xema-simplecdr.service
ls /etc/systemd/system/multi-user.target.wants/xema-simplecdr.service
if [ "$?" -ne "0" ]; then
ln -s /lib/systemd/system/xema-simplecdr.service /etc/systemd/system/multi-user.target.wants/xema-simplecdr.service
fi
systemctl daemon-reload
systemctl enable xema-simplecdr.service
wget -q https://raw.githubusercontent.com/xema-in/install/master/deps/xema-bff.service -O /tmp/xema-bff.service
cp /tmp/xema-bff.service /lib/systemd/system/xema-bff.service
ls /etc/systemd/system/multi-user.target.wants/xema-bff.service
if [ "$?" -ne "0" ]; then
ln -s /lib/systemd/system/xema-bff.service /etc/systemd/system/multi-user.target.wants/xema-bff.service
fi
systemctl daemon-reload
systemctl enable xema-bff.service
wget -q https://raw.githubusercontent.com/xema-in/install/master/deps/xema-ava.service -O /tmp/xema-ava.service
cp /tmp/xema-ava.service /lib/systemd/system/xema-ava.service
ls /etc/systemd/system/multi-user.target.wants/xema-ava.service
if [ "$?" -ne "0" ]; then
ln -s /lib/systemd/system/xema-ava.service /etc/systemd/system/multi-user.target.wants/xema-ava.service
fi
systemctl daemon-reload
systemctl enable xema-ava.service
wget -q https://raw.githubusercontent.com/xema-in/install/master/deps/xema-sipper.service -O /tmp/xema-sipper.service
cp /tmp/xema-sipper.service /lib/systemd/system/xema-sipper.service
ls /etc/systemd/system/multi-user.target.wants/xema-sipper.service
if [ "$?" -ne "0" ]; then
ln -s /lib/systemd/system/xema-sipper.service /etc/systemd/system/multi-user.target.wants/xema-sipper.service
fi
systemctl daemon-reload
systemctl enable xema-sipper.service
fi
# if [ "$distro" == "Ubuntu" ]; then
# echo "${red}$LINENO: Not implemented${reset}"
# fi
# if [ "$distro" == "CentOS" ]; then
# echo "${red}$LINENO: Not implemented${reset}"
# fi