diff --git a/docker-image-src/3.3/docker-entrypoint.sh b/docker-image-src/3.3/docker-entrypoint.sh index 1a9938f1..ba9c6244 100755 --- a/docker-image-src/3.3/docker-entrypoint.sh +++ b/docker-image-src/3.3/docker-entrypoint.sh @@ -245,7 +245,7 @@ if [[ "${cmd}" == *"neo4j"* ]]; then echo >&2 " In order to use Neo4j Enterprise Edition you must accept the license agreement. -(c) Neo4j Sweden AB. 2021. All Rights Reserved. +(c) Neo4j Sweden AB. 2019. All Rights Reserved. Use of this Software without a proper commercial license with Neo4j, Inc. or its affiliates is prohibited. diff --git a/docker-image-src/3.4/docker-entrypoint.sh b/docker-image-src/3.4/docker-entrypoint.sh index 4a4603e5..da29fb4a 100755 --- a/docker-image-src/3.4/docker-entrypoint.sh +++ b/docker-image-src/3.4/docker-entrypoint.sh @@ -245,7 +245,7 @@ if [[ "${cmd}" == *"neo4j"* ]]; then echo >&2 " In order to use Neo4j Enterprise Edition you must accept the license agreement. -(c) Neo4j Sweden AB. 2021. All Rights Reserved. +(c) Neo4j Sweden AB. 2019. All Rights Reserved. Use of this Software without a proper commercial license with Neo4j, Inc. or its affiliates is prohibited. diff --git a/docker-image-src/3.5/docker-entrypoint.sh b/docker-image-src/3.5/docker-entrypoint.sh index 74e30c6b..80ed5db7 100755 --- a/docker-image-src/3.5/docker-entrypoint.sh +++ b/docker-image-src/3.5/docker-entrypoint.sh @@ -95,7 +95,7 @@ function check_mounted_folder_readable fi } -function check_mounted_folder_writable_with_chown +function check_mounted_folder_with_chown { # The /data and /log directory are a bit different because they are very likely to be mounted by the user but not # necessarily writable. @@ -213,79 +213,6 @@ function install_neo4j_labs_plugins rm "${_old_config}" } -function add_docker_default_to_conf -{ - # docker defaults should NOT overwrite values already in the conf file - local _setting="${1}" - local _value="${2}" - local _neo4j_home="${3}" - - if ! grep -q "^${_setting}=" "${_neo4j_home}"/conf/neo4j.conf - then - echo -e "\n"${_setting}=${_value} >> "${_neo4j_home}"/conf/neo4j.conf - fi -} - -function add_env_setting_to_conf -{ - # settings from environment variables should overwrite values already in the conf - local _setting=${1} - local _value=${2} - local _neo4j_home=${3} - - if grep -q -F "${_setting}=" "${_neo4j_home}"/conf/neo4j.conf; then - # Remove any lines containing the setting already - sed --in-place "/^${_setting}=.*/d" "${_neo4j_home}"/conf/neo4j.conf - fi - # Then always append setting to file - echo "${_setting}=${_value}" >> "${_neo4j_home}"/conf/neo4j.conf -} - -function set_initial_password -{ - local _neo4j_auth="${1}" - - # set the neo4j initial password only if you run the database server - if [ "${cmd}" == "neo4j" ]; then - if [ "${_neo4j_auth:-}" == "none" ]; then - add_env_setting_to_conf "dbms.security.auth_enabled" "false" "${NEO4J_HOME}" - # NEO4J_dbms_security_auth__enabled=false - elif [[ "${_neo4j_auth:-}" =~ ^([^/]+)\/([^/]+)/?([tT][rR][uU][eE])?$ ]]; then - admin_user="${BASH_REMATCH[1]}" - password="${BASH_REMATCH[2]}" - do_reset="${BASH_REMATCH[3]}" - - if [ "${password}" == "neo4j" ]; then - echo >&2 "Invalid value for password. It cannot be 'neo4j', which is the default." - exit 1 - fi - if [ "${admin_user}" != "neo4j" ]; then - echo >&2 "Invalid admin username, it must be neo4j" - exit 1 - fi - - if running_as_root; then - # running set-initial-password as root will create subfolders to /data as root, causing startup fail when neo4j can't read or write the /data/dbms folder - # creating the folder first will avoid that - mkdir -p /data/dbms - chown "${userid}":"${groupid}" /data/dbms - fi - - # Will exit with error if users already exist (and print a message explaining that) - # we probably don't want the message though, since it throws an error message on restarting the container. - if [ "${do_reset}" == "true" ]; then - neo4j-admin set-initial-password "${password}" --require-password-change 2>/dev/null || true - else - neo4j-admin set-initial-password "${password}" 2>/dev/null || true - fi - elif [ -n "${_neo4j_auth:-}" ]; then - echo "$_neo4j_auth is invalid" - echo >&2 "Invalid value for NEO4J_AUTH: '${_neo4j_auth}'" - exit 1 - fi - fi -} - # If we're running as root, then run as the neo4j user. Otherwise # docker is running with --user and we simply use that user. Note # that su-exec, despite its name, does not replicate the functionality @@ -319,15 +246,13 @@ if running_as_root; then fi # Only prompt for license agreement if command contains "neo4j" in it -# ==== CHECK LICENSE AGREEMENT ==== - if [[ "${cmd}" == *"neo4j"* ]]; then if [ "${NEO4J_EDITION}" == "enterprise" ]; then if [ "${NEO4J_ACCEPT_LICENSE_AGREEMENT:=no}" != "yes" ]; then echo >&2 " In order to use Neo4j Enterprise Edition you must accept the license agreement. -(c) Neo4j Sweden AB. 2021. All Rights Reserved. +(c) Neo4j Sweden AB. 2019. All Rights Reserved. Use of this Software without a proper commercial license with Neo4j, Inc. or its affiliates is prohibited. @@ -349,8 +274,6 @@ To do this you can use the following docker argument: fi # Env variable naming convention: -# ==== RENAME LEGACY ENVIRONMENT CONF VARIABLES ==== - # - prefix NEO4J_ # - double underscore char '__' instead of single underscore '_' char in the setting name # - underscore char '_' instead of dot '.' char in the setting name @@ -360,7 +283,7 @@ fi # Backward compatibility - map old hardcoded env variables into new naming convention (if they aren't set already) # Set some to default values if unset -: ${NEO4J_dbms_tx__log_rotation_retention__policy:=${NEO4J_dbms_txLog_rotation_retentionPolicy:-}} +: ${NEO4J_dbms_tx__log_rotation_retention__policy:=${NEO4J_dbms_txLog_rotation_retentionPolicy:-"100M size"}} : ${NEO4J_wrapper_java_additional:=${NEO4J_UDC_SOURCE:-"-Dneo4j.ext.udc.source=docker"}} : ${NEO4J_dbms_unmanaged__extension__classes:=${NEO4J_dbms_unmanagedExtensionClasses:-}} : ${NEO4J_dbms_allow__format__migration:=${NEO4J_dbms_allowFormatMigration:-}} @@ -370,9 +293,13 @@ if [ "${NEO4J_EDITION}" == "enterprise" ]; then : ${NEO4J_causal__clustering_expected__core__cluster__size:=${NEO4J_causalClustering_expectedCoreClusterSize:-}} : ${NEO4J_causal__clustering_initial__discovery__members:=${NEO4J_causalClustering_initialDiscoveryMembers:-}} - : ${NEO4J_causal__clustering_discovery__advertised__address:=${NEO4J_causalClustering_discoveryAdvertisedAddress:-}} - : ${NEO4J_causal__clustering_transaction__advertised__address:=${NEO4J_causalClustering_transactionAdvertisedAddress:-}} - : ${NEO4J_causal__clustering_raft__advertised__address:=${NEO4J_causalClustering_raftAdvertisedAddress:-}} + : ${NEO4J_causal__clustering_discovery__advertised__address:=${NEO4J_causalClustering_discoveryAdvertisedAddress:-"$(hostname):5000"}} + : ${NEO4J_causal__clustering_transaction__advertised__address:=${NEO4J_causalClustering_transactionAdvertisedAddress:-"$(hostname):6000"}} + : ${NEO4J_causal__clustering_raft__advertised__address:=${NEO4J_causalClustering_raftAdvertisedAddress:-"$(hostname):7000"}} + # Custom settings for dockerized neo4j + : ${NEO4J_causal__clustering_discovery__advertised__address:=$(hostname):5000} + : ${NEO4J_causal__clustering_transaction__advertised__address:=$(hostname):6000} + : ${NEO4J_causal__clustering_raft__advertised__address:=$(hostname):7000} fi # unset old hardcoded unsupported env variables @@ -388,9 +315,6 @@ unset NEO4J_dbms_txLog_rotation_retentionPolicy NEO4J_UDC_SOURCE \ NEO4J_causalClustering_raftListenAddress \ NEO4J_causalClustering_raftAdvertisedAddress - -# ==== CHECK FILE PERMISSIONS ON MOUNTED FOLDERS ==== - if [ -d /conf ]; then if secure_mode_enabled; then check_mounted_folder_readable "/conf" @@ -409,7 +333,7 @@ if [ -d /plugins ]; then if secure_mode_enabled; then if [[ ! -z "${NEO4JLABS_PLUGINS:-}" ]]; then # We need write permissions - check_mounted_folder_writable_with_chown "/plugins" + check_mounted_folder_with_chown "/plugins" fi check_mounted_folder_readable "/plugins" fi @@ -431,41 +355,78 @@ if [ -d /metrics ]; then fi if [ -d /logs ]; then - check_mounted_folder_writable_with_chown "/logs" + check_mounted_folder_with_chown "/logs" : ${NEO4J_dbms_directories_logs:="/logs"} fi if [ -d /data ]; then - check_mounted_folder_writable_with_chown "/data" + check_mounted_folder_with_chown "/data" if [ -d /data/databases ]; then - check_mounted_folder_writable_with_chown "/data/databases" + check_mounted_folder_with_chown "/data/databases" fi if [ -d /data/dbms ]; then - check_mounted_folder_writable_with_chown "/data/dbms" + check_mounted_folder_with_chown "/data/dbms" fi fi -# ==== SET CONFIGURATIONS ==== -## == DOCKER SPECIFIC DEFAULT CONFIGURATIONS === -## these should not override *any* configurations set by the user +# set the neo4j initial password only if you run the database server +if [ "${cmd}" == "neo4j" ]; then + if [ "${NEO4J_AUTH:-}" == "none" ]; then + NEO4J_dbms_security_auth__enabled=false + elif [[ "${NEO4J_AUTH:-}" == neo4j/* ]]; then + password="${NEO4J_AUTH#neo4j/}" + if [ "${password}" == "neo4j" ]; then + echo >&2 "Invalid value for password. It cannot be 'neo4j', which is the default." + exit 1 + fi -add_docker_default_to_conf "dbms.tx_log.rotation.retention_policy" "100M size" "${NEO4J_HOME}" -add_docker_default_to_conf "dbms.memory.pagecache.size" "512M" "${NEO4J_HOME}" -add_docker_default_to_conf "dbms.default_listen_address" "0.0.0.0" "${NEO4J_HOME}" -add_docker_default_to_conf "dbms.connector.https.listen_address" "0.0.0.0:7473" "${NEO4J_HOME}" -add_docker_default_to_conf "dbms.connector.http.listen_address" "0.0.0.0:7474" "${NEO4J_HOME}" -add_docker_default_to_conf "dbms.connector.bolt.listen_address" "0.0.0.0:7687" "${NEO4J_HOME}" -# set enterprise only docker defaults -if [ "${NEO4J_EDITION}" == "enterprise" ]; -then - add_docker_default_to_conf "causal_clustering.discovery_advertised_address" "$(hostname):5000" "${NEO4J_HOME}" - add_docker_default_to_conf "causal_clustering.transaction_advertised_address" "$(hostname):6000" "${NEO4J_HOME}" - add_docker_default_to_conf "causal_clustering.raft_advertised_address" "$(hostname):7000" "${NEO4J_HOME}" + if running_as_root; then + # running set-initial-password as root will create subfolders to /data as root, causing startup fail when neo4j can't read or write the /data/dbms folder + # creating the folder first will avoid that + mkdir -p /data/dbms + chown "${userid}":"${groupid}" /data/dbms + fi + # Will exit with error if users already exist (and print a message explaining that) + # we probably don't want the message though, since it throws an error message on restarting the container. + neo4j-admin set-initial-password "${password}" 2>/dev/null || true + elif [ -n "${NEO4J_AUTH:-}" ]; then + echo >&2 "Invalid value for NEO4J_AUTH: '${NEO4J_AUTH}'" + exit 1 + fi fi -## == ENVIRONMENT VARIABLE CONFIGURATIONS === -## these override BOTH defaults and any existing values in the neo4j.conf file +declare -A COMMUNITY +declare -A ENTERPRISE + +COMMUNITY=( + [dbms.tx_log.rotation.retention_policy]="100M size" + [dbms.memory.pagecache.size]="512M" + [dbms.connectors.default_listen_address]="0.0.0.0" + [dbms.connector.https.listen_address]="0.0.0.0:7473" + [dbms.connector.http.listen_address]="0.0.0.0:7474" + [dbms.connector.bolt.listen_address]="0.0.0.0:7687" +) + +ENTERPRISE=( +) + +for conf in ${!COMMUNITY[@]} ; do + if ! grep -q "^$conf" "${NEO4J_HOME}"/conf/neo4j.conf + then + echo -e "\n"$conf=${COMMUNITY[$conf]} >> "${NEO4J_HOME}"/conf/neo4j.conf + fi +done + +for conf in ${!ENTERPRISE[@]} ; do + if [ "${NEO4J_EDITION}" == "enterprise" ]; + then + if ! grep -q "^$conf" "${NEO4J_HOME}"/conf/neo4j.conf + then + echo -e "\n"$conf=${ENTERPRISE[$conf]} >> "${NEO4J_HOME}"/conf/neo4j.conf + fi + fi +done #The udc.source=tarball should be replaced by udc.source=docker in both dbms.jvm.additional and wrapper.java.additional #Using sed to replace only this part will allow the custom configs to be added after, separated by a ,. @@ -478,29 +439,25 @@ if ! grep -q "dbms.jvm.additional=-Dunsupported.dbms.udc.source=docker" "${NEO4J sed -i -e 's/dbms.jvm.additional=/dbms.jvm.additional=-Dunsupported.dbms.udc.source=docker,/g' "${NEO4J_HOME}"/conf/neo4j.conf fi -# save NEO4J_HOME and NEO4J_AUTH to temp variables that don't begin with NEO4J_ so they don't get added to the conf -temp_neo4j_home="${NEO4J_HOME}" -temp_neo4j_auth="${NEO4J_AUTH:-}" # list env variables with prefix NEO4J_ and create settings from them -unset NEO4J_AUTH NEO4J_SHA256 NEO4J_TARBALL NEO4J_EDITION NEO4J_ACCEPT_LICENSE_AGREEMENT NEO4J_HOME +unset NEO4J_AUTH NEO4J_SHA256 NEO4J_TARBALL for i in $( set | grep ^NEO4J_ | awk -F'=' '{print $1}' | sort -rn ); do - setting=$(echo "${i}" | sed 's|^NEO4J_||' | sed 's|_|.|g' | sed 's|\.\.|_|g') - value=$(echo "${!i}") + setting=$(echo ${i} | sed 's|^NEO4J_||' | sed 's|_|.|g' | sed 's|\.\.|_|g') + value=$(echo ${!i}) # Don't allow settings with no value or settings that start with a number (neo4j converts settings to env variables and you cannot have an env variable that starts with a number) if [[ -n ${value} ]]; then if [[ ! "${setting}" =~ ^[0-9]+.*$ ]]; then - add_env_setting_to_conf "${setting}" "${value}" "${temp_neo4j_home}" + if grep -q -F "${setting}=" "${NEO4J_HOME}"/conf/neo4j.conf; then + # Remove any lines containing the setting already + sed --in-place "/^${setting}=.*/d" "${NEO4J_HOME}"/conf/neo4j.conf + fi + # Then always append setting to file + echo "${setting}=${value}" >> "${NEO4J_HOME}"/conf/neo4j.conf else echo >&2 "WARNING: ${setting} not written to conf file because settings that start with a number are not permitted" fi fi done -export NEO4J_HOME="${temp_neo4j_home}" -unset temp_neo4j_home - -# ==== SET PASSWORD AND PLUGINS ==== - -set_initial_password "${temp_neo4j_auth}" if [[ ! -z "${NEO4JLABS_PLUGINS:-}" ]]; then @@ -508,8 +465,6 @@ if [[ ! -z "${NEO4JLABS_PLUGINS:-}" ]]; then install_neo4j_labs_plugins fi -# ==== INVOKE NEO4J STARTUP ==== - [ -f "${EXTENSION_SCRIPT:-}" ] && . ${EXTENSION_SCRIPT} if [ "${cmd}" == "dump-config" ]; then @@ -528,4 +483,4 @@ if [ "${cmd}" == "neo4j" ]; then ${exec_cmd} neo4j console else ${exec_cmd} "$@" -fi +fi \ No newline at end of file diff --git a/docker-image-src/4.0/docker-entrypoint.sh b/docker-image-src/4.0/docker-entrypoint.sh index 5eea5343..5faa7593 100755 --- a/docker-image-src/4.0/docker-entrypoint.sh +++ b/docker-image-src/4.0/docker-entrypoint.sh @@ -213,79 +213,6 @@ function install_neo4j_labs_plugins rm "${_old_config}" } -function add_docker_default_to_conf -{ - # docker defaults should NOT overwrite values already in the conf file - local _setting="${1}" - local _value="${2}" - local _neo4j_home="${3}" - - if ! grep -q "^${_setting}=" "${_neo4j_home}"/conf/neo4j.conf - then - echo -e "\n"${_setting}=${_value} >> "${_neo4j_home}"/conf/neo4j.conf - fi -} - -function add_env_setting_to_conf -{ - # settings from environment variables should overwrite values already in the conf - local _setting=${1} - local _value=${2} - local _neo4j_home=${3} - - if grep -q -F "${_setting}=" "${_neo4j_home}"/conf/neo4j.conf; then - # Remove any lines containing the setting already - sed --in-place "/^${_setting}=.*/d" "${_neo4j_home}"/conf/neo4j.conf - fi - # Then always append setting to file - echo "${_setting}=${_value}" >> "${_neo4j_home}"/conf/neo4j.conf -} - -function set_initial_password -{ - local _neo4j_auth="${1}" - - # set the neo4j initial password only if you run the database server - if [ "${cmd}" == "neo4j" ]; then - if [ "${_neo4j_auth:-}" == "none" ]; then - add_env_setting_to_conf "dbms.security.auth_enabled" "false" "${NEO4J_HOME}" - # NEO4J_dbms_security_auth__enabled=false - elif [[ "${_neo4j_auth:-}" =~ ^([^/]+)\/([^/]+)/?([tT][rR][uU][eE])?$ ]]; then - admin_user="${BASH_REMATCH[1]}" - password="${BASH_REMATCH[2]}" - do_reset="${BASH_REMATCH[3]}" - - if [ "${password}" == "neo4j" ]; then - echo >&2 "Invalid value for password. It cannot be 'neo4j', which is the default." - exit 1 - fi - if [ "${admin_user}" != "neo4j" ]; then - echo >&2 "Invalid admin username, it must be neo4j" - exit 1 - fi - - if running_as_root; then - # running set-initial-password as root will create subfolders to /data as root, causing startup fail when neo4j can't read or write the /data/dbms folder - # creating the folder first will avoid that - mkdir -p /data/dbms - chown "${userid}":"${groupid}" /data/dbms - fi - - # Will exit with error if users already exist (and print a message explaining that) - # we probably don't want the message though, since it throws an error message on restarting the container. - if [ "${do_reset}" == "true" ]; then - neo4j-admin set-initial-password "${password}" --require-password-change 2>/dev/null || true - else - neo4j-admin set-initial-password "${password}" 2>/dev/null || true - fi - elif [ -n "${_neo4j_auth:-}" ]; then - echo "$_neo4j_auth is invalid" - echo >&2 "Invalid value for NEO4J_AUTH: '${_neo4j_auth}'" - exit 1 - fi - fi -} - # If we're running as root, then run as the neo4j user. Otherwise # docker is running with --user and we simply use that user. Note # that su-exec, despite its name, does not replicate the functionality @@ -315,15 +242,13 @@ if running_as_root; then fi # Only prompt for license agreement if command contains "neo4j" in it -# ==== CHECK LICENSE AGREEMENT ==== - if [[ "${cmd}" == *"neo4j"* ]]; then if [ "${NEO4J_EDITION}" == "enterprise" ]; then if [ "${NEO4J_ACCEPT_LICENSE_AGREEMENT:=no}" != "yes" ]; then echo >&2 " In order to use Neo4j Enterprise Edition you must accept the license agreement. -(c) Neo4j Sweden AB. 2021. All Rights Reserved. +(c) Neo4j Sweden AB. 2019. All Rights Reserved. Use of this Software without a proper commercial license with Neo4j, Inc. or its affiliates is prohibited. @@ -345,8 +270,6 @@ To do this you can use the following docker argument: fi # Env variable naming convention: -# ==== RENAME LEGACY ENVIRONMENT CONF VARIABLES ==== - # - prefix NEO4J_ # - double underscore char '__' instead of single underscore '_' char in the setting name # - underscore char '_' instead of dot '.' char in the setting name @@ -356,7 +279,7 @@ fi # Backward compatibility - map old hardcoded env variables into new naming convention (if they aren't set already) # Set some to default values if unset -: ${NEO4J_dbms_tx__log_rotation_retention__policy:=${NEO4J_dbms_txLog_rotation_retentionPolicy:-}} +: ${NEO4J_dbms_tx__log_rotation_retention__policy:=${NEO4J_dbms_txLog_rotation_retentionPolicy:-"100M size"}} : ${NEO4J_dbms_unmanaged__extension__classes:=${NEO4J_dbms_unmanagedExtensionClasses:-}} : ${NEO4J_dbms_allow__format__migration:=${NEO4J_dbms_allowFormatMigration:-}} : ${NEO4J_dbms_connectors_default__advertised__address:=${NEO4J_dbms_connectors_defaultAdvertisedAddress:-}} @@ -365,9 +288,13 @@ if [ "${NEO4J_EDITION}" == "enterprise" ]; then : ${NEO4J_causal__clustering_expected__core__cluster__size:=${NEO4J_causalClustering_expectedCoreClusterSize:-}} : ${NEO4J_causal__clustering_initial__discovery__members:=${NEO4J_causalClustering_initialDiscoveryMembers:-}} - : ${NEO4J_causal__clustering_discovery__advertised__address:=${NEO4J_causalClustering_discoveryAdvertisedAddress:-}} - : ${NEO4J_causal__clustering_transaction__advertised__address:=${NEO4J_causalClustering_transactionAdvertisedAddress:-}} - : ${NEO4J_causal__clustering_raft__advertised__address:=${NEO4J_causalClustering_raftAdvertisedAddress:-}} + : ${NEO4J_causal__clustering_discovery__advertised__address:=${NEO4J_causalClustering_discoveryAdvertisedAddress:-"$(hostname):5000"}} + : ${NEO4J_causal__clustering_transaction__advertised__address:=${NEO4J_causalClustering_transactionAdvertisedAddress:-"$(hostname):6000"}} + : ${NEO4J_causal__clustering_raft__advertised__address:=${NEO4J_causalClustering_raftAdvertisedAddress:-"$(hostname):7000"}} + # Custom settings for dockerized neo4j + : ${NEO4J_causal__clustering_discovery__advertised__address:=$(hostname):5000} + : ${NEO4J_causal__clustering_transaction__advertised__address:=$(hostname):6000} + : ${NEO4J_causal__clustering_raft__advertised__address:=$(hostname):7000} fi # unset old hardcoded unsupported env variables @@ -383,9 +310,6 @@ unset NEO4J_dbms_txLog_rotation_retentionPolicy NEO4J_UDC_SOURCE \ NEO4J_causalClustering_raftListenAddress \ NEO4J_causalClustering_raftAdvertisedAddress - -# ==== CHECK FILE PERMISSIONS ON MOUNTED FOLDERS ==== - if [ -d /conf ]; then check_mounted_folder_readable "/conf" find /conf -type f -exec cp {} "${NEO4J_HOME}"/conf \; @@ -434,28 +358,78 @@ if [ -d /data ]; then fi fi -# ==== SET CONFIGURATIONS ==== -## == DOCKER SPECIFIC DEFAULT CONFIGURATIONS === -## these should not override *any* configurations set by the user -add_docker_default_to_conf "dbms.tx_log.rotation.retention_policy" "100M size" "${NEO4J_HOME}" -add_docker_default_to_conf "dbms.memory.pagecache.size" "512M" "${NEO4J_HOME}" -add_docker_default_to_conf "dbms.default_listen_address" "0.0.0.0" "${NEO4J_HOME}" -# set enterprise only docker defaults -if [ "${NEO4J_EDITION}" == "enterprise" ]; -then - add_docker_default_to_conf "causal_clustering.discovery_advertised_address" "$(hostname):5000" "${NEO4J_HOME}" - add_docker_default_to_conf "causal_clustering.transaction_advertised_address" "$(hostname):6000" "${NEO4J_HOME}" - add_docker_default_to_conf "causal_clustering.raft_advertised_address" "$(hostname):7000" "${NEO4J_HOME}" +# set the neo4j initial password only if you run the database server +if [ "${cmd}" == "neo4j" ]; then + if [ "${NEO4J_AUTH:-}" == "none" ]; then + NEO4J_dbms_security_auth__enabled=false + elif [[ "${NEO4J_AUTH:-}" =~ ^([^/]+)\/([^/]+)/?([tT][rR][uU][eE])?$ ]]; then + admin_user="${BASH_REMATCH[1]}" + password="${BASH_REMATCH[2]}" + do_reset="${BASH_REMATCH[3]}" + + if [ "${password}" == "neo4j" ]; then + echo >&2 "Invalid value for password. It cannot be 'neo4j', which is the default." + exit 1 + fi + if [ "${admin_user}" != "neo4j" ]; then + echo >&2 "Invalid admin username, it must be neo4j" + exit 1 + fi + + if running_as_root; then + # running set-initial-password as root will create subfolders to /data as root, causing startup fail when neo4j can't read or write the /data/dbms folder + # creating the folder first will avoid that + mkdir -p /data/dbms + chown "${userid}":"${groupid}" /data/dbms + fi + + # Will exit with error if users already exist (and print a message explaining that) + # we probably don't want the message though, since it throws an error message on restarting the container. + if [ "${do_reset}" == "true" ]; then + neo4j-admin set-initial-password "${password}" --require-password-change 2>/dev/null || true + else + neo4j-admin set-initial-password "${password}" 2>/dev/null || true + fi + elif [ -n "${NEO4J_AUTH:-}" ]; then + echo "$NEO4J_AUTH is invalid" + echo >&2 "Invalid value for NEO4J_AUTH: '${NEO4J_AUTH}'" + exit 1 + fi fi -## == ENVIRONMENT VARIABLE CONFIGURATIONS === -## these override BOTH defaults and any existing values in the neo4j.conf file +declare -A COMMUNITY +declare -A ENTERPRISE + +COMMUNITY=( + [dbms.tx_log.rotation.retention_policy]="100M size" + [dbms.memory.pagecache.size]="512M" + [dbms.default_listen_address]="0.0.0.0" +) -# save NEO4J_HOME and NEO4J_AUTH to temp variables that don't begin with NEO4J_ so they don't get added to the conf +ENTERPRISE=( +) + +for conf in ${!COMMUNITY[@]} ; do + if ! grep -q "^$conf" "${NEO4J_HOME}"/conf/neo4j.conf + then + echo -e "\n"$conf=${COMMUNITY[$conf]} >> "${NEO4J_HOME}"/conf/neo4j.conf + fi +done + +for conf in ${!ENTERPRISE[@]} ; do + if [ "${NEO4J_EDITION}" == "enterprise" ]; + then + if ! grep -q "^$conf" "${NEO4J_HOME}"/conf/neo4j.conf + then + echo -e "\n"$conf=${ENTERPRISE[$conf]} >> "${NEO4J_HOME}"/conf/neo4j.conf + fi + fi +done + +# save NEO4J_HOME to a temp variable that doesn't begin with NEO4J_ so it doesn't get added to the conf temp_neo4j_home="${NEO4J_HOME}" -temp_neo4j_auth="${NEO4J_AUTH:-}" # list env variables with prefix NEO4J_ and create settings from them unset NEO4J_AUTH NEO4J_SHA256 NEO4J_TARBALL NEO4J_EDITION NEO4J_ACCEPT_LICENSE_AGREEMENT NEO4J_HOME for i in $( set | grep ^NEO4J_ | awk -F'=' '{print $1}' | sort -rn ); do @@ -464,7 +438,12 @@ for i in $( set | grep ^NEO4J_ | awk -F'=' '{print $1}' | sort -rn ); do # Don't allow settings with no value or settings that start with a number (neo4j converts settings to env variables and you cannot have an env variable that starts with a number) if [[ -n ${value} ]]; then if [[ ! "${setting}" =~ ^[0-9]+.*$ ]]; then - add_env_setting_to_conf "${setting}" "${value}" "${temp_neo4j_home}" + if grep -q -F "${setting}=" "${temp_neo4j_home}"/conf/neo4j.conf; then + # Remove any lines containing the setting already + sed --in-place "/^${setting}=.*/d" "${temp_neo4j_home}"/conf/neo4j.conf + fi + # Then always append setting to file + echo "${setting}=${value}" >> "${temp_neo4j_home}"/conf/neo4j.conf else echo >&2 "WARNING: ${setting} not written to conf file because settings that start with a number are not permitted" fi @@ -473,18 +452,12 @@ done export NEO4J_HOME="${temp_neo4j_home}" unset temp_neo4j_home -# ==== SET PASSWORD AND PLUGINS ==== - -set_initial_password "${temp_neo4j_auth}" - if [[ ! -z "${NEO4JLABS_PLUGINS:-}" ]]; then # NEO4JLABS_PLUGINS should be a json array of plugins like '["graph-algorithms", "apoc", "streams", "graphql"]' install_neo4j_labs_plugins fi -# ==== INVOKE NEO4J STARTUP ==== - [ -f "${EXTENSION_SCRIPT:-}" ] && . ${EXTENSION_SCRIPT} if [ "${cmd}" == "dump-config" ]; then diff --git a/docker-image-src/4.1/docker-entrypoint.sh b/docker-image-src/4.1/docker-entrypoint.sh index 5eea5343..d9ca5dce 100755 --- a/docker-image-src/4.1/docker-entrypoint.sh +++ b/docker-image-src/4.1/docker-entrypoint.sh @@ -213,22 +213,8 @@ function install_neo4j_labs_plugins rm "${_old_config}" } -function add_docker_default_to_conf +function add_setting_to_conf { - # docker defaults should NOT overwrite values already in the conf file - local _setting="${1}" - local _value="${2}" - local _neo4j_home="${3}" - - if ! grep -q "^${_setting}=" "${_neo4j_home}"/conf/neo4j.conf - then - echo -e "\n"${_setting}=${_value} >> "${_neo4j_home}"/conf/neo4j.conf - fi -} - -function add_env_setting_to_conf -{ - # settings from environment variables should overwrite values already in the conf local _setting=${1} local _value=${2} local _neo4j_home=${3} @@ -248,7 +234,7 @@ function set_initial_password # set the neo4j initial password only if you run the database server if [ "${cmd}" == "neo4j" ]; then if [ "${_neo4j_auth:-}" == "none" ]; then - add_env_setting_to_conf "dbms.security.auth_enabled" "false" "${NEO4J_HOME}" + add_setting_to_conf "dbms.security.auth_enabled" "false" "${NEO4J_HOME}" # NEO4J_dbms_security_auth__enabled=false elif [[ "${_neo4j_auth:-}" =~ ^([^/]+)\/([^/]+)/?([tT][rR][uU][eE])?$ ]]; then admin_user="${BASH_REMATCH[1]}" @@ -315,15 +301,13 @@ if running_as_root; then fi # Only prompt for license agreement if command contains "neo4j" in it -# ==== CHECK LICENSE AGREEMENT ==== - if [[ "${cmd}" == *"neo4j"* ]]; then if [ "${NEO4J_EDITION}" == "enterprise" ]; then if [ "${NEO4J_ACCEPT_LICENSE_AGREEMENT:=no}" != "yes" ]; then echo >&2 " In order to use Neo4j Enterprise Edition you must accept the license agreement. -(c) Neo4j Sweden AB. 2021. All Rights Reserved. +(c) Neo4j Sweden AB. 2019. All Rights Reserved. Use of this Software without a proper commercial license with Neo4j, Inc. or its affiliates is prohibited. @@ -345,8 +329,6 @@ To do this you can use the following docker argument: fi # Env variable naming convention: -# ==== RENAME LEGACY ENVIRONMENT CONF VARIABLES ==== - # - prefix NEO4J_ # - double underscore char '__' instead of single underscore '_' char in the setting name # - underscore char '_' instead of dot '.' char in the setting name @@ -356,7 +338,7 @@ fi # Backward compatibility - map old hardcoded env variables into new naming convention (if they aren't set already) # Set some to default values if unset -: ${NEO4J_dbms_tx__log_rotation_retention__policy:=${NEO4J_dbms_txLog_rotation_retentionPolicy:-}} +: ${NEO4J_dbms_tx__log_rotation_retention__policy:=${NEO4J_dbms_txLog_rotation_retentionPolicy:-"100M size"}} : ${NEO4J_dbms_unmanaged__extension__classes:=${NEO4J_dbms_unmanagedExtensionClasses:-}} : ${NEO4J_dbms_allow__format__migration:=${NEO4J_dbms_allowFormatMigration:-}} : ${NEO4J_dbms_connectors_default__advertised__address:=${NEO4J_dbms_connectors_defaultAdvertisedAddress:-}} @@ -365,9 +347,13 @@ if [ "${NEO4J_EDITION}" == "enterprise" ]; then : ${NEO4J_causal__clustering_expected__core__cluster__size:=${NEO4J_causalClustering_expectedCoreClusterSize:-}} : ${NEO4J_causal__clustering_initial__discovery__members:=${NEO4J_causalClustering_initialDiscoveryMembers:-}} - : ${NEO4J_causal__clustering_discovery__advertised__address:=${NEO4J_causalClustering_discoveryAdvertisedAddress:-}} - : ${NEO4J_causal__clustering_transaction__advertised__address:=${NEO4J_causalClustering_transactionAdvertisedAddress:-}} - : ${NEO4J_causal__clustering_raft__advertised__address:=${NEO4J_causalClustering_raftAdvertisedAddress:-}} + : ${NEO4J_causal__clustering_discovery__advertised__address:=${NEO4J_causalClustering_discoveryAdvertisedAddress:-"$(hostname):5000"}} + : ${NEO4J_causal__clustering_transaction__advertised__address:=${NEO4J_causalClustering_transactionAdvertisedAddress:-"$(hostname):6000"}} + : ${NEO4J_causal__clustering_raft__advertised__address:=${NEO4J_causalClustering_raftAdvertisedAddress:-"$(hostname):7000"}} + # Custom settings for dockerized neo4j + : ${NEO4J_causal__clustering_discovery__advertised__address:=$(hostname):5000} + : ${NEO4J_causal__clustering_transaction__advertised__address:=$(hostname):6000} + : ${NEO4J_causal__clustering_raft__advertised__address:=$(hostname):7000} fi # unset old hardcoded unsupported env variables @@ -383,9 +369,6 @@ unset NEO4J_dbms_txLog_rotation_retentionPolicy NEO4J_UDC_SOURCE \ NEO4J_causalClustering_raftListenAddress \ NEO4J_causalClustering_raftAdvertisedAddress - -# ==== CHECK FILE PERMISSIONS ON MOUNTED FOLDERS ==== - if [ -d /conf ]; then check_mounted_folder_readable "/conf" find /conf -type f -exec cp {} "${NEO4J_HOME}"/conf \; @@ -434,24 +417,34 @@ if [ -d /data ]; then fi fi -# ==== SET CONFIGURATIONS ==== +declare -A COMMUNITY +declare -A ENTERPRISE -## == DOCKER SPECIFIC DEFAULT CONFIGURATIONS === -## these should not override *any* configurations set by the user +COMMUNITY=( + [dbms.tx_log.rotation.retention_policy]="100M size" + [dbms.memory.pagecache.size]="512M" + [dbms.default_listen_address]="0.0.0.0" +) -add_docker_default_to_conf "dbms.tx_log.rotation.retention_policy" "100M size" "${NEO4J_HOME}" -add_docker_default_to_conf "dbms.memory.pagecache.size" "512M" "${NEO4J_HOME}" -add_docker_default_to_conf "dbms.default_listen_address" "0.0.0.0" "${NEO4J_HOME}" -# set enterprise only docker defaults -if [ "${NEO4J_EDITION}" == "enterprise" ]; -then - add_docker_default_to_conf "causal_clustering.discovery_advertised_address" "$(hostname):5000" "${NEO4J_HOME}" - add_docker_default_to_conf "causal_clustering.transaction_advertised_address" "$(hostname):6000" "${NEO4J_HOME}" - add_docker_default_to_conf "causal_clustering.raft_advertised_address" "$(hostname):7000" "${NEO4J_HOME}" -fi +ENTERPRISE=( +) -## == ENVIRONMENT VARIABLE CONFIGURATIONS === -## these override BOTH defaults and any existing values in the neo4j.conf file +for conf in ${!COMMUNITY[@]} ; do + if ! grep -q "^$conf" "${NEO4J_HOME}"/conf/neo4j.conf + then + echo -e "\n"$conf=${COMMUNITY[$conf]} >> "${NEO4J_HOME}"/conf/neo4j.conf + fi +done + +for conf in ${!ENTERPRISE[@]} ; do + if [ "${NEO4J_EDITION}" == "enterprise" ]; + then + if ! grep -q "^$conf" "${NEO4J_HOME}"/conf/neo4j.conf + then + echo -e "\n"$conf=${ENTERPRISE[$conf]} >> "${NEO4J_HOME}"/conf/neo4j.conf + fi + fi +done # save NEO4J_HOME and NEO4J_AUTH to temp variables that don't begin with NEO4J_ so they don't get added to the conf temp_neo4j_home="${NEO4J_HOME}" @@ -464,7 +457,7 @@ for i in $( set | grep ^NEO4J_ | awk -F'=' '{print $1}' | sort -rn ); do # Don't allow settings with no value or settings that start with a number (neo4j converts settings to env variables and you cannot have an env variable that starts with a number) if [[ -n ${value} ]]; then if [[ ! "${setting}" =~ ^[0-9]+.*$ ]]; then - add_env_setting_to_conf "${setting}" "${value}" "${temp_neo4j_home}" + add_setting_to_conf "${setting}" "${value}" "${temp_neo4j_home}" else echo >&2 "WARNING: ${setting} not written to conf file because settings that start with a number are not permitted" fi @@ -472,9 +465,6 @@ for i in $( set | grep ^NEO4J_ | awk -F'=' '{print $1}' | sort -rn ); do done export NEO4J_HOME="${temp_neo4j_home}" unset temp_neo4j_home - -# ==== SET PASSWORD AND PLUGINS ==== - set_initial_password "${temp_neo4j_auth}" @@ -483,8 +473,6 @@ if [[ ! -z "${NEO4JLABS_PLUGINS:-}" ]]; then install_neo4j_labs_plugins fi -# ==== INVOKE NEO4J STARTUP ==== - [ -f "${EXTENSION_SCRIPT:-}" ] && . ${EXTENSION_SCRIPT} if [ "${cmd}" == "dump-config" ]; then diff --git a/docker-image-src/4.2/docker-entrypoint.sh b/docker-image-src/4.2/docker-entrypoint.sh index 6a724445..37390393 100755 --- a/docker-image-src/4.2/docker-entrypoint.sh +++ b/docker-image-src/4.2/docker-entrypoint.sh @@ -219,22 +219,8 @@ function install_neo4j_labs_plugins rm "${_old_config}" } -function add_docker_default_to_conf +function add_setting_to_conf { - # docker defaults should NOT overwrite values already in the conf file - local _setting="${1}" - local _value="${2}" - local _neo4j_home="${3}" - - if ! grep -q "^${_setting}=" "${_neo4j_home}"/conf/neo4j.conf - then - echo -e "\n"${_setting}=${_value} >> "${_neo4j_home}"/conf/neo4j.conf - fi -} - -function add_env_setting_to_conf -{ - # settings from environment variables should overwrite values already in the conf local _setting=${1} local _value=${2} local _neo4j_home=${3} @@ -254,7 +240,7 @@ function set_initial_password # set the neo4j initial password only if you run the database server if [ "${cmd}" == "neo4j" ]; then if [ "${_neo4j_auth:-}" == "none" ]; then - add_env_setting_to_conf "dbms.security.auth_enabled" "false" "${NEO4J_HOME}" + add_setting_to_conf "dbms.security.auth_enabled" "false" "${NEO4J_HOME}" # NEO4J_dbms_security_auth__enabled=false elif [[ "${_neo4j_auth:-}" =~ ^([^/]+)\/([^/]+)/?([tT][rR][uU][eE])?$ ]]; then admin_user="${BASH_REMATCH[1]}" @@ -324,8 +310,6 @@ if running_as_root; then find "${NEO4J_HOME}"/conf -type f -exec chmod -R 600 {} \; fi -# ==== CHECK LICENSE AGREEMENT ==== - # Only prompt for license agreement if command contains "neo4j" in it if [[ "${cmd}" == *"neo4j"* ]]; then if [ "${NEO4J_EDITION}" == "enterprise" ]; then @@ -333,7 +317,7 @@ if [[ "${cmd}" == *"neo4j"* ]]; then echo >&2 " In order to use Neo4j Enterprise Edition you must accept the license agreement. -(c) Neo4j Sweden AB. 2021. All Rights Reserved. +(c) Neo4j Sweden AB. 2019. All Rights Reserved. Use of this Software without a proper commercial license with Neo4j, Inc. or its affiliates is prohibited. @@ -354,8 +338,6 @@ To do this you can use the following docker argument: fi fi -# ==== RENAME LEGACY ENVIRONMENT CONF VARIABLES ==== - # Env variable naming convention: # - prefix NEO4J_ # - double underscore char '__' instead of single underscore '_' char in the setting name @@ -366,7 +348,7 @@ fi # Backward compatibility - map old hardcoded env variables into new naming convention (if they aren't set already) # Set some to default values if unset -: ${NEO4J_dbms_tx__log_rotation_retention__policy:=${NEO4J_dbms_txLog_rotation_retentionPolicy:-}} +: ${NEO4J_dbms_tx__log_rotation_retention__policy:=${NEO4J_dbms_txLog_rotation_retentionPolicy:-"100M size"}} : ${NEO4J_dbms_unmanaged__extension__classes:=${NEO4J_dbms_unmanagedExtensionClasses:-}} : ${NEO4J_dbms_allow__format__migration:=${NEO4J_dbms_allowFormatMigration:-}} : ${NEO4J_dbms_connectors_default__advertised__address:=${NEO4J_dbms_connectors_defaultAdvertisedAddress:-}} @@ -375,9 +357,13 @@ if [ "${NEO4J_EDITION}" == "enterprise" ]; then : ${NEO4J_causal__clustering_expected__core__cluster__size:=${NEO4J_causalClustering_expectedCoreClusterSize:-}} : ${NEO4J_causal__clustering_initial__discovery__members:=${NEO4J_causalClustering_initialDiscoveryMembers:-}} - : ${NEO4J_causal__clustering_discovery__advertised__address:=${NEO4J_causalClustering_discoveryAdvertisedAddress:-}} - : ${NEO4J_causal__clustering_transaction__advertised__address:=${NEO4J_causalClustering_transactionAdvertisedAddress:-}} - : ${NEO4J_causal__clustering_raft__advertised__address:=${NEO4J_causalClustering_raftAdvertisedAddress:-}} + : ${NEO4J_causal__clustering_discovery__advertised__address:=${NEO4J_causalClustering_discoveryAdvertisedAddress:-"$(hostname):5000"}} + : ${NEO4J_causal__clustering_transaction__advertised__address:=${NEO4J_causalClustering_transactionAdvertisedAddress:-"$(hostname):6000"}} + : ${NEO4J_causal__clustering_raft__advertised__address:=${NEO4J_causalClustering_raftAdvertisedAddress:-"$(hostname):7000"}} + # Custom settings for dockerized neo4j + : ${NEO4J_causal__clustering_discovery__advertised__address:=$(hostname):5000} + : ${NEO4J_causal__clustering_transaction__advertised__address:=$(hostname):6000} + : ${NEO4J_causal__clustering_raft__advertised__address:=$(hostname):7000} fi # unset old hardcoded unsupported env variables @@ -393,9 +379,6 @@ unset NEO4J_dbms_txLog_rotation_retentionPolicy NEO4J_UDC_SOURCE \ NEO4J_causalClustering_raftListenAddress \ NEO4J_causalClustering_raftAdvertisedAddress - -# ==== CHECK FILE PERMISSIONS ON MOUNTED FOLDERS ==== - if [ -d /conf ]; then check_mounted_folder_readable "/conf" rm -rf "${NEO4J_HOME}"/conf/* @@ -450,24 +433,34 @@ if [ -d /licenses ]; then : ${NEO4J_dbms_directories_licenses:="/licenses"} fi -# ==== SET CONFIGURATIONS ==== +declare -A COMMUNITY +declare -A ENTERPRISE -## == DOCKER SPECIFIC DEFAULT CONFIGURATIONS === -## these should not override *any* configurations set by the user +COMMUNITY=( + [dbms.tx_log.rotation.retention_policy]="100M size" + [dbms.memory.pagecache.size]="512M" + [dbms.default_listen_address]="0.0.0.0" +) -add_docker_default_to_conf "dbms.tx_log.rotation.retention_policy" "100M size" "${NEO4J_HOME}" -add_docker_default_to_conf "dbms.memory.pagecache.size" "512M" "${NEO4J_HOME}" -add_docker_default_to_conf "dbms.default_listen_address" "0.0.0.0" "${NEO4J_HOME}" -# set enterprise only docker defaults -if [ "${NEO4J_EDITION}" == "enterprise" ]; -then - add_docker_default_to_conf "causal_clustering.discovery_advertised_address" "$(hostname):5000" "${NEO4J_HOME}" - add_docker_default_to_conf "causal_clustering.transaction_advertised_address" "$(hostname):6000" "${NEO4J_HOME}" - add_docker_default_to_conf "causal_clustering.raft_advertised_address" "$(hostname):7000" "${NEO4J_HOME}" -fi +ENTERPRISE=( +) -## == ENVIRONMENT VARIABLE CONFIGURATIONS === -## these override BOTH defaults and any existing values in the neo4j.conf file +for conf in ${!COMMUNITY[@]} ; do + if ! grep -q "^$conf" "${NEO4J_HOME}"/conf/neo4j.conf + then + echo -e "\n"$conf=${COMMUNITY[$conf]} >> "${NEO4J_HOME}"/conf/neo4j.conf + fi +done + +for conf in ${!ENTERPRISE[@]} ; do + if [ "${NEO4J_EDITION}" == "enterprise" ]; + then + if ! grep -q "^$conf" "${NEO4J_HOME}"/conf/neo4j.conf + then + echo -e "\n"$conf=${ENTERPRISE[$conf]} >> "${NEO4J_HOME}"/conf/neo4j.conf + fi + fi +done # save NEO4J_HOME and NEO4J_AUTH to temp variables that don't begin with NEO4J_ so they don't get added to the conf temp_neo4j_home="${NEO4J_HOME}" @@ -480,7 +473,7 @@ for i in $( set | grep ^NEO4J_ | awk -F'=' '{print $1}' | sort -rn ); do # Don't allow settings with no value or settings that start with a number (neo4j converts settings to env variables and you cannot have an env variable that starts with a number) if [[ -n ${value} ]]; then if [[ ! "${setting}" =~ ^[0-9]+.*$ ]]; then - add_env_setting_to_conf "${setting}" "${value}" "${temp_neo4j_home}" + add_setting_to_conf "${setting}" "${value}" "${temp_neo4j_home}" else echo >&2 "WARNING: ${setting} not written to conf file because settings that start with a number are not permitted" fi @@ -488,9 +481,6 @@ for i in $( set | grep ^NEO4J_ | awk -F'=' '{print $1}' | sort -rn ); do done export NEO4J_HOME="${temp_neo4j_home}" unset temp_neo4j_home - -# ==== SET PASSWORD AND PLUGINS ==== - set_initial_password "${temp_neo4j_auth}" @@ -499,8 +489,6 @@ if [[ ! -z "${NEO4JLABS_PLUGINS:-}" ]]; then install_neo4j_labs_plugins fi -# ==== INVOKE NEO4J STARTUP ==== - [ -f "${EXTENSION_SCRIPT:-}" ] && . ${EXTENSION_SCRIPT} if [ "${cmd}" == "dump-config" ]; then diff --git a/docker-image-src/4.3/docker-entrypoint.sh b/docker-image-src/4.3/docker-entrypoint.sh index dd80bb88..53b06c8c 100755 --- a/docker-image-src/4.3/docker-entrypoint.sh +++ b/docker-image-src/4.3/docker-entrypoint.sh @@ -219,22 +219,8 @@ function install_neo4j_labs_plugins rm "${_old_config}" } -function add_docker_default_to_conf +function add_setting_to_conf { - # docker defaults should NOT overwrite values already in the conf file - local _setting="${1}" - local _value="${2}" - local _neo4j_home="${3}" - - if ! grep -q "^${_setting}=" "${_neo4j_home}"/conf/neo4j.conf - then - echo -e "\n"${_setting}=${_value} >> "${_neo4j_home}"/conf/neo4j.conf - fi -} - -function add_env_setting_to_conf -{ - # settings from environment variables should overwrite values already in the conf local _setting=${1} local _value=${2} local _neo4j_home=${3} @@ -254,7 +240,7 @@ function set_initial_password # set the neo4j initial password only if you run the database server if [ "${cmd}" == "neo4j" ]; then if [ "${_neo4j_auth:-}" == "none" ]; then - add_env_setting_to_conf "dbms.security.auth_enabled" "false" "${NEO4J_HOME}" + add_setting_to_conf "dbms.security.auth_enabled" "false" "${NEO4J_HOME}" # NEO4J_dbms_security_auth__enabled=false elif [[ "${_neo4j_auth:-}" =~ ^([^/]+)\/([^/]+)/?([tT][rR][uU][eE])?$ ]]; then admin_user="${BASH_REMATCH[1]}" @@ -324,8 +310,6 @@ if running_as_root; then find "${NEO4J_HOME}"/conf -type f -exec chmod -R 600 {} \; fi -# ==== CHECK LICENSE AGREEMENT ==== - # Only prompt for license agreement if command contains "neo4j" in it if [[ "${cmd}" == *"neo4j"* ]]; then if [ "${NEO4J_EDITION}" == "enterprise" ]; then @@ -333,7 +317,7 @@ if [[ "${cmd}" == *"neo4j"* ]]; then echo >&2 " In order to use Neo4j Enterprise Edition you must accept the license agreement. -(c) Neo4j Sweden AB. 2021. All Rights Reserved. +(c) Neo4j Sweden AB. 2019. All Rights Reserved. Use of this Software without a proper commercial license with Neo4j, Inc. or its affiliates is prohibited. @@ -354,8 +338,6 @@ To do this you can use the following docker argument: fi fi -# ==== RENAME LEGACY ENVIRONMENT CONF VARIABLES ==== - # Env variable naming convention: # - prefix NEO4J_ # - double underscore char '__' instead of single underscore '_' char in the setting name @@ -366,7 +348,7 @@ fi # Backward compatibility - map old hardcoded env variables into new naming convention (if they aren't set already) # Set some to default values if unset -: ${NEO4J_dbms_tx__log_rotation_retention__policy:=${NEO4J_dbms_txLog_rotation_retentionPolicy:-}} +: ${NEO4J_dbms_tx__log_rotation_retention__policy:=${NEO4J_dbms_txLog_rotation_retentionPolicy:-"100M size"}} : ${NEO4J_dbms_unmanaged__extension__classes:=${NEO4J_dbms_unmanagedExtensionClasses:-}} : ${NEO4J_dbms_allow__format__migration:=${NEO4J_dbms_allowFormatMigration:-}} : ${NEO4J_dbms_connectors_default__advertised__address:=${NEO4J_dbms_connectors_defaultAdvertisedAddress:-}} @@ -375,9 +357,14 @@ if [ "${NEO4J_EDITION}" == "enterprise" ]; then : ${NEO4J_causal__clustering_expected__core__cluster__size:=${NEO4J_causalClustering_expectedCoreClusterSize:-}} : ${NEO4J_causal__clustering_initial__discovery__members:=${NEO4J_causalClustering_initialDiscoveryMembers:-}} - : ${NEO4J_causal__clustering_discovery__advertised__address:=${NEO4J_causalClustering_discoveryAdvertisedAddress:-}} - : ${NEO4J_causal__clustering_transaction__advertised__address:=${NEO4J_causalClustering_transactionAdvertisedAddress:-}} - : ${NEO4J_causal__clustering_raft__advertised__address:=${NEO4J_causalClustering_raftAdvertisedAddress:-}} + : ${NEO4J_causal__clustering_discovery__advertised__address:=${NEO4J_causalClustering_discoveryAdvertisedAddress:-"$(hostname):5000"}} + : ${NEO4J_causal__clustering_transaction__advertised__address:=${NEO4J_causalClustering_transactionAdvertisedAddress:-"$(hostname):6000"}} + : ${NEO4J_causal__clustering_raft__advertised__address:=${NEO4J_causalClustering_raftAdvertisedAddress:-"$(hostname):7000"}} + # Custom settings for dockerized neo4j + : ${NEO4J_dbms_routing_advertised__address:=$(hostname):7688} + : ${NEO4J_causal__clustering_discovery__advertised__address:=$(hostname):5000} + : ${NEO4J_causal__clustering_transaction__advertised__address:=$(hostname):6000} + : ${NEO4J_causal__clustering_raft__advertised__address:=$(hostname):7000} fi # unset old hardcoded unsupported env variables @@ -393,9 +380,6 @@ unset NEO4J_dbms_txLog_rotation_retentionPolicy NEO4J_UDC_SOURCE \ NEO4J_causalClustering_raftListenAddress \ NEO4J_causalClustering_raftAdvertisedAddress -# ==== CHECK FILE PERMISSIONS ON MOUNTED FOLDERS ==== - - if [ -d /conf ]; then check_mounted_folder_readable "/conf" rm -rf "${NEO4J_HOME}"/conf/* @@ -450,24 +434,34 @@ if [ -d /licenses ]; then : ${NEO4J_dbms_directories_licenses:="/licenses"} fi -# ==== SET CONFIGURATIONS ==== +declare -A COMMUNITY +declare -A ENTERPRISE -## == DOCKER SPECIFIC DEFAULT CONFIGURATIONS === -## these should not override *any* configurations set by the user +COMMUNITY=( + [dbms.tx_log.rotation.retention_policy]="100M size" + [dbms.memory.pagecache.size]="512M" + [dbms.default_listen_address]="0.0.0.0" +) -add_docker_default_to_conf "dbms.tx_log.rotation.retention_policy" "100M size" "${NEO4J_HOME}" -add_docker_default_to_conf "dbms.memory.pagecache.size" "512M" "${NEO4J_HOME}" -add_docker_default_to_conf "dbms.default_listen_address" "0.0.0.0" "${NEO4J_HOME}" -# set enterprise only docker defaults -if [ "${NEO4J_EDITION}" == "enterprise" ]; -then - add_docker_default_to_conf "causal_clustering.discovery_advertised_address" "$(hostname):5000" "${NEO4J_HOME}" - add_docker_default_to_conf "causal_clustering.transaction_advertised_address" "$(hostname):6000" "${NEO4J_HOME}" - add_docker_default_to_conf "causal_clustering.raft_advertised_address" "$(hostname):7000" "${NEO4J_HOME}" -fi +ENTERPRISE=( +) -## == ENVIRONMENT VARIABLE CONFIGURATIONS === -## these override BOTH defaults and any existing values in the neo4j.conf file +for conf in ${!COMMUNITY[@]} ; do + if ! grep -q "^$conf" "${NEO4J_HOME}"/conf/neo4j.conf + then + echo -e "\n"$conf=${COMMUNITY[$conf]} >> "${NEO4J_HOME}"/conf/neo4j.conf + fi +done + +for conf in ${!ENTERPRISE[@]} ; do + if [ "${NEO4J_EDITION}" == "enterprise" ]; + then + if ! grep -q "^$conf" "${NEO4J_HOME}"/conf/neo4j.conf + then + echo -e "\n"$conf=${ENTERPRISE[$conf]} >> "${NEO4J_HOME}"/conf/neo4j.conf + fi + fi +done # save NEO4J_HOME and NEO4J_AUTH to temp variables that don't begin with NEO4J_ so they don't get added to the conf temp_neo4j_home="${NEO4J_HOME}" @@ -480,7 +474,7 @@ for i in $( set | grep ^NEO4J_ | awk -F'=' '{print $1}' | sort -rn ); do # Don't allow settings with no value or settings that start with a number (neo4j converts settings to env variables and you cannot have an env variable that starts with a number) if [[ -n ${value} ]]; then if [[ ! "${setting}" =~ ^[0-9]+.*$ ]]; then - add_env_setting_to_conf "${setting}" "${value}" "${temp_neo4j_home}" + add_setting_to_conf "${setting}" "${value}" "${temp_neo4j_home}" else echo >&2 "WARNING: ${setting} not written to conf file because settings that start with a number are not permitted" fi @@ -488,9 +482,6 @@ for i in $( set | grep ^NEO4J_ | awk -F'=' '{print $1}' | sort -rn ); do done export NEO4J_HOME="${temp_neo4j_home}" unset temp_neo4j_home - -# ==== SET PASSWORD AND PLUGINS ==== - set_initial_password "${temp_neo4j_auth}" @@ -499,8 +490,6 @@ if [[ ! -z "${NEO4JLABS_PLUGINS:-}" ]]; then install_neo4j_labs_plugins fi -# ==== INVOKE NEO4J STARTUP ==== - [ -f "${EXTENSION_SCRIPT:-}" ] && . ${EXTENSION_SCRIPT} if [ "${cmd}" == "dump-config" ]; then diff --git a/docker-image-src/4.4/docker-entrypoint.sh b/docker-image-src/4.4/docker-entrypoint.sh index dd80bb88..44127039 100755 --- a/docker-image-src/4.4/docker-entrypoint.sh +++ b/docker-image-src/4.4/docker-entrypoint.sh @@ -219,22 +219,8 @@ function install_neo4j_labs_plugins rm "${_old_config}" } -function add_docker_default_to_conf +function add_setting_to_conf { - # docker defaults should NOT overwrite values already in the conf file - local _setting="${1}" - local _value="${2}" - local _neo4j_home="${3}" - - if ! grep -q "^${_setting}=" "${_neo4j_home}"/conf/neo4j.conf - then - echo -e "\n"${_setting}=${_value} >> "${_neo4j_home}"/conf/neo4j.conf - fi -} - -function add_env_setting_to_conf -{ - # settings from environment variables should overwrite values already in the conf local _setting=${1} local _value=${2} local _neo4j_home=${3} @@ -254,7 +240,7 @@ function set_initial_password # set the neo4j initial password only if you run the database server if [ "${cmd}" == "neo4j" ]; then if [ "${_neo4j_auth:-}" == "none" ]; then - add_env_setting_to_conf "dbms.security.auth_enabled" "false" "${NEO4J_HOME}" + add_setting_to_conf "dbms.security.auth_enabled" "false" "${NEO4J_HOME}" # NEO4J_dbms_security_auth__enabled=false elif [[ "${_neo4j_auth:-}" =~ ^([^/]+)\/([^/]+)/?([tT][rR][uU][eE])?$ ]]; then admin_user="${BASH_REMATCH[1]}" @@ -324,8 +310,6 @@ if running_as_root; then find "${NEO4J_HOME}"/conf -type f -exec chmod -R 600 {} \; fi -# ==== CHECK LICENSE AGREEMENT ==== - # Only prompt for license agreement if command contains "neo4j" in it if [[ "${cmd}" == *"neo4j"* ]]; then if [ "${NEO4J_EDITION}" == "enterprise" ]; then @@ -333,7 +317,7 @@ if [[ "${cmd}" == *"neo4j"* ]]; then echo >&2 " In order to use Neo4j Enterprise Edition you must accept the license agreement. -(c) Neo4j Sweden AB. 2021. All Rights Reserved. +(c) Neo4j Sweden AB. 2019. All Rights Reserved. Use of this Software without a proper commercial license with Neo4j, Inc. or its affiliates is prohibited. @@ -354,8 +338,6 @@ To do this you can use the following docker argument: fi fi -# ==== RENAME LEGACY ENVIRONMENT CONF VARIABLES ==== - # Env variable naming convention: # - prefix NEO4J_ # - double underscore char '__' instead of single underscore '_' char in the setting name @@ -366,7 +348,7 @@ fi # Backward compatibility - map old hardcoded env variables into new naming convention (if they aren't set already) # Set some to default values if unset -: ${NEO4J_dbms_tx__log_rotation_retention__policy:=${NEO4J_dbms_txLog_rotation_retentionPolicy:-}} +: ${NEO4J_dbms_tx__log_rotation_retention__policy:=${NEO4J_dbms_txLog_rotation_retentionPolicy:-"100M size"}} : ${NEO4J_dbms_unmanaged__extension__classes:=${NEO4J_dbms_unmanagedExtensionClasses:-}} : ${NEO4J_dbms_allow__format__migration:=${NEO4J_dbms_allowFormatMigration:-}} : ${NEO4J_dbms_connectors_default__advertised__address:=${NEO4J_dbms_connectors_defaultAdvertisedAddress:-}} @@ -375,9 +357,14 @@ if [ "${NEO4J_EDITION}" == "enterprise" ]; then : ${NEO4J_causal__clustering_expected__core__cluster__size:=${NEO4J_causalClustering_expectedCoreClusterSize:-}} : ${NEO4J_causal__clustering_initial__discovery__members:=${NEO4J_causalClustering_initialDiscoveryMembers:-}} - : ${NEO4J_causal__clustering_discovery__advertised__address:=${NEO4J_causalClustering_discoveryAdvertisedAddress:-}} - : ${NEO4J_causal__clustering_transaction__advertised__address:=${NEO4J_causalClustering_transactionAdvertisedAddress:-}} - : ${NEO4J_causal__clustering_raft__advertised__address:=${NEO4J_causalClustering_raftAdvertisedAddress:-}} + : ${NEO4J_causal__clustering_discovery__advertised__address:=${NEO4J_causalClustering_discoveryAdvertisedAddress:-"$(hostname):5000"}} + : ${NEO4J_causal__clustering_transaction__advertised__address:=${NEO4J_causalClustering_transactionAdvertisedAddress:-"$(hostname):6000"}} + : ${NEO4J_causal__clustering_raft__advertised__address:=${NEO4J_causalClustering_raftAdvertisedAddress:-"$(hostname):7000"}} + # Custom settings for dockerized neo4j + : ${NEO4J_dbms_routing_advertised__address:=$(hostname):7688} + : ${NEO4J_causal__clustering_discovery__advertised__address:=$(hostname):5000} + : ${NEO4J_causal__clustering_transaction__advertised__address:=$(hostname):6000} + : ${NEO4J_causal__clustering_raft__advertised__address:=$(hostname):7000} fi # unset old hardcoded unsupported env variables @@ -393,9 +380,6 @@ unset NEO4J_dbms_txLog_rotation_retentionPolicy NEO4J_UDC_SOURCE \ NEO4J_causalClustering_raftListenAddress \ NEO4J_causalClustering_raftAdvertisedAddress -# ==== CHECK FILE PERMISSIONS ON MOUNTED FOLDERS ==== - - if [ -d /conf ]; then check_mounted_folder_readable "/conf" rm -rf "${NEO4J_HOME}"/conf/* @@ -450,24 +434,34 @@ if [ -d /licenses ]; then : ${NEO4J_dbms_directories_licenses:="/licenses"} fi -# ==== SET CONFIGURATIONS ==== +declare -A COMMUNITY +declare -A ENTERPRISE -## == DOCKER SPECIFIC DEFAULT CONFIGURATIONS === -## these should not override *any* configurations set by the user +COMMUNITY=( + [dbms.tx_log.rotation.retention_policy]="100M size" + [dbms.memory.pagecache.size]="512M" + [dbms.default_listen_address]="0.0.0.0" +) -add_docker_default_to_conf "dbms.tx_log.rotation.retention_policy" "100M size" "${NEO4J_HOME}" -add_docker_default_to_conf "dbms.memory.pagecache.size" "512M" "${NEO4J_HOME}" -add_docker_default_to_conf "dbms.default_listen_address" "0.0.0.0" "${NEO4J_HOME}" -# set enterprise only docker defaults -if [ "${NEO4J_EDITION}" == "enterprise" ]; -then - add_docker_default_to_conf "causal_clustering.discovery_advertised_address" "$(hostname):5000" "${NEO4J_HOME}" - add_docker_default_to_conf "causal_clustering.transaction_advertised_address" "$(hostname):6000" "${NEO4J_HOME}" - add_docker_default_to_conf "causal_clustering.raft_advertised_address" "$(hostname):7000" "${NEO4J_HOME}" -fi +ENTERPRISE=( +) -## == ENVIRONMENT VARIABLE CONFIGURATIONS === -## these override BOTH defaults and any existing values in the neo4j.conf file +for conf in ${!COMMUNITY[@]} ; do + if ! grep -q "^$conf" "${NEO4J_HOME}"/conf/neo4j.conf + then + echo -e "\n"$conf=${COMMUNITY[$conf]} >> "${NEO4J_HOME}"/conf/neo4j.conf + fi +done + +for conf in ${!ENTERPRISE[@]} ; do + if [ "${NEO4J_EDITION}" == "enterprise" ]; + then + if ! grep -q "^$conf" "${NEO4J_HOME}"/conf/neo4j.conf + then + echo -e "\n"$conf=${ENTERPRISE[$conf]} >> "${NEO4J_HOME}"/conf/neo4j.conf + fi + fi +done # save NEO4J_HOME and NEO4J_AUTH to temp variables that don't begin with NEO4J_ so they don't get added to the conf temp_neo4j_home="${NEO4J_HOME}" @@ -480,7 +474,7 @@ for i in $( set | grep ^NEO4J_ | awk -F'=' '{print $1}' | sort -rn ); do # Don't allow settings with no value or settings that start with a number (neo4j converts settings to env variables and you cannot have an env variable that starts with a number) if [[ -n ${value} ]]; then if [[ ! "${setting}" =~ ^[0-9]+.*$ ]]; then - add_env_setting_to_conf "${setting}" "${value}" "${temp_neo4j_home}" + add_setting_to_conf "${setting}" "${value}" "${temp_neo4j_home}" else echo >&2 "WARNING: ${setting} not written to conf file because settings that start with a number are not permitted" fi @@ -488,9 +482,6 @@ for i in $( set | grep ^NEO4J_ | awk -F'=' '{print $1}' | sort -rn ); do done export NEO4J_HOME="${temp_neo4j_home}" unset temp_neo4j_home - -# ==== SET PASSWORD AND PLUGINS ==== - set_initial_password "${temp_neo4j_auth}" @@ -499,8 +490,6 @@ if [[ ! -z "${NEO4JLABS_PLUGINS:-}" ]]; then install_neo4j_labs_plugins fi -# ==== INVOKE NEO4J STARTUP ==== - [ -f "${EXTENSION_SCRIPT:-}" ] && . ${EXTENSION_SCRIPT} if [ "${cmd}" == "dump-config" ]; then @@ -512,30 +501,15 @@ if [ "${cmd}" == "dump-config" ]; then exit 0 fi -# this prints out a command for us to run. -# the command is something like: `java ...[lots of java options]... neo4j.mainClass ...[some neo4j options]...` -function get_neo4j_run_cmd { - - local extraArgs=() - - if [ "${EXTENDED_CONF+"yes"}" == "yes" ]; then - extraArgs+=("--expand-commands") - fi - - if running_as_root; then - gosu neo4j:neo4j neo4j console --dry-run "${extraArgs[@]}" - else - neo4j console --dry-run "${extraArgs[@]}" - fi -} - # Use su-exec to drop privileges to neo4j user # Note that su-exec, despite its name, does not replicate the # functionality of exec, so we need to use both if [ "${cmd}" == "neo4j" ]; then - # separate declaration and use of get_neo4j_run_cmd so that error codes are correctly surfaced - neo4j_console_cmd="$(get_neo4j_run_cmd)" - eval "${exec_cmd} ${neo4j_console_cmd?:No Neo4j command was generated}" + if [ "${EXTENDED_CONF+"yes"}" == "yes" ]; then + ${exec_cmd} neo4j console --expand-commands + else + ${exec_cmd} neo4j console + fi else - ${exec_cmd} "$@" + ${exec_cmd} "$@" fi diff --git a/src/test/java/com/neo4j/docker/TestConfSettings.java b/src/test/java/com/neo4j/docker/TestConfSettings.java index e3d0eaec..36f354d1 100644 --- a/src/test/java/com/neo4j/docker/TestConfSettings.java +++ b/src/test/java/com/neo4j/docker/TestConfSettings.java @@ -4,8 +4,10 @@ import com.neo4j.docker.utils.Neo4jVersion; import com.neo4j.docker.utils.SetContainerUser; import com.neo4j.docker.utils.TestSettings; +import org.junit.Assert; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Assumptions; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -58,23 +60,13 @@ private Map parseConfFile(File conf) throws FileNotFoundExceptio return configurations; } - private void assertConfigurationPresentInDebugLog( Path debugLog, String setting, String value, boolean shouldBeFound ) throws IOException + private boolean isStringPresentInDebugLog( Path debugLog, String matchThis) throws IOException { // searches the debug log for the given string, returns true if present Stream lines = Files.lines(debugLog); - String actualSetting = lines.filter(s -> s.contains( setting )).findFirst().orElse( "" ); + Optional isMatch = lines.filter(s -> s.contains(matchThis)).findFirst(); lines.close(); - if(shouldBeFound) - { - Assertions.assertTrue( !actualSetting.isEmpty(), setting+" was never set" ); - Assertions.assertTrue( actualSetting.contains( value ), - setting +" is set to the wrong value. Expected: "+value+" Actual: " + actualSetting ); - } - else - { - Assertions.assertTrue( actualSetting.isEmpty(), - setting+" was set when it should not have been. Actual value: "+actualSetting ); - } + return isMatch.isPresent(); } @Test @@ -184,7 +176,8 @@ void testReadsTheConfFile() throws Exception } //Check if the container reads the conf file - assertConfigurationPresentInDebugLog( debugLog, "dbms.memory.heap.max_size", "512", true ); + Assertions.assertTrue( isStringPresentInDebugLog( debugLog, "dbms.memory.heap.max_size=512" ), + "dbms.memory.heap.max_size was not set correctly"); } @Test @@ -283,13 +276,14 @@ void testEnvVarsOverride() throws Exception SetContainerUser.nonRootUser( container ); //Create EnvVarsOverride.conf file Path confFile = Paths.get( "src", "test", "resources", "confs", "EnvVarsOverride.conf" ); - Files.copy( confFile, confMount.resolve( "neo4j.conf" ) ); + Files.copy( confFile, confMount.resolve( "EnvVarsOverride.conf" ) ); //Start the container container.setWaitStrategy( Wait.forHttp( "/" ).forPort( 7474 ).forStatusCode( 200 ) ); container.start(); } - assertConfigurationPresentInDebugLog( debugLog, "dbms.memory.pagecache.size", "512m",true ); + Assertions.assertTrue( isStringPresentInDebugLog( debugLog, "dbms.memory.pagecache.size=512" ), + "dbms.memory.pagecache.size was not set correctly"); } @Test @@ -312,52 +306,18 @@ void testEnterpriseOnlyDefaultsConfigsAreSet () throws Exception //Read debug.log to check that causal_clustering confs are set successfully String expectedTxAddress = container.getContainerId().substring( 0, 12 ) + ":6000"; - assertConfigurationPresentInDebugLog( logMount.resolve( "debug.log" ), - "causal_clustering.transaction_advertised_address", - expectedTxAddress, - true ); - } - } - - @Test - void testEnterpriseOnlyDefaultsDontOverrideConfFile () throws Exception - { - Assumptions.assumeTrue(TestSettings.EDITION == TestSettings.Edition.ENTERPRISE, - "This is testing only ENTERPRISE EDITION configs"); - - try(GenericContainer container = createContainer()) - { - Path testOutputFolder = HostFileSystemOperations.createTempFolder( "ee-only-not-ovewritten-" ); - Path confMount = HostFileSystemOperations.createTempFolderAndMountAsVolume( - container, - "conf-", - "/conf", - testOutputFolder ); - Path logMount = HostFileSystemOperations.createTempFolderAndMountAsVolume( - container, - "logs-", - "/logs", - testOutputFolder ); - // mount a configuration file with enterprise only sttings already set - Path confFile = Paths.get( "src", "test", "resources", "confs", "EnterpriseOnlyNotOverwritten.conf"); - Files.copy( confFile, confMount.resolve( "neo4j.conf" ) ); - - //Start the container - SetContainerUser.nonRootUser( container ); - container.setWaitStrategy( Wait.forHttp( "/" ).forPort( 7474 ).forStatusCode( 200 ) ); - container.start(); - //Read debug.log to check that causal_clustering confs are set successfully - - assertConfigurationPresentInDebugLog( logMount.resolve( "debug.log" ), - "causal_clustering.transaction_advertised_address", - "localhost:6060", - true ); + Assertions.assertTrue( isStringPresentInDebugLog(logMount.resolve( "debug.log" ), + "causal_clustering.transaction_advertised_address=" + expectedTxAddress ), + "causal_clustering.transaction_advertised_address was not set correctly" ); } } + // disabled because there are currently no enterprise-only settings + @Disabled @Test void testCommunityDoesNotHaveEnterpriseConfigs() throws Exception { + Assert.fail( "This test should not have run!" ); Assumptions.assumeTrue(TestSettings.EDITION == TestSettings.Edition.COMMUNITY, "This is testing only COMMUNITY EDITION configs"); Path debugLog; @@ -376,9 +336,8 @@ void testCommunityDoesNotHaveEnterpriseConfigs() throws Exception } //Read debug.log to check that causal_clustering confs are not present - assertConfigurationPresentInDebugLog( debugLog, "causal_clustering.transaction_listen_address", - "*", - false ); + Assertions.assertFalse(isStringPresentInDebugLog( debugLog, "causal_clustering.transaction_listen_address" ), + "causal_clustering.transaction_listen_address should not be on the Community debug.log"); } @Test @@ -410,10 +369,13 @@ void testJvmAdditionalNotOverridden() throws Exception container.start(); } - assertConfigurationPresentInDebugLog( logMount.resolve( "debug.log"), - "dbms.jvm.additional", - "-Dunsupported.dbms.udc.source=docker,-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005", - true ); + //Read the debug.log to check that dbms.jvm.additional was set correctly + Stream lines = Files.lines(logMount.resolve("debug.log")); + Optional jvmAdditionalMatch = lines.filter(s -> s.contains("dbms.jvm.additional=-Dunsupported.dbms.udc.source=docker,-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005")).findFirst(); + lines.close(); + Assertions.assertTrue(isStringPresentInDebugLog( logMount.resolve("debug.log"), + "dbms.jvm.additional=-Dunsupported.dbms.udc.source=docker,-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005"), + "dbms.jvm.additional is overriden by Docker-entrypoint"); } @Test diff --git a/src/test/resources/confs/EnterpriseOnlyNotOverwritten.conf b/src/test/resources/confs/EnterpriseOnlyNotOverwritten.conf deleted file mode 100644 index 36c4c925..00000000 --- a/src/test/resources/confs/EnterpriseOnlyNotOverwritten.conf +++ /dev/null @@ -1 +0,0 @@ -causal_clustering.transaction_advertised_address=localhost:6060 \ No newline at end of file