File tree 1 file changed +29
-0
lines changed
1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change 2
2
# Wrapper around CHP entrypoint that changes defaults slightly
3
3
# to be more appropriate when run in a container.
4
4
5
+ # usage: file_env VAR [DEFAULT]
6
+ # ie: file_env 'XYZ_DB_PASSWORD' 'example'
7
+ # (will allow for "$XYZ_DB_PASSWORD_FILE" to fill in the value of
8
+ # "$XYZ_DB_PASSWORD" from a file, especially for Docker's secrets feature)
9
+ file_env () {
10
+ var=$1
11
+ file_var=" ${var} _FILE"
12
+ var_value=$( printenv $var || true)
13
+ file_var_value=$( printenv $file_var || true)
14
+ default_value=$2
15
+
16
+ if [ -n " $var_value " -a -n " $file_var_value " ]; then
17
+ echo >&2 " error: both $var and $file_var are set (but are exclusive)"
18
+ exit 1
19
+ fi
20
+
21
+ if [ -z " ${var_value} " ]; then
22
+ if [ -z " ${file_var_value} " ]; then
23
+ export " ${var} " =" ${default_value} "
24
+ else
25
+ export " ${var} " =" $( cat $file_var_value ) "
26
+ fi
27
+ fi
28
+
29
+ unset " $file_var "
30
+ }
31
+
32
+ file_env ' CONFIGPROXY_AUTH_TOKEN'
33
+
5
34
case " $@ " in
6
35
* " --api-ip" * )
7
36
break ;;
You can’t perform that action at this time.
0 commit comments