diff options
author | Hugo Hörnquist <hugo@lysator.liu.se> | 2023-06-20 18:08:39 +0200 |
---|---|---|
committer | Hugo Hörnquist <hugo@lysator.liu.se> | 2023-06-20 18:08:39 +0200 |
commit | 3672371d4153f3520c0c50f46085b29ba4580ece (patch) | |
tree | 22ea5c57f6b627f7f08318766f628f5996232c52 /files | |
parent | Remove invalid option from README. (diff) | |
download | hugonikanor-letsencrypt-3672371d4153f3520c0c50f46085b29ba4580ece.tar.gz hugonikanor-letsencrypt-3672371d4153f3520c0c50f46085b29ba4580ece.tar.xz |
Repair python script.
Diffstat (limited to 'files')
-rw-r--r-- | files/run_certbot.py | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/files/run_certbot.py b/files/run_certbot.py index f81f707..8b4dc20 100644 --- a/files/run_certbot.py +++ b/files/run_certbot.py @@ -1,6 +1,8 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 """ +Exec certbot with flags. + Gathers domain names to give to certbot, and then execs certbot. "Required" to send multiple domain names @@ -11,25 +13,32 @@ File managed by Puppet from __future__ import print_function import sys -import os +import os.path if len(sys.argv) != 2: print('Takes exactly one argument: the certificates name', file=sys.stderr) - os.exit(1) + sys.exit(1) cert_name = sys.argv[1] here = os.path.dirname(sys.argv[0]) cmdline = ['certbot', '--config', os.path.join(here, cert_name + ".ini")] -with open(os.path.join(here, cert_name + '.domains')) as f: - for line in f: - if not line: - continue - if line[0] == '#': - continue - cmdline += ['-d', line.strip()] + +domainlist_file = os.path.join(here, cert_name + '.domains') + +with open(domainlist_file) as f: + domains = [line.strip() for line in f + if line and line[0] != '#'] + +if not domains: + print('No domains configured. Check {}'.format(domainlist_file)) + sys.exit(1) + +for domain in domains: + cmdline += ['-d', domain] + cmdline += ['certonly'] os.execvp('certbot', cmdline) |