Skip to content

Commit

Permalink
Cleaner template implementation.
Browse files Browse the repository at this point in the history
  • Loading branch information
kportertx committed Oct 18, 2023
1 parent 3c9c0d2 commit 530fd9e
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 44 deletions.
16 changes: 5 additions & 11 deletions community/debian12/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 5 additions & 11 deletions enterprise/debian12/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 5 additions & 11 deletions federal/debian12/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 5 additions & 11 deletions template/0/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 530fd9e

Please sign in to comment.