Skip to content

Commit

Permalink
Move some older s6-overlay over to new format, fixes #2705
Browse files Browse the repository at this point in the history
  • Loading branch information
jc21 committed Mar 18, 2023
1 parent 8c15340 commit 82d9452
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 43 deletions.
2 changes: 0 additions & 2 deletions docker/rootfs/etc/cont-finish.d/.gitignore

This file was deleted.

3 changes: 0 additions & 3 deletions docker/rootfs/etc/cont-init.d/.gitignore

This file was deleted.

7 changes: 0 additions & 7 deletions docker/rootfs/etc/cont-init.d/01_perms.sh

This file was deleted.

29 changes: 0 additions & 29 deletions docker/rootfs/etc/cont-init.d/01_s6-secret-init.sh

This file was deleted.

2 changes: 0 additions & 2 deletions docker/rootfs/etc/fix-attrs.d/.gitignore

This file was deleted.

30 changes: 30 additions & 0 deletions docker/rootfs/etc/s6-overlay/s6-rc.d/prepare/script.sh
Expand Up @@ -48,10 +48,40 @@ else
echo resolver "$(awk 'BEGIN{ORS=" "} $1=="nameserver" { sub(/%.*$/,"",$2); print ($2 ~ ":")? "["$2"]": $2}' /etc/resolv.conf) valid=10s;" > /etc/nginx/conf.d/include/resolvers.conf
fi

echo "Changing ownership of /data/logs to $(id -u):$(id -g)"
chown -R "$(id -u):$(id -g)" /data/logs

# Handle IPV6 settings
/bin/handle-ipv6-setting /etc/nginx/conf.d
/bin/handle-ipv6-setting /data/nginx

# ref: https://github.com/linuxserver/docker-baseimage-alpine/blob/master/root/etc/cont-init.d/01-envfile

# in s6, environmental variables are written as text files for s6 to monitor
# search through full-path filenames for files ending in "__FILE"
echo "❯ Secrets-init ..."
for FILENAME in $(find /var/run/s6/container_environment/ | grep "__FILE$"); do
echo "[secret-init] Evaluating ${FILENAME##*/} ..."

# set SECRETFILE to the contents of the full-path textfile
SECRETFILE=$(cat "${FILENAME}")
# if SECRETFILE exists / is not null
if [[ -f "${SECRETFILE}" ]]; then
# strip the appended "__FILE" from environmental variable name ...
STRIPFILE=$(echo "${FILENAME}" | sed "s/__FILE//g")
# echo "[secret-init] Set STRIPFILE to ${STRIPFILE}" # DEBUG - rm for prod!

# ... and set value to contents of secretfile
# since s6 uses text files, this is effectively "export ..."
printf $(cat "${SECRETFILE}") > "${STRIPFILE}"
# echo "[secret-init] Set ${STRIPFILE##*/} to $(cat ${STRIPFILE})" # DEBUG - rm for prod!"
echo "[secret-init] Success! ${STRIPFILE##*/} set from ${FILENAME##*/}"

else
echo "[secret-init] cannot find secret in ${FILENAME}"
fi
done

echo
echo "-------------------------------------
_ _ ____ __ __
Expand Down

0 comments on commit 82d9452

Please sign in to comment.