Support loading application service files from /data/appservices/

This commit is contained in:
kaiyou 2018-02-05 23:13:27 +01:00
parent 107a5c9441
commit 1ffd9cb936
3 changed files with 18 additions and 2 deletions

View File

@ -59,7 +59,12 @@ The image expects a single volume, located at ``/data``, that will hold:
* temporary files during uploads; * temporary files during uploads;
* uploaded media and thumbnails; * uploaded media and thumbnails;
* the SQLite database if you do not configure postgres. * the SQLite database if you do not configure postgres;
* the appservices configuration.
In order to setup an application service, simply create an ``appservices``
directory in the data volume and write the application service Yaml
configuration file there. Multiple application services are supported.
## Environment ## Environment

View File

@ -128,7 +128,7 @@ recaptcha_siteverify_api: "https://www.google.com/recaptcha/api/siteverify"
{% if SYNAPSE_TURN_URIS %} {% if SYNAPSE_TURN_URIS %}
turn_uris: turn_uris:
{% for uri in SYNAPSE_TURN_URIS.split(',') %} - {{ uri }} {% for uri in SYNAPSE_TURN_URIS.split(',') %} - "{{ uri }}"
{% endfor %} {% endfor %}
turn_shared_secret: "{{ SYNAPSE_TURN_SECRET }}" turn_shared_secret: "{{ SYNAPSE_TURN_SECRET }}"
turn_user_lifetime: "1h" turn_user_lifetime: "1h"
@ -167,7 +167,14 @@ room_invite_state_types:
- "m.room.avatar" - "m.room.avatar"
- "m.room.name" - "m.room.name"
{% if SYNAPSE_APPSERVICES %}
app_service_config_files:
{% for appservice in SYNAPSE_APPSERVICES %} - "{{ appservice }}"
{% endfor %}
{% else %}
app_service_config_files: [] app_service_config_files: []
{% endif %}
macaroon_secret_key: "{{ SYNAPSE_MACAROON_SECRET_KEY }}" macaroon_secret_key: "{{ SYNAPSE_MACAROON_SECRET_KEY }}"
expire_access_token: False expire_access_token: False

View File

@ -4,6 +4,7 @@ import jinja2
import os import os
import sys import sys
import subprocess import subprocess
import glob
convert = lambda src, dst, environ: open(dst, "w").write(jinja2.Template(open(src).read()).render(**environ)) convert = lambda src, dst, environ: open(dst, "w").write(jinja2.Template(open(src).read()).render(**environ))
mode = sys.argv[1] if len(sys.argv) > 1 else None mode = sys.argv[1] if len(sys.argv) > 1 else None
@ -26,6 +27,9 @@ for secret in ("SYNAPSE_REGISTRATION_SHARED_SECRET", "SYNAPSE_MACAROON_SECRET_KE
print("Generating a random secret for {}".format(secret)) print("Generating a random secret for {}".format(secret))
environ[secret] = os.urandom(32).encode("hex") environ[secret] = os.urandom(32).encode("hex")
# Load appservices configurations
environ["SYNAPSE_APPSERVICES"] = glob.glob("/data/appservices/*.yaml")
# In generate mode, generate a configuration, missing keys, then exit # In generate mode, generate a configuration, missing keys, then exit
if mode == "generate": if mode == "generate":
os.execv("/usr/local/bin/python", args + ["--generate-config"]) os.execv("/usr/local/bin/python", args + ["--generate-config"])