2019-04-11 15:49:20 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
# -*-coding:UTF-8 -*
|
|
|
|
|
|
|
|
"""
|
|
|
|
Update AIL
|
|
|
|
============================
|
|
|
|
|
2019-04-12 14:07:40 +00:00
|
|
|
Update AIL in the background
|
2019-04-11 15:49:20 +00:00
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
import redis
|
|
|
|
import subprocess
|
2019-11-05 14:18:03 +00:00
|
|
|
|
|
|
|
sys.path.append(os.path.join(os.environ['AIL_BIN'], 'lib/'))
|
|
|
|
import ConfigLoader
|
2019-04-11 15:49:20 +00:00
|
|
|
|
2021-01-22 16:03:43 +00:00
|
|
|
def launch_background_upgrade(version, l_script_name):
|
2020-12-11 20:02:07 +00: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 16:03:43 +00: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 20:02:07 +00: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 14:45:31 +00:00
|
|
|
r_serv.srem('ail:to_update', version)
|
2020-12-11 20:02:07 +00:00
|
|
|
|
2021-01-22 16:03:43 +00: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 15:49:20 +00:00
|
|
|
if __name__ == "__main__":
|
|
|
|
|
2019-11-05 14:18:03 +00:00
|
|
|
config_loader = ConfigLoader.ConfigLoader()
|
|
|
|
|
|
|
|
r_serv = config_loader.get_redis_conn("ARDB_DB")
|
2019-11-11 13:54:12 +00:00
|
|
|
r_serv_onion = config_loader.get_redis_conn("ARDB_Onion")
|
2019-11-05 14:18:03 +00:00
|
|
|
config_loader = None
|
2019-04-11 15:49:20 +00:00
|
|
|
|
2021-01-22 16:03:43 +00:00
|
|
|
if r_serv.scard('ail:to_update') == 0:
|
|
|
|
clean_update_db()
|
2020-12-11 20:02:07 +00:00
|
|
|
|
|
|
|
|
2021-01-22 16:03:43 +00: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 16:05:21 +00:00
|
|
|
launch_background_upgrade('v3.7', ['Update_trackers.py'])
|