|
@@ -36,7 +36,6 @@ IN_DEFAULT_INSTALL=0
|
36
|
36
|
SHOW_ON_ABOUT=1
|
37
|
37
|
|
38
|
38
|
MATRIX_DATA_DIR='/var/lib/matrix'
|
39
|
|
-MATRIX_TURN_PORT=3478
|
40
|
39
|
MATRIX_PORT=8448
|
41
|
40
|
MATRIX_REPO="https://github.com/matrix-org/synapse"
|
42
|
41
|
MATRIX_COMMIT='f5a4001bb116c468cc5e8e0ae04a1c570e2cb171'
|
|
@@ -46,18 +45,6 @@ matrix_variables=(ONION_ONLY
|
46
|
45
|
MATRIX_PASSWORD
|
47
|
46
|
DEFAULT_DOMAIN_NAME)
|
48
|
47
|
|
49
|
|
-function matrix_generate_turn_key {
|
50
|
|
- local turnkey="${1}"
|
51
|
|
- local filepath="${2}"
|
52
|
|
-
|
53
|
|
- echo "lt-cred-mech" > "${filepath}"
|
54
|
|
- echo "use-auth-secret" >> "${filepath}"
|
55
|
|
- echo "static-auth-secret=${turnkey}" >> "${filepath}"
|
56
|
|
- echo "realm=turn.${DEFAULT_DOMAIN_NAME}" >> "${filepath}"
|
57
|
|
- echo "cert=${MATRIX_DATA_DIR}/${DEFAULT_DOMAIN_NAME}.tls.crt" >> "${filepath}"
|
58
|
|
- echo "pkey=${MATRIX_DATA_DIR}/${DEFAULT_DOMAIN_NAME}.tls.key" >> "${filepath}"
|
59
|
|
-}
|
60
|
|
-
|
61
|
48
|
function matrix_generate_synapse_file {
|
62
|
49
|
local filepath="${1}"
|
63
|
50
|
|
|
@@ -75,7 +62,7 @@ function matrix_configure_homeserver_yaml {
|
75
|
62
|
|
76
|
63
|
local ymltemp="$(mktemp)"
|
77
|
64
|
|
78
|
|
- awk -v TURNURIES="turn_uris: [\"turn:${DEFAULT_DOMAIN_NAME}:${MATRIX_TURN_PORT}?transport=udp\", \"turn:${DEFAULT_DOMAIN_NAME}:${MATRIX_TURN_PORT}?transport=tcp\"]" \
|
|
65
|
+ awk -v TURNURIES="turn_uris: [\"turn:${DEFAULT_DOMAIN_NAME}:${TURN_PORT}?transport=udp\", \"turn:${DEFAULT_DOMAIN_NAME}:${TURN_PORT}?transport=tcp\"]" \
|
79
|
66
|
-v TURNSHAREDSECRET="turn_shared_secret: \"${turnkey}\"" \
|
80
|
67
|
-v PIDFILE="pid_file: ${MATRIX_DATA_DIR}/homeserver.pid" \
|
81
|
68
|
-v DATABASE="database: \"${MATRIX_DATA_DIR}/homeserver.db\"" \
|
|
@@ -94,42 +81,15 @@ function matrix_configure_homeserver_yaml {
|
94
|
81
|
mv ${ymltemp} "${filepath}"
|
95
|
82
|
}
|
96
|
83
|
|
97
|
|
-function matrix_start {
|
98
|
|
- if [ -f ${MATRIX_DATA_DIR}/turnserver.conf ]; then
|
99
|
|
- echo "-=> start turn"
|
100
|
|
- /usr/bin/turnserver --daemon -c ${MATRIX_DATA_DIR}/turnserver.conf
|
101
|
|
- fi
|
102
|
|
-
|
103
|
|
- echo "-=> start riot.im client"
|
104
|
|
- (
|
105
|
|
- if [ -f ${MATRIX_DATA_DIR}/vector.im.conf ] || [ -f ${MATRIX_DATA_DIR}/riot.im.conf ] ; then
|
106
|
|
- echo "The riot web client is now handled via silvio/matrix-riot-docker"
|
107
|
|
- fi
|
108
|
|
- )
|
109
|
|
-
|
110
|
|
- echo "-=> start matrix"
|
111
|
|
- python -m synapse.app.homeserver --config-path ${MATRIX_DATA_DIR}/homeserver.yaml
|
112
|
|
-}
|
113
|
|
-
|
114
|
|
-function matrix_stop {
|
115
|
|
- echo "-=> stop matrix"
|
116
|
|
- echo "-=> via docker stop ..."
|
117
|
|
-}
|
118
|
|
-
|
119
|
|
-
|
120
|
84
|
function matrix_diff {
|
121
|
|
- echo "-=> Diff between local configfile and a fresh generated config file"
|
122
|
|
- echo "-=> some values are different in technical point of view, like"
|
123
|
|
- echo "-=> autogenerated secret keys etc..."
|
124
|
|
-
|
125
|
85
|
DIFFPARAMS="${DIFFPARAMS:-Naur}"
|
126
|
86
|
DEFAULT_DOMAIN_NAME="${DEFAULT_DOMAIN_NAME:-demo_server_name}"
|
127
|
87
|
REPORT_STATS="${REPORT_STATS:-no_or_yes}"
|
128
|
88
|
export DEFAULT_DOMAIN_NAME REPORT_STATS
|
129
|
89
|
|
130
|
|
- matrix_generate_synapse_file /tmp/homeserver.synapse.yaml
|
131
|
|
- diff -${DIFFPARAMS} /tmp/homeserver.synapse.yaml ${MATRIX_DATA_DIR}/homeserver.yaml
|
132
|
|
- rm /tmp/homeserver.synapse.yaml
|
|
90
|
+ matrix_generate_synapse_file $INSTALL_DIR/homeserver.synapse.yaml
|
|
91
|
+ diff -${DIFFPARAMS} $INSTALL_DIR/homeserver.synapse.yaml ${MATRIX_DATA_DIR}/homeserver.yaml
|
|
92
|
+ rm $INSTALL_DIR/homeserver.synapse.yaml
|
133
|
93
|
}
|
134
|
94
|
|
135
|
95
|
function matrix_generate {
|
|
@@ -141,14 +101,7 @@ function matrix_generate {
|
141
|
101
|
[[ "${REPORT_STATS}" != "yes" ]] && [[ "${REPORT_STATS}" != "no" ]] && \
|
142
|
102
|
echo "STOP! REPORT_STATS needs to be 'no' or 'yes'" && breakup="1"
|
143
|
103
|
|
144
|
|
- echo "-=> generate turn config"
|
145
|
|
- turnkey=$(pwgen -s 64 1)
|
146
|
|
- matrix_generate_turn_key $turnkey ${MATRIX_DATA_DIR}/turnserver.conf
|
147
|
|
-
|
148
|
|
- echo "-=> generate synapse config"
|
149
|
104
|
matrix_generate_synapse_file ${MATRIX_DATA_DIR}/homeserver.tmp
|
150
|
|
-
|
151
|
|
- echo "-=> configure some settings in homeserver.yaml"
|
152
|
105
|
matrix_configure_homeserver_yaml $turnkey ${MATRIX_DATA_DIR}/homeserver.tmp
|
153
|
106
|
|
154
|
107
|
mv ${MATRIX_DATA_DIR}/homeserver.tmp ${MATRIX_DATA_DIR}/homeserver.yaml
|
|
@@ -286,9 +239,12 @@ function restore_remote_synapse {
|
286
|
239
|
|
287
|
240
|
function remove_matrix {
|
288
|
241
|
firewall_remove ${MATRIX_PORT}
|
289
|
|
- firewall_remove ${MATRIX_TURN_PORT}
|
290
|
242
|
systemctl stop matrix
|
291
|
|
- systemcrl disable matrix
|
|
243
|
+
|
|
244
|
+ function_check remove_turn
|
|
245
|
+ remove_turn
|
|
246
|
+
|
|
247
|
+ systemctl disable matrix
|
292
|
248
|
if [ -f /etc/systemd/system/matrix.service ]; then
|
293
|
249
|
rm /etc/systemd/system/matrix.service
|
294
|
250
|
fi
|
|
@@ -306,17 +262,19 @@ function remove_matrix {
|
306
|
262
|
}
|
307
|
263
|
|
308
|
264
|
function install_matrix {
|
|
265
|
+ if [ ! -d $INSTALL_DIR ]; then
|
|
266
|
+ mkdir -p $INSTALL_DIR
|
|
267
|
+ fi
|
|
268
|
+
|
309
|
269
|
if [[ ${ONION_ONLY} == 'no' ]]; then
|
310
|
|
- # obtain a cert for the default domain
|
311
|
|
- if [[ "$(cert_exists ${DEFAULT_DOMAIN_NAME} pem)" == "0" ]]; then
|
|
270
|
+ if [ ! -f /etc/ssl/certs/${DEFAULT_DOMAIN_NAME}.pem ]; then
|
312
|
271
|
echo $'Obtaining certificate for the main domain'
|
313
|
272
|
create_site_certificate ${DEFAULT_DOMAIN_NAME} 'yes'
|
314
|
273
|
fi
|
315
|
274
|
fi
|
316
|
275
|
|
317
|
|
- REBUILD=1
|
318
|
276
|
export DEBIAN_FRONTEND=noninteractive
|
319
|
|
- apt-get -yq install coreutils coturn \
|
|
277
|
+ apt-get -yq install coreutils \
|
320
|
278
|
curl file gcc git libevent-2.0-5 \
|
321
|
279
|
libevent-dev libffi-dev libffi6 \
|
322
|
280
|
libgnutls28-dev libjpeg62-turbo \
|
|
@@ -325,7 +283,7 @@ function install_matrix {
|
325
|
283
|
libsqlite3-dev libssl-dev \
|
326
|
284
|
libssl1.0.0 libtool libxml2 \
|
327
|
285
|
libxml2-dev libxslt1-dev libxslt1.1 \
|
328
|
|
- make pwgen python python-dev \
|
|
286
|
+ make python python-dev \
|
329
|
287
|
python-pip python-psycopg2 \
|
330
|
288
|
python-virtualenv sqlite unzip \
|
331
|
289
|
zlib1g zlib1g-dev
|
|
@@ -357,6 +315,12 @@ function install_matrix {
|
357
|
315
|
chown -R matrix:matrix /etc/matrix
|
358
|
316
|
chown -R matrix:matrix /var/lib/matrix
|
359
|
317
|
|
|
318
|
+ function_check install_turn
|
|
319
|
+ install_turn
|
|
320
|
+
|
|
321
|
+ function_check matrix_generate
|
|
322
|
+ matrix_generate
|
|
323
|
+
|
360
|
324
|
echo '[Unit]' > /etc/systemd/system/matrix.service
|
361
|
325
|
echo 'Description=Matrix federated messaging' >> /etc/systemd/system/matrix.service
|
362
|
326
|
echo '' >> /etc/systemd/system/matrix.service
|
|
@@ -364,7 +328,6 @@ function install_matrix {
|
364
|
328
|
echo 'Type=simple' >> /etc/systemd/system/matrix.service
|
365
|
329
|
echo 'User=matrix' >> /etc/systemd/system/matrix.service
|
366
|
330
|
echo "WorkingDirectory=/etc/matrix" >> /etc/systemd/system/matrix.service
|
367
|
|
- echo "ExecStart=/usr/bin/turnserver --daemon -c ${MATRIX_DATA_DIR}/turnserver.conf" >> /etc/systemd/system/matrix.service
|
368
|
331
|
echo "ExecStart=/usr/bin/python -m synapse.app.homeserver --config-path ${MATRIX_DATA_DIR}/homeserver.yaml" >> /etc/systemd/system/matrix.service
|
369
|
332
|
echo 'Restart=always' >> /etc/systemd/system/matrix.service
|
370
|
333
|
echo 'RestartSec=10' >> /etc/systemd/system/matrix.service
|
|
@@ -378,7 +341,6 @@ function install_matrix {
|
378
|
341
|
update_default_domain
|
379
|
342
|
|
380
|
343
|
firewall_add matrix ${MATRIX_PORT}
|
381
|
|
- firewall_add matrix-turn ${MATRIX_TURN_PORT}
|
382
|
344
|
|
383
|
345
|
MATRIX_ONION_HOSTNAME=$(add_onion_service matrix ${MATRIX_PORT} ${MATRIX_PORT})
|
384
|
346
|
if [ ! ${MATRIX_PASSWORD} ]; then
|