update to 6.8.37

This commit is contained in:
zhw
2024-04-29 15:35:04 +08:00
parent fa9a865beb
commit ed34994f45
474 changed files with 125711 additions and 34665 deletions
+93 -3
View File
@@ -11,7 +11,6 @@
# 消息队列
# ------------------------------
import json
import downloadFile
import time
import public
import sys
@@ -91,6 +90,12 @@ class bt_task:
(task_name, task_type, task_shell, other, int(time.time()), 0))
public.WriteFile(self.__task_tips, 'True')
public.ExecShell("/etc/init.d/bt start")
if not public.M(self.__table).where('status=?', ('-1',)).count():
tip_file = "/dev/shm/.start_task.pl"
tip_time = public.readFile(tip_file)
if not tip_time or time.time() - int(tip_time) > 600:
public.ExecShell("/www/server/panel/BT-Task")
public.print_log("Background task restarted")
return task_id
# 修改任务
@@ -195,9 +200,11 @@ class bt_task:
def start_task(self):
noe = False
n = 0
tip_file = '/dev/shm/.start_task.pl'
while True:
try:
time.sleep(1)
public.writeFile(tip_file, str(int(time.time())))
n += 1
if not os.path.exists(self.__task_tips) and noe and n < 60:
continue
@@ -325,11 +332,20 @@ class bt_task:
self.install_rar()
public.ExecShell("cd '" + path + "' && "+rar_file +
" a -r '" + dfile + "' " + sfiles + " &> " + log_file)
elif z_type == '7z':
_7z_bin = self.get_7z_bin()
if not _7z_bin:
self.install_7zip()
err_msg = 'The p7zip component is not installed, an automatic installation has been attempted, please wait a few minutes and try again!'
public.WriteLog("File manager","Failed to compress file, reason: {}, file: {}".format(err_msg,sfile))
return public.returnMsg(False, err_msg)
public.ExecShell("cd {} && {} a -t7z {} {} -y &> {}".format(path, _7z_bin, dfile, sfiles, log_file))
else:
return public.return_msg_gettext(False,'Specified compression format is not supported!')
self.set_file_accept(dfile)
#public.WriteLog("TYPE_FILE", 'Compression succeeded!', (sfiles, dfile),not_web = self.not_web)
public.write_log_gettext("File manager", 'Compressed file [ {} ] to [ {} ] success', (sfiles, dfile))
return public.return_msg_gettext(True, 'Compression succeeded!')
# 文件解压
@@ -351,17 +367,53 @@ class bt_task:
rar_file = '/www/server/rar/unrar'
if not os.path.exists(rar_file):
self.install_rar()
public.ExecShell('echo "'+password+'"|' + rar_file +
' x -u -y "' + sfile + '" "' + dfile + '" &> ' + log_file)
pass_opt = '-p-'
if password:
password = password.replace("&","\&").replace('"','\"')
pass_opt = '-p"{}"'.format(password)
public.ExecShell(rar_file + ' x '+ pass_opt +' -u -y "' + sfile + '" "' + dfile + '" &> ' + log_file)
elif sfile[-4:] == '.war':
public.ExecShell("unzip -P '"+password+"' -o '" +
sfile + "' -d '" + dfile + "' &> " + log_file)
elif sfile[-4:] == '.bz2':
public.ExecShell("tar jxvf '" + sfile +
"' -C '" + dfile + "' &> " + log_file)
elif sfile[-3:] == '.7z':
_7zbin = self.get_7z_bin()
if not _7zbin:
self.install_7zip()
err_msg = 'The p7zip component is not installed, an automatic installation has been attempted, please wait a few minutes and try again!'
public.WriteLog("File manager","Failed to compress file, reason: {}, file: {}".format(err_msg,sfile))
return public.returnMsg(False, err_msg)
pass_opt = ""
if password:
pass_opt = '-p"{}"'.format(password)
public.ExecShell('{} x "{}" -o"{}" -y {} &> {}'.format(_7zbin,sfile,dfile,pass_opt,log_file))
else:
public.ExecShell("gunzip -c " + sfile + " > " + sfile[:-3])
# 异常处理
log_msg = public.readFile(log_file)
err_msg = None
if log_msg:
if log_msg.find("incorrect password") != -1 \
or log_msg.find("The specified password is incorrect.") != -1 \
or log_msg.find("Data Error in encrypted file. Wrong password") != -1:
err_msg = 'Decompression password error!'
public.WriteLog("File manager","Unzip file failed, reason: {}, file: {}".format(err_msg,sfile))
elif log_msg.find("unsupported compression method 99") != -1:
err_msg = 'Unsupported Zip encryption and compression, only ZIP traditional encryption is supported for ZIP archives!'
public.WriteLog("File manager","Unzip file failed, reason: {}, file: {}".format(err_msg,sfile))
elif log_msg.find("is not RAR archive") != -1:
err_msg = "It is not a rar archive, check whether to modify the file with the extension rar for other compression formats!"
public.WriteLog("File manager","Unzip file failed, reason: {}, file: {}".format(err_msg,sfile))
elif log_msg.find("gzip: stdin") != -1:
public.ExecShell("tar xvf '" + sfile + "' -C '" + dfile + "' &> " + log_file)
if err_msg: return public.returnMsg(False, err_msg)
# 检查是否设置权限
if self.check_dir(dfile):
sites_path = public.M('config').where(
@@ -374,8 +426,46 @@ class bt_task:
public.ExecShell("chown %s:%s %s" % (user, user, dfile))
#public.WriteLog("TYPE_FILE", 'Uncompression succeeded!', (sfile, dfile),not_web = self.not_web)
public.write_log_gettext("File manager", 'unzip file [ {} ] -> [ {} ] success', (sfile, dfile))
return public.return_msg_gettext(True, 'Uncompression succeeded!')
def get_7z_bin(self):
'''
@name 获取7z命令路径
@author hwliang
@return {string} 7z命令路径
'''
_7z_bins = ["/usr/bin/7z","/usr/bin/7za","/usr/bin/7zr"]
for _7z_bin in _7z_bins:
if os.path.exists(_7z_bin):
return _7z_bin
return None
def install_7zip(self):
'''
@name 安装7zip
@author hwliang
@return {bool} True/False
'''
_7z_bin = self.get_7z_bin()
if _7z_bin:
return True
# 是否已经尝试安装过
install_tip = '{}/data/7z_install.pl'.format(public.get_panel_path())
if os.path.exists(install_tip):
return False
if os.path.exists("/usr/bin/apt-get"):
public.ExecShell("nohup apt-get -y install p7zip-full &> /dev/null &")
elif os.path.exists("/usr/bin/yum"):
public.ExecShell("nohup yum -y install p7zip &> /dev/null &")
elif os.path.exists("/usr/bin/dnf"):
public.ExecShell("nohup dnf -y install p7zip &> /dev/null &")
else:
return False
return True
# 备份网站
def backup_site(self, id, log_file):
find = public.M('sites').where(