"Fossies" - the Fresh Open Source Software Archive 
Member "jitsi-meet-6193/debian/jitsi-meet-turnserver.postinst" (20 May 2022, 5914 Bytes) of package /linux/misc/jitsi-meet-6193.tar.gz:
As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Bash source code syntax highlighting (style:
standard) with prefixed line numbers and
code folding option.
Alternatively you can here
view or
download the uninterpreted source code file.
See also the last
Fossies "Diffs" side-by-side code changes report for "jitsi-meet-turnserver.postinst":
jitsi-meet_7210_vs_jitsi-meet_7287.
1 #!/bin/bash
2 # postinst script for jitsi-meet-turnserver
3 #
4 # see: dh_installdeb(1)
5
6 set -e
7
8 # summary of how this script can be called:
9 # * <postinst> `configure' <most-recently-configured-version>
10 # * <old-postinst> `abort-upgrade' <new version>
11 # * <conflictor's-postinst> `abort-remove' `in-favour' <package>
12 # <new-version>
13 # * <postinst> `abort-remove'
14 # * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
15 # <failed-install-package> <version> `removing'
16 # <conflicting-package> <version>
17 # for details, see http://www.debian.org/doc/debian-policy/ or
18 # the debian-policy package
19
20 case "$1" in
21 configure)
22 # loading debconf
23 . /usr/share/debconf/confmodule
24
25 # try to get host from jitsi-videobridge
26 db_get jitsi-videobridge/jvb-hostname
27 if [ -z "$RET" ] ; then
28 # server hostname
29 db_set jitsi-videobridge/jvb-hostname "localhost"
30 db_input critical jitsi-videobridge/jvb-hostname || true
31 db_go
32 fi
33 JVB_HOSTNAME=$(echo "$RET" | xargs echo -n)
34
35 TURN_CONFIG="/etc/turnserver.conf"
36 JITSI_MEET_CONFIG="/etc/jitsi/meet/$JVB_HOSTNAME-config.js"
37
38 # if there was a turn config backup it so we can configure
39 # we cannot recognize at the moment is this a user config or default config when installing coturn
40 if [[ -f $TURN_CONFIG ]] && ! grep -q "jitsi-meet coturn config" "$TURN_CONFIG" ; then
41 mv $TURN_CONFIG $TURN_CONFIG.bak
42 fi
43
44 # detect dpkg-reconfigure, just delete old links
45 db_get jitsi-meet-turnserver/jvb-hostname
46 JVB_HOSTNAME_OLD=$(echo "$RET" | xargs echo -n)
47 if [ -n "$RET" ] && [ ! "$JVB_HOSTNAME_OLD" = "$JVB_HOSTNAME" ] ; then
48 if [[ -f $TURN_CONFIG ]] && grep -q "jitsi-meet coturn config" "$TURN_CONFIG" ; then
49 rm -f $TURN_CONFIG
50 fi
51 fi
52
53 if [[ -f $TURN_CONFIG ]] ; then
54 echo "------------------------------------------------"
55 echo ""
56 echo "turnserver is already configured on this machine."
57 echo ""
58 echo "------------------------------------------------"
59
60 if grep -q "jitsi-meet coturn config" "$TURN_CONFIG" && ! grep -q "jitsi-meet coturn relay disable config" "$TURN_CONFIG" ; then
61 echo "Updating coturn config"
62 echo "# jitsi-meet coturn relay disable config. Do not modify this line
63 no-multicast-peers
64 no-cli
65 no-loopback-peers
66 no-tcp-relay
67 denied-peer-ip=0.0.0.0-0.255.255.255
68 denied-peer-ip=10.0.0.0-10.255.255.255
69 denied-peer-ip=100.64.0.0-100.127.255.255
70 denied-peer-ip=127.0.0.0-127.255.255.255
71 denied-peer-ip=169.254.0.0-169.254.255.255
72 denied-peer-ip=127.0.0.0-127.255.255.255
73 denied-peer-ip=172.16.0.0-172.31.255.255
74 denied-peer-ip=192.0.0.0-192.0.0.255
75 denied-peer-ip=192.0.2.0-192.0.2.255
76 denied-peer-ip=192.88.99.0-192.88.99.255
77 denied-peer-ip=192.168.0.0-192.168.255.255
78 denied-peer-ip=198.18.0.0-198.19.255.255
79 denied-peer-ip=198.51.100.0-198.51.100.255
80 denied-peer-ip=203.0.113.0-203.0.113.255
81 denied-peer-ip=240.0.0.0-255.255.255.255" >> $TURN_CONFIG
82
83 invoke-rc.d coturn restart || true
84 fi
85
86 db_stop
87 exit 0
88 fi
89
90 # stores the hostname so we will reuse it later, like in purge
91 db_set jitsi-meet-turnserver/jvb-hostname "$JVB_HOSTNAME"
92
93 # try to get turnserver password
94 db_get jitsi-meet-prosody/turn-secret
95 if [ -z "$RET" ] ; then
96 db_input critical jitsi-meet-prosody/turn-secret || true
97 db_go
98 fi
99 TURN_SECRET="$RET"
100
101 # no turn config exists, lt's copy template and fill it in
102 cp /usr/share/jitsi-meet-turnserver/turnserver.conf $TURN_CONFIG
103 sed -i "s/jitsi-meet.example.com/$JVB_HOSTNAME/g" $TURN_CONFIG
104 sed -i "s/__turnSecret__/$TURN_SECRET/g" $TURN_CONFIG
105
106 # SSL settings
107 db_get jitsi-meet/cert-choice
108 CERT_CHOICE="$RET"
109
110 if [ "$CERT_CHOICE" = "I want to use my own certificate" ] ; then
111 db_get jitsi-meet/cert-path-key
112 CERT_KEY="$RET"
113 db_get jitsi-meet/cert-path-crt
114 CERT_CRT="$RET"
115
116 # replace self-signed certificate paths with user provided ones
117 CERT_KEY_ESC=$(echo $CERT_KEY | sed 's/\./\\\./g')
118 CERT_KEY_ESC=$(echo $CERT_KEY_ESC | sed 's/\//\\\//g')
119 sed -i "s/pkey=\/etc\/jitsi\/meet\/.*key/pkey=$CERT_KEY_ESC/g" $TURN_CONFIG
120 CERT_CRT_ESC=$(echo $CERT_CRT | sed 's/\./\\\./g')
121 CERT_CRT_ESC=$(echo $CERT_CRT_ESC | sed 's/\//\\\//g')
122 sed -i "s/cert=\/etc\/jitsi\/meet\/.*crt/cert=$CERT_CRT_ESC/g" $TURN_CONFIG
123 fi
124
125 sed -i "s/#TURNSERVER_ENABLED/TURNSERVER_ENABLED/g" /etc/default/coturn
126 invoke-rc.d coturn restart || true
127
128 NGINX_STREAM_CONFIG="/etc/nginx/modules-enabled/60-jitsi-meet.conf"
129 if [ -f $NGINX_STREAM_CONFIG ] ; then
130 echo "------------------------------------------------"
131 echo ""
132 echo "You have multiplexing enabled, it is recommended to disable it and migrate to using websockets for the bridge channel."
133 echo "The support for sctp data channels is deprecated and will be dropped at some point."
134 echo "How to do it at: https://jitsi.org/multiplexing-to-bridge-ws-howto"
135 echo ""
136 echo "------------------------------------------------"
137 fi
138
139 # and we're done with debconf
140 db_stop
141 ;;
142
143 abort-upgrade|abort-remove|abort-deconfigure)
144 ;;
145
146 *)
147 echo "postinst called with unknown argument \`$1'" >&2
148 exit 1
149 ;;
150 esac
151
152 # dh_installdeb will replace this with shell code automatically
153 # generated by other debhelper scripts.
154
155 #DEBHELPER#
156
157 exit 0