-
Notifications
You must be signed in to change notification settings - Fork 22
/
jitsi-videosipgw-installer
1294 lines (1043 loc) · 40.8 KB
/
jitsi-videosipgw-installer
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
set -e
# -----------------------------------------------------------------------------
# globals
# -----------------------------------------------------------------------------
JITSI_TMPL=https://raw.githubusercontent.com/jitsi-contrib/installers/main/templates/jitsi
JITSI_MEET_CONFIG=/etc/jitsi/meet/$JITSI_HOST-config.js
PROSODY_CONFIG=/etc/prosody/conf.avail/$JITSI_HOST.cfg.lua
NGINX_CONFIG=/etc/nginx/sites-available/$JITSI_HOST.conf
PROSODY_PLUGINS_VERSION=20241128
PROSODY_PLUGINS_ARCHIVE=https://github.com/jitsi-contrib/prosody-plugins/archive/refs/tags/v$PROSODY_PLUGINS_VERSION.tar.gz
CHECKMYPORT=https://checkmyport.emrah.com
TCP=(80 443 4444 5222 5280 5269 5347 5349 8080 8888 9090)
UDP=(5000 5349 10000)
# -----------------------------------------------------------------------------
# globals (extra)
# -----------------------------------------------------------------------------
JIBRI_TMPL=https://raw.githubusercontent.com/jitsi-contrib/installers/main/templates/jibri
PJPROJECT_REPO="https://github.com/jitsi/pjproject"
PJPROJECT_BRANCH="jibri-2.13-dev1"
if [[ -z "$APP_ID" ]]; then
APP_ID="jitsi-$RANDOM"
fi
if [[ -z "$APP_SECRET" ]]; then
APP_SECRET="$(openssl rand -hex 20)"
fi
# -----------------------------------------------------------------------------
# output format
# -----------------------------------------------------------------------------
out() {
printf "\n"
while IFS= read -r line; do
printf "\033[0;31m>>>\033[0m \033[0;33m%s\033[0m\n" "$line"
done
}
# -----------------------------------------------------------------------------
# trap on exit
# -----------------------------------------------------------------------------
function on_exit {
if [[ "$COMPLETED" != true ]]; then
out <<< "Something went wrong. Not completed!"
exit 1
else
out <<EOF
Installation Duration: $DURATION
Completed successfully!
EOF
exit 0
fi
}
COMPLETED=false
trap on_exit EXIT
# -----------------------------------------------------------------------------
# environment
# -----------------------------------------------------------------------------
DEBIAN_FRONTEND=noninteractive
START_TIME=$(date +%s)
BASEDIR=$(pwd)
DEFAULT_ROUTE=$(ip route | egrep '^default ' | head -n1)
PUBLIC_INTERFACE=${DEFAULT_ROUTE##*dev }
PUBLIC_INTERFACE=${PUBLIC_INTERFACE/% */}
PUBLIC_IP=$(ip addr show $PUBLIC_INTERFACE | egrep "$PUBLIC_INTERFACE$" | \
xargs | cut -d " " -f 2 | cut -d "/" -f1)
# -----------------------------------------------------------------------------
# environment check (phase 1)
# -----------------------------------------------------------------------------
clear
# are you sure
out <<EOF
This script can be harmful and will remove already installed Jitsi if exists.
Don't use it on a working production server.
If you are sure then write YES (uppercase) and press enter to start!
EOF
read answer
if [[ "$answer" != "YES" ]]; then
out <<EOF
Aborted! not approved, typed: $answer
EOF
exit 1
fi
# whoami
out <<< "checking the user account..."
if [[ "$(whoami)" != "root" ]]; then
out <<EOF
Aborted! You are not the root user: $(whoami)
Recommendation: Use the following command to be the 'root' user
su -l
EOF
exit 1
fi
# distro
out <<< "checking the distro..."
[[ $(command -v lsb_release) ]] && \
DISTRO=$(lsb_release -c | cut -d: -f2 | xargs) || \
DISTRO=$(grep VERSION_CODENAME /etc/os-release | cut -d= -f2)
if [[ "$DISTRO" = "focal" ]] || \
[[ "$DISTRO" = "jammy" ]] || \
[[ "$DISTRO" = "bullseye" ]]; then
LUA="5.2"
JDK="11"
elif [[ "$DISTRO" = "bookworm" ]]; then
LUA="5.3"
JDK="17"
else
out <<EOF
Aborted! Your distro is not supported
Recommendation: Use a supported distribution:
- Debian 12 Bookworm
- Debian 11 Bullseye
- Ubuntu 22.04 Jammy Jellyfish
- Ubuntu 20.04 Focal Fossa
EOF
exit 1
fi
# memory
out <<< "checking the total memory..."
MEM=$(cat /proc/meminfo | grep MemTotal | egrep -o "[0-9]*")
if [[ "$MEM" -lt 7000000 ]]; then
out <<EOF
Aborted! Not enough memory: $MEM kB
Recommendation: The total memory should be at least 8 GB
EOF
exit 1
fi
# jitsi host address
out <<< "checking Jitsi FQDN..."
if [[ -z "$JITSI_HOST" ]]; then
out <<EOF
Aborted! Unknown Jitsi host address
Recommendation: Set Jitsi host address and try again, e.g.
export JITSI_HOST=jitsi.yourdomain.com
EOF
exit 1
fi
# jitsi fqdn
if [[ -z "$(echo $JITSI_HOST | egrep -o '[a-zA-Z]')" ]]; then
out <<EOF
Aborted! Jitsi host address is not FQDN: $JITSI_HOST
Recommendation: Don't use an IP address, use a valid FQDN address
EOF
exit 1
fi
# turn host address
out <<< "checking TURN FQDN..."
if [[ -z "$TURN_HOST" ]]; then
out <<EOF
Aborted! Unknown TURN host address
Recommendation: Set TURN host address and try again, e.g.
export TURN_HOST=turn.yourdomain.com
EOF
exit 1
fi
# turn fqdn
if [[ -z "$(echo $TURN_HOST | egrep -o '[a-zA-Z]')" ]]; then
out <<EOF
Aborted! TURN host address is not FQDN: $TURN_HOST
Recommendation: Don't use an IP address, use a valid FQDN address
EOF
exit 1
fi
# jitsi == turn
if [[ "$JITSI_HOST" = "$TURN_HOST" ]]; then
out <<EOF
Aborted! Jitsi host address and TURN host address are the same
Recommendation: Use different addresses for Jitsi and TURN, e.g.
export JITSI_HOST=jitsi.yourdomain.com
export TURN_HOST=turn.yourdomain.com
EOF
exit 1
fi
# -----------------------------------------------------------------------------
# environment check (extra)
# -----------------------------------------------------------------------------
# core
out <<< "checking the number of cores..."
CORES=$(nproc --all)
if [[ "$CORES" -lt 4 ]]; then
out <<EOF
Aborted! Not enough cores: $CORES
Recommendation: It should be at least 4 cores
EOF
exit 1
fi
# snd_aloop
out <<< "checking the snd-aloop support..."
if [[ "$DISTRO" = "focal" ]] || \
[[ "$DISTRO" = "jammy" ]]; then
apt-get $APT_PROXY -y install linux-modules-extra-$(uname -r) \
-o Dpkg::Options::="--force-confdef" \
-o Dpkg::Options::="--force-confold"
fi
if [[ "$DISTRO" = "bullseye" ]] || \
[[ "$DISTRO" = "bookworm" ]]; then
KERNEL="linux-image-$(dpkg --print-architecture)"
else
KERNEL="linux-image-generic"
fi
modprobe snd_aloop 2>/dev/null || true
if [[ -z "$(grep snd_aloop /proc/modules)" ]]; then
out <<EOF
Aborted! This kernel ($(uname -r)) does not support snd_aloop module.
Recommendation: Install the standard Linux kernel package and reboot with it.
Probably it's the "$KERNEL" package in your case.
EOF
exit 1
fi
# -----------------------------------------------------------------------------
# remove the old installation if exists
# -----------------------------------------------------------------------------
out <<< "removing the old installation if exists..."
systemctl stop virtual-camera-0.service || true
systemctl stop virtual-camera-1.service || true
systemctl stop excalidraw.service || true
systemctl stop sip-dial-plan.service || true
systemctl stop sip-xorg.service || true
systemctl stop jibri-xorg.service || true
systemctl stop jigasi.service || true
systemctl stop jitsi-videobridge2.service || true
systemctl stop jicofo.service || true
systemctl stop prosody.service || true
systemctl stop coturn.service || true
systemctl stop nginx.service || true
systemctl stop certbot.timer || true
systemctl stop certbot.service || true
apt-mark unhold 'jitsi-*' || true
apt-mark unhold jicofo || true
apt-mark unhold jibri || true
apt-mark unhold jigasi || true
apt-mark unhold google-chrome-stable || true
apt-get -y purge jibri || true
apt-get -y purge jigasi || true
apt-get -y purge 'jitsi-*' || true
apt-get -y purge jicofo || true
apt-get -y purge prosody || true
apt-get -y purge 'prosody-*' || true
apt-get -y purge coturn || true
apt-get -y purge nginx || true
apt-get -y purge 'nginx-*' || true
apt-get -y purge 'libnginx-*' || true
apt-get -y purge 'openjdk-*' || true
apt-get -y purge 'lua*' || true
apt-get -y purge 'liblua*' || true
apt-get -y purge 'adoptopenjdk-*' || true
apt-get -y purge certbot || true
apt-get -y purge ffmpeg || true
apt-get -y purge nodejs || true
apt-get -y purge chromium chromium-common chromium-driver || true
apt-get -y purge chromium-browser chromium-chromedriver || true
apt-get -y purge chromium-codecs-ffmpeg chromium-codecs-ffmpeg-extra || true
apt-get -y purge google-chrome-stable || true
apt-get -y purge va-driver-all vdpau-driver-all || true
apt-get -y purge "v4l2loopback-*" || true
apt-get -y purge build-essential || true
apt-get -y purge alsa-utils unclutter x11vnc || true
apt-get -y purge libv4l-dev libsdl2-dev libavcodec-dev libavdevice-dev \
libavfilter-dev libavformat-dev libavutil-dev libswscale-dev \
libasound2-dev libopus-dev libvpx-dev libssl-dev || true
apt-get -y autoremove --purge
deluser excalidraw || true
delgroup excalidraw || true
deluser jibri || true
delgroup jibri || true
rm -rf /home/excalidraw
rm -rf /home/jibri
rm -rf /etc/chromium
rm -rf /etc/jitsi
rm -rf /etc/prosody
rm -rf /etc/coturn
rm -rf /etc/nginx
rm -rf /etc/opt/chrome
rm -rf /etc/systemd/system/jibri*
rm -rf /etc/systemd/system/sip-*
rm -rf /etc/systemd/system/certbot.service.d
rm -rf /etc/systemd/system/nginx.service.d
rm -rf /etc/systemd/system/prosody.service.d
rm -rf /etc/systemd/system/virtual-camera-*
rm -rf /opt/google
rm -rf /opt/jitsi
rm -rf /usr/lib/node_modules
rm -rf /usr/local/share/nginx
rm -rf /usr/share/jitsi-meet
rm -rf /usr/share/jitsi-videobridge
rm -rf /usr/share/jicofo
rm -rf /var/lib/prosody
rm -f /etc/apt/sources.list.d/jitsi-stable.list
rm -f /etc/apt/sources.list.d/google-chrome.list
rm -f /etc/apt/sources.list.d/prosody.list
rm -f /etc/modprobe.d/alsa-loopback.conf
rm -f /etc/modprobe.d/v4l2loopback.conf
rm -f /etc/sudoers.d/jibri
rm -f /usr/local/bin/chromedriver
rm -f /usr/local/bin/google-chrome
rm -f /usr/local/bin/pjsua
find /usr/local/share/ca-certificates -xtype l -delete
# -----------------------------------------------------------------------------
# packages (base)
# -----------------------------------------------------------------------------
out <<< "installing base packages..."
for i in $(seq 3); do
apt-get -y --allow-releaseinfo-change update && sleep 3 && break
done
apt-get $APT_PROXY -y install apt-utils \
-o Dpkg::Options::="--force-confdef" \
-o Dpkg::Options::="--force-confold"
apt-get $APT_PROXY -y upgrade \
-o Dpkg::Options::="--force-confdef" \
-o Dpkg::Options::="--force-confold"
apt-get $APT_PROXY -y install wget curl ca-certificates openssl
apt-get $APT_PROXY -y install apt-transport-https gnupg
apt-get $APT_PROXY -y install iputils-ping dnsutils
apt-get $APT_PROXY -y install tmux vim less ack jq rsync bzip2
apt-get $APT_PROXY -y install procps htop bmon
apt-get $APT_PROXY -y install net-tools ngrep ncat
apt-get $APT_PROXY -y install ssl-cert certbot
apt-get $APT_PROXY -y install gcc git
# -----------------------------------------------------------------------------
# environment check (phase 2)
# -----------------------------------------------------------------------------
# external ip
out <<< "checking the external IP..."
if [[ -n "$JITSI_IP" ]]; then
EXTERNAL_IP=$JITSI_IP
else
EXTERNAL_IP=$(dig -4 +short myip.opendns.com a @resolver1.opendns.com) \
|| true
fi
if [[ -z "$EXTERNAL_IP" ]]; then
out <<EOF
Aborted! The external IP not found
Recommendation: Check if myip.opendns.com is accessible
EOF
exit 1
fi
# jitsi host A record
out <<< "checking DNS record for $JITSI_HOST..."
if [[ -n "$JITSI_IP" ]]; then
IP=$JITSI_IP
else
IP=$(dig -4 +short $JITSI_HOST @resolver1.opendns.com | tail -1) || true
fi
if [[ -z "$IP" ]]; then
out <<EOF
Aborted! $JITSI_HOST is not resolvable on Internet
Recommendation: Set DNS A record for $JITSI_HOST on a public DNS.
If this is a test setup and you don't have a reachable address, export
the public IP by setting JITSI_IP and disable LetsEncrypt certificate
by setting DONT_SET_LETSENCRYPT. e.g.
export JITSI_IP=$EXTERNAL_IP
export DONT_SET_LETSENCRYPT=true
EOF
exit 1
fi
# jitsi ip == external ip
out <<< "checking $JITSI_HOST resolved IP..."
if [[ "$IP" != "$EXTERNAL_IP" ]]; then
out <<EOF
Aborted! $JITSI_HOST does not point to this server: $EXTERNAL_IP <> $IP
Recommendation: Set $EXTERNAL_IP as DNS A record for $JITSI_HOST
If this is a test setup and you don't have a reachable address, export
the public IP by setting JITSI_IP and disable LetsEncrypt certificate
by setting DONT_SET_LETSENCRYPT. e.g.
export JITSI_IP=$EXTERNAL_IP
export DONT_SET_LETSENCRYPT=true
EOF
exit 1
fi
# turn host A record
out <<< "checking DNS record for $TURN_HOST..."
if [[ -n "$JITSI_IP" ]]; then
IP=$JITSI_IP
else
IP=$(dig -4 +short $TURN_HOST @resolver1.opendns.com | tail -1) || true
fi
if [[ -z "$IP" ]]; then
out <<EOF
Aborted! $TURN_HOST is not resolvable on Internet
Recommendation: Set DNS CNAME or A record for $TURN_HOST on a public DNS
EOF
exit 1
fi
# turn ip == external ip
out <<< "checking $TURN_HOST resolved IP..."
if [[ "$IP" != "$EXTERNAL_IP" ]]; then
out <<EOF
Aborted! $TURN_HOST does not point to this server: $EXTERNAL_IP <> $IP
Recommendation: Set $EXTERNAL_IP as DNS A record for $TURN_HOST
EOF
exit 1
fi
# -----------------------------------------------------------------------------
# port availability check
# -----------------------------------------------------------------------------
out <<< "checking the availability of TCP ports..."
netstat -ltnp | egrep '^tcp' | while read -r l; do
port=$(echo $l | awk '{print $4}' | rev | cut -d: -f1 | rev)
for p in ${TCP[*]}; do
if [[ "$p" = "$port" ]]; then
prog=$(echo $l | cut -d/ -f2)
proto=$(echo $l | awk '{print $1}')
out <<EOF
Aborted! The port $proto/$port is already in use by $prog
Recommendation: disable this application or change its port
EOF
exit 1
fi
done
done
out <<< "checking the availability of UDP ports..."
netstat -lunp | egrep '^udp' | while read -r l; do
port=$(echo $l | awk '{print $4}' | rev | cut -d: -f1 | rev)
for p in ${UDP[*]}; do
if [[ "$p" = "$port" ]]; then
prog=$(echo $l | cut -d/ -f2)
proto=$(echo $l | awk '{print $1}')
out <<EOF
Aborted! The port $proto/$port is already in use by $prog
Recommendation: remove this application or change its port
EOF
exit 1
fi
done
done
# -----------------------------------------------------------------------------
# accessibility check
# -----------------------------------------------------------------------------
TEXT=$(openssl rand -hex 20)
out <<< "checking the checkmyport service..."
RES=$(timeout 8 curl -s "$CHECKMYPORT?proto=udp&port=60000&text=$TEXT" || true)
if [[ "$RES" != "ok" ]]; then
out <<EOF
Aborted! The accessibility check failed
Recommendation: Check if $CHECKMYPORT is accessible
EOF
[[ -z "$JITSI_IP" ]] && exit 1
fi
# tcp/80
out <<< "checking TCP/80 accessibility..."
(sleep 3 && \
timeout 8 curl -s "$CHECKMYPORT?proto=tcp&port=80&text=$TEXT" \
>/dev/null 2>&1 || true) &
RES=$(timeout 8 ncat -l 0.0.0.0 80 | tr -d '\0' || true)
if [[ "$RES" != "$TEXT" ]]; then
out <<EOF
Aborted! TCP/80 is not accessible
Recommendation: Check firewall and NAT rules, allow TCP/80
EOF
[[ -z "$JITSI_IP" ]] && exit 1
fi
# tcp/443
out <<< "checking TCP/443 accessibility..."
(sleep 3 && \
timeout 8 curl -s "$CHECKMYPORT?proto=tcp&port=443&text=$TEXT" \
>/dev/null 2>&1 || true) &
RES=$(timeout 8 ncat -l 0.0.0.0 443 | tr -d '\0' || true)
if [[ "$RES" != "$TEXT" ]]; then
out <<EOF
Aborted! TCP/443 is not accessible
Recommendation: Check firewall and NAT rules, allow TCP/443
EOF
[[ -z "$JITSI_IP" ]] && exit 1
fi
# udp/10000
out <<< "checking UDP/10000 accessibility..."
(sleep 3 && \
timeout 8 curl -s "$CHECKMYPORT?proto=udp&port=10000&text=$TEXT" \
>/dev/null 2>&1 || true) &
RES=$(timeout 8 ncat -u -l 0.0.0.0 10000 | tr -d '\0' || true)
if [[ "$RES" != "$TEXT" ]]; then
out <<EOF
Aborted! UDP/10000 is not accessible
Recommendation: Check firewall and NAT rules, allow UDP/10000
EOF
[[ -z "$JITSI_IP" ]] && exit 1
fi
# ports are ok
timeout 8 curl -s "$CHECKMYPORT?proto=udp&port=60000&text=ok-port" \
>/dev/null || true
# -----------------------------------------------------------------------------
# packages
# -----------------------------------------------------------------------------
out <<< "installing Jitsi..."
# openjdk-xx-jre-headless
apt-get $APT_PROXY -y install openjdk-$JDK-jre-headless
# lua
apt-get $APT_PROXY -y install lua$LUA
# nodesource.list
wget -T 10 -qO /tmp/nodesource.gpg.key \
https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key
cat /tmp/nodesource.gpg.key | gpg --dearmor \
>/usr/share/keyrings/nodesource.gpg
wget -T 10 -O /etc/apt/sources.list.d/nodesource.list \
$JITSI_TMPL/etc/apt/sources.list.d/nodesource.list
# prosody sources.list for Ubuntu Focal and Debian Bookworm
if [[ "$DISTRO" = "focal" ]] || \
[[ "$DISTRO" = "bookworm" ]]; then
wget -T 10 -qO /tmp/prosody.gpg.key \
https://prosody.im/files/prosody-debian-packages.key
cat /tmp/prosody.gpg.key | gpg --dearmor > /usr/share/keyrings/prosody.gpg
wget -T 10 -O /etc/apt/sources.list.d/prosody.list \
$JITSI_TMPL/etc/apt/sources.list.d/prosody.list.$DISTRO
fi
# jitsi-meet
wget -T 10 -qO /tmp/jitsi.gpg.key https://download.jitsi.org/jitsi-key.gpg.key
cat /tmp/jitsi.gpg.key | gpg --dearmor > /usr/share/keyrings/jitsi.gpg
wget -T 10 -O /etc/apt/sources.list.d/jitsi-stable.list \
$JITSI_TMPL/etc/apt/sources.list.d/jitsi-stable.list
apt-get update
debconf-set-selections <<< \
"jicofo jitsi-videobridge/jvb-hostname string $JITSI_HOST"
debconf-set-selections <<< \
"jitsi-meet-web-config jitsi-meet/cert-choice select Generate a new self-signed certificate"
apt-get $APT_PROXY -y --install-recommends install jitsi-meet
apt-get $APT_PROXY -y install libnginx-mod-stream
apt-get $APT_PROXY -y install nodejs
apt-mark hold 'jitsi-*' jicofo
# packages are ok
timeout 8 curl -s "$CHECKMYPORT?proto=udp&port=60000&text=ok-package" \
>/dev/null || true
# -----------------------------------------------------------------------------
# packages (extra, token)
# -----------------------------------------------------------------------------
out <<< "installing token packages..."
debconf-set-selections <<< \
"jitsi-meet-tokens jitsi-meet-tokens/appid string $APP_ID"
debconf-set-selections <<< \
"jitsi-meet-tokens jitsi-meet-tokens/appsecret password $APP_SECRET"
apt-get -y --allow-change-held-packages install jitsi-meet-tokens
apt-mark hold jitsi-meet-tokens
# token packages are ok
timeout 8 curl -s "$CHECKMYPORT?proto=udp&port=60000&text=ok-package-token" \
>/dev/null || true
# -----------------------------------------------------------------------------
# packages (extra, jibri)
# -----------------------------------------------------------------------------
out <<< "installing jibri packages..."
if [[ "$DISTRO" = "bullseye" ]]; then
sed -i "s~ bullseye main$~ bullseye main contrib non-free~" \
/etc/apt/sources.list
sed -i "s~ bullseye-updates main$~ bullseye-updates main contrib non-free~" \
/etc/apt/sources.list
sed -i "s~ bullseye-security main$~ bullseye-security main contrib non-free~" \
/etc/apt/sources.list
fi
wget -T 10 -qO /tmp/google-chrome.gpg.key \
https://dl.google.com/linux/linux_signing_key.pub
apt-key add /tmp/google-chrome.gpg.key
wget -T 10 -O /etc/apt/sources.list.d/google-chrome.list \
$JIBRI_TMPL/etc/apt/sources.list.d/google-chrome.list
apt-get -y --allow-releaseinfo-change update
apt-get $APT_PROXY -y install kmod alsa-utils
apt-get $APT_PROXY -y install libnss3-tools unzip unclutter
apt-get $APT_PROXY -y install va-driver-all vdpau-driver-all
apt-get $APT_PROXY -y --install-recommends install ffmpeg
apt-get $APT_PROXY -y --install-recommends install google-chrome-stable
apt-mark hold google-chrome-stable
CHROME_VER=$(dpkg -s google-chrome-stable | egrep "^Version" | \
cut -d " " -f2 | cut -d "-" -f1)
CHROME_STORE="https://storage.googleapis.com/chrome-for-testing-public"
CHROMEDRIVER="$CHROME_STORE/${CHROME_VER}/linux64/chromedriver-linux64.zip"
wget -T 30 -qO /tmp/chromedriver-linux64.zip $CHROMEDRIVER
rm -rf /tmp/chromedriver-linux64
unzip -o /tmp/chromedriver-linux64.zip -d /tmp
mv /tmp/chromedriver-linux64/chromedriver /usr/local/bin/
chmod 755 /usr/local/bin/chromedriver
apt-get $APT_PROXY -y install x11vnc
apt-get $APT_PROXY -y install sudo
apt-get $APT_PROXY -y install jibri
apt-mark hold jibri
apt-get -y purge upower
apt-get -y --purge autoremove
# jibri packages are ok
timeout 8 curl -s "$CHECKMYPORT?proto=udp&port=60000&text=ok-package-jibri" \
>/dev/null || true
# -----------------------------------------------------------------------------
# packages (extra, videosipgw)
# -----------------------------------------------------------------------------
out <<< "installing videosipgw packages..."
apt-get -y --install-recommends install v4l2loopback-dkms v4l2loopback-utils
apt-get -y install build-essential
apt-get -y install libv4l-dev libsdl2-dev libavcodec-dev \
libavdevice-dev libavfilter-dev libavformat-dev libavutil-dev \
libswscale-dev libasound2-dev libopus-dev libvpx-dev libssl-dev
# videosipgw packages are ok
timeout 8 curl -s \
"$CHECKMYPORT?proto=udp&port=60000&text=ok-package-videosipgw" \
>/dev/null || true
# -----------------------------------------------------------------------------
# backup
# -----------------------------------------------------------------------------
out <<< "backups..."
# jitsi-meet
cp $JITSI_MEET_CONFIG $JITSI_MEET_CONFIG.org
# coturn
cp /etc/turnserver.conf /etc/turnserver.conf.org
# prosody
cp /etc/prosody/prosody.cfg.lua /etc/prosody/prosody.cfg.lua.org
cp $PROSODY_CONFIG $PROSODY_CONFIG.org
# jicofo
cp /etc/jitsi/jicofo/config /etc/jitsi/jicofo/config.org
cp /etc/jitsi/jicofo/jicofo.conf /etc/jitsi/jicofo/jicofo.conf.org
# jvb
cp /etc/jitsi/videobridge/config /etc/jitsi/videobridge/config.org
cp /etc/jitsi/videobridge/jvb.conf /etc/jitsi/videobridge/jvb.conf.org
cp /etc/jitsi/videobridge/sip-communicator.properties \
/etc/jitsi/videobridge/sip-communicator.properties.org
# nginx
cp /etc/nginx/nginx.conf /etc/nginx/nginx.conf.org
cp $NGINX_CONFIG $NGINX_CONFIG.org
# -----------------------------------------------------------------------------
# backup (extra)
# -----------------------------------------------------------------------------
cp /etc/modules /etc/modules.org
cp /etc/hosts /etc/hosts.org
# sip
cp /opt/jitsi/jibri/pjsua.sh /opt/jitsi/jibri/pjsua.sh.org
cp /opt/jitsi/jibri/finalize_sip.sh /opt/jitsi/jibri/finalize_sip.sh.org
cp /etc/jitsi/jibri/pjsua.config /etc/jitsi/jibri/pjsua.config.org
# -----------------------------------------------------------------------------
# configuration (extra, jibri)
# -----------------------------------------------------------------------------
out <<< "jibri related configuration..."
# snd_aloop
[[ -z "$(egrep '^snd_aloop' /etc/modules)" ]] && echo snd_aloop >>/etc/modules
# snd_aloop options (extra, videosipgw)
wget -T 10 -O /etc/modprobe.d/alsa-loopback.conf \
$JIBRI_TMPL/etc/modprobe.d/alsa-loopback.conf
modprobe snd-aloop
# hosts
sed -i -E "s/(\s)$JITSI_HOST/\1/" /etc/hosts
sed -i -E "/^[0-9.]+\s*$/d" /etc/hosts
sed -i "/127.0.2.1\s/d" /etc/hosts
sed -i "$ a 127.0.2.1 $JITSI_HOST" /etc/hosts
# google chrome
mkdir -p /etc/opt/chrome/policies/managed
wget -T 10 -O /etc/opt/chrome/policies/managed/jibri_policies.json \
$JIBRI_TMPL/etc/opt/chrome/policies/managed/jibri_policies.json
# sudo
wget -T 10 -O /etc/sudoers.d/jibri $JIBRI_TMPL/etc/sudoers.d/jibri
chmod 440 /etc/sudoers.d/jibri
# -----------------------------------------------------------------------------
# configuration (extra, videosipgw)
# -----------------------------------------------------------------------------
out <<< "videosipgw related configuration..."
# v4l2loopback options
wget -T 10 -O /etc/modprobe.d/v4l2loopback.conf \
$JIBRI_TMPL/etc/modprobe.d/v4l2loopback.conf
# v4l2loopback
[[ -z "$(egrep '^v4l2loopback' /etc/modules)" ]] && \
echo v4l2loopback >>/etc/modules
modprobe v4l2loopback
# resolution 1280x720
sed -ri 's/^(\s*)Modes "1920/\1#Modes "1920/' \
/etc/jitsi/jibri/xorg-video-dummy.conf
sed -ri 's/^(\s*)#Modes "1280/\1Modes "1280/' \
/etc/jitsi/jibri/xorg-video-dummy.conf
# xorg DISPLAY :1
wget -T 10 -O /etc/systemd/system/sip-xorg.service \
$JIBRI_TMPL/etc/systemd/system/sip-xorg.service
systemctl daemon-reload
systemctl enable sip-xorg.service
# icewm DISPLAY :1
wget -T 10 -O /etc/systemd/system/sip-icewm.service \
$JIBRI_TMPL/etc/systemd/system/sip-icewm.service
systemctl daemon-reload
systemctl enable sip-icewm.service
# -----------------------------------------------------------------------------
# self-signed certificates
# -----------------------------------------------------------------------------
out <<< "self-signed certificates..."
ln -sf /etc/jitsi/meet/*.crt /usr/local/share/ca-certificates/
update-ca-certificates -f
# self-signed certificates is ok
timeout 8 curl -s "$CHECKMYPORT?proto=udp&port=60000&text=ok-conf-selfcerts" \
>/dev/null || true
# -----------------------------------------------------------------------------
# certbot
# -----------------------------------------------------------------------------
out <<< "configuring Certbot..."
mkdir -p /etc/systemd/system/certbot.service.d
wget -T 10 -O /etc/systemd/system/certbot.service.d/override.conf \
$JITSI_TMPL/etc/systemd/system/certbot.service.d/override.conf
systemctl daemon-reload
# certbot config is ok
timeout 8 curl -s "$CHECKMYPORT?proto=udp&port=60000&text=ok-conf-certbot" \
>/dev/null || true
# -----------------------------------------------------------------------------
# coturn
# -----------------------------------------------------------------------------
out <<< "configuring Coturn..."
cat >>/etc/turnserver.conf <<EOF
# the following lines added by installer
listening-ip=$PUBLIC_IP
allowed-peer-ip=$PUBLIC_IP
no-udp
EOF
adduser turnserver ssl-cert
systemctl restart coturn.service
# coturn config is ok
timeout 8 curl -s "$CHECKMYPORT?proto=udp&port=60000&text=ok-conf-coturn" \
>/dev/null || true
# -----------------------------------------------------------------------------
# prosody
# -----------------------------------------------------------------------------
out <<< "configuring Prosody..."
mkdir -p /etc/systemd/system/prosody.service.d
wget -T 10 -O /etc/systemd/system/prosody.service.d/override.conf \
$JITSI_TMPL/etc/systemd/system/prosody.service.d/override.conf
wget -T 10 -O /etc/prosody/conf.avail/network.cfg.lua \
$JITSI_TMPL/etc/prosody/conf.avail/network.cfg.lua
ln -s ../conf.avail/network.cfg.lua /etc/prosody/conf.d/
sed -i "/rate *=.*kb.s/ s/[0-9]*kb/1024kb/" /etc/prosody/prosody.cfg.lua
sed -i "s/^-- \(https_ports = { };\)/\1/" $PROSODY_CONFIG
sed -i "/turns.*tcp/ s/host\s*=[^,]*/host = \"$TURN_HOST\"/" $PROSODY_CONFIG
sed -i "/turns.*tcp/ s/5349/443/" $PROSODY_CONFIG
sed -i '/^plugin_paths/ s~ }~, "/usr/share/jitsi-meet/prosody-plugins-contrib/" }~' \
$PROSODY_CONFIG
# jitsi-contrib-prosody-plugins
wget -T 10 -O /tmp/v$PROSODY_PLUGINS_VERSION.tar.gz $PROSODY_PLUGINS_ARCHIVE
tar -xf /tmp/v$PROSODY_PLUGINS_VERSION.tar.gz
mv prosody-plugins-$PROSODY_PLUGINS_VERSION \
/usr/share/jitsi-meet/prosody-plugins-contrib
# extra (guest)
wget -T 10 -O /etc/prosody/conf.avail/guest.$JITSI_HOST.cfg.lua \
$JITSI_TMPL/etc/prosody/conf.avail/guest.cfg.lua
sed -i "s/___JITSI_HOST___/$JITSI_HOST/" \
/etc/prosody/conf.avail/guest.$JITSI_HOST.cfg.lua
ln -s ../conf.avail/guest.$JITSI_HOST.cfg.lua /etc/prosody/conf.d/
# extra (token)
sed -i '/\s*app_secret=/a \
\ allow_empty_token = true' $PROSODY_CONFIG
sed -i '/^Component .conference\./,/admins/!b; /\s*"token_verification"/a \
\ "token_affiliation";' $PROSODY_CONFIG
# extra (jibri, videosipgw)
wget -T 10 -O /etc/prosody/conf.avail/sip.$JITSI_HOST.cfg.lua \
$JITSI_TMPL/etc/prosody/conf.avail/sip.cfg.lua
sed -i "s/___JITSI_HOST___/$JITSI_HOST/" \
/etc/prosody/conf.avail/sip.$JITSI_HOST.cfg.lua
ln -s ../conf.avail/sip.$JITSI_HOST.cfg.lua /etc/prosody/conf.d/
sed -i "/-- muc_lobby_whitelist/a \
\ muc_lobby_whitelist = { \"sip.$JITSI_HOST\" }" $PROSODY_CONFIG
sed -i "/muc_password_whitelist =/a \
\ \"sip@sip.$JITSI_HOST\"," $PROSODY_CONFIG
# prosody restart
systemctl daemon-reload
systemctl restart prosody.service
# prosody accounts (extra, jibri)
PASSWD1=$(openssl rand -hex 20)
PASSWD2=$(openssl rand -hex 20)
prosodyctl unregister jibri auth.$JITSI_HOST || true
prosodyctl register jibri auth.$JITSI_HOST $PASSWD1
prosodyctl unregister sip sip.$JITSI_HOST || true
prosodyctl register sip sip.$JITSI_HOST $PASSWD2
# prosody config is ok
timeout 8 curl -s "$CHECKMYPORT?proto=udp&port=60000&text=ok-conf-prosody" \
>/dev/null || true
# -----------------------------------------------------------------------------
# jicofo
# -----------------------------------------------------------------------------
out <<< "configuring Jicofo..."
# add the custom config
cat >>/etc/jitsi/jicofo/config <<EOF
# set the maximum memory for the jicofo daemon
JICOFO_MAX_MEMORY=3072m
EOF
# add enable-auto-owner
hocon -f /etc/jitsi/jicofo/jicofo.conf \
set jicofo.conference.enable-auto-owner true
# extra (token)
hocon -f /etc/jitsi/jicofo/jicofo.conf \
set jicofo.conference.enable-auto-owner false
hocon -f /etc/jitsi/jicofo/jicofo.conf \
set jicofo.authentication.enabled true
hocon -f /etc/jitsi/jicofo/jicofo.conf \
set jicofo.authentication.type "XMPP"
hocon -f /etc/jitsi/jicofo/jicofo.conf \
set jicofo.authentication.login-url "$JITSI_HOST"
hocon -f /etc/jitsi/jicofo/jicofo.conf \
set jicofo.authentication.enable-auto-login false
hocon -f /etc/jitsi/jicofo/jicofo.conf \
set jicofo.authentication.authentication-lifetime "100 milliseconds"
# extra (videosipgw)
hocon -f /etc/jitsi/jicofo/jicofo.conf \
set jicofo.jibri-sip.brewery-jid \
"\"[email protected].$JITSI_HOST\""
# jicofo restart
systemctl restart jicofo.service
# jicofo config is ok
timeout 8 curl -s "$CHECKMYPORT?proto=udp&port=60000&text=ok-conf-jicofo" \
>/dev/null || true
# -----------------------------------------------------------------------------
# jitsi-meet (extra)
# -----------------------------------------------------------------------------
out <<< "configuring jitsi-meet..."
wget -T 10 -O /usr/share/jitsi-meet/static/branding.json \
$JITSI_TMPL/usr/share/jitsi-meet/static/branding.json
wget -T 10 -O /tmp/config.branding.js \
$JITSI_TMPL/etc/jitsi/meet/config.branding.js
cat /tmp/config.branding.js >>$JITSI_MEET_CONFIG
wget -T 10 -O /tmp/config.whiteboard.js \
$JITSI_TMPL/etc/jitsi/meet/config.whiteboard.js
cat /tmp/config.whiteboard.js >>$JITSI_MEET_CONFIG
wget -T 10 -O /tmp/config.anonymousdomain.js \
$JITSI_TMPL/etc/jitsi/meet/config.anonymousdomain.js
cat /tmp/config.anonymousdomain.js >>$JITSI_MEET_CONFIG
wget -T 10 -O /tmp/config.peoplesearch.js \
$JITSI_TMPL/etc/jitsi/meet/config.peoplesearch.js
cat /tmp/config.peoplesearch.js >>$JITSI_MEET_CONFIG
wget -T 10 -O /tmp/config.disableprofile.js \
$JITSI_TMPL/etc/jitsi/meet/config.disableprofile.js
cat /tmp/config.disableprofile.js >>$JITSI_MEET_CONFIG
sed -i "s/___JITSI_FQDN___/$JITSI_HOST/" $JITSI_MEET_CONFIG
# jitsi-meet config is ok
timeout 8 curl -s "$CHECKMYPORT?proto=udp&port=60000&text=ok-conf-jitsi-meet" \
>/dev/null || true
# -----------------------------------------------------------------------------
# nginx
# -----------------------------------------------------------------------------
out <<< "configuring Nginx..."