|
@@ -1,4 +1,4 @@
|
1
|
|
-#!/bin/sh
|
|
1
|
+#!/bin/bash
|
2
|
2
|
# postinst script for jitsi-meet
|
3
|
3
|
#
|
4
|
4
|
# see: dh_installdeb(1)
|
|
@@ -20,67 +20,154 @@ set -e
|
20
|
20
|
case "$1" in
|
21
|
21
|
configure)
|
22
|
22
|
|
23
|
|
- . /etc/jitsi/videobridge/config
|
|
23
|
+ JVB_ETC_CONFIG="/etc/jitsi/videobridge/config"
|
|
24
|
+ JVB_CONFIG="/usr/share/jitsi-videobridge/.sip-communicator/sip-communicator.properties"
|
|
25
|
+
|
|
26
|
+ . $JVB_ETC_CONFIG
|
24
|
27
|
|
25
|
28
|
# loading debconf
|
26
|
29
|
. /usr/share/debconf/confmodule
|
27
|
30
|
|
28
|
|
- # detect dpkg-reconfigure, just delete old links
|
|
31
|
+ # detect dpkg-reconfigure
|
|
32
|
+ RECONFIGURING="false"
|
29
|
33
|
db_get jitsi-meet/jvb-hostname
|
30
|
34
|
JVB_HOSTNAME_OLD=$RET
|
31
|
35
|
if [ -n "$RET" ] && [ ! "$JVB_HOSTNAME_OLD" = "$JVB_HOSTNAME" ] ; then
|
32
|
|
- rm -f /etc/nginx/sites-enabled/$JVB_HOSTNAME_OLD.conf
|
|
36
|
+ RECONFIGURING="true"
|
33
|
37
|
rm -f /etc/jitsi/meet/$JVB_HOSTNAME_OLD-config.js
|
34
|
38
|
fi
|
35
|
39
|
|
|
40
|
+ JVB_SERVE="false"
|
|
41
|
+ db_get jitsi-meet/jvb-serve
|
|
42
|
+ if [ -n "$RET" ] && [ "$RET" = "true" ] ; then
|
|
43
|
+ JVB_SERVE="true"
|
|
44
|
+ fi
|
|
45
|
+
|
36
|
46
|
# stores the hostname so we will reuse it later, like in purge
|
37
|
47
|
db_set jitsi-meet/jvb-hostname $JVB_HOSTNAME
|
38
|
48
|
|
39
|
|
- # nginx conf
|
40
|
|
- if [ ! -f /etc/nginx/sites-available/$JVB_HOSTNAME.conf ]; then
|
41
|
|
- cp /usr/share/doc/jitsi-meet/jitsi-meet.example /etc/nginx/sites-available/$JVB_HOSTNAME.conf
|
42
|
|
- if [ ! -f /etc/nginx/sites-enabled/$JVB_HOSTNAME.conf ]; then
|
43
|
|
- ln -s /etc/nginx/sites-available/$JVB_HOSTNAME.conf /etc/nginx/sites-enabled/$JVB_HOSTNAME.conf
|
44
|
|
- fi
|
45
|
|
- sed -i "s/jitsi-meet.example.com/$JVB_HOSTNAME/g" /etc/nginx/sites-available/$JVB_HOSTNAME.conf
|
46
|
|
- fi
|
47
|
|
-
|
48
|
49
|
# SSL for nginx
|
49
|
50
|
db_get jitsi-meet/cert-choice
|
50
|
51
|
CERT_CHOICE="$RET"
|
51
|
|
- if [ "$CERT_CHOICE" = 'A certificate is available and the files are uploaded on the server' ]; then
|
52
|
|
- db_set jitsi-meet/cert-path-key "/etc/ssl/$JVB_HOSTNAME.key"
|
53
|
|
- db_input critical jitsi-meet/cert-path-key || true
|
54
|
|
- db_go
|
55
|
|
- db_get jitsi-meet/cert-path-key
|
56
|
|
- CERT_KEY="$RET"
|
57
|
|
- db_set jitsi-meet/cert-path-crt "/etc/ssl/$JVB_HOSTNAME.crt"
|
58
|
|
- db_input critical jitsi-meet/cert-path-crt || true
|
59
|
|
- db_go
|
60
|
|
- db_get jitsi-meet/cert-path-crt
|
61
|
|
- CERT_CRT="$RET"
|
62
|
|
- # replace self-signed certificate paths with user provided ones
|
63
|
|
- CERT_KEY_ESC=$(echo $CERT_KEY | sed 's/\./\\\./g')
|
64
|
|
- CERT_KEY_ESC=$(echo $CERT_KEY_ESC | sed 's/\//\\\//g')
|
65
|
|
- sed -i "s/ssl_certificate_key\ \/var\/lib\/prosody\/.*key/ssl_certificate_key\ $CERT_KEY_ESC/g" \
|
66
|
|
- /etc/nginx/sites-available/$JVB_HOSTNAME.conf
|
67
|
|
- CERT_CRT_ESC=$(echo $CERT_CRT | sed 's/\./\\\./g')
|
68
|
|
- CERT_CRT_ESC=$(echo $CERT_CRT_ESC | sed 's/\//\\\//g')
|
69
|
|
- sed -i "s/ssl_certificate\ \/var\/lib\/prosody\/.*crt/ssl_certificate\ $CERT_CRT_ESC/g" \
|
70
|
|
- /etc/nginx/sites-available/$JVB_HOSTNAME.conf
|
71
|
|
- fi
|
|
52
|
+ UPLOADED_CERT_CHOICE="A certificate is available and the files are uploaded on the server"
|
72
|
53
|
|
73
|
54
|
# jitsi meet
|
74
|
55
|
JITSI_MEET_CONFIG="/etc/jitsi/meet/$JVB_HOSTNAME-config.js"
|
75
|
|
- if [ ! -f $JITSI_MEET_CONFIG ]; then
|
|
56
|
+ if [ ! -f $JITSI_MEET_CONFIG ] ; then
|
76
|
57
|
cp /usr/share/doc/jitsi-meet/config.js $JITSI_MEET_CONFIG
|
77
|
58
|
sed -i "s/jitsi-meet.example.com/$JVB_HOSTNAME/g" $JITSI_MEET_CONFIG
|
78
|
59
|
fi
|
79
|
60
|
|
|
61
|
+ # this is new install let's configure jvb to serve meet
|
|
62
|
+ if [[ -z $FORCE_NGINX && ( -z $JVB_HOSTNAME_OLD || "$JVB_SERVE" = "true" ) ]] ; then
|
|
63
|
+ # this is a reconfigure, lets just delete old links
|
|
64
|
+ if [ "$RECONFIGURING" = "true" ] ; then
|
|
65
|
+ rm -f $JVB_CONFIG
|
|
66
|
+ fi
|
|
67
|
+
|
|
68
|
+ # configure jvb
|
|
69
|
+ echo "AUTHBIND=yes" >> $JVB_ETC_CONFIG
|
|
70
|
+ sed -i "s/JVB_OPTS=.*/JVB_OPTS=--apis=rest,xmpp/g" $JVB_ETC_CONFIG
|
|
71
|
+
|
|
72
|
+ echo "org.jitsi.videobridge.rest.jetty.host=::" >> $JVB_CONFIG
|
|
73
|
+ echo "org.jitsi.videobridge.rest.jetty.port=443" >> $JVB_CONFIG
|
|
74
|
+ echo "org.jitsi.videobridge.rest.jetty.ProxyServlet.hostHeader=$JVB_HOSTNAME" >> $JVB_CONFIG
|
|
75
|
+ echo "org.jitsi.videobridge.rest.jetty.ProxyServlet.pathSpec=/http-bind" >> $JVB_CONFIG
|
|
76
|
+ echo "org.jitsi.videobridge.rest.jetty.ProxyServlet.proxyTo=http://localhost:5280/http-bind" >> $JVB_CONFIG
|
|
77
|
+ echo "org.jitsi.videobridge.rest.jetty.ResourceHandler.resourceBase=/usr/share/jitsi-meet" >> $JVB_CONFIG
|
|
78
|
+ echo "org.jitsi.videobridge.rest.jetty.ResourceHandler.alias./config.js=/etc/jitsi/meet/$JVB_HOSTNAME-config.js" >> $JVB_CONFIG
|
|
79
|
+ echo "org.jitsi.videobridge.rest.jetty.RewriteHandler.regex=^/([a-zA-Z0-9]+)$" >> $JVB_CONFIG
|
|
80
|
+ echo "org.jitsi.videobridge.rest.jetty.RewriteHandler.replacement=/" >> $JVB_CONFIG
|
|
81
|
+ echo "org.jitsi.videobridge.rest.jetty.tls.port=443" >> $JVB_CONFIG
|
|
82
|
+ echo "org.jitsi.videobridge.TCP_HARVESTER_PORT=443" >> $JVB_CONFIG
|
|
83
|
+ echo "org.jitsi.videobridge.rest.jetty.sslContextFactory.keyStorePath=/etc/jitsi/videobridge/$JVB_HOSTNAME.jks" >> $JVB_CONFIG
|
|
84
|
+ echo "org.jitsi.videobridge.rest.jetty.sslContextFactory.keyStorePassword=changeit" >> $JVB_CONFIG
|
|
85
|
+
|
|
86
|
+ # configure authbind to allow jvb to bind to privileged ports
|
|
87
|
+ OWNER=$(stat -c '%U' /usr/share/jitsi-videobridge)
|
|
88
|
+ GROUP=$(stat -c '%G' /usr/share/jitsi-videobridge)
|
|
89
|
+ JVB_UID="`id -u $OWNER`"
|
|
90
|
+ if [ ! -f "/etc/authbind/byuid/$JVB_UID" ] ; then
|
|
91
|
+ if [ ! -d "/etc/authbind/byuid" ] ; then
|
|
92
|
+ mkdir -p /etc/authbind/byuid
|
|
93
|
+ chmod 755 /etc/authbind
|
|
94
|
+ chmod 755 /etc/authbind/byuid
|
|
95
|
+ fi
|
|
96
|
+ echo '::,443' >/etc/authbind/byuid/$JVB_UID
|
|
97
|
+ chown $OWNER:$GROUP /etc/authbind/byuid/$JVB_UID
|
|
98
|
+ chmod 700 /etc/authbind/byuid/$JVB_UID
|
|
99
|
+ fi
|
|
100
|
+
|
|
101
|
+ if [ "$CERT_CHOICE" = "$UPLOADED_CERT_CHOICE" ] ; then
|
|
102
|
+ # create jks from uploaded certs
|
|
103
|
+ openssl pkcs12 -export \
|
|
104
|
+ -in /etc/ssl/$JVB_HOSTNAME.crt \
|
|
105
|
+ -inkey /etc/ssl/$JVB_HOSTNAME.key \
|
|
106
|
+ -passout pass:changeit > /etc/jitsi/videobridge/$JVB_HOSTNAME.p12
|
|
107
|
+ keytool -importkeystore \
|
|
108
|
+ -srckeystore /etc/jitsi/videobridge/$JVB_HOSTNAME.p12 \
|
|
109
|
+ -destkeystore /etc/jitsi/videobridge/$JVB_HOSTNAME.jks \
|
|
110
|
+ -srcstoretype pkcs12 \
|
|
111
|
+ -noprompt -storepass changeit -srcstorepass changeit
|
|
112
|
+ else
|
|
113
|
+ # create jks from self-signed certs
|
|
114
|
+ openssl pkcs12 -export \
|
|
115
|
+ -in /var/lib/prosody/$JVB_HOSTNAME.crt \
|
|
116
|
+ -inkey /var/lib/prosody/$JVB_HOSTNAME.key \
|
|
117
|
+ -passout pass:changeit > /etc/jitsi/videobridge/$JVB_HOSTNAME.p12
|
|
118
|
+ keytool -importkeystore \
|
|
119
|
+ -srckeystore /etc/jitsi/videobridge/$JVB_HOSTNAME.p12 \
|
|
120
|
+ -destkeystore /etc/jitsi/videobridge/$JVB_HOSTNAME.jks \
|
|
121
|
+ -srcstoretype pkcs12 \
|
|
122
|
+ -noprompt -storepass changeit -srcstorepass changeit
|
|
123
|
+ fi
|
|
124
|
+
|
|
125
|
+ db_set jitsi-meet/jvb-serve "true"
|
|
126
|
+
|
|
127
|
+ invoke-rc.d jitsi-videobridge restart
|
|
128
|
+ elif [[ "$FORCE_NGINX" = "true" || ( -n $JVB_HOSTNAME_OLD && "$JVB_SERVE" = "false" ) ]] ; then
|
|
129
|
+ # this is a reconfigure, lets just delete old links
|
|
130
|
+ if [ "$RECONFIGURING" = "true" ] ; then
|
|
131
|
+ rm -f /etc/nginx/sites-enabled/$JVB_HOSTNAME_OLD.conf
|
|
132
|
+ rm -f /etc/jitsi/meet/$JVB_HOSTNAME_OLD-config.js
|
|
133
|
+ fi
|
|
134
|
+
|
|
135
|
+ # nginx conf
|
|
136
|
+ if [ ! -f /etc/nginx/sites-available/$JVB_HOSTNAME.conf ] ; then
|
|
137
|
+ cp /usr/share/doc/jitsi-meet/jitsi-meet.example /etc/nginx/sites-available/$JVB_HOSTNAME.conf
|
|
138
|
+ if [ ! -f /etc/nginx/sites-enabled/$JVB_HOSTNAME.conf ] ; then
|
|
139
|
+ ln -s /etc/nginx/sites-available/$JVB_HOSTNAME.conf /etc/nginx/sites-enabled/$JVB_HOSTNAME.conf
|
|
140
|
+ fi
|
|
141
|
+ sed -i "s/jitsi-meet.example.com/$JVB_HOSTNAME/g" /etc/nginx/sites-available/$JVB_HOSTNAME.conf
|
|
142
|
+ fi
|
|
143
|
+
|
|
144
|
+ if [ "$CERT_CHOICE" = "$UPLOADED_CERT_CHOICE" ] ; then
|
|
145
|
+ db_set jitsi-meet/cert-path-key "/etc/ssl/$JVB_HOSTNAME.key"
|
|
146
|
+ db_input critical jitsi-meet/cert-path-key || true
|
|
147
|
+ db_go
|
|
148
|
+ db_get jitsi-meet/cert-path-key
|
|
149
|
+ CERT_KEY="$RET"
|
|
150
|
+ db_set jitsi-meet/cert-path-crt "/etc/ssl/$JVB_HOSTNAME.crt"
|
|
151
|
+ db_input critical jitsi-meet/cert-path-crt || true
|
|
152
|
+ db_go
|
|
153
|
+ db_get jitsi-meet/cert-path-crt
|
|
154
|
+ CERT_CRT="$RET"
|
|
155
|
+ # replace self-signed certificate paths with user provided ones
|
|
156
|
+ CERT_KEY_ESC=$(echo $CERT_KEY | sed 's/\./\\\./g')
|
|
157
|
+ CERT_KEY_ESC=$(echo $CERT_KEY_ESC | sed 's/\//\\\//g')
|
|
158
|
+ sed -i "s/ssl_certificate_key\ \/var\/lib\/prosody\/.*key/ssl_certificate_key\ $CERT_KEY_ESC/g" \
|
|
159
|
+ /etc/nginx/sites-available/$JVB_HOSTNAME.conf
|
|
160
|
+ CERT_CRT_ESC=$(echo $CERT_CRT | sed 's/\./\\\./g')
|
|
161
|
+ CERT_CRT_ESC=$(echo $CERT_CRT_ESC | sed 's/\//\\\//g')
|
|
162
|
+ sed -i "s/ssl_certificate\ \/var\/lib\/prosody\/.*crt/ssl_certificate\ $CERT_CRT_ESC/g" \
|
|
163
|
+ /etc/nginx/sites-available/$JVB_HOSTNAME.conf
|
|
164
|
+ fi
|
|
165
|
+
|
|
166
|
+ invoke-rc.d nginx reload
|
|
167
|
+ fi
|
|
168
|
+
|
80
|
169
|
# and we're done with debconf
|
81
|
170
|
db_stop
|
82
|
|
-
|
83
|
|
- invoke-rc.d nginx reload
|
84
|
171
|
;;
|
85
|
172
|
|
86
|
173
|
abort-upgrade|abort-remove|abort-deconfigure)
|