@@ -21,37 +21,18 @@ trap "clean_exit" EXIT
21
21
# Source "util.sh" so we can have our nice tools.
22
22
. " $( cd " $( dirname " $0 " ) " ; pwd) /util.sh"
23
23
24
- # Configuration file
25
- if [ -n " ${NGINX_CERTBOT_CONFIG_FILE} " ] && [ ! -f " ${NGINX_CERTBOT_CONFIG_FILE} " ]; then
26
- # If the variable is set but the file doesn't exist we error out since this
27
- # is most likely a user error.
28
- error " NGINX_CERTBOT_CONFIG_FILE is configured but '${NGINX_CERTBOT_CONFIG_FILE} ' does not exist, exiting"
29
- exit 1
30
- fi
31
- export CONFIG_FILE=" ${NGINX_CERTBOT_CONFIG_FILE:-/ etc/ nginx-certbot/ config.yml} "
32
-
33
- # If the config file exist we extract configuration from it and override any corresponding environment variables:
34
- # - nginx-certbot.debug overrides DEBUG
35
- # - nginx-certbot.dhparam-size overrides DHPARAM_SIZE
36
- # - nginx-certbot.renewal-interval overrides RENEWAL_INTERVAL
37
- if [ -f " ${CONFIG_FILE} " ]; then
38
- debug " Configuration file '${CONFIG_FILE} ' exist."
39
- YAML_DEBUG=$( shyaml get-value nginx-certbot.debug ' ' < " ${CONFIG_FILE} " )
40
- if [ " ${YAML_DEBUG} " == " True" ] || [ " ${YAML_DEBUG} " == " 1" ]; then
41
- export DEBUG=1
42
- elif [ " ${YAML_DEBUG} " == " False" ] || [ " ${YAML_DEBUG} " == " 0" ]; then
43
- export DEBUG=0
44
- fi
45
- YAML_DHPARAM_SIZE=$( shyaml get-value nginx-certbot.dhparam-size ' ' < " ${CONFIG_FILE} " )
46
- if [ -n " ${YAML_DHPARAM_SIZE} " ]; then
47
- export DHPARAM_SIZE=${YAML_DHPARAM_SIZE}
48
- fi
49
- YAML_RENEWAL_INTERVAL=$( shyaml get-value nginx-certbot.renewal-interval ' ' < " ${CONFIG_FILE} " )
50
- if [ -n " ${YAML_RENEWAL_INTERVAL} " ]; then
51
- export RENEWAL_INTERVAL=${YAML_RENEWAL_INTERVAL}
24
+ # Configuration file from NGINX_CERTBOT_CONFIG_FILE environment variable. We make some noise
25
+ # here during startup if the variable is set to a file that doesn't exist since this is most
26
+ # likely a user error.
27
+ CONFIG_FILE=" ${NGINX_CERTBOT_CONFIG_FILE:-/ etc/ nginx-certbot/ config.yml} "
28
+ if [ ! -f " ${CONFIG_FILE} " ]; then
29
+ if [ -n " ${NGINX_CERTBOT_CONFIG_FILE} " ]; then
30
+ warning " NGINX_CERTBOT_CONFIG_FILE is configured but '${CONFIG_FILE} ' does not exist."
31
+ else
32
+ debug " Configuration file '${CONFIG_FILE} ' doesn't exist."
52
33
fi
53
34
else
54
- debug " Configuration file '${CONFIG_FILE} ' doesn't exist. Falling back to environment variables and default values ."
35
+ debug " Configuration file '${CONFIG_FILE} ' exist."
55
36
fi
56
37
57
38
# If the environment variable `DEBUG=1` is set, then this message is printed.
76
57
debug " PID of the main Nginx process: ${NGINX_PID} "
77
58
78
59
# Make sure a renewal interval is set before continuing.
60
+ # If we have a config file with 'nginx-certbot.renewal-interval' set we let that override
61
+ # the RENEWAL_INTERVAL environment variable
62
+ if [ -f " ${CONFIG_FILE} " ]; then
63
+ YAML_RENEWAL_INTERVAL=$( shyaml get-value nginx-certbot.renewal-interval ' ' < " ${CONFIG_FILE} " )
64
+ if [ -n " ${YAML_RENEWAL_INTERVAL} " ]; then
65
+ RENEWAL_INTERVAL=${YAML_RENEWAL_INTERVAL}
66
+ debug " Using nginx-certbot.renewal-interval=${RENEWAL_INTERVAL} from config file."
67
+ fi
68
+ fi
79
69
if [ -z " ${RENEWAL_INTERVAL} " ]; then
80
70
debug " RENEWAL_INTERVAL unset, using default of '8d'"
81
71
RENEWAL_INTERVAL=' 8d'
0 commit comments