Build config.exs from config.exs.tpl

This commit is contained in:
pitchum 2024-01-17 08:11:07 +00:00
parent d804d339fe
commit 267626aeba
3 changed files with 21 additions and 15 deletions

2
debian/install vendored
View File

@ -1,2 +1,2 @@
debian/config.exs etc/mobilizon debian/config.exs.tpl etc/mobilizon
_build/prod/rel/mobilizon usr/share _build/prod/rel/mobilizon usr/share

20
debian/postinst vendored
View File

@ -10,7 +10,7 @@ set -e
case "$1" in case "$1" in
configure) configure)
# TODO create system user # Create a dedicated system user
if ! getent passwd mobilizon >/dev/null; then if ! getent passwd mobilizon >/dev/null; then
adduser \ adduser \
--disabled-password \ --disabled-password \
@ -23,24 +23,30 @@ case "$1" in
mobilizon mobilizon
fi fi
if [ ! -f /etc/mobilizon/config.exs ]; then
# Use debconf values to initialize config.exs # Use debconf values to initialize config.exs
cp /etc/mobilizon/config.exs.tpl /etc/mobilizon/config.exs.tmp
db_get mobilizon/domain_name db_get mobilizon/domain_name
sed -i "s/__DOMAIN_NAME__/${RET}/" /etc/mobilizon/config.exs sed -i "s/__DOMAIN_NAME__/${RET}/" /etc/mobilizon/config.exs.tmp
db_get mobilizon/listen_port db_get mobilizon/listen_port
sed -i "s/__LISTEN_PORT__/${RET}/" /etc/mobilizon/config.exs sed -i "s/__LISTEN_PORT__/${RET}/" /etc/mobilizon/config.exs.tmp
db_get mobilizon/db_host db_get mobilizon/db_host
sed -i "s/__DB_HOST__/${RET}/" /etc/mobilizon/config.exs sed -i "s/__DB_HOST__/${RET}/" /etc/mobilizon/config.exs.tmp
db_get mobilizon/db_name db_get mobilizon/db_name
sed -i "s/__DB_NAME__/${RET}/" /etc/mobilizon/config.exs sed -i "s/__DB_NAME__/${RET}/" /etc/mobilizon/config.exs.tmp
db_get mobilizon/db_username db_get mobilizon/db_username
sed -i "s/__DB_USERNAME__/${RET}/" /etc/mobilizon/config.exs sed -i "s/__DB_USERNAME__/${RET}/" /etc/mobilizon/config.exs.tmp
db_get mobilizon/db_userpass db_get mobilizon/db_userpass
sed -i "s/__DB_USERPASS__/${RET}/" /etc/mobilizon/config.exs sed -i "s/__DB_USERPASS__/${RET}/" /etc/mobilizon/config.exs.tmp
mv /etc/mobilizon/config.exs.tmp /etc/mobilizon/config.exs
fi
;; ;;