diff --git a/debian/config.exs b/debian/config.exs.tpl similarity index 100% rename from debian/config.exs rename to debian/config.exs.tpl diff --git a/debian/install b/debian/install index 7ec3dce8..175bcb9e 100644 --- a/debian/install +++ b/debian/install @@ -1,2 +1,2 @@ -debian/config.exs etc/mobilizon +debian/config.exs.tpl etc/mobilizon _build/prod/rel/mobilizon usr/share diff --git a/debian/postinst b/debian/postinst index ddf8228e..2431f0ca 100644 --- a/debian/postinst +++ b/debian/postinst @@ -10,7 +10,7 @@ set -e case "$1" in configure) - # TODO create system user + # Create a dedicated system user if ! getent passwd mobilizon >/dev/null; then adduser \ --disabled-password \ @@ -23,24 +23,30 @@ case "$1" in mobilizon fi - # Use debconf values to initialize config.exs - db_get mobilizon/domain_name - sed -i "s/__DOMAIN_NAME__/${RET}/" /etc/mobilizon/config.exs + 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 - db_get mobilizon/listen_port - sed -i "s/__LISTEN_PORT__/${RET}/" /etc/mobilizon/config.exs + db_get mobilizon/domain_name + sed -i "s/__DOMAIN_NAME__/${RET}/" /etc/mobilizon/config.exs.tmp - db_get mobilizon/db_host - sed -i "s/__DB_HOST__/${RET}/" /etc/mobilizon/config.exs + db_get mobilizon/listen_port + sed -i "s/__LISTEN_PORT__/${RET}/" /etc/mobilizon/config.exs.tmp - db_get mobilizon/db_name - sed -i "s/__DB_NAME__/${RET}/" /etc/mobilizon/config.exs + db_get mobilizon/db_host + sed -i "s/__DB_HOST__/${RET}/" /etc/mobilizon/config.exs.tmp - db_get mobilizon/db_username - sed -i "s/__DB_USERNAME__/${RET}/" /etc/mobilizon/config.exs + db_get mobilizon/db_name + sed -i "s/__DB_NAME__/${RET}/" /etc/mobilizon/config.exs.tmp - db_get mobilizon/db_userpass - sed -i "s/__DB_USERPASS__/${RET}/" /etc/mobilizon/config.exs + 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 ;;