Skip to content

Commit

Permalink
Override omero.db.name (fix #16)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
joshmoore committed Feb 8, 2018
1 parent 0e8a533 commit 387bef5
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion 60-database.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}"

Expand All @@ -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
}

0 comments on commit 387bef5

Please sign in to comment.