|
|
@ -17,27 +17,52 @@ |
|
|
|
service_def=$(get_compose_service_def "$SERVICE_NAME") || return 1 |
|
|
|
options="$(e "$service_def" | shyaml -y get-value options)" || true |
|
|
|
|
|
|
|
|
|
|
|
SYNAPSE_OPTIONS=( |
|
|
|
|
|
|
|
server-name:string ## The server name |
|
|
|
report-stats:bool ## Enable anon stat reporting back to the Matrix project |
|
|
|
enable-registration:bool ## Enable registration on the Synapse instance. |
|
|
|
allow-guest:bool ## allow guest joining this server. |
|
|
|
event-cache-size:size ## event cache size [default 10K]. |
|
|
|
max-upload-size:size ## max upload size [default 10M]. |
|
|
|
server_name:string ## The server name |
|
|
|
|
|
|
|
report_stats:bool ## Enable anon stat reporting back to the Matrix project |
|
|
|
enable_registration:bool ## Enable registration on the Synapse instance. |
|
|
|
allow_guest_access:bool ## allow guest joining this server. |
|
|
|
event_cache_size:size ## event cache size [default 10K]. |
|
|
|
max_upload_size:size ## max upload size [default 10M]. |
|
|
|
|
|
|
|
## shared secrets |
|
|
|
registration-shared-secret:string ## registrering users if registration is disable. |
|
|
|
macaroon-secret-key:string ## secret for signing access tokens to the server. |
|
|
|
registration_shared_secret:string ## registrering users if registration is disable. |
|
|
|
macaroon_secret_key:string ## secret for signing access tokens to the server. |
|
|
|
|
|
|
|
## recaptcha |
|
|
|
recaptcha-public-key:string ## required in order to enable recaptcha upon registration |
|
|
|
recaptcha-private-key:string ## required in order to enable recaptcha upon registration |
|
|
|
recaptcha_public_key:string ## required to have recaptcha upon registration |
|
|
|
recaptcha_private_key:string ## required to have recaptcha upon registration |
|
|
|
enable_registration_captcha:bool ## required to have recaptcha upon registration |
|
|
|
recaptcha_siteverify_api:string |
|
|
|
|
|
|
|
## others |
|
|
|
soft_file_limit:numeric |
|
|
|
rc_messages_per_second:float |
|
|
|
rc_message_burst_count:float |
|
|
|
federation_rc_window_size:numeric |
|
|
|
federation_rc_sleep_limit:numeric |
|
|
|
federation_rc_sleep_delay:numeric |
|
|
|
federation_rc_reject_limit:numeric |
|
|
|
federation_rc_concurrent:numeric |
|
|
|
max_image_pixels:size |
|
|
|
dynamic_thumbnails:bool |
|
|
|
url_preview_enabled:bool |
|
|
|
max_spider_size:size |
|
|
|
bcrypt_rounds:numeric |
|
|
|
enable_group_creation:bool |
|
|
|
trusted_third_party_id_servers:sequence |
|
|
|
enable_metrics:bool |
|
|
|
room_invite_state_types:sequence |
|
|
|
expire_access_token:bool |
|
|
|
key_refresh_interval:string |
|
|
|
perspectives:struct |
|
|
|
password_config:struct |
|
|
|
|
|
|
|
## NOT SUPPORTED YET |
|
|
|
#thumbnail_sizes |
|
|
|
|
|
|
|
## turn |
|
|
|
turn-uris:string ## coma-separated list of TURN uris to enable TURN for this homeserver. |
|
|
|
turn-secret:string ## TURN shared secret if required. |
|
|
|
) |
|
|
|
|
|
|
|
OPTIONS_CONCAT=" ${SYNAPSE_OPTIONS[*]} " |
|
|
@ -64,6 +89,23 @@ while read-0 key val; do |
|
|
|
die "Invalid value for ${WHITE}$key$NORMAL, please use numeric value." |
|
|
|
fi |
|
|
|
;; |
|
|
|
*" ${key_option}:float "*) |
|
|
|
if ! is_float "$val"; then |
|
|
|
die "Invalid value for ${WHITE}$key$NORMAL, please use float value." |
|
|
|
fi |
|
|
|
;; |
|
|
|
*" ${key_option}:struct "*) |
|
|
|
val_type=$(e "$val" | shyaml get-type) || return 1 |
|
|
|
if [ "$val_type" != "struct" ]; then |
|
|
|
die "Invalid value for ${WHITE}$key$NORMAL, please use struct value." |
|
|
|
fi |
|
|
|
;; |
|
|
|
*" ${key_option}:sequence "*) |
|
|
|
val_type=$(e "$val" | shyaml get-type) || return 1 |
|
|
|
if [ "$val_type" != "sequence" ]; then |
|
|
|
die "Invalid value for ${WHITE}$key$NORMAL, please use sequence value." |
|
|
|
fi |
|
|
|
;; |
|
|
|
*" ${key_option}:string "*) |
|
|
|
: |
|
|
|
;; |
|
|
@ -80,17 +122,86 @@ while read-0 key val; do |
|
|
|
;; |
|
|
|
esac |
|
|
|
yaml_opts+=("$key" "$val") |
|
|
|
done < <(e "$options" | yaml_opt_flatten) |
|
|
|
done < <(e "$options" | shyaml key-values-0) |
|
|
|
|
|
|
|
|
|
|
|
setup_dirs || exit 1 |
|
|
|
cfg-base || exit 1 |
|
|
|
cfg-merge "$options" || exit 1 |
|
|
|
|
|
|
|
|
|
|
|
HOST_KEY_DIR=$SERVICE_DATASTORE$DATA_DIR/keys |
|
|
|
for name_secret in registration_shared_secret macaroon_secret_key; do |
|
|
|
secret=$(e "$options" | shyaml -q get-value "$name_secret") || true |
|
|
|
if [ "$secret" == "None" ]; then |
|
|
|
secret="" |
|
|
|
fi |
|
|
|
|
|
|
|
coming_from_file= |
|
|
|
key_file="$HOST_KEY_DIR/${name_secret}.key" |
|
|
|
if [ -z "$secret" ]; then |
|
|
|
if [ -e "$key_file" ]; then |
|
|
|
secret="$(cat "$key_file")" |
|
|
|
coming_from_file=true |
|
|
|
else |
|
|
|
secret="$(gen_password 64)" |
|
|
|
fi |
|
|
|
cfg-merge "${name_secret}: \"$secret\"" || exit 1 |
|
|
|
fi |
|
|
|
|
|
|
|
if [ -z "$coming_from_file" ]; then |
|
|
|
e "$secret" > "$key_file" |
|
|
|
chown -v "$uid:$gid" "$key_file" && |
|
|
|
chmod -v 600 "$key_file" || exit 1 |
|
|
|
fi |
|
|
|
done |
|
|
|
|
|
|
|
|
|
|
|
## XXXvlab: what to do with appservices ? |
|
|
|
# environ["SYNAPSE_APPSERVICES"] = glob.glob("/data/appservices/*.yaml") |
|
|
|
# {% if SYNAPSE_APPSERVICES %} |
|
|
|
# app_service_config_files: |
|
|
|
# {% for appservice in SYNAPSE_APPSERVICES %} - "{{ appservice }}" |
|
|
|
# {% endfor %} |
|
|
|
# {% else %} |
|
|
|
# app_service_config_files: [] |
|
|
|
# {% endif %} |
|
|
|
|
|
|
|
# ## Turn ## |
|
|
|
|
|
|
|
# {% if SYNAPSE_TURN_URIS %} |
|
|
|
# turn_uris: |
|
|
|
# {% for uri in SYNAPSE_TURN_URIS.split(',') %} - "{{ uri }}" |
|
|
|
# {% endfor %} |
|
|
|
# turn_shared_secret: "{{ SYNAPSE_TURN_SECRET }}" |
|
|
|
# turn_user_lifetime: "1h" |
|
|
|
# turn_allow_guests: True |
|
|
|
# {% else %} |
|
|
|
# turn_uris: [] |
|
|
|
# turn_shared_secret: "YOUR_SHARED_SECRET" |
|
|
|
# turn_user_lifetime: "1h" |
|
|
|
# turn_allow_guests: True |
|
|
|
# {% endif %} |
|
|
|
|
|
|
|
## XXXvlab: for SMTP relation |
|
|
|
# {% if SYNAPSE_SMTP_HOST %} |
|
|
|
# email: |
|
|
|
# enable_notifs: false |
|
|
|
# smtp_host: "{{ SYNAPSE_SMTP_HOST }}" |
|
|
|
# smtp_port: {{ SYNAPSE_SMTP_PORT or "25" }} |
|
|
|
# smtp_user: "{{ SYNAPSE_SMTP_USER }}" |
|
|
|
# smtp_pass: "{{ SYNAPSE_SMTP_PASSWORD }}" |
|
|
|
# require_transport_security: False |
|
|
|
# notif_from: "{{ SYNAPSE_SMTP_FROM or "hostmaster@" + SYNAPSE_SERVER_NAME }}" |
|
|
|
# app_name: Matrix |
|
|
|
# # if template_dir is unset, uses the example templates that are part of |
|
|
|
# # the Synapse distribution. |
|
|
|
# #template_dir: res/templates |
|
|
|
# notif_template_html: notif_mail.html |
|
|
|
# notif_template_text: notif_mail.txt |
|
|
|
# notif_for_new_users: True |
|
|
|
# riot_base_url: "https://{{ SYNAPSE_SERVER_NAME }}" |
|
|
|
# {% endif %} |
|
|
|
|
|
|
|
config="\ |
|
|
|
$SERVICE_NAME: |
|
|
|
environment: |
|
|
|
SYNAPSE_NO_TLS: \"yes\" |
|
|
|
" |
|
|
|
|
|
|
|
while read-0 key value; do |
|
|
|
key=${key//-/_} |
|
|
|
config+="$(printf "\n SYNAPSE_%s: %s" "${key^^}" "$value")" |
|
|
|
done < <(array_values_to_stdin yaml_opts) |
|
|
|
|
|
|
|
init-config-add "$config" |