Fix certbot execution in letsencrypt jobs

This commit is contained in:
Théophile Diot 2024-03-13 09:11:27 +00:00
parent 64a0a17b20
commit abf716500c
No known key found for this signature in database
GPG key ID: 248FEA4BAE400D06
2 changed files with 10 additions and 8 deletions

View file

@ -28,7 +28,7 @@ LETS_ENCRYPT_LOGS_DIR = join(sep, "var", "log", "bunkerweb")
def certbot_new(domains: str, email: str, use_letsencrypt_staging: bool = False) -> int:
with Popen(
process = Popen(
[
CERTBOT_BIN,
"certonly",
@ -57,11 +57,12 @@ def certbot_new(domains: str, email: str, use_letsencrypt_staging: bool = False)
stderr=PIPE,
universal_newlines=True,
env=environ.copy() | {"PYTHONPATH": join(sep, "usr", "share", "bunkerweb", "deps", "python")},
) as process:
)
while process.poll() is None:
if process.stderr:
for line in process.stderr:
LOGGER_CERTBOT.info(line.strip())
return process.returncode
return process.returncode
status = 0

View file

@ -48,7 +48,7 @@ try:
JOB = Job(LOGGER)
with Popen(
process = Popen(
[
CERTBOT_BIN,
"renew",
@ -64,14 +64,15 @@ try:
stderr=PIPE,
universal_newlines=True,
env=environ.copy() | {"PYTHONPATH": join(sep, "usr", "share", "bunkerweb", "deps", "python")},
) as process:
)
while process.poll() is None:
if process.stderr:
for line in process.stderr:
LOGGER_CERTBOT.info(line.strip())
if process.returncode == 0:
status = 2
LOGGER.error("Certificates renewal failed")
if process.returncode != 0:
status = 2
LOGGER.error("Certificates renewal failed")
# Save Let's Encrypt data to db cache
if LETS_ENCRYPT_PATH.is_dir() and list(LETS_ENCRYPT_PATH.iterdir()):