set server_name at install time

This commit is contained in:
Girish Ramakrishnan
2020-04-08 19:14:47 -07:00
parent 9465099b08
commit 349bbfd452

View File

@@ -7,8 +7,11 @@ mkdir -p /app/data/data /app/data/configs /run/synapse
if [[ ! -f /app/data/configs/homeserver.yaml ]]; then if [[ ! -f /app/data/configs/homeserver.yaml ]]; then
echo "==> Detected first run" echo "==> Detected first run"
# this is set at installation time and not changed after
server_name=$(python -c "from publicsuffix2 import get_sld; print(get_sld('${CLOUDRON_APP_DOMAIN}'));")
python3 -m synapse.app.homeserver \ python3 -m synapse.app.homeserver \
--server-name ${CLOUDRON_APP_DOMAIN} \ --server-name ${server_name} \
--config-path /app/data/configs/homeserver.yaml \ --config-path /app/data/configs/homeserver.yaml \
--config-directory /app/data/configs \ --config-directory /app/data/configs \
--data-directory /app/data/data \ --data-directory /app/data/data \
@@ -17,16 +20,13 @@ if [[ ! -f /app/data/configs/homeserver.yaml ]]; then
# fix logging configuration # fix logging configuration
cp /app/pkg/homeserver.yaml.template /app/data/configs/homeserver.yaml cp /app/pkg/homeserver.yaml.template /app/data/configs/homeserver.yaml
mv /app/data/configs/${CLOUDRON_APP_DOMAIN}.log.config /app/data/configs/log.config mv /app/data/configs/${server_name}.log.config /app/data/configs/log.config
yq w -i /app/data/configs/homeserver.yaml log_config /app/data/configs/log.config yq w -i /app/data/configs/homeserver.yaml log_config /app/data/configs/log.config
yq w -i /app/data/configs/log.config handlers.file.filename /run/synapse/homeserver.log yq w -i /app/data/configs/log.config handlers.file.filename /run/synapse/homeserver.log
mv /app/data/configs/${CLOUDRON_APP_DOMAIN}.signing.key /app/data/configs/signing.key mv /app/data/configs/${server_name}.signing.key /app/data/configs/signing.key
# this is set at installation time and not changed after
server_name=$(python -c "from publicsuffix2 import get_sld; print(get_sld('${CLOUDRON_APP_DOMAIN}'));")
yq w -i /app/data/configs/homeserver.yaml server_name "${CLOUDRON_APP_DOMAIN}"
yq w -i /app/data/configs/homeserver.yaml server_name "${server_name}"
yq w -i /app/data/configs/homeserver.yaml registration_shared_secret "$(pwgen -1s 64)" yq w -i /app/data/configs/homeserver.yaml registration_shared_secret "$(pwgen -1s 64)"
fi fi