[add] command:certbot-hook
This commit is contained in:
parent
2f54c4cfa4
commit
391b52a5d9
|
|
@ -8,5 +8,5 @@ import json as _json
|
||||||
import http.client as _http_client
|
import http.client as _http_client
|
||||||
import argparse as _argparse
|
import argparse as _argparse
|
||||||
import pathlib as _pathlib
|
import pathlib as _pathlib
|
||||||
|
import time as _time
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,13 @@ def args(
|
||||||
default = None
|
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(
|
argumentparser.add_argument(
|
||||||
"command",
|
"command",
|
||||||
type = str
|
type = str
|
||||||
|
|
@ -84,6 +91,24 @@ def main(
|
||||||
content
|
content
|
||||||
)
|
)
|
||||||
# print(_json.dumps(result, indent = "\t"))
|
# 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:
|
else:
|
||||||
log("unhandled command '%s'" % (arguments.command, ))
|
log("unhandled command '%s'" % (arguments.command, ))
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue