1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
#!/usr/bin/env python3
# SPDX-FileCopyrightText: 2024 Matthew Fennell <matthew@fennell.dev>
#
# SPDX-License-Identifier: AGPL-3.0-only
import logging
import subprocess
import tomllib
def main() -> None:
with open("config.toml", "rb") as config_file:
full_config = tomllib.load(config_file)
config = full_config["config"]
domains = full_config["domains"]
for domain in domains.values():
subdomain_list = domain["domains"]
subdomain_requests = [
request
for subdomain in subdomain_list
for request in ("--domains", subdomain)
]
command = (
[
"lego",
"--accept-tos",
"--email",
domain["acme_email"],
"--dns",
"desec",
"--server",
config["acme_server"],
"--dns.disable-cp",
]
+ subdomain_requests
+ ["renew", "--renew-hook", domain["renew_script"]]
)
environment = {
"DESEC_POLLING_INTERVAL": str(config["timeout_seconds"]),
"DESEC_TOKEN": domain["desec_token"],
}
logging.info(f"Running command {command}")
subprocess.run(command, env=environment)
if __name__ == "__main__":
main()
|