diff --git a/root/etc/s6-overlay/s6-rc.d/init-envfile/run b/root/etc/s6-overlay/s6-rc.d/init-envfile/run index 5dbf809..592df52 100755 --- a/root/etc/s6-overlay/s6-rc.d/init-envfile/run +++ b/root/etc/s6-overlay/s6-rc.d/init-envfile/run @@ -1,17 +1,19 @@ #!/usr/bin/with-contenv bash # shellcheck shell=bash -if find /run/s6/container_environment/*"FILE__"* -maxdepth 1 > /dev/null 2>&1; then - for FILENAME in /run/s6/container_environment/*; do - if [[ "${FILENAME##*/}" == "FILE__"* ]]; then +if find /run/s6/container_environment/FILE__* -maxdepth 1 > /dev/null 2>&1; then + for FILENAME in /run/s6/container_environment/FILE__*; do SECRETFILE=$(cat "${FILENAME}") if [[ -f ${SECRETFILE} ]]; then FILESTRIP=${FILENAME//FILE__/} + if [[ $(tail -n1 "${SECRETFILE}" | wc -l) != 0 ]]; then + echo "[env-init] Your secret: ${FILENAME##*/}" + echo " contains a trailing newline and may not work as expected" + fi cat "${SECRETFILE}" >"${FILESTRIP}" echo "[env-init] ${FILESTRIP##*/} set from ${FILENAME##*/}" else echo "[env-init] cannot find secret in ${FILENAME##*/}" fi - fi done fi