debianize-mobilizon/debian/postinst

77 lines
2.1 KiB
Plaintext
Raw Normal View History

2024-01-14 12:35:39 +01:00
#!/bin/sh
# postinst script for mobilizon.
#
# See: dh_installdeb(1).
set -e
2024-01-14 12:27:41 +01:00
# Load debconf
. /usr/share/debconf/confmodule
2024-01-14 12:35:39 +01:00
case "$1" in
configure)
2024-01-17 09:11:07 +01:00
# Create a dedicated system user
2024-01-14 12:35:39 +01:00
if ! getent passwd mobilizon >/dev/null; then
adduser \
--disabled-password \
--quiet \
--system \
--home /usr/share/mobilizon \
--no-create-home \
--gecos "Mobilizon server" \
--group \
mobilizon
fi
2024-01-14 12:27:41 +01:00
2024-01-17 09:11:07 +01:00
if [ ! -f /etc/mobilizon/config.exs ]; then
# Use debconf values to initialize config.exs
cp /etc/mobilizon/config.exs.tpl /etc/mobilizon/config.exs.tmp
2024-01-14 12:27:41 +01:00
2024-01-17 09:11:07 +01:00
db_get mobilizon/domain_name
sed -i "s/__DOMAIN_NAME__/${RET}/" /etc/mobilizon/config.exs.tmp
2024-01-14 12:27:41 +01:00
2024-01-17 09:11:07 +01:00
db_get mobilizon/listen_port
sed -i "s/__LISTEN_PORT__/${RET}/" /etc/mobilizon/config.exs.tmp
2024-01-14 12:27:41 +01:00
2024-01-17 09:11:07 +01:00
db_get mobilizon/db_host
sed -i "s/__DB_HOST__/${RET}/" /etc/mobilizon/config.exs.tmp
2024-01-14 12:27:41 +01:00
2024-01-17 09:11:07 +01:00
db_get mobilizon/db_name
sed -i "s/__DB_NAME__/${RET}/" /etc/mobilizon/config.exs.tmp
2024-01-14 12:27:41 +01:00
2024-01-17 09:11:07 +01:00
db_get mobilizon/db_username
sed -i "s/__DB_USERNAME__/${RET}/" /etc/mobilizon/config.exs.tmp
db_get mobilizon/db_userpass
sed -i "s/__DB_USERPASS__/${RET}/" /etc/mobilizon/config.exs.tmp
mv /etc/mobilizon/config.exs.tmp /etc/mobilizon/config.exs
fi
2024-01-14 12:35:39 +01:00
# Set permissions
chown -R mobilizon: /var/lib/mobilizon/geo_db
chown -R mobilizon: /var/lib/mobilizon/sitemap
chown -R mobilizon: /var/lib/mobilizon/timezones
chown -R mobilizon: /var/lib/mobilizon/tzdata
chown -R mobilizon: /var/lib/mobilizon/uploads
# Initialize/update database schema
/usr/bin/mobilizon_ctl migrate
2024-01-14 12:35:39 +01:00
;;
abort-upgrade|abort-remove|abort-deconfigure)
;;
*)
echo "postinst called with unknown argument '$1'" >&2
exit 1
;;
esac
# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.
#DEBHELPER#
exit 0