File tree Expand file tree Collapse file tree 1 file changed +6
-11
lines changed
files/docker-entrypoint.d Expand file tree Collapse file tree 1 file changed +6
-11
lines changed Original file line number Diff line number Diff line change 1
- #! /bin/sh
1
+ #! /bin/bash
2
2
3
- # A stripped down copy paste of https://github.com/nginxinc/docker-nginx/blob/master/entrypoint/20-envsubst-on-templates.sh
3
+ # A stripped down copy of https://github.com/nginxinc/docker-nginx/blob/master/entrypoint/20-envsubst-on-templates.sh
4
4
5
5
set -e
6
6
7
- ME=$( basename $0 )
7
+ ME=$( basename " $0 " )
8
8
9
9
www_envsubst () {
10
10
local www_dir=" ${NGINX_ENVSUBST_WWW_DIR:-/ var/ www/ } "
11
- local template defined_envs
12
11
13
- defined_envs=$( printf ' ${%s} ' $( env | cut -d= -f1) )
14
-
15
12
[ -d " $www_dir " ] || return 0
16
13
if [ ! -w " $www_dir " ]; then
17
14
echo >&3 " $ME : ERROR: $www_dir is not writable"
18
15
return 0
19
16
fi
20
17
21
- find " $www_dir " -follow -type f -print | while read -r file; do
22
- tmpfile=$( mktemp)
23
- cp --attributes-only --preserve " $file " " $tmpfile "
24
- envsubst " $defined_envs " < " $file " > " $tmpfile " && mv " $tmpfile " " $file "
18
+ grep --recursive --no-messages --files-with-matches " \$ {" " $www_dir " | while read -r file; do
19
+ envsubst < " $file " > " $file .new" && cp --attributes-only --preserve " $file " " $file .new" && mv " $file .new" " $file "
25
20
done
26
21
}
27
22
28
23
www_envsubst
29
24
30
- exit 0
25
+ exit 0
You can’t perform that action at this time.
0 commit comments