File tree Expand file tree Collapse file tree 2 files changed +29
-0
lines changed
docker/rootfs/etc/cont-init.d Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Original file line number Diff line number Diff line change 1
1
*
2
2
! .gitignore
3
+ ! 01_envfile.sh
Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+ # ref: https://github.com/linuxserver/docker-baseimage-alpine/blob/master/root/etc/cont-init.d/01-envfile
3
+
4
+ # in s6, environmental variables are written as text files for s6 to monitor
5
+ for FILENAME in $( find /var/run/s6/container_environment/ | grep " ^.*__FILE" ) ; do
6
+ echo " [secret-init] Evaluating ${FILENAME} "
7
+
8
+ # set SECRETFILE to the contents of the variable
9
+ SECRETFILE=$( cat ${FILENAME} )
10
+ # SECRETFILE=${FILENAME}
11
+ echo " [secret-init] Setting SECRETFILE to ${SECRETFILE} ..." # DEBUG - rm for prod!
12
+
13
+ # if SECRETFILE exists / is not null
14
+ if [[ -f ${SECRETFILE} ]]; then
15
+ # strip the appended "__FILE" from environmental variable name ...
16
+ STRIPFILE=$( echo $FILENAME | sed " s/__FILE//g" )
17
+ echo " [secret-init] Set STRIPFILE to ${STRIPFILE} " # DEBUG - rm for prod!
18
+
19
+ # ... and set value to contents of secretfile
20
+ # since s6 uses text files, this is effectively "export ..."
21
+ cat ${SECRETFILE} > ${STRIPFILE}
22
+ echo " [secret-init] Set ${STRIPFILE} to $( cat ${STRIPFILE} ) " # DEBUG - rm for prod!"
23
+ echo " [secret-init] Success! ${STRIPFILE##*/ } set from ${FILENAME##*/ } "
24
+
25
+ else
26
+ echo " [secret-init] cannot find secret in ${FILENAME##*/ } "
27
+ fi
28
+ done
You can’t perform that action at this time.
0 commit comments