GoDaddyPy autoupdate example
Reference:
To get godaddypy
https://pypi.python.org/pypi/GoDaddyPy
To get API key and secert
https://developer.godaddy.com/getstarted
root@radius02:~/godaddy# crontab -l
5 * * * * /usr/local/bin/GoDaddy.sh
root@radius02:~/godaddy# cat /usr/local/bin/GoDaddy.sh
#!/bin/sh
myip=`dig a 3rd free domain name @8.8.8.8 +short`
lastip=`dig a godaddy domain name @8.8.8.8 +short`
if [ "$myip" != "$lastip" ]; then
python2 /usr/local/bin/godaddy_ddns.py
fi
root@radius02:~/godaddy# cat /usr/local/bin/godaddy_ddns.py
#!/usr/bin/env python
import pif
import datetime
from godaddypy import Client, Account
import requests
import urllib3
# Suppress InsecureRequestWarning: Unverified HTTPS
urllib3.disable_warnings()
domain='godaddy domain name'
public_ip = pif.get_public_ip()
my_acct = Account(api_key='Key', api_secret='secret')
client = Client(my_acct)
client.get_domains()
#client.get_a_records(domain)
client.get_records(domain, record_type='A')
client.update_ip(public_ip, domains=[domain])
now = datetime.datetime.now()
f = open('/var/log/godaddy.log','a')
f.write(public_ip)
f.write(" updated on ")
f.write(now.strftime("%Y/%m/%d %H:%M:%S"))
f.write(".\n")
f.close()
Remarks: I post this because I forget where the script I put once setup. Here to share and remind me. Cheers!
Updated on 3 Aug 2018... version change update the latest godaddypy and make change in red to script.
To get godaddypy
https://pypi.python.org/pypi/GoDaddyPy
To get API key and secert
https://developer.godaddy.com/getstarted
root@radius02:~/godaddy# crontab -l
5 * * * * /usr/local/bin/GoDaddy.sh
root@radius02:~/godaddy# cat /usr/local/bin/GoDaddy.sh
#!/bin/sh
myip=`dig a 3rd free domain name @8.8.8.8 +short`
lastip=`dig a godaddy domain name @8.8.8.8 +short`
if [ "$myip" != "$lastip" ]; then
python2 /usr/local/bin/godaddy_ddns.py
fi
root@radius02:~/godaddy# cat /usr/local/bin/godaddy_ddns.py
#!/usr/bin/env python
import pif
import datetime
from godaddypy import Client, Account
import requests
import urllib3
# Suppress InsecureRequestWarning: Unverified HTTPS
urllib3.disable_warnings()
domain='godaddy domain name'
public_ip = pif.get_public_ip()
my_acct = Account(api_key='Key', api_secret='secret')
client = Client(my_acct)
client.get_domains()
#client.get_a_records(domain)
client.get_records(domain, record_type='A')
client.update_ip(public_ip, domains=[domain])
now = datetime.datetime.now()
f = open('/var/log/godaddy.log','a')
f.write(public_ip)
f.write(" updated on ")
f.write(now.strftime("%Y/%m/%d %H:%M:%S"))
f.write(".\n")
f.close()
Remarks: I post this because I forget where the script I put once setup. Here to share and remind me. Cheers!
Updated on 3 Aug 2018... version change update the latest godaddypy and make change in red to script.
Comments