Small fixes

This commit is contained in:
rune 2023-03-20 14:57:15 +01:00
parent 9b17a3e685
commit e67aa99088

View File

@ -383,10 +383,7 @@ def updateip(force):
remote = current.read().decode('utf-8')
remoteData = json.loads(remote)
remoteIP4 = remoteData['domain_record']['data']
if force == True:
remoteIP4 = '0.0.0.0'
# Only update domains with outdated IP's
if remoteIP4 != current_ip:
if remoteIP4 != current_ip or force == True:
data = {'type': 'A', 'data': current_ip}
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)
@ -441,7 +438,7 @@ def updatedb():
cursor = conn.cursor()
info = conn.execute("PRAGMA table_info('subdomains')").fetchall()
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.commit()