Small fixes
This commit is contained in:
parent
9b17a3e685
commit
e67aa99088
7
ddns.py
7
ddns.py
@ -383,10 +383,7 @@ def updateip(force):
|
|||||||
remote = current.read().decode('utf-8')
|
remote = current.read().decode('utf-8')
|
||||||
remoteData = json.loads(remote)
|
remoteData = json.loads(remote)
|
||||||
remoteIP4 = remoteData['domain_record']['data']
|
remoteIP4 = remoteData['domain_record']['data']
|
||||||
if force == True:
|
if remoteIP4 != current_ip or force == True:
|
||||||
remoteIP4 = '0.0.0.0'
|
|
||||||
# Only update domains with outdated IP's
|
|
||||||
if remoteIP4 != current_ip:
|
|
||||||
data = {'type': 'A', 'data': current_ip}
|
data = {'type': 'A', 'data': current_ip}
|
||||||
headers = {'Authorization': 'Bearer ' + apikey, "Content-Type": "application/json"}
|
headers = {'Authorization': 'Bearer ' + apikey, "Content-Type": "application/json"}
|
||||||
response = requests.patch('https://api.digitalocean.com/v2/domains/'+domain_name+'/records/' + subdomain_id, data=json.dumps(data), headers=headers)
|
response = requests.patch('https://api.digitalocean.com/v2/domains/'+domain_name+'/records/' + subdomain_id, data=json.dumps(data), headers=headers)
|
||||||
@ -441,7 +438,7 @@ def updatedb():
|
|||||||
cursor = conn.cursor()
|
cursor = conn.cursor()
|
||||||
info = conn.execute("PRAGMA table_info('subdomains')").fetchall()
|
info = conn.execute("PRAGMA table_info('subdomains')").fetchall()
|
||||||
if not any(new_table in word for word in info):
|
if not any(new_table in word for word in info):
|
||||||
add_column = "ALTER TABLE subdomains ADD COLUMN last_updated text"
|
add_column = "ALTER TABLE subdomains ADD COLUMN last_updated text default 'N/A'"
|
||||||
conn.execute(add_column)
|
conn.execute(add_column)
|
||||||
conn.commit()
|
conn.commit()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user