diff --git a/bitnami/mongodb/4.2/debian-10/Dockerfile b/bitnami/mongodb/4.2/debian-10/Dockerfile index 19cdbf1a3797..52cf0517141d 100644 --- a/bitnami/mongodb/4.2/debian-10/Dockerfile +++ b/bitnami/mongodb/4.2/debian-10/Dockerfile @@ -25,7 +25,7 @@ RUN curl --silent -L https://github.com/mikefarah/yq/releases/download/2.4.0/yq_ COPY rootfs / RUN /postunpack.sh ENV BITNAMI_APP_NAME="mongodb" \ - BITNAMI_IMAGE_VERSION="4.2.3-debian-10-r9" \ + BITNAMI_IMAGE_VERSION="4.2.3-debian-10-r10" \ NAMI_PREFIX="/.nami" \ PATH="/opt/bitnami/mongodb/bin:$PATH" diff --git a/bitnami/mongodb/4.2/debian-10/prebuildfs/libfile.sh b/bitnami/mongodb/4.2/debian-10/prebuildfs/libfile.sh index 12010f043e49..337e2e779701 100644 --- a/bitnami/mongodb/4.2/debian-10/prebuildfs/libfile.sh +++ b/bitnami/mongodb/4.2/debian-10/prebuildfs/libfile.sh @@ -5,18 +5,56 @@ # Functions ######################## -# Ensure a line exists in the file by replacing a matching line. +# Replace a regex in a file # Arguments: # $1 - filename -# $2 - line -# $3 - match +# $2 - match regex +# $3 - substitute regex +# $4 - use POSIX regex. Default: true # Returns: # None ######################### -file_contains_line() { +replace_in_file() { local filename="${1:?filename is required}" - local line="${2:?line is required}" - local match="${3:?match is required}" + local match_regex="${2:?match regex is required}" + local substitute_regex="${3:?substitute regex is required}" + local posix_regex=${4:-true} - sed --in-place "s/^$match\$/$line/" "$filename" + local result + + # We should avoid using 'sed in-place' substitutions + # 1) They are not compatible with files mounted from ConfigMap(s) + # 2) We found incompatibility issues with Debian10 and "in-place" substitutions + if [[ $posix_regex = true ]]; then + result="$(sed -E "s@$match_regex@$substitute_regex@g" "$filename")" + else + result="$(sed "s@$match_regex@$substitute_regex@g" "$filename")" + fi + echo "$result" > "$filename" +} + +######################## +# Remove a line in a file based on a regex +# Arguments: +# $1 - filename +# $2 - match regex +# $3 - use POSIX regex. Default: true +# Returns: +# None +######################### +remove_in_file() { + local filename="${1:?filename is required}" + local match_regex="${2:?match regex is required}" + local posix_regex=${3:-true} + local result + + # We should avoid using 'sed in-place' substitutions + # 1) They are not compatible with files mounted from ConfigMap(s) + # 2) We found incompatibility issues with Debian10 and "in-place" substitutions + if [[ $posix_regex = true ]]; then + result="$(sed -E "/$match_regex/d" "$filename")" + else + result="$(sed "/$match_regex/d" "$filename")" + fi + echo "$result" > "$filename" } diff --git a/bitnami/mongodb/4.2/debian-10/rootfs/libmongodb.sh b/bitnami/mongodb/4.2/debian-10/rootfs/libmongodb.sh index 480fce46bb7e..ba62a87280c8 100644 --- a/bitnami/mongodb/4.2/debian-10/rootfs/libmongodb.sh +++ b/bitnami/mongodb/4.2/debian-10/rootfs/libmongodb.sh @@ -584,7 +584,13 @@ rs.initiate({"_id":"$MONGODB_REPLICA_SET_NAME", "members":[{"_id":0,"host":"$nod EOF ) - grep -q "\"ok\" : 1\|\"code\" : 23" <<< "$result" + # Code 23 is considered OK + # It indicates that the node is already initialized + if grep -q "\"code\" : 23" <<< "$result"; then + warn "Node already initialized." + return 0 + fi + grep -q "\"ok\" : 1" <<< "$result" } @@ -609,10 +615,9 @@ EOF # It indicates a possiblely desynced configuration, # which will become resynced when the secondary joins the replicaset. if grep -q "\"code\" : 103" <<< "$result"; then - warn "The ReplicaSet configuration is not aligned with primary node's configuration. Starting secondary node so it syncs with ReplicaSet..." - return 0 + warn "The ReplicaSet configuration is not aligned with primary node's configuration. Starting secondary node so it syncs with ReplicaSet..." + return 0 fi - grep -q "\"ok\" : 1" <<< "$result" } diff --git a/bitnami/mongodb/README.md b/bitnami/mongodb/README.md index e057229dfc8b..0e9a19296a6e 100644 --- a/bitnami/mongodb/README.md +++ b/bitnami/mongodb/README.md @@ -49,7 +49,7 @@ Learn more about the Bitnami tagging policy and the difference between rolling t * [`4.2-ol-7`, `4.2.3-ol-7-r8` (4.2/ol-7/Dockerfile)](https://github.com/bitnami/bitnami-docker-mongodb/blob/4.2.3-ol-7-r8/4.2/ol-7/Dockerfile) -* [`4.2-debian-10`, `4.2.3-debian-10-r9`, `4.2`, `4.2.3` (4.2/debian-10/Dockerfile)](https://github.com/bitnami/bitnami-docker-mongodb/blob/4.2.3-debian-10-r9/4.2/debian-10/Dockerfile) +* [`4.2-debian-10`, `4.2.3-debian-10-r10`, `4.2`, `4.2.3` (4.2/debian-10/Dockerfile)](https://github.com/bitnami/bitnami-docker-mongodb/blob/4.2.3-debian-10-r10/4.2/debian-10/Dockerfile) * [`4.0-ol-7`, `4.0.16-ol-7-r3` (4.0/ol-7/Dockerfile)](https://github.com/bitnami/bitnami-docker-mongodb/blob/4.0.16-ol-7-r3/4.0/ol-7/Dockerfile) * [`3.6-ol-7`, `3.6.17-ol-7-r8` (3.6/ol-7/Dockerfile)](https://github.com/bitnami/bitnami-docker-mongodb/blob/3.6.17-ol-7-r8/3.6/ol-7/Dockerfile) * [`3.6-debian-10`, `0.0.0-debian-10-r0`, `3.6`, `0.0.0` (3.6/debian-10/Dockerfile)](https://github.com/bitnami/bitnami-docker-mongodb/blob/0.0.0-debian-10-r0/3.6/debian-10/Dockerfile)