forked from silvio/docker-matrix
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathjobs.sh
executable file
·72 lines (64 loc) · 2.34 KB
/
jobs.sh
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
#!/usr/bin/env bash
OPTION="${1}"
if [ ! -z "${ROOTPATH}" ]; then
echo ":: We have changed the semantic and doesn't need the ROOTPATH"
echo ":: variable anymore"
fi
case $OPTION in
"start")
echo "-=> start matrix"
python -m synapse.app.homeserver \
--config-path /data/homeserver.yaml \
;;
"stop")
echo "-=> stop matrix"
echo "-=> via docker stop ..."
;;
"version")
VERSION=$(tail -n 1 /synapse.version)
echo "-=> Matrix Version: ${VERSION}"
;;
"migrate")
synapse_port_db \
--sqlite-database /data/homeserver.db \
--postgres-config /data/homeserver.yaml \
--curses
;;
"generate")
breakup="0"
[[ -z "${SERVER_NAME}" ]] && echo "STOP! environment variable SERVER_NAME must be set" && breakup="1"
[[ -z "${REPORT_STATS}" ]] && echo "STOP! environment variable REPORT_STATS must be set to 'no' or 'yes'" && breakup="1"
[[ "${breakup}" == "1" ]] && exit 1
[[ "${REPORT_STATS}" != "yes" ]] && [[ "${REPORT_STATS}" != "no" ]] && \
echo "STOP! REPORT_STATS needs to be 'no' or 'yes'" && breakup="1"
echo "-=> generate synapse config"
python -m synapse.app.homeserver \
--config-path /data/homeserver.yaml \
--generate-config \
--report-stats ${REPORT_STATS} \
--server-name ${SERVER_NAME}
export TURNKEY=$(</data/TURNKEY)
echo "-=> configure some settings in homeserver.yaml"
awk -v SERVER_NAME="${SERVERNAME}" \
-v TURNURIES="turn_uris: [\"turn:${SERVER_NAME}:3478?transport=udp\", \"turn:${SERVER_NAME}:3478?transport=tcp\"]" \
-v TURNSHAREDSECRET="turn_shared_secret: \"${TURNKEY}\"" \
-v PIDFILE="pid_file: /data/homeserver.pid" \
-v DATABASE="database: \"/data/homeserver.db\"" \
-v LOGFILE="log_file: \"/data/homeserver.log\"" \
-v MEDIASTORE="media_store_path: \"/data/media_store\"" \
'{
sub(/turn_shared_secret: "YOUR_SHARED_SECRET"/, TURNSHAREDSECRET);
sub(/turn_uris: \[\]/, TURNURIES);
sub(/pid_file: \/homeserver.pid/, PIDFILE);
sub(/database: "\/homeserver.db"/, DATABASE);
sub(/log_file: "\/homeserver.log"/, LOGFILE);
sub(/media_store_path: "\/media_store"/, MEDIASTORE);
print;
}' /data/homeserver.yaml > /data/homeserver.tmp
mv /data/homeserver.tmp /data/homeserver.yaml
echo "-=> you can now review the generated configuration file homeserver.yaml"
;;
*)
echo "-=> unknown \'$OPTION\'"
;;
esac