Moving around DB credentials and dumps

This commit is contained in:
Miguel Gagliardo 2024-04-10 18:05:17 +01:00
parent 9c6de75189
commit 969187d956
1 changed files with 8 additions and 9 deletions

View File

@ -86,9 +86,15 @@ echo -e "Create docker network\n"
docker network create --driver=bridge --subnet=10.10.10.0/24 --gateway=10.10.10.1 matrix_server docker network create --driver=bridge --subnet=10.10.10.0/24 --gateway=10.10.10.1 matrix_server
# Randomly pick a DB password
PG_PASS=$(pwgen -s 28 -1)
# Replace PG_PASS Password and DOMAIN in docker compose YAML
sed -i "s|DOMAIN|${DOMAIN}|g" "${BASE_DIR}/docker-compose.yaml"
sed -i "s|PG_PASS|${PG_PASS}|g" "${BASE_DIR}/docker-compose.yaml"
# Generate synapse file # Generate synapse file
echo -e "Generating synapse file..\n" echo -e "Generating synapse file..\n"
docker compose run --rm -e SYNAPSE_SERVER_NAME=${DOMAIN} -e SYNAPSE_REPORT_STATS=yes synapse generate docker compose run --rm -e SYNAPSE_SERVER_NAME=${DOMAIN} -e SYNAPSE_REPORT_STATS=yes synapse generate
# Replace DB config in Synapse's homeserver.yaml # Replace DB config in Synapse's homeserver.yaml
@ -113,18 +119,12 @@ turn_allow_guests: False
turn_user_lifetime: 86400000 turn_user_lifetime: 86400000
turn_shared_secret: "${TURN_STATIC_SECRET}" turn_shared_secret: "${TURN_STATIC_SECRET}"
turn_uris: [ "turn:${DOMAIN}?transport=udp" ] turn_uris: [ "turn:${DOMAIN}?transport=udp" ]
suppress_key_server_warning: true
EOF EOF
# Randomly pick a DB password
PG_PASS=$(pwgen -s 28 -1)
# Replace Password in homeserver.yaml # Replace Password in homeserver.yaml
sed -i "s|PG_PASS|${PG_PASS}|g" "${BASE_DIR}/config/synapse/homeserver.yaml" sed -i "s|PG_PASS|${PG_PASS}|g" "${BASE_DIR}/config/synapse/homeserver.yaml"
# Replace PG_PASS Password and DOMAIN in docker compose YAML
sed -i "s|DOMAIN|${DOMAIN}|g" "${BASE_DIR}/docker-compose.yaml"
sed -i "s|PG_PASS|${PG_PASS}|g" "${BASE_DIR}/docker-compose.yaml"
# Replace Sliding Sync key # Replace Sliding Sync key
SLIDING_SYNC_KEY=$(openssl rand -hex 32) SLIDING_SYNC_KEY=$(openssl rand -hex 32)
sed -i "s|SLIDING_SYNC_KEY|${SLIDING_SYNC_KEY}|g" "${BASE_DIR}/docker-compose.yaml" sed -i "s|SLIDING_SYNC_KEY|${SLIDING_SYNC_KEY}|g" "${BASE_DIR}/docker-compose.yaml"
@ -226,5 +226,4 @@ systemctl enable --now coturn
# Finally, start services # Finally, start services
# Ensuring the DB dir is clean before bootstrapping # Ensuring the DB dir is clean before bootstrapping
rm -rf ${BASE_DIR}/db/*
systemctl enable --now matrix.service systemctl enable --now matrix.service