diff --git a/3.7-rc/alpine/docker-entrypoint.sh b/3.7-rc/alpine/docker-entrypoint.sh index 32b765c3..094b72f4 100755 --- a/3.7-rc/alpine/docker-entrypoint.sh +++ b/3.7-rc/alpine/docker-entrypoint.sh @@ -202,6 +202,16 @@ oldConfigFile="$configBase.config" newConfigFile="$configBase.conf" shouldWriteConfig="$haveConfig" +if [ -n "$shouldWriteConfig" ] && ! touch "$newConfigFile"; then + # config file exists but it isn't writeable (likely read-only mount, such as Kubernetes configMap) + export RABBITMQ_CONFIG_FILE='/tmp/rabbitmq.conf' + cp "$newConfigFile" "$RABBITMQ_CONFIG_FILE" + echo >&2 + echo >&2 "WARNING: '$newConfigFile' is not writable, but environment variables have been provided which request that we write to it" + echo >&2 " We have copied it to '$RABBITMQ_CONFIG_FILE' so it can be amended to work around the problem, but it is recommended that the read-only source file should be modified and the environment variables removed instead." + echo >&2 + newConfigFile="$RABBITMQ_CONFIG_FILE" +fi if [ -n "$shouldWriteConfig" ] && [ -f "$oldConfigFile" ]; then { echo "error: Docker configuration environment variables specified, but old-style (Erlang syntax) configuration file '$oldConfigFile' exists" diff --git a/3.7-rc/ubuntu/docker-entrypoint.sh b/3.7-rc/ubuntu/docker-entrypoint.sh index 4b002977..e159f8b5 100755 --- a/3.7-rc/ubuntu/docker-entrypoint.sh +++ b/3.7-rc/ubuntu/docker-entrypoint.sh @@ -202,6 +202,16 @@ oldConfigFile="$configBase.config" newConfigFile="$configBase.conf" shouldWriteConfig="$haveConfig" +if [ -n "$shouldWriteConfig" ] && ! touch "$newConfigFile"; then + # config file exists but it isn't writeable (likely read-only mount, such as Kubernetes configMap) + export RABBITMQ_CONFIG_FILE='/tmp/rabbitmq.conf' + cp "$newConfigFile" "$RABBITMQ_CONFIG_FILE" + echo >&2 + echo >&2 "WARNING: '$newConfigFile' is not writable, but environment variables have been provided which request that we write to it" + echo >&2 " We have copied it to '$RABBITMQ_CONFIG_FILE' so it can be amended to work around the problem, but it is recommended that the read-only source file should be modified and the environment variables removed instead." + echo >&2 + newConfigFile="$RABBITMQ_CONFIG_FILE" +fi if [ -n "$shouldWriteConfig" ] && [ -f "$oldConfigFile" ]; then { echo "error: Docker configuration environment variables specified, but old-style (Erlang syntax) configuration file '$oldConfigFile' exists" diff --git a/3.7/alpine/docker-entrypoint.sh b/3.7/alpine/docker-entrypoint.sh index 32b765c3..094b72f4 100755 --- a/3.7/alpine/docker-entrypoint.sh +++ b/3.7/alpine/docker-entrypoint.sh @@ -202,6 +202,16 @@ oldConfigFile="$configBase.config" newConfigFile="$configBase.conf" shouldWriteConfig="$haveConfig" +if [ -n "$shouldWriteConfig" ] && ! touch "$newConfigFile"; then + # config file exists but it isn't writeable (likely read-only mount, such as Kubernetes configMap) + export RABBITMQ_CONFIG_FILE='/tmp/rabbitmq.conf' + cp "$newConfigFile" "$RABBITMQ_CONFIG_FILE" + echo >&2 + echo >&2 "WARNING: '$newConfigFile' is not writable, but environment variables have been provided which request that we write to it" + echo >&2 " We have copied it to '$RABBITMQ_CONFIG_FILE' so it can be amended to work around the problem, but it is recommended that the read-only source file should be modified and the environment variables removed instead." + echo >&2 + newConfigFile="$RABBITMQ_CONFIG_FILE" +fi if [ -n "$shouldWriteConfig" ] && [ -f "$oldConfigFile" ]; then { echo "error: Docker configuration environment variables specified, but old-style (Erlang syntax) configuration file '$oldConfigFile' exists" diff --git a/3.7/ubuntu/docker-entrypoint.sh b/3.7/ubuntu/docker-entrypoint.sh index 4b002977..e159f8b5 100755 --- a/3.7/ubuntu/docker-entrypoint.sh +++ b/3.7/ubuntu/docker-entrypoint.sh @@ -202,6 +202,16 @@ oldConfigFile="$configBase.config" newConfigFile="$configBase.conf" shouldWriteConfig="$haveConfig" +if [ -n "$shouldWriteConfig" ] && ! touch "$newConfigFile"; then + # config file exists but it isn't writeable (likely read-only mount, such as Kubernetes configMap) + export RABBITMQ_CONFIG_FILE='/tmp/rabbitmq.conf' + cp "$newConfigFile" "$RABBITMQ_CONFIG_FILE" + echo >&2 + echo >&2 "WARNING: '$newConfigFile' is not writable, but environment variables have been provided which request that we write to it" + echo >&2 " We have copied it to '$RABBITMQ_CONFIG_FILE' so it can be amended to work around the problem, but it is recommended that the read-only source file should be modified and the environment variables removed instead." + echo >&2 + newConfigFile="$RABBITMQ_CONFIG_FILE" +fi if [ -n "$shouldWriteConfig" ] && [ -f "$oldConfigFile" ]; then { echo "error: Docker configuration environment variables specified, but old-style (Erlang syntax) configuration file '$oldConfigFile' exists" diff --git a/3.8-rc/alpine/docker-entrypoint.sh b/3.8-rc/alpine/docker-entrypoint.sh index 32b765c3..094b72f4 100755 --- a/3.8-rc/alpine/docker-entrypoint.sh +++ b/3.8-rc/alpine/docker-entrypoint.sh @@ -202,6 +202,16 @@ oldConfigFile="$configBase.config" newConfigFile="$configBase.conf" shouldWriteConfig="$haveConfig" +if [ -n "$shouldWriteConfig" ] && ! touch "$newConfigFile"; then + # config file exists but it isn't writeable (likely read-only mount, such as Kubernetes configMap) + export RABBITMQ_CONFIG_FILE='/tmp/rabbitmq.conf' + cp "$newConfigFile" "$RABBITMQ_CONFIG_FILE" + echo >&2 + echo >&2 "WARNING: '$newConfigFile' is not writable, but environment variables have been provided which request that we write to it" + echo >&2 " We have copied it to '$RABBITMQ_CONFIG_FILE' so it can be amended to work around the problem, but it is recommended that the read-only source file should be modified and the environment variables removed instead." + echo >&2 + newConfigFile="$RABBITMQ_CONFIG_FILE" +fi if [ -n "$shouldWriteConfig" ] && [ -f "$oldConfigFile" ]; then { echo "error: Docker configuration environment variables specified, but old-style (Erlang syntax) configuration file '$oldConfigFile' exists" diff --git a/3.8-rc/ubuntu/docker-entrypoint.sh b/3.8-rc/ubuntu/docker-entrypoint.sh index 4b002977..e159f8b5 100755 --- a/3.8-rc/ubuntu/docker-entrypoint.sh +++ b/3.8-rc/ubuntu/docker-entrypoint.sh @@ -202,6 +202,16 @@ oldConfigFile="$configBase.config" newConfigFile="$configBase.conf" shouldWriteConfig="$haveConfig" +if [ -n "$shouldWriteConfig" ] && ! touch "$newConfigFile"; then + # config file exists but it isn't writeable (likely read-only mount, such as Kubernetes configMap) + export RABBITMQ_CONFIG_FILE='/tmp/rabbitmq.conf' + cp "$newConfigFile" "$RABBITMQ_CONFIG_FILE" + echo >&2 + echo >&2 "WARNING: '$newConfigFile' is not writable, but environment variables have been provided which request that we write to it" + echo >&2 " We have copied it to '$RABBITMQ_CONFIG_FILE' so it can be amended to work around the problem, but it is recommended that the read-only source file should be modified and the environment variables removed instead." + echo >&2 + newConfigFile="$RABBITMQ_CONFIG_FILE" +fi if [ -n "$shouldWriteConfig" ] && [ -f "$oldConfigFile" ]; then { echo "error: Docker configuration environment variables specified, but old-style (Erlang syntax) configuration file '$oldConfigFile' exists" diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 4b002977..e159f8b5 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -202,6 +202,16 @@ oldConfigFile="$configBase.config" newConfigFile="$configBase.conf" shouldWriteConfig="$haveConfig" +if [ -n "$shouldWriteConfig" ] && ! touch "$newConfigFile"; then + # config file exists but it isn't writeable (likely read-only mount, such as Kubernetes configMap) + export RABBITMQ_CONFIG_FILE='/tmp/rabbitmq.conf' + cp "$newConfigFile" "$RABBITMQ_CONFIG_FILE" + echo >&2 + echo >&2 "WARNING: '$newConfigFile' is not writable, but environment variables have been provided which request that we write to it" + echo >&2 " We have copied it to '$RABBITMQ_CONFIG_FILE' so it can be amended to work around the problem, but it is recommended that the read-only source file should be modified and the environment variables removed instead." + echo >&2 + newConfigFile="$RABBITMQ_CONFIG_FILE" +fi if [ -n "$shouldWriteConfig" ] && [ -f "$oldConfigFile" ]; then { echo "error: Docker configuration environment variables specified, but old-style (Erlang syntax) configuration file '$oldConfigFile' exists"