Skip to content

Commit 63a71af

Browse files
committed
beta s6 secrets
1 parent 64761ee commit 63a71af

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
*
22
!.gitignore
3+
!01_envfile.sh
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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

0 commit comments

Comments
 (0)