This repository has been archived by the owner on Oct 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
/
matrix-synapse.sh
executable file
·78 lines (66 loc) · 1.92 KB
/
matrix-synapse.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
72
73
74
75
76
77
78
#!/bin/sh -eu
APP="synapse.app.homeserver"
ARGS=""
GEN=""
case "${1:-start}" in
# HS
start|serve|synapse.app.homeserver)
[ $# -gt 0 ] && shift
;;
# Worker
synapse.* )
APP="$1"
shift
if [ $# -lt 2 ]; then
echo "You need to specify at least \`-c /worker-config.yaml\` if trying to run a worker"
echo
echo "More information can be found on https://github.com/matrix-org/synapse/blob/master/docs/workers.md"
exit 1
fi
;;
*)
exec "$@"
;;
esac
if [ ! -f /synapse/config/homeserver.yaml ] && [ -z "$GEN" ]; then
echo "Missing /synapse/config/homeserver.yaml, you need to generate and supply a configuration before you can run the homeserver."
exit 1
fi
# XXX: Might be suitable to read all config from tmp path, for envvar support on read-only root
if [ ! -e /synapse/config/log.yaml ]; then
if touch /synapse/config/log.yaml 2>/dev/null; then
(
set +eu
cp /synapse/log.yaml /synapse/config/log.yaml || true
)
else
echo "Warning, no log config was specified, and the init script is not allowed to write one."
echo "You should manually insert the log config into your config folder;"
echo
cat /synapse/log.yaml
echo
fi
fi
if [ $(id -u) -eq 0 ]; then
# TODO: Avoid doing this on every boot as well
echo "Running as root, ensuring file ownership..."
(
set +eu
chown -R synapse:synapse /synapse/config /synapse/keys /synapse/tls || true
chown -R synapse:synapse /synapse/data &
) > /dev/null 2>&1
fi
if [ -n "${USE_JEMALLOC:-}" ]; then
export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libjemalloc.so.2
fi
if [ -d '/synapse/config/conf.d' ]; then
ARGS="-c /synapse/config/conf.d $ARGS"
fi
command_str="python"
args_str="-B -m $APP -c /synapse/config/homeserver.yaml $ARGS $*"
echo "> $command_str $args_str"
if [ $(id -u) -eq 0 ]; then
exec su synapse -s /bin/sh -c "$command_str $args_str"
else
exec $command_str $args_str
fi