2020-05-31 22:49:07 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
set -e
|
|
|
|
|
|
2024-05-13 22:51:32 -04:00
|
|
|
# TODO: implement debconf support that is maintainable without duplicating the config
|
|
|
|
|
#. /usr/share/debconf/confmodule
|
2020-11-13 20:35:22 +01:00
|
|
|
|
2025-05-02 22:23:39 +00:00
|
|
|
TUWUNEL_DATABASE_PATH=/var/lib/tuwunel
|
|
|
|
|
TUWUNEL_CONFIG_PATH=/etc/tuwunel
|
2020-05-31 22:49:07 +02:00
|
|
|
|
|
|
|
|
case "$1" in
|
|
|
|
|
configure)
|
2025-05-02 22:23:39 +00:00
|
|
|
# Create the `tuwunel` user if it does not exist yet.
|
|
|
|
|
if ! getent passwd tuwunel > /dev/null ; then
|
|
|
|
|
echo 'Adding system user for the tuwunel Matrix homeserver' 1>&2
|
2020-05-31 22:49:07 +02:00
|
|
|
adduser --system --group --quiet \
|
2025-05-02 22:23:39 +00:00
|
|
|
--home "$TUWUNEL_DATABASE_PATH" \
|
2020-05-31 22:49:07 +02:00
|
|
|
--disabled-login \
|
2024-03-11 20:15:40 -04:00
|
|
|
--shell "/usr/sbin/nologin" \
|
2025-05-02 22:23:39 +00:00
|
|
|
tuwunel
|
2020-05-31 22:49:07 +02:00
|
|
|
fi
|
|
|
|
|
|
2023-07-23 12:14:59 +02:00
|
|
|
# Create the database path if it does not exist yet and fix up ownership
|
2024-05-13 22:51:32 -04:00
|
|
|
# and permissions for the config.
|
2025-05-02 22:23:39 +00:00
|
|
|
mkdir -v -p "$TUWUNEL_DATABASE_PATH"
|
2024-05-13 22:51:32 -04:00
|
|
|
|
2024-05-28 09:14:30 +02:00
|
|
|
# symlink the previous location for compatibility if it does not exist yet.
|
|
|
|
|
if ! test -L "/var/lib/matrix-conduit" ; then
|
2025-05-02 22:23:39 +00:00
|
|
|
ln -s -v "$TUWUNEL_DATABASE_PATH" "/var/lib/matrix-conduit"
|
|
|
|
|
fi
|
|
|
|
|
if ! test -L "/var/lib/conduwuit" ; then
|
|
|
|
|
ln -s -v "$TUWUNEL_DATABASE_PATH" "/var/lib/conduwuit"
|
2024-05-28 09:14:30 +02:00
|
|
|
fi
|
2024-05-15 11:53:30 -04:00
|
|
|
|
2025-05-02 22:23:39 +00:00
|
|
|
chown -v tuwunel:tuwunel -R "$TUWUNEL_DATABASE_PATH"
|
|
|
|
|
chown -v tuwunel:tuwunel -R "$TUWUNEL_CONFIG_PATH"
|
2024-05-13 22:51:32 -04:00
|
|
|
|
2025-05-02 22:23:39 +00:00
|
|
|
chmod -v 740 "$TUWUNEL_DATABASE_PATH"
|
2024-05-13 22:51:32 -04:00
|
|
|
|
2024-05-15 11:45:35 -04:00
|
|
|
echo ''
|
2025-05-02 22:23:39 +00:00
|
|
|
echo 'Make sure you edit the example config at /etc/tuwunel/tuwunel.toml before starting!'
|
|
|
|
|
echo 'To start the server, run: systemctl start tuwunel.service'
|
2024-05-15 11:45:35 -04:00
|
|
|
echo ''
|
|
|
|
|
|
2020-05-31 22:49:07 +02:00
|
|
|
;;
|
|
|
|
|
esac
|
|
|
|
|
|
|
|
|
|
#DEBHELPER#
|