diff --git a/community/debian12/entrypoint.sh b/community/debian12/entrypoint.sh index 1aa9d0ea..c96d4e1e 100755 --- a/community/debian12/entrypoint.sh +++ b/community/debian12/entrypoint.sh @@ -27,20 +27,14 @@ function bash_eval_template() { local template_file=$1 local target_file=$2 - echo "" >"${target_file}" - - while IFS= read -r line; do - if grep -qE "[$][(]|[{]" <<<"${line}"; then - local update - update=$(eval echo "\"${line}\"") || exit 1 - grep -qE "[^[:space:]]*" <<<"${update}" && echo "${update}" >>"${target_file}" - else - echo "${line}" >>"${target_file}" - fi - done <"${template_file}" + local template= + template=$(cat "${template_file}") + local expanded= + expanded=$(eval echo "\"${template}\"" | grep -Ev '^[[:blank:]]*$') # Ignore failure when template is mounted in a read-only filesystem. rm "${template_file}" || true + echo "${expanded}" >"${target_file}" } # Fill out conffile with above values diff --git a/enterprise/debian12/entrypoint.sh b/enterprise/debian12/entrypoint.sh index 1aa9d0ea..c96d4e1e 100755 --- a/enterprise/debian12/entrypoint.sh +++ b/enterprise/debian12/entrypoint.sh @@ -27,20 +27,14 @@ function bash_eval_template() { local template_file=$1 local target_file=$2 - echo "" >"${target_file}" - - while IFS= read -r line; do - if grep -qE "[$][(]|[{]" <<<"${line}"; then - local update - update=$(eval echo "\"${line}\"") || exit 1 - grep -qE "[^[:space:]]*" <<<"${update}" && echo "${update}" >>"${target_file}" - else - echo "${line}" >>"${target_file}" - fi - done <"${template_file}" + local template= + template=$(cat "${template_file}") + local expanded= + expanded=$(eval echo "\"${template}\"" | grep -Ev '^[[:blank:]]*$') # Ignore failure when template is mounted in a read-only filesystem. rm "${template_file}" || true + echo "${expanded}" >"${target_file}" } # Fill out conffile with above values diff --git a/federal/debian12/entrypoint.sh b/federal/debian12/entrypoint.sh index 1aa9d0ea..c96d4e1e 100755 --- a/federal/debian12/entrypoint.sh +++ b/federal/debian12/entrypoint.sh @@ -27,20 +27,14 @@ function bash_eval_template() { local template_file=$1 local target_file=$2 - echo "" >"${target_file}" - - while IFS= read -r line; do - if grep -qE "[$][(]|[{]" <<<"${line}"; then - local update - update=$(eval echo "\"${line}\"") || exit 1 - grep -qE "[^[:space:]]*" <<<"${update}" && echo "${update}" >>"${target_file}" - else - echo "${line}" >>"${target_file}" - fi - done <"${template_file}" + local template= + template=$(cat "${template_file}") + local expanded= + expanded=$(eval echo "\"${template}\"" | grep -Ev '^[[:blank:]]*$') # Ignore failure when template is mounted in a read-only filesystem. rm "${template_file}" || true + echo "${expanded}" >"${target_file}" } # Fill out conffile with above values diff --git a/template/0/entrypoint.sh b/template/0/entrypoint.sh index 1aa9d0ea..c96d4e1e 100755 --- a/template/0/entrypoint.sh +++ b/template/0/entrypoint.sh @@ -27,20 +27,14 @@ function bash_eval_template() { local template_file=$1 local target_file=$2 - echo "" >"${target_file}" - - while IFS= read -r line; do - if grep -qE "[$][(]|[{]" <<<"${line}"; then - local update - update=$(eval echo "\"${line}\"") || exit 1 - grep -qE "[^[:space:]]*" <<<"${update}" && echo "${update}" >>"${target_file}" - else - echo "${line}" >>"${target_file}" - fi - done <"${template_file}" + local template= + template=$(cat "${template_file}") + local expanded= + expanded=$(eval echo "\"${template}\"" | grep -Ev '^[[:blank:]]*$') # Ignore failure when template is mounted in a read-only filesystem. rm "${template_file}" || true + echo "${expanded}" >"${target_file}" } # Fill out conffile with above values