|
1 | | -#! /bin/bash |
| 1 | +#!/usr/bin/with-contenv bash |
2 | 2 | # ref: https://github.com/linuxserver/docker-baseimage-alpine/blob/master/root/etc/cont-init.d/01-envfile |
3 | 3 |
|
4 | 4 | # in s6, environmental variables are written as text files for s6 to monitor |
5 | 5 | # seach through full-path filenames for files ending in "__FILE" |
6 | 6 | for FILENAME in $(find /var/run/s6/container_environment/ | grep "__FILE$"); do |
7 | | - echo "[secret-init] Evaluating ${FILENAME##*/}" |
| 7 | + echo "[secret-init] Evaluating ${FILENAME##*/} ..." |
8 | 8 |
|
9 | 9 | # set SECRETFILE to the contents of the full-path textfile |
10 | 10 | SECRETFILE=$(cat ${FILENAME}) |
11 | 11 | # SECRETFILE=${FILENAME} |
12 | | - echo "[secret-init] Setting SECRETFILE to ${SECRETFILE}..." # DEBUG - rm for prod! |
| 12 | + # echo "[secret-init] Set SECRETFILE to ${SECRETFILE}" # DEBUG - rm for prod! |
13 | 13 |
|
14 | 14 | # if SECRETFILE exists / is not null |
15 | 15 | if [[ -f ${SECRETFILE} ]]; then |
16 | 16 | # strip the appended "__FILE" from environmental variable name ... |
17 | 17 | STRIPFILE=$(echo ${FILENAME} | sed "s/__FILE//g") |
18 | | - echo "[secret-init] Set STRIPFILE to ${STRIPFILE}" # DEBUG - rm for prod! |
| 18 | + # echo "[secret-init] Set STRIPFILE to ${STRIPFILE}" # DEBUG - rm for prod! |
19 | 19 |
|
20 | 20 | # ... and set value to contents of secretfile |
21 | 21 | # since s6 uses text files, this is effectively "export ..." |
22 | | - # cat ${SECRETFILE} > ${STRIPFILE} |
23 | | - cat $(${SECRETFILE} | sed "s/[^\w.-]+//g") > ${STRIPFILE} |
24 | | - echo "[secret-init] Set ${STRIPFILE} to $(cat ${STRIPFILE})" # DEBUG - rm for prod!" |
25 | | - echo "[secret-init] Success! ${STRIPFILE} set from ${FILENAME}" |
| 22 | + printf $(cat ${SECRETFILE}) > ${STRIPFILE} |
| 23 | + # echo "[secret-init] Set ${STRIPFILE##*/} to $(cat ${STRIPFILE})" # DEBUG - rm for prod!" |
| 24 | + echo "[secret-init] Success! ${STRIPFILE##*/} set from ${FILENAME##*/}" |
26 | 25 |
|
27 | 26 | else |
28 | 27 | echo "[secret-init] cannot find secret in ${FILENAME}" |
|
0 commit comments