43 lines
892 B
Python
Executable file
43 lines
892 B
Python
Executable file
#!/usr/bin/python3
|
|
|
|
# SPDX-FileCopyrightText: 2021 Luca Beltrame <lbeltrame@kde.org>
|
|
#
|
|
# SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
import os
|
|
import time
|
|
|
|
import requests
|
|
|
|
IWANTMYNAME_ENDPOINT = "https://iwantmyname.com/basicauth/ddns"
|
|
|
|
|
|
def main():
|
|
|
|
with open("/etc/letsencrypt/credentials") as handle:
|
|
user, password = handle.read().strip().split()
|
|
|
|
domain = os.environ["CERTBOT_DOMAIN"]
|
|
validation_token = os.environ["CERTBOT_VALIDATION"]
|
|
|
|
print("DEBUG", domain, validation_token)
|
|
|
|
if "*." in domain:
|
|
domain = domain.replace("*.", "")
|
|
|
|
subdomain = f"_acme-challenge.{domain}"
|
|
|
|
params = {
|
|
"hostname": subdomain,
|
|
"type": "txt",
|
|
"value": validation_token
|
|
}
|
|
|
|
req = requests.get(IWANTMYNAME_ENDPOINT, params=params,
|
|
auth=(user, password))
|
|
|
|
time.sleep(60)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|