From 4539899cae116a5d90c24a95fb3e647e7718ea84 Mon Sep 17 00:00:00 2001 From: Adam Birds Date: Sun, 28 Mar 2021 03:32:51 +0100 Subject: [PATCH] installer: Add support for custom database user and dbname. Add support for custom database names and database users, which can be set with the `--postgresql-database-name` and `--postgresql-database-user` install script options. If these parameters aren't provided, then the defaults remain "zulip". Fixes #17662. Co-authored-by: Alex Vandiver --- scripts/lib/install | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/scripts/lib/install b/scripts/lib/install index e76345a13f..74ce652f82 100755 --- a/scripts/lib/install +++ b/scripts/lib/install @@ -28,6 +28,10 @@ Options: install process; used when this command is run once in a highly-controlled environment to produce an image which is used elsewhere. Uncommon. + --postgresql-database-name=zulip + Sets the PostgreSQL database name. + --postgresql-database-user=zulip + Sets the PostgreSQL database user. --postgresql-version=13 Sets the version of PostgreSQL that will be installed. --postgresql-missing-dictionaries @@ -47,7 +51,7 @@ EOF # Shell option parsing. Over time, we'll want to move some of the # environment variables below into this self-documenting system. -args="$(getopt -o '' --long help,hostname:,email:,certbot,self-signed-cert,cacert:,postgresql-version:,postgresql-missing-dictionaries,no-init-db,no-overwrite-settings,no-dist-upgrade -n "$0" -- "$@")" +args="$(getopt -o '' --long help,hostname:,email:,certbot,self-signed-cert,cacert:,postgresql-database-name:,postgresql-database-user:,postgresql-version:,postgresql-missing-dictionaries,no-init-db,no-overwrite-settings,no-dist-upgrade -n "$0" -- "$@")" eval "set -- $args" while true; do case "$1" in @@ -80,7 +84,16 @@ while true; do SELF_SIGNED_CERT=1 shift ;; - + --postgresql-database-name) + POSTGRESQL_DATABASE_NAME="$2" + shift + shift + ;; + --postgresql-database-user) + POSTGRESQL_DATABASE_USER="$2" + shift + shift + ;; --postgresql-version) POSTGRESQL_VERSION="$2" shift @@ -416,6 +429,14 @@ EOF crudini --del /etc/zulip/zulip.conf postgresql fi + if [ -n "$POSTGRESQL_DATABASE_NAME" ]; then + crudini --set /etc/zulip/zulip.conf postgresql database_name "$POSTGRESQL_DATABASE_NAME" + fi + + if [ -n "$POSTGRESQL_DATABASE_USER" ]; then + crudini --set /etc/zulip/zulip.conf postgresql database_user "$POSTGRESQL_DATABASE_USER" + fi + # Note: there are four dpkg-query outputs to consider: # # root@host# dpkg-query --showformat '${Status}\n' -W rabbitmq-server 2>/dev/null