matrix-synapse-py3.postinst 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #!/bin/sh -e
  2. # shellcheck disable=SC1091
  3. . /usr/share/debconf/confmodule
  4. CONFIGFILE_SERVERNAME="/etc/matrix-synapse/conf.d/server_name.yaml"
  5. CONFIGFILE_REPORTSTATS="/etc/matrix-synapse/conf.d/report_stats.yaml"
  6. USER="matrix-synapse"
  7. case "$1" in
  8. configure|reconfigure)
  9. # generate template config files if they don't exist
  10. mkdir -p "/etc/matrix-synapse/conf.d/"
  11. if [ ! -e "$CONFIGFILE_SERVERNAME" ]; then
  12. cat > "$CONFIGFILE_SERVERNAME" <<EOF
  13. # This file is autogenerated, and will be recreated on upgrade if it is deleted.
  14. # Any changes you make will be preserved.
  15. # The domain name of the server, with optional explicit port.
  16. # This is used by remote servers to connect to this server,
  17. # e.g. matrix.org, localhost:8080, etc.
  18. # This is also the last part of your UserID.
  19. #
  20. server_name: ''
  21. EOF
  22. fi
  23. if [ ! -e "$CONFIGFILE_REPORTSTATS" ]; then
  24. cat > "$CONFIGFILE_REPORTSTATS" <<EOF
  25. # This file is autogenerated, and will be recreated on upgrade if it is deleted.
  26. # Any changes you make will be preserved.
  27. # Whether to report anonymized homeserver usage statistics.
  28. report_stats: false
  29. EOF
  30. fi
  31. # update the config files according to whatever is in the debconf database
  32. /opt/venvs/matrix-synapse/lib/manage_debconf.pl update
  33. if ! getent passwd $USER >/dev/null; then
  34. adduser --quiet --system --no-create-home --home /var/lib/matrix-synapse $USER
  35. fi
  36. for DIR in /var/lib/matrix-synapse /var/log/matrix-synapse /etc/matrix-synapse; do
  37. if ! dpkg-statoverride --list --quiet $DIR >/dev/null; then
  38. dpkg-statoverride --force --quiet --update --add $USER nogroup 0755 $DIR
  39. fi
  40. done
  41. ;;
  42. esac
  43. #DEBHELPER#
  44. exit 0