2019-04-11 17:49:20 +02:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
# -*-coding:UTF-8 -*
|
|
|
|
|
|
|
|
"""
|
|
|
|
Update AIL
|
|
|
|
============================
|
|
|
|
|
2019-04-12 16:07:40 +02:00
|
|
|
Update AIL in the background
|
2019-04-11 17:49:20 +02:00
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
import redis
|
|
|
|
import subprocess
|
2019-11-05 15:18:03 +01:00
|
|
|
|
|
|
|
sys.path.append(os.path.join(os.environ['AIL_BIN'], 'lib/'))
|
|
|
|
import ConfigLoader
|
2019-04-11 17:49:20 +02:00
|
|
|
|
2021-01-22 17:03:43 +01:00
|
|
|
def launch_background_upgrade(version, l_script_name):
|
2020-12-11 21:02:07 +01:00
|
|
|
if r_serv.sismember('ail:to_update', version):
|
|
|
|
r_serv.delete('ail:update_error')
|
|
|
|
r_serv.set('ail:update_in_progress', version)
|
|
|
|
r_serv.set('ail:current_background_update', version)
|
|
|
|
|
2021-01-22 17:03:43 +01:00
|
|
|
for script_name in l_script_name:
|
|
|
|
r_serv.set('ail:current_background_script', script_name)
|
|
|
|
update_file = os.path.join(os.environ['AIL_HOME'], 'update', version, script_name)
|
|
|
|
process = subprocess.run(['python' ,update_file])
|
|
|
|
update_progress = r_serv.get('ail:current_background_script_stat')
|
|
|
|
#if update_progress:
|
|
|
|
# if int(update_progress) != 100:
|
|
|
|
# r_serv.set('ail:update_error', 'Update {} Failed'.format(version))
|
2020-12-11 21:02:07 +01:00
|
|
|
|
|
|
|
update_progress = r_serv.get('ail:current_background_script_stat')
|
|
|
|
if update_progress:
|
|
|
|
if int(update_progress) == 100:
|
|
|
|
r_serv.delete('ail:update_in_progress')
|
|
|
|
r_serv.delete('ail:current_background_script')
|
|
|
|
r_serv.delete('ail:current_background_script_stat')
|
|
|
|
r_serv.delete('ail:current_background_update')
|
2021-01-06 15:45:31 +01:00
|
|
|
r_serv.srem('ail:to_update', version)
|
2020-12-11 21:02:07 +01:00
|
|
|
|
2021-01-22 17:03:43 +01:00
|
|
|
def clean_update_db():
|
|
|
|
r_serv.delete('ail:update_error')
|
|
|
|
r_serv.delete('ail:update_in_progress')
|
|
|
|
r_serv.delete('ail:current_background_script')
|
|
|
|
r_serv.delete('ail:current_background_script_stat')
|
|
|
|
r_serv.delete('ail:current_background_update')
|
|
|
|
|
2019-04-11 17:49:20 +02:00
|
|
|
if __name__ == "__main__":
|
|
|
|
|
2019-11-05 15:18:03 +01:00
|
|
|
config_loader = ConfigLoader.ConfigLoader()
|
|
|
|
|
|
|
|
r_serv = config_loader.get_redis_conn("ARDB_DB")
|
2019-11-11 14:54:12 +01:00
|
|
|
r_serv_onion = config_loader.get_redis_conn("ARDB_Onion")
|
2019-11-05 15:18:03 +01:00
|
|
|
config_loader = None
|
2019-04-11 17:49:20 +02:00
|
|
|
|
2021-01-22 17:03:43 +01:00
|
|
|
if r_serv.scard('ail:to_update') == 0:
|
|
|
|
clean_update_db()
|
2020-12-11 21:02:07 +01:00
|
|
|
|
|
|
|
|
2021-01-22 17:03:43 +01:00
|
|
|
launch_background_upgrade('v1.5', ['Update-ARDB_Onions.py', 'Update-ARDB_Metadata.py', 'Update-ARDB_Tags.py', 'Update-ARDB_Tags_background.py', 'Update-ARDB_Onions_screenshots.py'])
|
|
|
|
launch_background_upgrade('v2.4', ['Update_domain.py'])
|
|
|
|
launch_background_upgrade('v2.6', ['Update_screenshots.py'])
|
|
|
|
launch_background_upgrade('v2.7', ['Update_domain_tags.py'])
|
|
|
|
launch_background_upgrade('v3.4', ['Update_domain.py'])
|
2021-08-27 18:05:21 +02:00
|
|
|
launch_background_upgrade('v3.7', ['Update_trackers.py'])
|