Files
aaPanel/class_v2/btdockerModelV2/script/flush_plugin_.py
T
Jack ed55fa708d Update to 7.7.0
Since version 7.7.0, we recommend yours update python to 3.12.

[+] Using nginx technology to load static files improves access speed
[+] Refactor homepage, website, FTP, and database using vue3
[+] Table loading changed to skeleton screen
[+] Add Website statistics-v2 professional plug-in
[+] Add Home page - top 5 resource occupancy
[+] Add protection for Files management (requires Tamper-proof for Enterprise 3.7)
[+] Website, FTP, Databases page add program status
[+] Add FTP log analysis (only supports Centos)
[+] Add password-free login to phpMyAdmin
[+] Add Proxy Project in Website (Supported when web service uses Nginx)
[+] Add WP Toolkit (Pro version only)
[+] Redesigned Docker module
[+] Add WP Toolkit Protection
[+] Add WP Toolkit Backup and Restore
[+] Add WP Toolkit Migrated
[+] Add WP Toolkit Clone site (supports new domain and subdomain)
[+] Add WP Toolkit Create site from backup of other panel
[+] Add WP Toolkit support for Cron automatic backup (only save Local disk)
[+] Add WP Toolkit operation log
[+] Add Integrity check for WP Toolkit
[+] Add WP Toolkit plug-in management and themes management

[*] Optimize phpMyAdmin formula access method
[*] Optimize Home page PHP display problem
[*] Optimize jump to the login interface after the login expires
[*] Optimize automatic renewal of SSL at some times
[*] Optimize Let's Encrypt to increase application success rate

[-] Fix Logs Audit cannot be opened
[-] Fix apache URL rewrite issue
[-] Fix phpmyadmin installation problem
[-] Fix the problem that some servers cannot install software
[-] Fix upload file error
[-] Fix left menu hiding problem
[-] Fix aaPanel Mobile QR code display problem
[-] Fix problem that third-party plug-ins are not displayed in the App Store
[-] Fix issue where the menu bar is blank when opening new tabs
[-] Fixed panel not being accessible in some cases
[-] Fix the issue where Curl warning caused the inability to apply for SSL
[-] Fix Quota issues for Website, FTP, Databases
[-] Fix file interface display problem on mobile terminal
2024-07-19 11:25:10 +08:00

135 lines
4.0 KiB
Python

# coding: utf-8
import sys, os
os.chdir('/www/server/panel/')
sys.path.insert(0, "class/")
import PluginLoader
import public
import time
def clear_hosts():
"""
@name 清理hosts文件中的bt.cn记录
@return:
"""
remove = 0
try:
import requests
requests.packages.urllib3.disable_warnings(requests.packages.urllib3.exceptions.InsecureRequestWarning)
url = 'https://www.bt.cn/api/ip/info_json'
res = requests.post(url, verify=False)
if res.status_code == 404:
remove = 1
elif res.status_code == 200 or res.status_code == 400:
res = res.json()
if res != "[]":
remove = 1
except:
result = public.ExecShell("curl -sS --connect-timeout 3 -m 60 -k https://www.bt.cn/api/ip/info_json")[0]
if result != "[]":
remove = 1
hosts_file = '/etc/hosts'
if remove == 1 and os.path.exists(hosts_file):
public.ExecShell('sed -i "/www.bt.cn/d" /etc/hosts')
def flush_cache():
'''
@name 更新缓存
@author hwliang
@return void
'''
try:
# start_time = time.time()
res = PluginLoader.get_plugin_list(1)
spath = '{}/data/pay_type.json'.format(public.get_panel_path())
public.downloadFile(public.get_url() + '/install/lib/pay_type.json', spath)
import plugin_deployment
plugin_deployment.plugin_deployment().GetCloudList(None)
# timeout = time.time() - start_time
if 'ip' in res and res['ip']:
pass
else:
if isinstance(res, dict) and not 'msg' in res: res['msg'] = 'Connection failure!'
except:
pass
def flush_php_order_cache():
"""
更新软件商店php顺序缓存
@return:
"""
spath = '{}/data/php_order.json'.format(public.get_panel_path())
public.downloadFile(public.get_url() + '/install/lib/php_order.json', spath)
def flush_msg_json():
"""
@name 更新消息json
"""
try:
spath = '{}/data/msg.json'.format(public.get_panel_path())
public.downloadFile(public.get_url() + '/linux/panel/msg/msg.json', spath)
except:
pass
def flush_docker_project_info():
'''
@name 更新docker_project版本信息
@author wzz
@return void
'''
msg = "docker_projcet version information"
try:
# start_time = time.time()
res = PluginLoader.get_plugin_list(1)
config_path = f"{public.get_panel_path()}/config"
spath = f"{config_path}/docker_project_info.json"
url = "/install/lib/docker_project/docker_project_info.json"
public.downloadFile(f"{public.get_url()}{url}", spath)
import plugin_deployment
plugin_deployment.plugin_deployment().GetCloudList(None)
# timeout = time.time() - start_time
if 'ip' in res and res['ip']:
pass
else:
if isinstance(res, dict) and not 'msg' in res: res['msg'] = 'Connection failure!'
except:
pass
# 2024/3/20 上午 11:09 更新docker_hub镜像排行数据
def flush_docker_hub_repos():
'''
@name 更新docker_hub镜像排行数据
@author wzz <2024/3/20 上午 11:09>
@param "data":{"参数名":""} <数据类型> 参数描述
@return dict{"status":True/False,"msg":"提示信息"}
'''
public.ExecShell("/www/server/panel/pyenv/bin/python3 /www/server/panel/class_v2/btdockerModelV2/script/syncreposdb.py")
if __name__ == '__main__':
tip_date_tie = '/tmp/.fluah_time'
if os.path.exists(tip_date_tie):
last_time = int(public.readFile(tip_date_tie))
timeout = time.time() - last_time
if timeout < 600:
print("Execution interval is too short, exit - {}!".format(timeout))
sys.exit()
clear_hosts()
flush_cache()
flush_php_order_cache()
flush_msg_json()
flush_docker_project_info()
flush_docker_hub_repos()
public.writeFile(tip_date_tie, str(int(time.time())))