|
48 | 48 | 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
|
49 | 49 | fi
|
50 | 50 |
|
| 51 | +echo "Changing ownership of /data/logs to $(id -u):$(id -g)" |
| 52 | +chown -R "$(id -u):$(id -g)" /data/logs |
| 53 | + |
51 | 54 | # Handle IPV6 settings
|
52 | 55 | /bin/handle-ipv6-setting /etc/nginx/conf.d
|
53 | 56 | /bin/handle-ipv6-setting /data/nginx
|
54 | 57 |
|
| 58 | +# ref: https://github.com/linuxserver/docker-baseimage-alpine/blob/master/root/etc/cont-init.d/01-envfile |
| 59 | + |
| 60 | +# in s6, environmental variables are written as text files for s6 to monitor |
| 61 | +# search through full-path filenames for files ending in "__FILE" |
| 62 | +echo "❯ Secrets-init ..." |
| 63 | +for FILENAME in $(find /var/run/s6/container_environment/ | grep "__FILE$"); do |
| 64 | + echo "[secret-init] Evaluating ${FILENAME##*/} ..." |
| 65 | + |
| 66 | + # set SECRETFILE to the contents of the full-path textfile |
| 67 | + SECRETFILE=$(cat "${FILENAME}") |
| 68 | + # if SECRETFILE exists / is not null |
| 69 | + if [[ -f "${SECRETFILE}" ]]; then |
| 70 | + # strip the appended "__FILE" from environmental variable name ... |
| 71 | + STRIPFILE=$(echo "${FILENAME}" | sed "s/__FILE//g") |
| 72 | + # echo "[secret-init] Set STRIPFILE to ${STRIPFILE}" # DEBUG - rm for prod! |
| 73 | + |
| 74 | + # ... and set value to contents of secretfile |
| 75 | + # since s6 uses text files, this is effectively "export ..." |
| 76 | + printf $(cat "${SECRETFILE}") > "${STRIPFILE}" |
| 77 | + # echo "[secret-init] Set ${STRIPFILE##*/} to $(cat ${STRIPFILE})" # DEBUG - rm for prod!" |
| 78 | + echo "[secret-init] Success! ${STRIPFILE##*/} set from ${FILENAME##*/}" |
| 79 | + |
| 80 | + else |
| 81 | + echo "[secret-init] cannot find secret in ${FILENAME}" |
| 82 | + fi |
| 83 | +done |
| 84 | + |
55 | 85 | echo
|
56 | 86 | echo "-------------------------------------
|
57 | 87 | _ _ ____ __ __
|
|
0 commit comments