1
0
mirror of https://github.com/Mailu/Mailu.git synced 2024-12-14 10:53:30 +02:00
Mailu/core/nginx/letsencrypt.py

45 lines
1.2 KiB
Python
Raw Normal View History

#!/usr/bin/python3
import os
import time
import subprocess
2022-03-17 12:35:31 +02:00
hostnames = ','.join(set(host.strip() for host in os.environ['HOSTNAMES'].split(',')))
2022-03-10 13:31:01 +02:00
command = [
"certbot",
"-n", "--agree-tos", # non-interactive
2022-03-10 13:31:01 +02:00
"-d", hostnames, "--expand", "--allow-subset-of-names",
"-m", "{}@{}".format(os.environ["POSTMASTER"], os.environ["DOMAIN"]),
"certonly", "--standalone",
"--cert-name", "mailu",
"--preferred-challenges", "http", "--http-01-port", "8008",
"--keep-until-expiring",
2021-08-23 19:41:44 +02:00
"--renew-with-new-domains",
2021-08-09 21:06:15 +02:00
"--config-dir", "/certs/letsencrypt",
"--post-hook", "/config.py"
]
command2 = [
"certbot",
"-n", "--agree-tos", # non-interactive
2022-03-10 13:31:01 +02:00
"-d", hostnames, "--expand", "--allow-subset-of-names",
2021-08-09 21:06:15 +02:00
"-m", "{}@{}".format(os.environ["POSTMASTER"], os.environ["DOMAIN"]),
"certonly", "--standalone",
"--cert-name", "mailu-ecdsa",
"--preferred-challenges", "http", "--http-01-port", "8008",
"--keep-until-expiring",
"--key-type", "ecdsa",
2021-08-23 19:41:44 +02:00
"--renew-with-new-domains",
"--config-dir", "/certs/letsencrypt",
"--post-hook", "/config.py"
]
# Wait for nginx to start
time.sleep(5)
# Run certbot every day
while True:
subprocess.call(command)
2021-08-09 21:06:15 +02:00
subprocess.call(command2)
time.sleep(86400)