diff --git a/platform/platform-setup/src/main/standalone/database.properties b/platform/platform-setup/src/main/standalone/database.properties index 41b06ce180..eee5bb8237 100644 --- a/platform/platform-setup/src/main/standalone/database.properties +++ b/platform/platform-setup/src/main/standalone/database.properties @@ -10,7 +10,8 @@ # Bonita database properties ######################################### -# Valid values are: h2, postgres in Community edition, and also sqlserver, oracle, mysql in Subscription editions +# Valid values for Community edition: h2, postgres +# Valid values for Enterprise editions: h2, postgres, sqlserver, oracle, mysql db.vendor=h2 # when using h2, no server or port setting is needed since connexion is made using file protocol mode using relative directory: db.server.name=SERVER_NAME @@ -24,7 +25,8 @@ db.password= ################################### # Business Data database properties ################################### -# Valid values are: h2, postgres in Community edition, and also sqlserver, oracle, mysql in Subscription editions +# Valid values for Community edition: h2, postgres +# Valid values for Enterprise editions: h2, postgres, sqlserver, oracle, mysql bdm.db.vendor=h2 bdm.db.server.name=SERVER_NAME bdm.db.server.port=SERVER_PORT diff --git a/platform/platform-setup/src/main/standalone/setup.bat b/platform/platform-setup/src/main/standalone/setup.bat index 74c4ba3570..8c95d9e2e5 100644 --- a/platform/platform-setup/src/main/standalone/setup.bat +++ b/platform/platform-setup/src/main/standalone/setup.bat @@ -1,7 +1,7 @@ @echo off setlocal EnableDelayedExpansion -:: Let's position into folder containing this script: +:: Let's position into the folder containing this script: set CURRENTDIR="%cd%" set BASEDIR=%~dp0 cd %BASEDIR% @@ -17,20 +17,49 @@ set LIB_FOLDER=%BASEDIR%\lib FOR /F "tokens=1,* delims== eol=#" %%A IN (database.properties) DO (set %%A=%%B) set BONITA_DATABASE=%db.vendor% +set BONITA_BDM_DATABASE=%bdm.db.vendor% -IF NOT "%BONITA_DATABASE%" == "h2" IF NOT "%BONITA_DATABASE%" == "postgres" ( - echo Cannot determine database vendor valid values are [h2, postgres]. - echo Please configure file %BASEDIR%database.properties properly. +call :checkVendorSupported %BONITA_DATABASE% +if ERRORLEVEL 1 ( + exit /b 1 +) +call :checkVendorSupported %BONITA_BDM_DATABASE% +if ERRORLEVEL 1 ( exit /b 1 ) -"%JAVA_CMD%" -cp "%BASEDIR%;%CFG_FOLDER%;%INITIAL_CFG_FOLDER%;%LIB_FOLDER%\*" -Dsysprop.bonita.db.vendor=%BONITA_DATABASE% org.bonitasoft.platform.setup.PlatformSetupApplication %* +"%JAVA_CMD%" -cp "%BASEDIR%;%CFG_FOLDER%;%INITIAL_CFG_FOLDER%;%LIB_FOLDER%\*" ^ + -Dsysprop.bonita.db.vendor=%BONITA_DATABASE% ^ + -Dsysprop.bonita.bdm.db.vendor=%BONITA_BDM_DATABASE% ^ + org.bonitasoft.platform.setup.PlatformSetupApplication %* -if errorlevel 1 ( +if ERRORLEVEL 1 ( exit /b 1 ) :: restore previous folder: cd %CURRENTDIR% -exit /b 0 \ No newline at end of file +:: exit script with success +exit /b 0 + + +REM Function that exits with an error message if the vendor is not supported +REM - first argument is the database vendor value to check +:checkVendorSupported +set DB_VENDOR=%1 +set IS_SUPPORTED=false +for %%d in (h2 postgres) do ( + if "%%d" == "!DB_VENDOR!" ( + set IS_SUPPORTED=true + goto :breakLoop + ) +) +:breakLoop +if "!IS_SUPPORTED!" == "false" ( + echo ERROR: Unsupported database vendor ^(valid values are h2, postgres^). + echo For access to additional databases ^(oracle, mysql, sqlserver^), please consider upgrading to the Enterprise Edition. + echo Please update file %BASEDIR%database.properties to set a valid value. + exit /b 1 +) +exit /b 0 diff --git a/platform/platform-setup/src/main/standalone/setup.sh b/platform/platform-setup/src/main/standalone/setup.sh index 70daa77add..6284f95cae 100644 --- a/platform/platform-setup/src/main/standalone/setup.sh +++ b/platform/platform-setup/src/main/standalone/setup.sh @@ -1,7 +1,29 @@ #!/bin/sh set -e -BASEDIR=$(cd $(dirname $(dirname "$0")/..) && pwd -P) +# Function that exits with an error message if the vendor is not supported +# - first argument is the database vendor value to check +check_vendor_supported() { + db_vendor=$1 + is_supported=false + # supported databases: + set -- h2 postgres + for db in "$@"; do + if [ "$db" = "$db_vendor" ]; then + is_supported=true + break + fi + done + if [ "$is_supported" = false ]; then + echo "ERROR: Unsupported database vendor (valid values are h2, postgres)." + echo "For access to additional databases (oracle, mysql, sqlserver), please consider upgrading to the Enterprise Edition." + echo "Please update file ${BASEDIR}/database.properties to set a valid value." + exit 1 + fi +} + +# Let's position into the folder containing this script: +BASEDIR=$(cd "$(dirname "$(dirname "$0")/..")" && pwd -P) cd "${BASEDIR}" # JAVA_CMD is exported by start-bonita.sh, so that same Java command is used: @@ -15,14 +37,15 @@ for lib in lib/*.jar; do done BONITA_DATABASE=$(grep '^db.vendor=' database.properties | sed -e 's/db.vendor=//g') +check_vendor_supported "$BONITA_DATABASE" -if [ "$BONITA_DATABASE" != "h2" ] && [ "$BONITA_DATABASE" != "postgres" ]; then - echo "Cannot determine database vendor (valid values are h2, postgres)." - echo "Please configure file ${BASEDIR}/database.properties properly." - exit 1 -fi +BONITA_BDM_DATABASE=$(grep '^bdm.db.vendor=' database.properties | sed -e 's/bdm.db.vendor=//g') +check_vendor_supported "$BONITA_BDM_DATABASE" -"${JAVA_EXE}" -cp "${BASEDIR}:${CFG_FOLDER}:${INITIAL_CFG_FOLDER}${LIBS_CP}" ${JVM_OPTS} -Dsysprop.bonita.db.vendor=${BONITA_DATABASE} org.bonitasoft.platform.setup.PlatformSetupApplication "$@" +"${JAVA_EXE}" -cp "${BASEDIR}:${CFG_FOLDER}:${INITIAL_CFG_FOLDER}${LIBS_CP}" "${JVM_OPTS}" \ + -Dsysprop.bonita.db.vendor="${BONITA_DATABASE}" \ + -Dsysprop.bonita.bdm.db.vendor="${BONITA_BDM_DATABASE}" \ + org.bonitasoft.platform.setup.PlatformSetupApplication "$@" COD_RET=$? if [ ${COD_RET} -ne 0 ]; then cd - 1>/dev/null diff --git a/platform/platform-setup/src/test/resources/database.properties b/platform/platform-setup/src/test/resources/database.properties index 645b9aac73..807a5ea14f 100644 --- a/platform/platform-setup/src/test/resources/database.properties +++ b/platform/platform-setup/src/test/resources/database.properties @@ -15,7 +15,8 @@ # Bonita database properties ######################################### -# Valid values are: h2, postgres in Community edition, and also sqlserver, oracle, mysql in Subscription editions +# Valid values for Community edition: h2, postgres +# Valid values for Enterprise editions: h2, postgres, sqlserver, oracle, mysql db.vendor=h2 # when using h2, no server or port setting is needed since connexion is made using file protocol mode using relative directory: db.server.name=SERVER_NAME @@ -29,7 +30,8 @@ db.password= ################################### # Business Data database properties ################################### -# Valid values are: h2, postgres in Community edition, and also sqlserver, oracle, mysql in Subscription editions +# Valid values for Community edition: h2, postgres +# Valid values for Enterprise editions: h2, postgres, sqlserver, oracle, mysql bdm.db.vendor=h2 bdm.db.server.name=SERVER_NAME bdm.db.server.port=SERVER_PORT