@@ -8,16 +8,15 @@ info "Starting certificate renewal process"
8
8
9
9
# If we have a config file we parse it and let definitions within take
10
10
# precedence over any environment variables.
11
- config_file=" ${NGINX_CERTBOT_CONFIG_FILE:-/ etc/ nginx-certbot/ config.yml} "
12
- if [ -f " ${config_file} " ]; then
13
- certbot_authenticator=" $( shyaml get-value certbot.authenticator ' ' < " ${config_file} " ) "
14
- certbot_elliptic_curve=" $( shyaml get-value certbot.elliptic-curve ' ' < " ${config_file} " ) "
15
- certbot_email=" $( shyaml get-value certbot.email ' ' < " ${config_file} " ) "
16
- certbot_key_type=" $( shyaml get-value certbot.key-type ' ' < " ${config_file} " ) "
17
- certbot_rsa_key_size=" $( shyaml get-value certbot.rsa-key-size ' ' < " ${config_file} " ) "
18
- certbot_staging=" $( shyaml get-value certbot.staging ' ' < " ${config_file} " ) "
19
- certbot_production_url=" $( shyaml get-value certbot.production_url ' ' < " ${config_file} " ) "
20
- certbot_staging_url=" $( shyaml get-value certbot.staging_url ' ' < " ${config_file} " ) "
11
+ if [ -f " ${CONFIG_FILE} " ]; then
12
+ certbot_authenticator=" $( shyaml get-value certbot.authenticator ' ' < " ${CONFIG_FILE} " ) "
13
+ certbot_elliptic_curve=" $( shyaml get-value certbot.elliptic-curve ' ' < " ${CONFIG_FILE} " ) "
14
+ certbot_email=" $( shyaml get-value certbot.email ' ' < " ${CONFIG_FILE} " ) "
15
+ certbot_key_type=" $( shyaml get-value certbot.key-type ' ' < " ${CONFIG_FILE} " ) "
16
+ certbot_rsa_key_size=" $( shyaml get-value certbot.rsa-key-size ' ' < " ${CONFIG_FILE} " ) "
17
+ certbot_staging=" $( shyaml get-value certbot.staging ' ' < " ${CONFIG_FILE} " ) "
18
+ certbot_production_url=" $( shyaml get-value certbot.production_url ' ' < " ${CONFIG_FILE} " ) "
19
+ certbot_staging_url=" $( shyaml get-value certbot.staging_url ' ' < " ${CONFIG_FILE} " ) "
21
20
fi
22
21
23
22
# Environment variable fallbacks
@@ -135,19 +134,19 @@ get_certificate() {
135
134
# If we have a config file we request certificates based on the specifications
136
135
# within that file otherwise we parse the nginx config files to automatically
137
136
# discover certificate names, key types, authenticators, and domains.
138
- if [ -f " ${config_file } " ]; then
139
- debug " Using config file '${config_file } ' for certificate specifications"
137
+ if [ -f " ${CONFIG_FILE } " ]; then
138
+ debug " Using config file '${CONFIG_FILE } ' for certificate specifications"
140
139
# Loop over the certificates array and request the certificates
141
140
while read -r -d ' ' cert; do
142
141
debug " Parsing certificate specification"
143
142
144
- # cert- name (required)
145
- cert_name=" $( shyaml get-value cert- name ' ' <<< " ${cert}" ) "
143
+ # name (required)
144
+ cert_name=" $( shyaml get-value name ' ' <<< " ${cert}" ) "
146
145
if [ -z " ${cert_name} " ]; then
147
- error " 'cert- name' is missing; ignoring this certificate specification"
146
+ error " 'name' is missing; ignoring this certificate specification"
148
147
continue
149
148
fi
150
- debug " Certificate cert- name is: ${cert_name} "
149
+ debug " Certificate name is: ${cert_name} "
151
150
152
151
# domains (required)
153
152
domains=()
@@ -190,7 +189,7 @@ if [ -f "${config_file}" ]; then
190
189
if ! get_certificate " ${cert_name} " " ${domain_request} " " ${key_type} " " ${authenticator} " " ${rsa_key_size} " " ${elliptic_curve} " " ${credentials} " ; then
191
190
error " Certbot failed for '${cert_name} '. Check the logs for details."
192
191
fi
193
- done < <( shyaml -y get-values-0 certificates ' ' < ${config_file} )
192
+ done < <( shyaml -y get-values-0 certificates ' ' < " ${CONFIG_FILE} " )
194
193
else
195
194
debug " Using automatic discovery of nginx conf file for certificate specifications"
196
195
# This will return an associative array that looks something like this:
0 commit comments