From 387bef53743cd83fccccad3f23fc583994685602 Mon Sep 17 00:00:00 2001 From: jmoore Date: Thu, 8 Feb 2018 07:31:07 +0000 Subject: [PATCH] Override omero.db.name (fix #16) omego assumes that the DBHOSE and DBNAME are set via bin/omero config. DBNAME was previously *not* set to prevent an accidental upgrade of a database. Here we set DBNAME only if the database has not been created elsewhere. --- 60-database.sh | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/60-database.sh b/60-database.sh index 076c153a..7d4b2c9c 100755 --- a/60-database.sh +++ b/60-database.sh @@ -16,8 +16,17 @@ else DBHOST=db $omero config set omero.db.host "$DBHOST" fi + +CONFIG_omero_db_name=${CONFIG_omero_db_name:-} +if [ -n "$CONFIG_omero_db_name" ]; then + DBNAME="$CONFIG_omero_db_name" +else + DBNAME=omero + # Delay setting in config until *after* + # the upgrade is attempted. +fi + DBUSER="${CONFIG_omero_db_user:-omero}" -DBNAME="${CONFIG_omero_db_name:-omero}" DBPASS="${CONFIG_omero_db_pass:-omero}" ROOTPASS="${ROOTPASS:-omero}" @@ -40,6 +49,8 @@ psql -w -h "$DBHOST" -U "$DBUSER" "$DBNAME" -c \ echo "Upgrading database" $omego db upgrade --serverdir=OMERO.server } || { + $omero config set omero.db.host "$DBHOST" + $omero config set omero.db.name "$DBNAME" echo "Initialising database" $omego db init --rootpass "$ROOTPASS" --serverdir=OMERO.server }