Created
January 3, 2015 22:14
-
-
Save rjmoggach/e5b7c0a8b14c07117306 to your computer and use it in GitHub Desktop.
Webfaction Google Apps DNS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python2.5 | |
import xmlrpclib | |
# EDIT: webfaction credentials | |
username = raw_input("Please enter your username: ") | |
password = raw_input("Please enter your password: ") | |
# no need to edit below this line | |
server = xmlrpclib.Server('https://api.webfaction.com/') | |
session_id, account = server.login(username, password) | |
domain = raw_input("Please enter your domain name (no www, etc): ") | |
cnames = [ | |
"calendar", | |
"drive", | |
"groups", | |
"mail", | |
"sites", | |
"www" | |
] | |
mx_info = [ | |
['ASPMX.L.GOOGLE.COM','10'], | |
['ALT1.ASPMX.L.GOOGLE.COM','20'], | |
['ALT2.ASPMX.L.GOOGLE.COM','20'], | |
['ASPMX2.GOOGLEMAIL.COM','30'], | |
['ASPMX3.GOOGLEMAIL.COM','30'], | |
['ASPMX4.GOOGLEMAIL.COM','30'], | |
['ASPMX5.GOOGLEMAIL.COM','30'], | |
] | |
xmpp_info = [ | |
['ALT1.XMPP-SERVER.L.GOOGLE.COM', '20', '0', '5269'], | |
['ALT2.XMPP-SERVER.L.GOOGLE.COM', '20', '0', '5269'], | |
['ALT3.XMPP-SERVER.L.GOOGLE.COM', '20', '0', '5269'], | |
['ALT4.XMPP-SERVER.L.GOOGLE.COM', '20', '0', '5269'], | |
['XMPP-SERVER.L.GOOGLE.COM', '5', '0', '5269'] | |
] | |
xmpp_domains = [ | |
"_jabber._tcp", | |
"_xmpp-client._tcp", | |
"_xmpp-server.tcp" | |
] | |
# create mx records | |
for mx in mx_info: | |
server.create_dns_override(session_id,domain,'','',mx[0],mx[1],'') | |
# create CNAME record | |
for dmn in cnames: | |
try: | |
subdomain = eval(dmn) | |
try: | |
server.create_domain(session_id, domain, subdomain) | |
print "Subdomain %s created." % subdomain | |
except: | |
print "Subdomain %s exists." % subdomain | |
pass | |
try: | |
server.create_dns_override(session_id, subdomain + "." + domain,'','ghs.google.com','','','') | |
print "DNS override %s created." % subdomain | |
except: | |
pass | |
except: | |
print "No value for %s." % dmn | |
pass | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment