From 219a7a86530241e06e073de94c6ebaf82a9283d8 Mon Sep 17 00:00:00 2001 From: jmoore Date: Thu, 8 Feb 2018 07:31:07 +0000 Subject: [PATCH 1/2] 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 | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/60-database.sh b/60-database.sh index 076c153a..d4909e63 100755 --- a/60-database.sh +++ b/60-database.sh @@ -16,8 +16,19 @@ 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" + DBNAME_src=env +else + # Delay setting in config until *after* + # the upgrade is attempted. + DBNAME=omero + DBNAME_src=default +fi + DBUSER="${CONFIG_omero_db_user:-omero}" -DBNAME="${CONFIG_omero_db_name:-omero}" DBPASS="${CONFIG_omero_db_pass:-omero}" ROOTPASS="${ROOTPASS:-omero}" @@ -40,6 +51,9 @@ psql -w -h "$DBHOST" -U "$DBUSER" "$DBNAME" -c \ echo "Upgrading database" $omego db upgrade --serverdir=OMERO.server } || { + if [ "$DBNAME_src" = default ]; then + $omero config set omero.db.name "$DBNAME" + fi echo "Initialising database" $omego db init --rootpass "$ROOTPASS" --serverdir=OMERO.server } From da676548954512de64fba8719fe0c149e275011d Mon Sep 17 00:00:00 2001 From: jmoore Date: Mon, 19 Feb 2018 11:12:56 +0100 Subject: [PATCH 2/2] Also set the property on restart --- 60-database.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/60-database.sh b/60-database.sh index d4909e63..460f4dd0 100755 --- a/60-database.sh +++ b/60-database.sh @@ -53,6 +53,8 @@ psql -w -h "$DBHOST" -U "$DBUSER" "$DBNAME" -c \ } || { if [ "$DBNAME_src" = default ]; then $omero config set omero.db.name "$DBNAME" + # And set for restarts + echo config set omero.db.name \"$DBNAME\" > /opt/omero/server/config/60-database.omero fi echo "Initialising database" $omego db init --rootpass "$ROOTPASS" --serverdir=OMERO.server