feat: use comments in config files to file certificates

config files in /etc/nginx/conf.d can contain:

```

```

certificates files are in /etc/nginx/conf.d/certificates

these contain un commented lines
This commit is contained in:
Giles Bradshaw 2020-12-18 20:46:26 +00:00
parent eaa43581bd
commit b72a880868
2 changed files with 3 additions and 3 deletions

View File

@ -1,7 +1,7 @@
server {
# Listen on plain old HTTP
listen 80 default_server reuseport;
listen [::]:80 default_server reuseport;
#listen [::]:80 default_server reuseport;
# Pass this particular URL off to certbot, to authenticate HTTPS certificates
location '/.well-known/acme-challenge' {

View File

@ -15,14 +15,14 @@ error() {
# /etc/letsencrypt/live/<primary_domain_name>/privkey.pem
parse_domains() {
# For each configuration file in /etc/nginx/conf.d/*.conf*
for conf_file in /etc/nginx/conf.d/*.conf*; do
for conf_file in /etc/nginx/conf.d/certificates/*.conf*; do
sed -n -r -e 's&^\s*ssl_certificate_key\s*\/etc/letsencrypt/live/(.*)/privkey.pem;\s*(#.*)?$&\1&p' $conf_file | xargs echo
done
}
# Given a config file path, spit out all the ssl_certificate_key file paths
parse_keyfiles() {
sed -n -e 's&^\s*ssl_certificate_key\s*\(.*\);&\1&p' "$1"
sed -n -e 's&^\s*# ssl_certificate_key\s*\(.*\);&\1&p' "$1"
}
# Given a config file path, return 0 if all keyfiles exist (or there are no