28 lines
718 B
Python
Executable File
28 lines
718 B
Python
Executable File
#!/usr/bin/env python3
|
|
"""Create the _acme-challenge TXT record for a Certbot DNS-01 renewal."""
|
|
import os
|
|
import sys
|
|
import time
|
|
from pathlib import Path
|
|
|
|
sys.path.insert(0, str(Path(__file__).resolve().parent))
|
|
|
|
from arvan_dns import txt_visible, upsert_txt, zone_and_record
|
|
|
|
|
|
def main():
|
|
domain = os.environ["CERTBOT_DOMAIN"]
|
|
value = os.environ["CERTBOT_VALIDATION"]
|
|
zone, name, fqdn = zone_and_record(domain)
|
|
upsert_txt(zone, name, value)
|
|
for _ in range(18):
|
|
if txt_visible(fqdn, value):
|
|
print("TXT record is visible")
|
|
return
|
|
time.sleep(10)
|
|
raise SystemExit("TXT record was not visible in public DNS in time")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|