diff --git a/start.sh b/start.sh index d240b61..238f2de 100755 --- a/start.sh +++ b/start.sh @@ -16,63 +16,64 @@ if [[ ! -f /app/data/configs/homeserver.yaml ]]; then --config-directory /app/data/configs \ --data-directory /app/data/data \ --generate-config \ - --report-stats=no + --report-stats=no # fix logging configuration cp /app/pkg/homeserver.yaml.template /app/data/configs/homeserver.yaml 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/log.config handlers.file.filename /run/synapse/homeserver.log + yq eval -i ".log_config=\"/app/data/configs/log.config\"" /app/data/configs/homeserver.yaml + yq eval -i ".handlers.file.filename=\"/run/synapse/homeserver.log\"" /app/data/configs/log.config mv /app/data/configs/${server_name}.signing.key /app/data/configs/signing.key - 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 eval -i ".server_name=\"${server_name}\"" /app/data/configs/homeserver.yaml + yq eval -i ".registration_shared_secret=\"$(pwgen -1s 64)\"" /app/data/configs/homeserver.yaml - yq w -i /app/data/configs/homeserver.yaml auto_join_rooms "[]" - yq w -i /app/data/configs/homeserver.yaml auto_join_rooms\[0\] "#discuss:${server_name}" + yq eval -i ".auto_join_rooms=[]" /app/data/configs/homeserver.yaml + yq eval -i ".auto_join_rooms[0]=\"#discuss:${server_name}\"" /app/data/configs/homeserver.yaml if [[ -z "${CLOUDRON_LDAP_SERVER:-}" ]]; then - yq w -i /app/data/configs/homeserver.yaml enable_registration true - yq w -i /app/data/configs/homeserver.yaml password_config.pepper "$(pwgen -1s 12)" + yq eval -i ".enable_registration=true" /app/data/configs/homeserver.yaml + yq eval -i ".password_config.pepper=\"$(pwgen -1s 12)\"" /app/data/configs/homeserver.yaml fi fi [[ ! -f /app/data/index.html ]] && cp /app/pkg/index.html /app/data/index.html echo "==> Configuring synapse" -yq w -i /app/data/configs/homeserver.yaml public_baseurl "${CLOUDRON_APP_ORIGIN}" +yq eval -i ".public_baseurl=\"${CLOUDRON_APP_ORIGIN}\"" /app/data/configs/homeserver.yaml # database -yq w -i /app/data/configs/homeserver.yaml database.args.user "${CLOUDRON_POSTGRESQL_USERNAME}" -yq w -i /app/data/configs/homeserver.yaml database.args.password "${CLOUDRON_POSTGRESQL_PASSWORD}" -yq w -i /app/data/configs/homeserver.yaml database.args.database "${CLOUDRON_POSTGRESQL_DATABASE}" -yq w -i /app/data/configs/homeserver.yaml database.args.host "${CLOUDRON_POSTGRESQL_HOST}" +yq eval -i ".database.args.user=\"${CLOUDRON_POSTGRESQL_USERNAME}\"" /app/data/configs/homeserver.yaml +yq eval -i ".database.args.password=\"${CLOUDRON_POSTGRESQL_PASSWORD}\"" /app/data/configs/homeserver.yaml +yq eval -i ".database.args.database=\"${CLOUDRON_POSTGRESQL_DATABASE}\"" /app/data/configs/homeserver.yaml +yq eval -i ".database.args.host=\"${CLOUDRON_POSTGRESQL_HOST}\"" /app/data/configs/homeserver.yaml # email -yq w -i /app/data/configs/homeserver.yaml email.smtp_host "${CLOUDRON_MAIL_SMTP_SERVER}" -yq w -i /app/data/configs/homeserver.yaml email.smtp_port "${CLOUDRON_MAIL_SMTP_PORT}" -yq w -i /app/data/configs/homeserver.yaml email.smtp_user "${CLOUDRON_MAIL_SMTP_USERNAME}" -yq w -i /app/data/configs/homeserver.yaml email.smtp_pass "${CLOUDRON_MAIL_SMTP_PASSWORD}" -yq w -i /app/data/configs/homeserver.yaml email.notif_from "%(app)s <${CLOUDRON_MAIL_FROM}>" +yq eval -i ".email.smtp_host=\"${CLOUDRON_MAIL_SMTP_SERVER}\"" /app/data/configs/homeserver.yaml +yq eval -i ".email.smtp_port=${CLOUDRON_MAIL_SMTP_PORT}" /app/data/configs/homeserver.yaml +yq eval -i ".email.smtp_user=\"${CLOUDRON_MAIL_SMTP_USERNAME}\"" /app/data/configs/homeserver.yaml +yq eval -i ".email.smtp_pass=\"${CLOUDRON_MAIL_SMTP_PASSWORD}\"" /app/data/configs/homeserver.yaml +yq eval -i ".email.notif_from=\"%(app)s <${CLOUDRON_MAIL_FROM}>\"" /app/data/configs/homeserver.yaml # ldap if [[ -n "${CLOUDRON_LDAP_SERVER:-}" ]]; then - yq w -i /app/data/configs/homeserver.yaml 'password_providers[0].config.uri' "${CLOUDRON_LDAP_URL}" - yq w -i /app/data/configs/homeserver.yaml 'password_providers[0].config.start_tls' false - yq w -i /app/data/configs/homeserver.yaml 'password_providers[0].config.base' "${CLOUDRON_LDAP_USERS_BASE_DN}" - yq w -i /app/data/configs/homeserver.yaml 'password_providers[0].config.bind_dn' "${CLOUDRON_LDAP_BIND_DN}" - yq w -i /app/data/configs/homeserver.yaml 'password_providers[0].config.bind_password' "${CLOUDRON_LDAP_BIND_PASSWORD}" - yq w -i /app/data/configs/homeserver.yaml 'password_providers[0].config.filter' "(objectClass=user)" + yq eval -i ".password_providers[0].config.uri=\"${CLOUDRON_LDAP_URL}\"" /app/data/configs/homeserver.yaml + yq eval -i ".password_providers[0].config.start_tls=false" /app/data/configs/homeserver.yaml + yq eval -i ".password_providers[0].config.base=\"${CLOUDRON_LDAP_USERS_BASE_DN}\"" /app/data/configs/homeserver.yaml + yq eval -i ".password_providers[0].config.bind_dn=\"${CLOUDRON_LDAP_BIND_DN}\"" /app/data/configs/homeserver.yaml + yq eval -i ".password_providers[0].config.bind_password=\"${CLOUDRON_LDAP_BIND_PASSWORD}\"" /app/data/configs/homeserver.yaml + yq eval -i ".password_providers[0].config.filter=\"(objectClass=user)\"" /app/data/configs/homeserver.yaml + else - yq w -i /app/data/configs/homeserver.yaml password_config.localdb_enabled true + yq eval -i ".password_config.localdb_enabled=true" /app/data/configs/homeserver.yaml fi # turn (https://github.com/matrix-org/synapse/blob/master/docs/turn-howto.md#synapse-setup) -yq w -i /app/data/configs/homeserver.yaml turn_uris "[]" -yq w -i /app/data/configs/homeserver.yaml turn_uris\[0\] "turn:${CLOUDRON_TURN_SERVER}:${CLOUDRON_TURN_TLS_PORT}?transport=udp" -yq w -i /app/data/configs/homeserver.yaml turn_uris\[1\] "turn:${CLOUDRON_TURN_SERVER}:${CLOUDRON_TURN_TLS_PORT}?transport=tcp" -yq w -i /app/data/configs/homeserver.yaml turn_shared_secret "${CLOUDRON_TURN_SECRET}" +yq eval -i ".turn_uris=[]" /app/data/configs/homeserver.yaml +yq eval -i ".turn_uris[0]=\"turn:${CLOUDRON_TURN_SERVER}:${CLOUDRON_TURN_TLS_PORT}?transport=udp\"" /app/data/configs/homeserver.yaml +yq eval -i ".turn_uris[1]=\"turn:${CLOUDRON_TURN_SERVER}:${CLOUDRON_TURN_TLS_PORT}?transport=tcp\"" /app/data/configs/homeserver.yaml +yq eval -i ".turn_shared_secret=\"${CLOUDRON_TURN_SECRET}\"" /app/data/configs/homeserver.yaml # fix permissions echo "==> Fixing permissions"