mirror of
https://github.com/aaPanel/aaPanel.git
synced 2026-09-09 11:07:39 +02:00
update 6.5.1
This commit is contained in:
+43
-43
@@ -76,7 +76,7 @@ class bt_task:
|
||||
self.clean_log()
|
||||
public.M(self.__table).add('name,type,shell,other,addtime,status',(task_name,task_type,task_shell,other,int(time.time()),0))
|
||||
public.WriteFile(self.__task_tips,'True')
|
||||
os.system("/etc/init.d/bt start")
|
||||
public.ExecShell("/etc/init.d/bt start")
|
||||
return True
|
||||
|
||||
|
||||
@@ -90,28 +90,28 @@ class bt_task:
|
||||
task_info = self.get_task_find(get.id)
|
||||
public.M(self.__table).where('id=?',(get.id,)).delete();
|
||||
if str(task_info['status']) == '-1':
|
||||
os.system("kill -9 $(ps aux|grep 'task.py'|grep -v grep|awk '{print $2}')")
|
||||
public.ExecShell("kill -9 $(ps aux|grep 'task.py'|grep -v grep|awk '{print $2}')")
|
||||
if task_info['type'] == '1':
|
||||
if os.path.exists(task_info['other']): os.remove(task_info['other'])
|
||||
elif task_info['type'] == '3':
|
||||
z_info = json.loads(task_info['other'])
|
||||
if z_info['z_type'] == 'tar.gz':
|
||||
os.system("kill -9 $(ps aux|grep 'tar -zcvf'|grep -v grep|awk '{print $2}')")
|
||||
public.ExecShell("kill -9 $(ps aux|grep 'tar -zcvf'|grep -v grep|awk '{print $2}')")
|
||||
elif z_info['z_type'] == 'rar':
|
||||
os.system("kill -9 $(ps aux|grep /www/server/rar/rar|grep -v grep|awk '{print $2}')")
|
||||
public.ExecShell("kill -9 $(ps aux|grep /www/server/rar/rar|grep -v grep|awk '{print $2}')")
|
||||
elif z_info['z_type'] == 'zip':
|
||||
os.system("kill -9 $(ps aux|grep '.zip -r'|grep -v grep|awk '{print $2}')")
|
||||
os.system("kill -9 $(ps aux|grep '.zip\' -r'|grep -v grep|awk '{print $2}')")
|
||||
public.ExecShell("kill -9 $(ps aux|grep '.zip -r'|grep -v grep|awk '{print $2}')")
|
||||
public.ExecShell("kill -9 $(ps aux|grep '.zip\' -r'|grep -v grep|awk '{print $2}')")
|
||||
if os.path.exists(z_info['dfile']): os.remove(z_info['dfile'])
|
||||
elif task_info['type'] == '2':
|
||||
os.system("kill -9 $(ps aux|grep 'tar -zxvf'|grep -v grep|awk '{print $2}')")
|
||||
os.system("kill -9 $(ps aux|grep '/www/server/rar/unrar'|grep -v grep|awk '{print $2}')")
|
||||
os.system("kill -9 $(ps aux|grep 'unzip -P'|grep -v grep|awk '{print $2}')")
|
||||
os.system("kill -9 $(ps aux|grep 'gunzip -c'|grep -v grep|awk '{print $2}')")
|
||||
public.ExecShell("kill -9 $(ps aux|grep 'tar -zxvf'|grep -v grep|awk '{print $2}')")
|
||||
public.ExecShell("kill -9 $(ps aux|grep '/www/server/rar/unrar'|grep -v grep|awk '{print $2}')")
|
||||
public.ExecShell("kill -9 $(ps aux|grep 'unzip -P'|grep -v grep|awk '{print $2}')")
|
||||
public.ExecShell("kill -9 $(ps aux|grep 'gunzip -c'|grep -v grep|awk '{print $2}')")
|
||||
elif task_info['type'] == '0':
|
||||
os.system("kill -9 $(ps aux|grep '"+task_info['shell']+"'|grep -v grep|awk '{print $2}')")
|
||||
public.ExecShell("kill -9 $(ps aux|grep '"+task_info['shell']+"'|grep -v grep|awk '{print $2}')")
|
||||
|
||||
os.system("/etc/init.d/bt start")
|
||||
public.ExecShell("/etc/init.d/bt start")
|
||||
return public.returnMsg(True,'TASK_CANCEL')
|
||||
|
||||
#取一条任务
|
||||
@@ -131,7 +131,7 @@ class bt_task:
|
||||
task_type = int(task_type)
|
||||
#开始执行
|
||||
if task_type == 0: #执行命令
|
||||
os.system(task_shell + ' &> ' + log_file)
|
||||
public.ExecShell(task_shell + ' &> ' + log_file)
|
||||
elif task_type == 1: #下载文件
|
||||
down_file = downloadFile.downloadFile()
|
||||
down_file.logPath = log_file
|
||||
@@ -234,13 +234,13 @@ class bt_task:
|
||||
|
||||
#判断压缩格式
|
||||
if z_type == 'zip':
|
||||
os.system("cd '"+path+"' && zip '"+dfile+"' -r "+sfiles+" &> "+log_file)
|
||||
public.ExecShell("cd '"+path+"' && zip '"+dfile+"' -r "+sfiles+" &> "+log_file)
|
||||
elif z_type == 'tar.gz':
|
||||
os.system("cd '" + path + "' && tar -zcvf '" + dfile + "' " + sfiles + " &> " + log_file);
|
||||
public.ExecShell("cd '" + path + "' && tar -zcvf '" + dfile + "' " + sfiles + " &> " + log_file);
|
||||
elif z_type == 'rar':
|
||||
rar_file = '/www/server/rar/rar'
|
||||
if not os.path.exists(rar_file): self.install_rar()
|
||||
os.system("cd '" + path + "' && "+rar_file+" a -r '" + dfile + "' " + sfiles + " &> " + log_file)
|
||||
public.ExecShell("cd '" + path + "' && "+rar_file+" a -r '" + dfile + "' " + sfiles + " &> " + log_file)
|
||||
else:
|
||||
return public.returnMsg(False,'NOT_SUP_COMP_FORMAT')
|
||||
|
||||
@@ -259,19 +259,19 @@ class bt_task:
|
||||
|
||||
#判断压缩包格式
|
||||
if sfile[-4:] == '.zip':
|
||||
os.system("unzip -P '"+password+"' -o '" + sfile + "' -d '" + dfile + "' &> " + log_file)
|
||||
public.ExecShell("unzip -P '"+password+"' -o '" + sfile + "' -d '" + dfile + "' &> " + log_file)
|
||||
elif sfile[-7:] == '.tar.gz' or sfile[-4:] == '.tgz':
|
||||
os.system("tar zxvf '" + sfile + "' -C '" + dfile + "' &> " + log_file)
|
||||
public.ExecShell("tar zxvf '" + sfile + "' -C '" + dfile + "' &> " + log_file)
|
||||
elif sfile[-4:] == '.rar':
|
||||
rar_file = '/www/server/rar/unrar'
|
||||
if not os.path.exists(rar_file): self.install_rar()
|
||||
os.system('echo "'+password+'"|' + rar_file + ' x -u -y "' + sfile + '" "' + dfile + '" &> ' + log_file)
|
||||
public.ExecShell('echo "'+password+'"|' + rar_file + ' x -u -y "' + sfile + '" "' + dfile + '" &> ' + log_file)
|
||||
elif sfile[-4:] == '.war':
|
||||
os.system("unzip -P '"+password+"' -o '" + sfile + "' -d '" + dfile + "' &> " + log_file)
|
||||
public.ExecShell("unzip -P '"+password+"' -o '" + sfile + "' -d '" + dfile + "' &> " + log_file)
|
||||
elif sfile[-4:] == '.bz2':
|
||||
os.system("tar jxvf '" + sfile + "' -C '" + dfile + "' &> " + log_file)
|
||||
public.ExecShell("tar jxvf '" + sfile + "' -C '" + dfile + "' &> " + log_file)
|
||||
else:
|
||||
os.system("gunzip -c " + sfile + " > " + sfile[:-3])
|
||||
public.ExecShell("gunzip -c " + sfile + " > " + sfile[:-3])
|
||||
|
||||
#检查是否设置权限
|
||||
if self.check_dir(dfile):
|
||||
@@ -281,7 +281,7 @@ class bt_task:
|
||||
else:
|
||||
import pwd
|
||||
user = pwd.getpwuid(os.stat(dfile).st_uid).pw_name
|
||||
os.system("chown %s:%s %s" % (user,user,dfile))
|
||||
public.ExecShell("chown %s:%s %s" % (user,user,dfile))
|
||||
|
||||
public.WriteLog("TYPE_FILE", 'UNZIP_SUCCESS',(sfile,dfile));
|
||||
return public.returnMsg(True,'UNZIP_SUCCESS');
|
||||
@@ -296,7 +296,7 @@ class bt_task:
|
||||
if not (os.path.exists(backupPath)): os.makedirs(backupPath)
|
||||
|
||||
execStr = "cd '" + find['path'] + "' && zip '" + zipName + "' -x .user.ini -r ./ &> " + log_file
|
||||
os.system(execStr)
|
||||
public.ExecShell(execStr)
|
||||
|
||||
sql = public.M('backup').add('type,name,pid,filename,size,addtime',(0,fileName,find['id'],zipName,0,public.getDate()));
|
||||
public.WriteLog('TYPE_SITE', 'SITE_BACKUP_SUCCESS',(find['name'],));
|
||||
@@ -307,12 +307,12 @@ class bt_task:
|
||||
name = public.M('databases').where("id=?",(id,)).getField('name')
|
||||
find = public.M('config').where('id=?',(1,)).field('mysql_root,backup_path').find()
|
||||
|
||||
if not os.path.exists(find['backup_path'] + '/database'): os.system('mkdir -p ' + find['backup_path'] + '/database')
|
||||
if not os.path.exists(find['backup_path'] + '/database'): public.ExecShell('mkdir -p ' + find['backup_path'] + '/database')
|
||||
self.mypass(True, find['mysql_root'])
|
||||
|
||||
fileName = name + '_' + time.strftime('%Y%m%d_%H%M%S',time.localtime()) + '.sql.gz'
|
||||
backupName = find['backup_path'] + '/database/' + fileName
|
||||
os.system("/www/server/mysql/bin/mysqldump --force --opt \"" + name + "\" | gzip > " + backupName)
|
||||
public.ExecShell("/www/server/mysql/bin/mysqldump --force --opt \"" + name + "\" | gzip > " + backupName)
|
||||
if not os.path.exists(backupName): return public.returnMsg(False,'BACKUP_ERROR')
|
||||
|
||||
self.mypass(False, find['mysql_root'])
|
||||
@@ -352,15 +352,15 @@ class bt_task:
|
||||
|
||||
if not os.path.exists(backupPath + '/' + tmpFile) or tmpFile == '': return public.returnMsg(False, 'FILE_NOT_EXISTS',(tmpFile,))
|
||||
self.mypass(True, root);
|
||||
os.system(public.GetConfigValue('setup_path') + "/mysql/bin/mysql -uroot -p" + root + " --force \"" + name + "\" < " + backupPath + '/' +tmpFile)
|
||||
public.ExecShell(public.GetConfigValue('setup_path') + "/mysql/bin/mysql -uroot -p" + root + " --force \"" + name + "\" < " + backupPath + '/' +tmpFile)
|
||||
self.mypass(False, root);
|
||||
if isgizp:
|
||||
os.system('cd ' +backupPath+ ' && gzip ' + file.split('/')[-1][:-3]);
|
||||
public.ExecShell('cd ' +backupPath+ ' && gzip ' + file.split('/')[-1][:-3]);
|
||||
else:
|
||||
os.system("rm -f " + backupPath + '/' +tmpFile)
|
||||
public.ExecShell("rm -f " + backupPath + '/' +tmpFile)
|
||||
else:
|
||||
self.mypass(True, root);
|
||||
os.system(public.GetConfigValue('setup_path') + "/mysql/bin/mysql -uroot -p" + root + " --force \"" + name + "\" < " + file)
|
||||
public.ExecShell(public.GetConfigValue('setup_path') + "/mysql/bin/mysql -uroot -p" + root + " --force \"" + name + "\" < " + file)
|
||||
self.mypass(False, root);
|
||||
|
||||
|
||||
@@ -372,8 +372,8 @@ class bt_task:
|
||||
#配置
|
||||
def mypass(self,act,root):
|
||||
my_cnf = '/etc/my.cnf'
|
||||
os.system("sed -i '/user=root/d' " + my_cnf)
|
||||
os.system("sed -i '/password=/d' " + my_cnf)
|
||||
public.ExecShell("sed -i '/user=root/d' " + my_cnf)
|
||||
public.ExecShell("sed -i '/password=/d' " + my_cnf)
|
||||
if act:
|
||||
mycnf = public.readFile(my_cnf);
|
||||
rep = "\[mysqldump\]\nuser=root"
|
||||
@@ -384,11 +384,11 @@ class bt_task:
|
||||
|
||||
#设置权限
|
||||
def set_file_accept(self,filename):
|
||||
os.system('chown -R www:www ' + filename)
|
||||
# os.system('chmod -R 755 ' + filename)
|
||||
public.ExecShell('chown -R www:www ' + filename)
|
||||
# public.ExecShell('chmod -R 755 ' + filename)
|
||||
a = 'find {filename} -type d |xargs chmod 0755'.format(filename=filename)
|
||||
os.system(a)
|
||||
os.system('find {filename} -type f |xargs chmod 0644'.format(filename=filename))
|
||||
public.ExecShell(a)
|
||||
public.ExecShell('find {filename} -type f |xargs chmod 0644'.format(filename=filename))
|
||||
|
||||
|
||||
#检查敏感目录
|
||||
@@ -436,7 +436,7 @@ class bt_task:
|
||||
try:
|
||||
import rarfile
|
||||
except:
|
||||
os.system("pip install rarfile")
|
||||
public.ExecShell("pip install rarfile")
|
||||
return True
|
||||
|
||||
import platform
|
||||
@@ -445,18 +445,18 @@ class bt_task:
|
||||
download_url = public.get_url() + '/src/rarlinux'+os_bit+'-5.6.1.tar.gz';
|
||||
|
||||
tmp_file = '/tmp/bt_rar.tar.gz'
|
||||
os.system('wget -O ' + tmp_file + ' ' + download_url)
|
||||
if os.path.exists(unrar_file): os.system("rm -rf /www/server/rar")
|
||||
os.system("tar xvf " + tmp_file + ' -C /www/server/')
|
||||
public.ExecShell('wget -O ' + tmp_file + ' ' + download_url)
|
||||
if os.path.exists(unrar_file): public.ExecShell("rm -rf /www/server/rar")
|
||||
public.ExecShell("tar xvf " + tmp_file + ' -C /www/server/')
|
||||
if os.path.exists(tmp_file): os.remove(tmp_file)
|
||||
if not os.path.exists(unrar_file): return False
|
||||
|
||||
if os.path.exists(bin_unrar): os.remove(bin_unrar)
|
||||
if os.path.exists(bin_rar): os.remove(bin_rar)
|
||||
|
||||
os.system('ln -sf ' + unrar_file + ' ' + bin_unrar)
|
||||
os.system('ln -sf ' + rar_file + ' ' + bin_rar)
|
||||
#os.system("pip install rarfile")
|
||||
public.ExecShell('ln -sf ' + unrar_file + ' ' + bin_unrar)
|
||||
public.ExecShell('ln -sf ' + rar_file + ' ' + bin_rar)
|
||||
#public.ExecShell("pip install rarfile")
|
||||
return True
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user