diff --git a/source/head.py b/source/head.py index 23fa5a0..5212350 100644 --- a/source/head.py +++ b/source/head.py @@ -8,5 +8,5 @@ import json as _json import http.client as _http_client import argparse as _argparse import pathlib as _pathlib - +import time as _time diff --git a/source/main.py b/source/main.py index 87f135e..3d72f82 100644 --- a/source/main.py +++ b/source/main.py @@ -31,6 +31,13 @@ def args( default = None ) ''' + argumentparser.add_argument( + '--delay', + dest = "delay", + type = float, + default = 60.0, + help = "seconds to wait at end of certbot auth hook", + ) argumentparser.add_argument( "command", type = str @@ -84,6 +91,24 @@ def main( content ) # print(_json.dumps(result, indent = "\t")) + elif (arguments.command == "certbot-hook"): + domain_full = _os.environ["CERTBOT_DOMAIN"] + domain_full_parts = _os.environ["CERTBOT_DOMAIN"].split(".", 1) + domain = domain_full_parts[1] + name = domain_full_parts[0] + type_ = "TXT" + content = _os.environ["CERTBOT_VALIDATION"] + api_macro_save( + conf_get("environment"), + conf_get("account.username"), + conf_get("account.password"), + domain, + name, + type_, + content + ) + _time.sleep(args.delay) + # print(_json.dumps(result, indent = "\t")) else: log("unhandled command '%s'" % (arguments.command, ))