summaryrefslogtreecommitdiff
path: root/renew-all
diff options
context:
space:
mode:
authorMatthew Fennell <matthew@fennell.dev>2025-12-28 19:42:04 +0000
committerMatthew Fennell <matthew@fennell.dev>2025-12-29 01:47:22 +0000
commit33da4e3f920515bb4341953a5f350fe83b9e8d59 (patch)
tree9af064347104e636dc632e974b0b2b7bf6f7690d /renew-all
parentd00d1009e056b4771f953b4c53c4d07545d9cd5b (diff)
Accept env argument from the terminal
This is used to determine the letsencrypt endpoint to hit. I used to have a single variable for the endpoint, and I would uncomment the prod or nonprod endpoint depending on the circumstances. The two endpoints are given in separate variables in the config file: acme_server_nonprod and acme_server_prod. Likewise, the renew_script variable has been split into renew_script_nonprod and renew_script_prod. Choose between them using the argument.
Diffstat (limited to 'renew-all')
-rwxr-xr-xrenew-all9
1 files changed, 7 insertions, 2 deletions
diff --git a/renew-all b/renew-all
index 8d1455a..9774c28 100755
--- a/renew-all
+++ b/renew-all
@@ -3,10 +3,15 @@
#
# SPDX-License-Identifier: AGPL-3.0-only
+import argparse
import logging
import subprocess
import tomllib
+parser = argparse.ArgumentParser()
+parser.add_argument("--env", required=True, choices=["prod", "nonprod"])
+args = parser.parse_args()
+
def main() -> None:
with open("/etc/opt/acme/config.toml", "rb") as config_file:
@@ -31,11 +36,11 @@ def main() -> None:
"--dns",
domain["provider"],
"--server",
- config["acme_server_prod"],
+ config[f"acme_server_{args.env}"],
"--dns.disable-cp",
]
+ subdomain_requests
- + ["renew", "--renew-hook", domain["renew_script"]]
+ + ["renew", "--renew-hook", domain[f"renew_script_{args.env}"]]
)
environment = {
"DESEC_POLLING_INTERVAL": str(config["timeout_seconds"]),