Debian Codegraph @

mtxclient/.ci/synapse/setup-synapse.sh

raw symbols SCIP
1 #!/bin/sh
2
3 set -e
4
5 export DEBIAN_FRONTEND=noninteractive
6
7 apt-get update && apt-get -y install --no-install-recommends runit postgresql openssl
8
9
10 mkdir /data2
11
12 mkdir /data2/db
13 chown postgres /data2/db
14
15 # Initialise & start the database
16 su -c '/usr/lib/postgresql/15/bin/initdb -D /data2/db -E "UTF-8" --lc-collate="C" --lc-ctype="C" --username=postgres' postgres
17 su -c '/usr/lib/postgresql/15/bin/pg_ctl -w -D /data2/db start' postgres
18 su -c '/usr/lib/postgresql/15/bin/createuser synapse_user' postgres
19 su -c '/usr/lib/postgresql/15/bin/createdb -O synapse_user synapse' postgres
20
21 sed -i 's,/data,/data2,g' /start.py
22
23 SYNAPSE_SERVER_NAME=synapse SYNAPSE_REPORT_STATS=no /start.py generate
24
25 openssl req -x509 -newkey rsa:4096 -keyout data2/synapse.tls.key -out data2/synapse.tls.crt -days 365 -subj '/CN=synapse' -nodes
26 chmod 0777 data2/synapse.tls.crt
27 chmod 0777 data2/synapse.tls.key
28
29 # yes, the empty line is needed
30 cat <<EOF >> /data2/homeserver.yaml
31 server_name: "synapse"
32 pid_file: /data2/homeserver.pid
33 listeners:
34 - port: 8008
35 tls: true
36 type: http
37 x_forwarded: true
38 resources:
39 - names: [client, federation]
40 compress: false
41 - port: 8009
42 tls: false
43 type: http
44 x_forwarded: true
45 resources:
46 - names: [client, federation]
47 compress: false
48 database:
49 name: psycopg2
50 args:
51 user: synapse_user
52 database: synapse
53 host: localhost
54 cp_min: 5
55 cp_max: 10
56 log_config: "/data2/synapse.log.config"
57 media_store_path: /data2/media_store
58 registration_shared_secret: "&=bz^dG2c34^NHZYMidt7crX~ZheXN0r1dV02uKapb9uxmktR:"
59 report_stats: false
60 macaroon_secret_key: "Ea#Ny0z,r=kv&2.H47au0QSsL&QDjpZqxYX0NcUe9EKsX~Eyrz"
61 form_secret: ";,kjZhkoUnRLbUq@H21PJcX#T+p&MuNi4O9qbH*gZk2+84ree+"
62 signing_key_path: "/data2/synapse.signing.key"
63 trusted_key_servers: []
64
65
66 enable_registration: true
67 enable_registration_without_verification: true
68
69 room_list_publication_rules:
70 - action: allow
71
72 tls_certificate_path: "/data2/synapse.tls.crt"
73 tls_private_key_path: "/data2/synapse.tls.key"
74
75 rc_message:
76 per_second: 10000
77 burst_count: 100000
78
79 rc_registration:
80 per_second: 10000
81 burst_count: 30000
82
83 rc_login:
84 address:
85 per_second: 10000
86 burst_count: 30000
87 account:
88 per_second: 10000
89 burst_count: 30000
90 failed_attempts:
91 per_second: 10000
92 burst_count: 30000
93
94 rc_admin_redaction:
95 per_second: 1000
96 burst_count: 5000
97
98 rc_joins:
99 local:
100 per_second: 10000
101 burst_count: 100000
102 remote:
103 per_second: 10000
104 burst_count: 100000
105
106 rc_presence:
107 per_user:
108 per_second: 10000
109 burst_count: 100000
110
111 experimental_features:
112 msc3266_enabled: true
113 EOF
114
115 # start synapse and create users
116 /start.py &
117
118 echo Waiting for synapse to start...
119 until curl -s -f -k https://localhost:8008/_matrix/client/versions; do echo "Checking ..."; sleep 2; done
120 echo Register alice
121 register_new_matrix_user --admin -u alice -p secret -c /data2/homeserver.yaml http://localhost:8009
122 echo Register bob
123 register_new_matrix_user --admin -u bob -p secret -c /data2/homeserver.yaml http://localhost:8009
124 echo Register carl
125 register_new_matrix_user --admin -u carl -p secret -c /data2/homeserver.yaml http://localhost:8009
126 echo Register presence
127 register_new_matrix_user --admin -u presence -p secret -c /data2/homeserver.yaml http://localhost:8009
128 echo Register presencesync
129 register_new_matrix_user --admin -u presencesync -p secret -c /data2/homeserver.yaml http://localhost:8009
130
131 exit 0
132