Added last checked timestamp. Added setup script and instuctions for manual install
This commit is contained in:
15
ddns.py
15
ddns.py
@@ -19,7 +19,7 @@ filepath = homefilepath.joinpath('.config/ddns')
|
||||
database = filepath.joinpath('ddns.db')
|
||||
logfile = filepath.joinpath('ddns.log')
|
||||
logging.basicConfig(filename=logfile,level=logging.INFO)
|
||||
app_version = '0.3'
|
||||
app_version = '0.4'
|
||||
|
||||
|
||||
def get_ip():
|
||||
@@ -47,6 +47,7 @@ def connect_database():
|
||||
try:
|
||||
conn = sqlite3.connect(database)
|
||||
except Error as e:
|
||||
logging.error(time.strftime("%Y-%m-%d %H:%M")+' - Error : ' + str(e))
|
||||
print(e)
|
||||
finally:
|
||||
if conn:
|
||||
@@ -393,6 +394,10 @@ def updateip(force):
|
||||
cursor.execute('UPDATE subdomains SET current_ip4=? WHERE id = ?',(current_ip,subdomain_id,))
|
||||
cursor.execute('UPDATE subdomains SET last_updated=? WHERE id = ?',(now.strftime("%d/%m/%Y %H:%M:%S"),subdomain_id,))
|
||||
conn.commit()
|
||||
else:
|
||||
cursor.execute('UPDATE subdomains SET last_checked=? WHERE id = ?',(now.strftime("%d/%m/%Y %H:%M:%S"),subdomain_id,))
|
||||
conn.commit()
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -435,13 +440,19 @@ def updatedb():
|
||||
# Update DB with new column 20.03.23
|
||||
# Add last updated field for subdomains
|
||||
new_table = 'last_updated'
|
||||
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 default 'N/A'"
|
||||
conn.execute(add_column)
|
||||
conn.commit()
|
||||
|
||||
new_table = 'last_checked'
|
||||
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_checked text default 'N/A'"
|
||||
conn.execute(add_column)
|
||||
conn.commit()
|
||||
|
||||
|
||||
|
||||
# Commandline arguments
|
||||
|
Reference in New Issue
Block a user