Newer
Older
certbot-dns-inwx / certbot-dns-auth.py
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu May 31 17:23:20 2018

@author: Pascal Gollor (https://gitbucket.pgollor.de)
"""


import os, sys, time


def main():
	d = os.environ.get('CERTBOT_DOMAIN')
	if (not d):
		sys.exit('CERTBOT_DOMAIN not set!')
	# end if

	v = os.environ.get('CERTBOT_VALIDATION')
	if (not v):
		sys.exit('CERTBOT_VALIDATION not set!')
	# end if

	# check domain
	if (d.count('.') > 1):
		sys.exit('Subdomains not supported!')
	# end if

	dirName = os.path.dirname(os.path.abspath(sys.argv[0]))
	cmd = dirName + "/update-record.py -m create -c " + dirName + "/conf.cfg" + " -t 300 -r TXT _acme-challenge." + d + " " + v;
	os.system(cmd)

	# sleep to make sure the change has time to propagate over to DNS
	time.sleep(10)
# end main


if __name__ == '__main__':
	main()
# end if