Split config into a Debian and local part

* The Debian part will be generated and managed by Debconf and configure
  homeserver name, address and port
* The local part will just be a config file that shows the other
  configuration options

Added the address configuration and moved the config generation
from the config to the postinst script.
This commit is contained in:
Paul van Tilburg 2020-11-13 20:35:22 +01:00
parent 79692db45d
commit f72554de10
No known key found for this signature in database
GPG key ID: C6DE073EDA9EEC4D
7 changed files with 98 additions and 64 deletions

47
debian/postinst vendored
View file

@ -1,6 +1,10 @@
#!/bin/sh
set -e
. /usr/share/debconf/confmodule
CONDUIT_CONFIG_PATH=/etc/matrix-conduit
CONDUIT_CONFIG_FILE="$CONDUIT_CONFIG_PATH/debian"
CONDUIT_DATABASE_PATH=/var/lib/matrix-conduit
case "$1" in
@ -20,6 +24,49 @@ case "$1" in
mkdir -p "$CONDUIT_DATABASE_PATH"
chown _matrix-conduit "$CONDUIT_DATABASE_PATH"
fi
# Write the debconf values in the config.
db_get matrix-conduit/hostname
ROCKET_SERVER_NAME="$RET"
db_get matrix-conduit/address
ROCKET_ADDRESS="$RET"
db_get matrix-conduit/port
ROCKET_PORT="$RET"
cat >"$CONDUIT_CONFIG_FILE" << EOF
# Conduit homeserver Debian configuration
#
# Conduit is an application based on the Rocket web framework.
# Configuration of Conduit happens via Debconf (of which the resulting config
# is in this file) and optionally by uncommenting and tweaking the variables in
# /etc/matrix-conduit/local.
# THIS FILE IS GENERATED BY DEBCONF AND WILL BE OVERRIDDEN!
#
# Please make changes by running:
#
# \$ dpkg-reconfigure matrix-conduit
#
# or by providing overriding changes in /etc/matrix-conduit/local.
# The server (host)name of the Matrix homeserver.
#
# This is the hostname the homeserver will be reachable at via a client.
ROCKET_SERVER_NAME="$ROCKET_SERVER_NAME"
# The address the Matrix homeserver listens on.
#
# By default the server listens on address 0.0.0.0. Change this to 127.0.0.1 to
# only listen on the localhost when using a reverse proxy.
ROCKET_ADDRESS="$ROCKET_ADDRESS"
# The port of the Matrix homeserver.
#
# This port is could be any available port if accessed by a reverse proxy.
# By default the server listens on port 8000.
ROCKET_PORT="$ROCKET_PORT"
# THIS FILE IS GENERATED BY DEBCONF AND WILL BE OVERRIDDEN!
EOF
;;
esac