summaryrefslogtreecommitdiff
path: root/godaddy_add_txt.py
diff options
context:
space:
mode:
Diffstat (limited to 'godaddy_add_txt.py')
-rwxr-xr-xgodaddy_add_txt.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/godaddy_add_txt.py b/godaddy_add_txt.py
new file mode 100755
index 0000000..4733bb1
--- /dev/null
+++ b/godaddy_add_txt.py
@@ -0,0 +1,33 @@
+#!/usr/bin/env python3
+import requests
+import json
+from os import environ
+from time import sleep
+
+if not 'CERTBOT_DOMAIN' in environ:
+ print("Environment variable CERTBOT_DOMAIN is not set.\nMake sure you're running this script as a certbot hook.")
+ exit(1)
+
+if not 'CERTBOT_VALIDATION' in environ:
+ print("Environment variable CERTBOT_VALIDATION is not set.\nMake sure you're running this script as a certbot hook.")
+ exit(1)
+
+domain = environ['CERTBOT_DOMAIN']
+validation = environ['CERTBOT_VALIDATION']
+
+key = 'e4NBykPszU4u_AQSkww3bDD4mBYUn4jERAL'
+secret = 'Wg9Pr9Du82cPU3FP6H6CNr'
+
+s = requests.session()
+s.headers.update({
+ 'Authorization' : "sso-key {}:{}".format(key, secret)
+ })
+
+data = {"name": "_acme-challenge",
+ "data": validation,
+ "ttl": 600,
+ "type": "TXT"}
+
+r = s.patch("https://api.godaddy.com/v1/domains/{}/records".format(domain), json = [data])
+
+sleep(20)