| 1 | #!/bin/shscip-shell filesystem . . `/bin/sh`. |
| 2 | |
| 3 | set -e |
| 4 | |
| 5 | export DEBIAN_FRONTEND=noninteractive |
| 6 | |
| 7 | apt-getscip-shell system . . apt-get. update && apt-getscip-shell system . . apt-get. -y install --no-install-recommends runit postgresql openssl |
| 8 | |
| 9 | |
| 10 | mkdirscip-shell system . . mkdir. /data2scip-shell filesystem . . `/data2`. |
| 11 | |
| 12 | mkdirscip-shell system . . mkdir. /data2/dbscip-shell filesystem . . `/data2/db`. |
| 13 | chownscip-shell system . . chown. postgres /data2/dbscip-shell filesystem . . `/data2/db`. |
| 14 | |
| 15 | # Initialise & start the database |
| 16 | suscip-shell system . . su. -c '/usr/lib/postgresql/15/bin/initdb -D /data2/db -E "UTF-8" --lc-collate="C" --lc-ctype="C" --username=postgresscip-shell filesystem . . `/usr/lib/postgresql/15/bin/initdb -D /data2/db -E "UTF-8" --lc-collate="C" --lc-ctype="C" --username=postgres`.' postgres |
| 17 | suscip-shell system . . su. -c '/usr/lib/postgresql/15/bin/pg_ctl -w -D /data2/db startscip-shell filesystem . . `/usr/lib/postgresql/15/bin/pg_ctl -w -D /data2/db start`.' postgres |
| 18 | suscip-shell system . . su. -c '/usr/lib/postgresql/15/bin/createuser synapse_userscip-shell filesystem . . `/usr/lib/postgresql/15/bin/createuser synapse_user`.' postgres |
| 19 | suscip-shell system . . su. -c '/usr/lib/postgresql/15/bin/createdb -O synapse_user synapsescip-shell filesystem . . `/usr/lib/postgresql/15/bin/createdb -O synapse_user synapse`.' postgres |
| 20 | |
| 21 | sedscip-shell system . . sed. -i 's,/data,/data2,g' /start.pyscip-shell filesystem . . `/start.py`. |
| 22 | |
| 23 | SYNAPSE_SERVER_NAME=synapse SYNAPSE_REPORT_STATS=no /start.pyscip-shell filesystem . . `/start.py`. generate |
| 24 | |
| 25 | opensslscip-shell system . . openssl. req -x509 -newkey rsa:4096 -keyout data2/synapse.tls.key -out data2/synapse.tls.crt -days 365 -subj '/CN=synapsescip-shell filesystem . . `/CN=synapse`.' -nodes |
| 26 | chmodscip-shell system . . chmod. 0777 data2/synapse.tls.crt |
| 27 | chmodscip-shell system . . chmod. 0777 data2/synapse.tls.key |
| 28 | |
| 29 | # yes, the empty line is needed |
| 30 | catscip-shell system . . cat. <<EOF >> /data2/homeserver.yamlscip-shell filesystem . . `/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.pyscip-shell filesystem . . `/start.py`. & |
| 117 | |
| 118 | echoscip-shell system . . echo. Waiting for synapse to start... |
| 119 | until curlscip-shell system . . curl. -s -f -k https://localhost:8008/_matrix/client/versions; do echoscip-shell system . . echo. "Checking ..."; sleepscip-shell system . . sleep. 2; done |
| 120 | echoscip-shell system . . echo. Register alice |
| 121 | register_new_matrix_user --admin -u alice -p secret -c /data2/homeserver.yamlscip-shell filesystem . . `/data2/homeserver.yaml`. http://localhost:8009 |
| 122 | echoscip-shell system . . echo. Register bob |
| 123 | register_new_matrix_user --admin -u bob -p secret -c /data2/homeserver.yamlscip-shell filesystem . . `/data2/homeserver.yaml`. http://localhost:8009 |
| 124 | echoscip-shell system . . echo. Register carl |
| 125 | register_new_matrix_user --admin -u carl -p secret -c /data2/homeserver.yamlscip-shell filesystem . . `/data2/homeserver.yaml`. http://localhost:8009 |
| 126 | echoscip-shell system . . echo. Register presence |
| 127 | register_new_matrix_user --admin -u presence -p secret -c /data2/homeserver.yamlscip-shell filesystem . . `/data2/homeserver.yaml`. http://localhost:8009 |
| 128 | echoscip-shell system . . echo. Register presencesync |
| 129 | register_new_matrix_user --admin -u presencesync -p secret -c /data2/homeserver.yamlscip-shell filesystem . . `/data2/homeserver.yaml`. http://localhost:8009 |
| 130 | |
| 131 | exit 0 |
| 132 |