From 1624b8063c7a1a6f8930c0fd2bd0a0d8eb162566 Mon Sep 17 00:00:00 2001 From: default Date: Mon, 7 Mar 2022 10:28:07 +0000 Subject: [PATCH 1/2] [NEW] add options entry to pass to posgresql command line --- postgres/hooks/postgres_database-relation-joined | 13 +++++++++++-- postgres/lib/common | 3 ++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/postgres/hooks/postgres_database-relation-joined b/postgres/hooks/postgres_database-relation-joined index 5dfc31a..f8de1d0 100755 --- a/postgres/hooks/postgres_database-relation-joined +++ b/postgres/hooks/postgres_database-relation-joined @@ -22,6 +22,7 @@ USER=$(relation-get user) || { set -e + ## YYY: check that password was not already generated/set for the same user ## use session state storage. @@ -47,12 +48,20 @@ fi array_read-0 extensions < <(relation-get extensions 2>/dev/null | shyaml get-values-0) + ensure_db_docker_running ## XXXvlab: should send all these into only one docker... if ! db_has_database "$DBNAME"; then - db_create "$DBNAME" || exit 1 - + INITDB_ARGS=(encoding lc-collate lc-ctype template) + CREATEDB_OPTS=() + for option in "${INITDB_ARGS[@]}"; do + value="$(relation-get "$option" 2>/dev/null)" || true + if [ -n "$value" ]; then + CREATEDB_OPTS+=("--$option=$value") + fi + done + db_create "$DBNAME" "${CREATEDB_OPTS[@]}" || exit 1 if sql=$(relation-get init-sql); then ddb "$DBNAME" > /dev/null < <(e "$sql") || exit 1 fi diff --git a/postgres/lib/common b/postgres/lib/common index a6feb29..20947b2 100644 --- a/postgres/lib/common +++ b/postgres/lib/common @@ -63,7 +63,8 @@ db_drop () { db_create () { local dbname="$1" - dcmd createdb "$dbname" || return 1 + shift + dcmd createdb "$dbname" "$@" || return 1 info "Database '$dbname' created." } -- 2.30.2 From 1601a26c763012cb4d4ba26d4b5541f1115a5f91 Mon Sep 17 00:00:00 2001 From: default Date: Mon, 7 Mar 2022 10:30:16 +0000 Subject: [PATCH 2/2] [NEW] update synapse to latest version. --- synapse/hooks/init | 7 +++++++ synapse/lib/common | 25 ++++++++++++++----------- synapse/metadata.yml | 9 +++++++-- 3 files changed, 28 insertions(+), 13 deletions(-) diff --git a/synapse/hooks/init b/synapse/hooks/init index 53e5c9f..189e4a3 100755 --- a/synapse/hooks/init +++ b/synapse/hooks/init @@ -12,6 +12,13 @@ . lib/common + +#if ! [ -f "$HOST_CONFIG_FILE" ]; then +# cfg-init +#fi +#exit 17 + + # Please note that postgres detect on its own if its datadir needs to be populated service_def=$(get_compose_service_def "$SERVICE_NAME") || return 1 diff --git a/synapse/lib/common b/synapse/lib/common index ae3fb1a..4221452 100644 --- a/synapse/lib/common +++ b/synapse/lib/common @@ -19,21 +19,21 @@ yaml_opt_flatten() { CFG_DIR=/etc/synapse -DATA_DIR=/var/lib/synapse -CONFIG_FILE="$CFG_DIR/config.yml" -HOST_CONFIG_FILE="${SERVICE_CONFIGSTORE}$CONFIG_FILE" +DATA_DIR=/data +CONFIG_FILE="$DATA_DIR/homeserver.yaml" +HOST_CONFIG_FILE="${SERVICE_DATASTORE}$CONFIG_FILE" setup_dirs() { local dirs dir - dirs=("$SERVICE_DATASTORE/var/lib/synapse") - uid_gid=($(docker_get_uid_gid "$SERVICE_NAME" "synapse" "synapse")) || { + dirs=("$SERVICE_DATASTORE/data") + uid_gid=($(docker_get_uid_gid "$SERVICE_NAME" "root" "root")) || { err "Could not fetch uid/gid on image of service ${DARKYELLOW}$SERVICE_NAME${NORMAL}." return 1 } - uid="${uid_gid[0]}" - gid="${uid_gid[1]}" + uid="991" + gid="991" for dir in "${dirs[@]}"; do mkdir -p "$dir" find "$dir" \! -uid "$uid" -print0 | while read-0 f; do @@ -46,7 +46,8 @@ setup_dirs() { dirs=( "${SERVICE_CONFIGSTORE}/$CFG_DIR" - "${SERVICE_DATASTORE}/var/lib/synapse/keys" + "${SERVICE_DATASTORE}/$DATA_DIR/keys" + "${SERVICE_DATASTORE}/$DATA_DIR/media" ) for dir in "${dirs[@]}"; do mkdir -p "$dir" @@ -63,6 +64,8 @@ cfg-merge() { } + + cfg-base() { cat < "$HOST_CONFIG_FILE" @@ -72,7 +75,7 @@ cfg-base() { # pid_file: /var/run/synapse/synapse.pid web_client: False soft_file_limit: 0 -log_config: "$CFG_DIR/logging.yml" +log_config: "$DATA_DIR/logging.yml" ## Ports @@ -164,7 +167,7 @@ turn_user_lifetime: 1h trusted_third_party_id_servers: - matrix.org - vector.im - +suppress_key_server_warning: true ## Metrics enable_metrics: false @@ -206,7 +209,7 @@ app_service_config_files: [] EOF - cat < "$SERVICE_CONFIGSTORE$CFG_DIR"/logging.yml + cat < "$SERVICE_DATASTORE$DATA_DIR"/logging.yml version: 1 formatters: diff --git a/synapse/metadata.yml b/synapse/metadata.yml index c51366c..069a471 100644 --- a/synapse/metadata.yml +++ b/synapse/metadata.yml @@ -1,10 +1,10 @@ description: Synapse maintainer: "Valentin Lab " -docker-image: docker.0k.io/synapse:1.0 +docker-image: matrixdotorg/synapse:latest config-resources: - /etc/synapse data-resources: - - /var/lib/synapse + - /data host-resources: - /etc/localtime:ro @@ -33,6 +33,11 @@ uses: auto: summon solves: database: "main storage" + default-options: + encoding: UTF-8 + lc-collate: C + lc-ctype: C + template: template0 # log-rotate: # constraint: recommended # auto: pair -- 2.30.2