diff options
author | Paul van Tilburg <paul@luon.net> | 2020-11-13 20:35:22 +0100 |
---|---|---|
committer | Paul van Tilburg <paul@luon.net> | 2020-11-24 14:42:18 +0100 |
commit | f72554de1014eea6b5c224548e9d0aeb15553cf7 (patch) | |
tree | 8aa4d15c8a575069a80e8aa448ab48528bb7ed3c /debian | |
parent | 79692db45dfe2fec6d0fec280bfba2be740d58a5 (diff) | |
download | conduit-f72554de1014eea6b5c224548e9d0aeb15553cf7.zip |
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.
Diffstat (limited to 'debian')
-rw-r--r-- | debian/config | 14 | ||||
-rw-r--r-- | debian/env | 48 | ||||
-rw-r--r-- | debian/env.local | 33 | ||||
-rw-r--r-- | debian/matrix-conduit.service | 3 | ||||
-rw-r--r-- | debian/postinst | 47 | ||||
-rw-r--r-- | debian/templates | 13 |
6 files changed, 96 insertions, 62 deletions
diff --git a/debian/config b/debian/config index a9ad498..8710ef9 100644 --- a/debian/config +++ b/debian/config @@ -4,20 +4,14 @@ set -e # Source debconf library. . /usr/share/debconf/confmodule -CONDUIT_CONFIG_PATH=/etc/matrix-conduit -CONDUIT_CONFIG_FILE="$CONDUIT_CONFIG_PATH/env" - -# Ask for the Matrix homeserver name and port. +# Ask for the Matrix homeserver name, address and port. db_input high matrix-conduit/hostname || true db_go -db_input medium matrix-conduit/port || true +db_input low matrix-conduit/address || true db_go -# Update the values in the config. -db_get matrix-conduit/hostname -sed -i -e "s/^ROCKET_SERVER_NAME=.*/ROCKET_SERVER_NAME=\"$RET\"/" $CONDUIT_CONFIG_FILE -db_get matrix-conduit/port -sed -i -e "s/^ROCKET_PORT=.*/ROCKET_PORT=\"$RET\"/" $CONDUIT_CONFIG_FILE +db_input medium matrix-conduit/port || true +db_go exit 0 diff --git a/debian/env b/debian/env deleted file mode 100644 index 3f72c5b..0000000 --- a/debian/env +++ /dev/null @@ -1,48 +0,0 @@ -# Conduit homeserver configuration -# -# Conduit is an application based on the Rocket web framework. -# Configuration of Conduit can happen either via a `Rocket.toml` file that -# is placed in /var/lib/matrix-conduit or via setting the environment -# variables below. - -# The server (host)name of the Matrix homeserver. -# -# This is the hostname the homeserver will be reachable at via a client. -ROCKET_SERVER_NAME="YOURSERVERNAME.HERE" - -# The address the Matrix homeserver listens on. -# -# By default the server listens on 0.0.0.0. Change this for example to -# 127.0.0.1 to only listen on the localhost when using a reverse proxy. -#ROCKET_ADDRESS="0.0.0.0" - -# The port of the Matrix homeserver. -# -# This port is often accessed by a reverse proxy. -ROCKET_PORT="14004" - -# The maximum size of a Matrix HTTP requests in bytes. -# -# This mostly affects the size of files that can be downloaded/uploaded. -ROCKET_MAX_REQUEST_SIZE=20000000 - -# Whether user registration is allowed. -# -# User registration is allowed by default. -#ROCKET_REGISTRATION_DISABLED=true - -# Whether encryption is enabled. -# -# (End-to-end) encryption is enabled by default. -#ROCKET_ENCRYPTION_DISABLED=true - -# Whether federation with other Matrix servers is enabled. -# -# Federation is disabled by default; it is still experimental. -#ROCKET_FEDERATION_ENABLED=true - -# The log level of the homeserver. -# -# The log level is "critical" by default. -# Allowed values are: "off", "normal", "debug", "critical" -#ROCKET_LOG="normal" diff --git a/debian/env.local b/debian/env.local new file mode 100644 index 0000000..cd552de --- /dev/null +++ b/debian/env.local @@ -0,0 +1,33 @@ +# Conduit homeserver local configuration +# +# Conduit is an application based on the Rocket web framework. +# Configuration of Conduit happens via Debconf (see the resulting config in +# `/etc/matrix-conduit/debian`) and optionally by uncommenting and tweaking the +# variables in this file below. + +# The maximum size of a Matrix HTTP requests in bytes. +# +# This mostly affects the size of files that can be downloaded/uploaded. +# It defaults to 20971520 (20MB). +#ROCKET_MAX_REQUEST_SIZE=20971520 + +# Whether user registration is allowed. +# +# User registration is not disabled by default. +#ROCKET_REGISTRATION_DISABLED=false + +# Whether encryption is enabled. +# +# (End-to-end) encryption is not disabled by default. +#ROCKET_ENCRYPTION_DISABLED=false + +# Whether federation with other Matrix servers is enabled. +# +# Federation is not enabled by default; it is still experimental. +#ROCKET_FEDERATION_ENABLED=false + +# The log level of the homeserver. +# +# The log level is "critical" by default. +# Allowed values are: "off", "normal", "debug", "critical" +#ROCKET_LOG="critical" diff --git a/debian/matrix-conduit.service b/debian/matrix-conduit.service index 96c4856..42969c1 100644 --- a/debian/matrix-conduit.service +++ b/debian/matrix-conduit.service @@ -9,7 +9,8 @@ Type=simple Environment="ROCKET_ENV=production" Environment="ROCKET_DATABASE_PATH=/var/lib/matrix-conduit" -EnvironmentFile=/etc/matrix-conduit/env +EnvironmentFile=/etc/matrix-conduit/debian +EnvironmentFile=/etc/matrix-conduit/local ExecStart=/usr/sbin/matrix-conduit Restart=on-failure diff --git a/debian/postinst b/debian/postinst index ee684da..bd7fb85 100644 --- a/debian/postinst +++ b/debian/postinst @@ -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 diff --git a/debian/templates b/debian/templates index 66bf55c..a408f84 100644 --- a/debian/templates +++ b/debian/templates @@ -1,14 +1,21 @@ Template: matrix-conduit/hostname Type: string Default: localhost -Description: The server (host)name of the Matrix homeserver. +Description: The server (host)name of the Matrix homeserver This is the hostname the homeserver will be reachable at via a client. . If set to "localhost", you can connect with a client locally and clients - from other hosts and also other servers will not be able to reach you! + from other hosts and also other homeservers will not be able to reach you! + +Template: matrix-conduit/address +Type: string +Default: 127.0.0.1 +Description: The listen address of the Matrix homeserver + This is the address the homeserver will listen on. Leave it set to 127.0.0.1 + when using a reverse proxy. Template: matrix-conduit/port Type: string Default: 14004 Description: The port of the Matrix homeserver - This port is often accessed by a reverse proxy. + This port is most often just accessed by a reverse proxy. |