#!/bin/bash DATA_DIR="/var/lib/synapse" ask_report_stats() { cat <<-EOF :: Please opt in or out of reporting anonymized homeserver usage statistics, by setting the report_stats key in your config file (/etc/synapse/homeserver.yaml) to either True or False. We would really appreciate it if you could help our project out by reporting anonymized usage statistics from your homeserver. Only very basic aggregate data (e.g. number of users) will be reported, but it helps us to track the growth of the Matrix community, and helps us to make Matrix a success, as well as to convince other networks that they should peer with us. Thank you. :: Note that the homeserver won't start unless you make the choice. EOF } post_upgrade() { systemctl daemon-reload if (( $(vercmp "$2" "0.10.1.rc1-3") < 0 )); then ask_report_stats fi } ## arg 1: the new package version post_install() { systemd-sysusers /usr/lib/sysusers.d/synapse.conf systemctl daemon-reload if [[ ! -e /etc/synapse/homeserver.yaml ]]; then cat <<-EOF :: A sample configuration file will be created in /etc/synapse/homeserver.yaml, using /var/lib/synapse as the data directory and localhost:8448 as server name and port. Customize it as necessary or regenerate with the following command: python2.7 -m synapse.app.homeserver --config-path <...> --generate-config (pass --help to see other options). EOF install -dm700 -o synapse -g synapse "$DATA_DIR" cd "$DATA_DIR" # we pass --report-stats just to make it generate the config python2.7 \ -m synapse.app.homeserver \ --config-path /etc/synapse/homeserver.yaml \ --generate-config \ --server-name localhost \ --bind-port 8448 \ --report-stats=no # let user make the choice sed -re 's|^(report_stats:.*)$|#&|' \ -i /etc/synapse/homeserver.yaml echo ask_report_stats fi }