mirror of
https://github.com/aaPanel/aaPanel.git
synced 2026-09-07 01:57:38 +02:00
v6.8.12
1. Add disk IO information to the homepage 2. Add a clear list button in the upload window 3. Optimize the background task overhead of the panel 4. Optimize the disk information caching mechanism 5. Panel Pro edition is online 6. Optimize panel resource usage 7. Optimize SSL certificate renewal 8. Fix the problem of reporting an error when the security entrance is empty 9. Fix the problem of infinite recursion when copying directories in extreme cases
This commit is contained in:
+139
-138
@@ -13,25 +13,25 @@
|
||||
|
||||
import public,json,os,time,sys,re
|
||||
from BTPanel import session
|
||||
class obj: id=0;
|
||||
class obj: id=0
|
||||
class plugin_deployment:
|
||||
__setupPath = 'data';
|
||||
__panelPath = '/www/server/panel';
|
||||
__setupPath = 'data'
|
||||
__panelPath = '/www/server/panel'
|
||||
logPath = 'data/deployment_speed.json'
|
||||
__tmp = '/www/server/panel/temp/'
|
||||
timeoutCount = 0;
|
||||
oldTime = 0;
|
||||
timeoutCount = 0
|
||||
oldTime = 0
|
||||
|
||||
#获取列表
|
||||
def GetList(self,get):
|
||||
self.GetCloudList(get);
|
||||
jsonFile = self.__panelPath + '/data/deployment_list.json';
|
||||
if not os.path.exists(jsonFile): return public.returnMsg(False,'Profile does not exist!');
|
||||
self.GetCloudList(get)
|
||||
jsonFile = self.__panelPath + '/data/deployment_list.json'
|
||||
if not os.path.exists(jsonFile): return public.returnMsg(False,'Profile does not exist!')
|
||||
data = {}
|
||||
data = self.get_input_list(json.loads(public.readFile(jsonFile)));
|
||||
data = self.get_input_list(json.loads(public.readFile(jsonFile)))
|
||||
|
||||
if not hasattr(get,'type'):
|
||||
get.type = 0;
|
||||
get.type = 0
|
||||
else:
|
||||
get.type = int(get.type)
|
||||
if not hasattr(get,'search'):
|
||||
@@ -39,32 +39,32 @@ class plugin_deployment:
|
||||
m = 0
|
||||
else:
|
||||
if sys.version_info[0] == 2:
|
||||
search = get.search.encode('utf-8').lower();
|
||||
search = get.search.encode('utf-8').lower()
|
||||
else:
|
||||
search = get.search.lower();
|
||||
search = get.search.lower()
|
||||
m = 1
|
||||
|
||||
tmp = [];
|
||||
tmp = []
|
||||
for d in data['list']:
|
||||
i=0;
|
||||
i=0
|
||||
if get.type > 0:
|
||||
if get.type == d['type']: i+=1
|
||||
else:
|
||||
i+=1
|
||||
if search:
|
||||
if d['name'].lower().find(search) != -1: i+=1;
|
||||
if d['title'].lower().find(search) != -1: i+=1;
|
||||
if d['ps'].lower().find(search) != -1: i+=1;
|
||||
if get.type > 0 and get.type != d['type']: i -= 1;
|
||||
if d['name'].lower().find(search) != -1: i+=1
|
||||
if d['title'].lower().find(search) != -1: i+=1
|
||||
if d['ps'].lower().find(search) != -1: i+=1
|
||||
if get.type > 0 and get.type != d['type']: i -= 1
|
||||
|
||||
if i>m:
|
||||
del(d['versions'][0]['download'])
|
||||
del(d['versions'][0]['md5'])
|
||||
d = self.get_icon(d)
|
||||
tmp.append(d);
|
||||
tmp.append(d)
|
||||
|
||||
data['list'] = tmp;
|
||||
return data;
|
||||
data['list'] = tmp
|
||||
return data
|
||||
|
||||
#获取图标
|
||||
def get_icon(self,pinfo):
|
||||
@@ -81,16 +81,16 @@ class plugin_deployment:
|
||||
|
||||
#获取插件列表
|
||||
def GetDepList(self,get):
|
||||
jsonFile = self.__setupPath + '/deployment_list.json';
|
||||
if not os.path.exists(jsonFile): return public.returnMsg(False,'Profile does not exist!');
|
||||
jsonFile = self.__setupPath + '/deployment_list.json'
|
||||
if not os.path.exists(jsonFile): return public.returnMsg(False,'Profile does not exist!')
|
||||
data = {}
|
||||
data = json.loads(public.readFile(jsonFile));
|
||||
return self.get_input_list(data);
|
||||
data = json.loads(public.readFile(jsonFile))
|
||||
return self.get_input_list(data)
|
||||
|
||||
#获取本地导入的插件
|
||||
def get_input_list(self,data):
|
||||
try:
|
||||
jsonFile = self.__setupPath + '/deployment_list_other.json';
|
||||
jsonFile = self.__setupPath + '/deployment_list_other.json'
|
||||
if not os.path.exists(jsonFile): return data
|
||||
i_data = json.loads(public.readFile(jsonFile))
|
||||
for d in i_data:
|
||||
@@ -101,33 +101,34 @@ class plugin_deployment:
|
||||
#从云端获取列表
|
||||
def GetCloudList(self,get):
|
||||
try:
|
||||
jsonFile = self.__setupPath + '/deployment_list.json';
|
||||
jsonFile = self.__setupPath + '/deployment_list.json'
|
||||
if not 'package' in session or not os.path.exists(jsonFile) or hasattr(get,'force'):
|
||||
downloadUrl = 'http://www.bt.cn/api/panel/get_deplist';
|
||||
tmp = json.loads(public.httpGet(downloadUrl,3));
|
||||
if not tmp: return public.returnMsg(False,'Failed to get from the cloud!');
|
||||
public.writeFile(jsonFile,json.dumps(tmp));
|
||||
downloadUrl = 'http://www.bt.cn/api/panel/get_deplist'
|
||||
pdata = public.get_pdata()
|
||||
tmp = json.loads(public.httpPost(downloadUrl,pdata,3))
|
||||
if not tmp: return public.returnMsg(False,'Failed to get from the cloud!')
|
||||
public.writeFile(jsonFile,json.dumps(tmp))
|
||||
session['package'] = True
|
||||
return public.returnMsg(True,'Update completed!');
|
||||
return public.returnMsg(True,'No need to update!');
|
||||
return public.returnMsg(True,'Update completed!')
|
||||
return public.returnMsg(True,'No need to update!')
|
||||
except:
|
||||
return public.returnMsg(False,'Failed to get from the cloud!');
|
||||
return public.returnMsg(False,'Failed to get from the cloud!')
|
||||
|
||||
|
||||
|
||||
#导入程序包
|
||||
def AddPackage(self,get):
|
||||
jsonFile = self.__setupPath + '/deployment_list_other.json';
|
||||
jsonFile = self.__setupPath + '/deployment_list_other.json'
|
||||
if not os.path.exists(jsonFile):
|
||||
public.writeFile(jsonFile,'[]')
|
||||
pinfo = {}
|
||||
pinfo['name'] = get.name;
|
||||
pinfo['title'] = get.title;
|
||||
pinfo['version'] = get.version;
|
||||
pinfo['php'] = get.php;
|
||||
pinfo['ps'] = get.ps;
|
||||
pinfo['name'] = get.name
|
||||
pinfo['title'] = get.title
|
||||
pinfo['version'] = get.version
|
||||
pinfo['php'] = get.php
|
||||
pinfo['ps'] = get.ps
|
||||
pinfo['official'] = '#'
|
||||
pinfo['sort'] = 1000;
|
||||
pinfo['sort'] = 1000
|
||||
pinfo['min_image'] = ''
|
||||
pinfo['id'] = 0
|
||||
pinfo['type'] = 100
|
||||
@@ -154,24 +155,24 @@ class plugin_deployment:
|
||||
"version_msg": "test2"}
|
||||
version['md5'] = self.GetFileMd5(s_file)
|
||||
pinfo['versions'].append(version)
|
||||
data = json.loads(public.readFile(jsonFile));
|
||||
data = json.loads(public.readFile(jsonFile))
|
||||
is_exists = False
|
||||
for i in range(len(data)):
|
||||
if data[i]['name'] == pinfo['name']:
|
||||
data[i] = pinfo
|
||||
is_exists = True
|
||||
|
||||
if not is_exists: data.append(pinfo);
|
||||
if not is_exists: data.append(pinfo)
|
||||
|
||||
public.writeFile(jsonFile,json.dumps(data));
|
||||
return public.returnMsg(True,'Import Success!');
|
||||
public.writeFile(jsonFile,json.dumps(data))
|
||||
return public.returnMsg(True,'Import Success!')
|
||||
|
||||
#取本地包信息
|
||||
def GetPackageOther(self,get):
|
||||
p_name = get.p_name
|
||||
jsonFile = self.__setupPath + '/deployment_list_other.json';
|
||||
jsonFile = self.__setupPath + '/deployment_list_other.json'
|
||||
if not os.path.exists(jsonFile): public.returnMsg(False,'could not find [%s]' % p_name)
|
||||
data = json.loads(public.readFile(jsonFile));
|
||||
data = json.loads(public.readFile(jsonFile))
|
||||
|
||||
for i in range(len(data)):
|
||||
if data[i]['name'] == p_name: return data[i]
|
||||
@@ -180,23 +181,23 @@ class plugin_deployment:
|
||||
|
||||
#删除程序包
|
||||
def DelPackage(self,get):
|
||||
jsonFile = self.__setupPath + '/deployment_list_other.json';
|
||||
if not os.path.exists(jsonFile): return public.returnMsg(False,'Profile does not exist!');
|
||||
jsonFile = self.__setupPath + '/deployment_list_other.json'
|
||||
if not os.path.exists(jsonFile): return public.returnMsg(False,'Profile does not exist!')
|
||||
|
||||
data = {}
|
||||
data = json.loads(public.readFile(jsonFile));
|
||||
data = json.loads(public.readFile(jsonFile))
|
||||
|
||||
tmp = [];
|
||||
tmp = []
|
||||
for d in data:
|
||||
if d['name'] == get.dname:
|
||||
s_file = self.__panelPath + '/package/' + d['name'] + '.zip'
|
||||
if os.path.exists(s_file): os.remove(s_file)
|
||||
continue;
|
||||
tmp.append(d);
|
||||
continue
|
||||
tmp.append(d)
|
||||
|
||||
data = tmp;
|
||||
public.writeFile(jsonFile,json.dumps(data));
|
||||
return public.returnMsg(True,'Successfully deleted!');
|
||||
data = tmp
|
||||
public.writeFile(jsonFile,json.dumps(data))
|
||||
return public.returnMsg(True,'Successfully deleted!')
|
||||
|
||||
#下载文件
|
||||
def DownloadFile(self,url,filename):
|
||||
@@ -205,15 +206,15 @@ class plugin_deployment:
|
||||
if not os.path.exists(path): os.makedirs(path)
|
||||
import urllib,socket
|
||||
socket.setdefaulttimeout(10)
|
||||
self.pre = 0;
|
||||
self.oldTime = time.time();
|
||||
self.pre = 0
|
||||
self.oldTime = time.time()
|
||||
if sys.version_info[0] == 2:
|
||||
urllib.urlretrieve(url,filename=filename,reporthook= self.DownloadHook)
|
||||
else:
|
||||
urllib.request.urlretrieve(url,filename=filename,reporthook= self.DownloadHook)
|
||||
self.WriteLogs(json.dumps({'name':'Download File','total':0,'used':0,'pre':0,'speed':0}));
|
||||
self.WriteLogs(json.dumps({'name':'Download File','total':0,'used':0,'pre':0,'speed':0}))
|
||||
except:
|
||||
if self.timeoutCount > 5: return;
|
||||
if self.timeoutCount > 5: return
|
||||
self.timeoutCount += 1
|
||||
time.sleep(5)
|
||||
self.DownloadFile(url,filename)
|
||||
@@ -223,14 +224,14 @@ class plugin_deployment:
|
||||
used = count * blockSize
|
||||
pre1 = int((100.0 * used / totalSize))
|
||||
if self.pre != pre1:
|
||||
dspeed = used / (time.time() - self.oldTime);
|
||||
dspeed = used / (time.time() - self.oldTime)
|
||||
speed = {'name':'Download File','total':totalSize,'used':used,'pre':self.pre,'speed':dspeed}
|
||||
self.WriteLogs(json.dumps(speed))
|
||||
self.pre = pre1
|
||||
|
||||
#写输出日志
|
||||
def WriteLogs(self,logMsg):
|
||||
fp = open(self.logPath,'w+');
|
||||
fp = open(self.logPath,'w+')
|
||||
fp.write(logMsg)
|
||||
fp.close()
|
||||
|
||||
@@ -240,8 +241,8 @@ class plugin_deployment:
|
||||
#param string php_version PHP版本
|
||||
def SetupPackage(self,get):
|
||||
name = get.dname
|
||||
site_name = get.site_name;
|
||||
php_version = get.php_version;
|
||||
site_name = get.site_name
|
||||
php_version = get.php_version
|
||||
#取基础信息
|
||||
find = public.M('sites').where('name=?',(site_name,)).field('id,path,name').find()
|
||||
if not 'path' in find:
|
||||
@@ -249,57 +250,57 @@ class plugin_deployment:
|
||||
path = find['path']
|
||||
if path.replace('//','/') == '/': return public.returnMsg(False,'Dangerous website root directory!')
|
||||
#获取包信息
|
||||
pinfo = self.GetPackageInfo(name);
|
||||
pinfo = self.GetPackageInfo(name)
|
||||
id = pinfo['id']
|
||||
if not pinfo: return public.returnMsg(False,'The specified package does not exist.!');
|
||||
if not pinfo: return public.returnMsg(False,'The specified package does not exist.!')
|
||||
|
||||
#检查本地包
|
||||
self.WriteLogs(json.dumps({'name':'Verifying package...','total':0,'used':0,'pre':0,'speed':0}));
|
||||
self.WriteLogs(json.dumps({'name':'Verifying package...','total':0,'used':0,'pre':0,'speed':0}))
|
||||
pack_path = self.__panelPath + '/package'
|
||||
if not os.path.exists(pack_path): os.makedirs(pack_path,384)
|
||||
packageZip = pack_path + '/'+ name + '.zip';
|
||||
isDownload = False;
|
||||
packageZip = pack_path + '/'+ name + '.zip'
|
||||
isDownload = False
|
||||
if os.path.exists(packageZip):
|
||||
md5str = self.GetFileMd5(packageZip);
|
||||
if md5str != pinfo['versions'][0]['md5']: isDownload = True;
|
||||
md5str = self.GetFileMd5(packageZip)
|
||||
if md5str != pinfo['versions'][0]['md5']: isDownload = True
|
||||
else:
|
||||
isDownload = True;
|
||||
isDownload = True
|
||||
|
||||
#下载文件
|
||||
if isDownload:
|
||||
self.WriteLogs(json.dumps({'name':'Downloading file ...','total':0,'used':0,'pre':0,'speed':0}));
|
||||
if pinfo['versions'][0]['download']: self.DownloadFile('http://www.bt.cn/api/Pluginother/get_file?fname=' + pinfo['versions'][0]['download'], packageZip);
|
||||
self.WriteLogs(json.dumps({'name':'Downloading file ...','total':0,'used':0,'pre':0,'speed':0}))
|
||||
if pinfo['versions'][0]['download']: self.DownloadFile('http://www.bt.cn/api/Pluginother/get_file?fname=' + pinfo['versions'][0]['download'], packageZip)
|
||||
|
||||
if not os.path.exists(packageZip): return public.returnMsg(False,'File download failed!' + packageZip);
|
||||
if not os.path.exists(packageZip): return public.returnMsg(False,'File download failed!' + packageZip)
|
||||
|
||||
pinfo = self.set_temp_file(packageZip,path)
|
||||
if not pinfo: return public.returnMsg(False,'Cannot find [aaPanel Auto Deployment Configuration File] in the installation package')
|
||||
|
||||
#设置权限
|
||||
self.WriteLogs(json.dumps({'name':'Setting permissions','total':0,'used':0,'pre':0,'speed':0}));
|
||||
public.ExecShell('chmod -R 755 ' + path);
|
||||
public.ExecShell('chown -R www.www ' + path);
|
||||
self.WriteLogs(json.dumps({'name':'Setting permissions','total':0,'used':0,'pre':0,'speed':0}))
|
||||
public.ExecShell('chmod -R 755 ' + path)
|
||||
public.ExecShell('chown -R www.www ' + path)
|
||||
if pinfo['chmod']:
|
||||
for chm in pinfo['chmod']:
|
||||
public.ExecShell('chmod -R ' + str(chm['mode']) + ' ' + (path + '/' + chm['path']).replace('//','/'));
|
||||
public.ExecShell('chmod -R ' + str(chm['mode']) + ' ' + (path + '/' + chm['path']).replace('//','/'))
|
||||
|
||||
#安装PHP扩展
|
||||
self.WriteLogs(json.dumps({'name':'Install the necessary PHP extensions','total':0,'used':0,'pre':0,'speed':0}));
|
||||
self.WriteLogs(json.dumps({'name':'Install the necessary PHP extensions','total':0,'used':0,'pre':0,'speed':0}))
|
||||
import files
|
||||
mfile = files.files();
|
||||
if type(pinfo['php_ext']) != list : pinfo['php_ext'] = pinfo['php_ext'].strip().split(',')
|
||||
for ext in pinfo['php_ext']:
|
||||
if ext == 'pathinfo':
|
||||
import config
|
||||
con = config.config();
|
||||
get.version = php_version;
|
||||
get.type = 'on';
|
||||
con.setPathInfo(get);
|
||||
con = config.config()
|
||||
get.version = php_version
|
||||
get.type = 'on'
|
||||
con.setPathInfo(get)
|
||||
else:
|
||||
get.name = ext
|
||||
get.version = php_version
|
||||
get.type = '1';
|
||||
mfile.InstallSoft(get);
|
||||
get.type = '1'
|
||||
mfile.InstallSoft(get)
|
||||
|
||||
#解禁PHP函数
|
||||
if 'enable_functions' in pinfo:
|
||||
@@ -308,48 +309,48 @@ class plugin_deployment:
|
||||
php_f = public.GetConfigValue('setup_path') + '/php/' + php_version + '/etc/php.ini'
|
||||
php_c = public.readFile(php_f)
|
||||
rep = "disable_functions\s*=\s{0,1}(.*)\n"
|
||||
tmp = re.search(rep,php_c).groups();
|
||||
disable_functions = tmp[0].split(',');
|
||||
tmp = re.search(rep,php_c).groups()
|
||||
disable_functions = tmp[0].split(',')
|
||||
for fun in pinfo['enable_functions']:
|
||||
fun = fun.strip()
|
||||
if fun in disable_functions: disable_functions.remove(fun)
|
||||
disable_functions = ','.join(disable_functions)
|
||||
php_c = re.sub(rep, 'disable_functions = ' + disable_functions + "\n", php_c);
|
||||
php_c = re.sub(rep, 'disable_functions = ' + disable_functions + "\n", php_c)
|
||||
public.writeFile(php_f,php_c)
|
||||
public.phpReload(php_version)
|
||||
except:pass
|
||||
|
||||
|
||||
#执行额外shell进行依赖安装
|
||||
self.WriteLogs(json.dumps({'name':'Execute extra SHELL','total':0,'used':0,'pre':0,'speed':0}));
|
||||
self.WriteLogs(json.dumps({'name':'Execute extra SHELL','total':0,'used':0,'pre':0,'speed':0}))
|
||||
if os.path.exists(path+'/install.sh'):
|
||||
public.ExecShell('cd '+path+' && bash ' + 'install.sh ' + find['name'] + " &> install.log");
|
||||
public.ExecShell('cd '+path+' && bash ' + 'install.sh ' + find['name'] + " &> install.log")
|
||||
public.ExecShell('rm -f ' + path+'/install.sh')
|
||||
|
||||
#是否执行Composer
|
||||
if os.path.exists(path + '/composer.json'):
|
||||
self.WriteLogs(json.dumps({'name':'Execute Composer','total':0,'used':0,'pre':0,'speed':0}));
|
||||
self.WriteLogs(json.dumps({'name':'Execute Composer','total':0,'used':0,'pre':0,'speed':0}))
|
||||
if not os.path.exists(path + '/composer.lock'):
|
||||
execPHP = '/www/server/php/' + php_version +'/bin/php';
|
||||
execPHP = '/www/server/php/' + php_version +'/bin/php'
|
||||
if execPHP:
|
||||
if public.get_url().find('125.88'):
|
||||
public.ExecShell('cd ' +path+' && '+execPHP+' /usr/bin/composer config repo.packagist composer https://packagist.phpcomposer.com');
|
||||
import panelSite;
|
||||
public.ExecShell('cd ' +path+' && '+execPHP+' /usr/bin/composer config repo.packagist composer https://packagist.phpcomposer.com')
|
||||
import panelSite
|
||||
phpini = '/www/server/php/' + php_version + '/etc/php.ini'
|
||||
phpiniConf = public.readFile(phpini);
|
||||
phpiniConf = phpiniConf.replace('proc_open,proc_get_status,','');
|
||||
public.writeFile(phpini,phpiniConf);
|
||||
public.ExecShell('nohup cd '+path+' && '+execPHP+' /usr/bin/composer install -vvv > /tmp/composer.log 2>&1 &');
|
||||
phpiniConf = public.readFile(phpini)
|
||||
phpiniConf = phpiniConf.replace('proc_open,proc_get_status,','')
|
||||
public.writeFile(phpini,phpiniConf)
|
||||
public.ExecShell('nohup cd '+path+' && '+execPHP+' /usr/bin/composer install -vvv > /tmp/composer.log 2>&1 &')
|
||||
|
||||
#写伪静态
|
||||
self.WriteLogs(json.dumps({'name':'Set URL rewrite','total':0,'used':0,'pre':0,'speed':0}));
|
||||
swfile = path + '/nginx.rewrite';
|
||||
self.WriteLogs(json.dumps({'name':'Set URL rewrite','total':0,'used':0,'pre':0,'speed':0}))
|
||||
swfile = path + '/nginx.rewrite'
|
||||
if os.path.exists(swfile):
|
||||
rewriteConf = public.readFile(swfile);
|
||||
dwfile = self.__panelPath + '/vhost/rewrite/' + site_name + '.conf';
|
||||
public.writeFile(dwfile,rewriteConf);
|
||||
rewriteConf = public.readFile(swfile)
|
||||
dwfile = self.__panelPath + '/vhost/rewrite/' + site_name + '.conf'
|
||||
public.writeFile(dwfile,rewriteConf)
|
||||
|
||||
swfile = path + '/.htaccess';
|
||||
swfile = path + '/.htaccess'
|
||||
if os.path.exists(swfile):
|
||||
swpath = (path + '/'+ pinfo['run_path'] + '/.htaccess').replace('//','/')
|
||||
if pinfo['run_path'] != '/' and not os.path.exists(swpath):
|
||||
@@ -366,23 +367,23 @@ class plugin_deployment:
|
||||
if rm_file_body.find('panel-heading') != -1: os.remove(rm_file)
|
||||
|
||||
#设置运行目录
|
||||
self.WriteLogs(json.dumps({'name':'Set the run directory','total':0,'used':0,'pre':0,'speed':0}));
|
||||
self.WriteLogs(json.dumps({'name':'Set the run directory','total':0,'used':0,'pre':0,'speed':0}))
|
||||
if pinfo['run_path'] != '/':
|
||||
import panelSite;
|
||||
siteObj = panelSite.panelSite();
|
||||
mobj = obj();
|
||||
mobj.id = find['id'];
|
||||
mobj.runPath = pinfo['run_path'];
|
||||
siteObj.SetSiteRunPath(mobj);
|
||||
import panelSite
|
||||
siteObj = panelSite.panelSite()
|
||||
mobj = obj()
|
||||
mobj.id = find['id']
|
||||
mobj.runPath = pinfo['run_path']
|
||||
siteObj.SetSiteRunPath(mobj)
|
||||
|
||||
#导入数据
|
||||
self.WriteLogs(json.dumps({'name':'Import database','total':0,'used':0,'pre':0,'speed':0}));
|
||||
self.WriteLogs(json.dumps({'name':'Import database','total':0,'used':0,'pre':0,'speed':0}))
|
||||
if os.path.exists(path+'/import.sql'):
|
||||
databaseInfo = public.M('databases').where('pid=?',(find['id'],)).field('username,password').find();
|
||||
databaseInfo = public.M('databases').where('pid=?',(find['id'],)).field('username,password').find()
|
||||
if databaseInfo:
|
||||
public.ExecShell('/www/server/mysql/bin/mysql -u' + databaseInfo['username'] + ' -p' + databaseInfo['password'] + ' ' + databaseInfo['username'] + ' < ' + path + '/import.sql');
|
||||
public.ExecShell('rm -f ' + path + '/import.sql');
|
||||
siteConfigFile = (path + '/' + pinfo['db_config']).replace('//','/');
|
||||
public.ExecShell('/www/server/mysql/bin/mysql -u' + databaseInfo['username'] + ' -p' + databaseInfo['password'] + ' ' + databaseInfo['username'] + ' < ' + path + '/import.sql')
|
||||
public.ExecShell('rm -f ' + path + '/import.sql')
|
||||
siteConfigFile = (path + '/' + pinfo['db_config']).replace('//','/')
|
||||
if os.path.exists(siteConfigFile):
|
||||
siteConfig = public.readFile(siteConfigFile)
|
||||
siteConfig = siteConfig.replace('BT_DB_USERNAME',databaseInfo['username'])
|
||||
@@ -391,7 +392,7 @@ class plugin_deployment:
|
||||
public.writeFile(siteConfigFile,siteConfig)
|
||||
|
||||
#清理文件和目录
|
||||
self.WriteLogs(json.dumps({'name':'清理多余的文件','total':0,'used':0,'pre':0,'speed':0}));
|
||||
self.WriteLogs(json.dumps({'name':'清理多余的文件','total':0,'used':0,'pre':0,'speed':0}))
|
||||
if type(pinfo['remove_file']) == str : pinfo['remove_file'] = pinfo['remove_file'].strip().split(',')
|
||||
print(pinfo['remove_file'])
|
||||
for f_path in pinfo['remove_file']:
|
||||
@@ -405,17 +406,17 @@ class plugin_deployment:
|
||||
else:
|
||||
public.ExecShell("rm -rf " + filename)
|
||||
|
||||
public.serviceReload();
|
||||
if id: self.depTotal(id);
|
||||
self.WriteLogs(json.dumps({'name':'Ready to deploy','total':0,'used':0,'pre':0,'speed':0}));
|
||||
return public.returnMsg(True,pinfo);
|
||||
public.serviceReload()
|
||||
if id: self.depTotal(id)
|
||||
self.WriteLogs(json.dumps({'name':'Ready to deploy','total':0,'used':0,'pre':0,'speed':0}))
|
||||
return public.returnMsg(True,pinfo)
|
||||
|
||||
|
||||
#处理临时文件
|
||||
def set_temp_file(self,filename,path):
|
||||
public.ExecShell("rm -rf " + self.__tmp + '/*')
|
||||
self.WriteLogs(json.dumps({'name':'Unpacking the package...','total':0,'used':0,'pre':0,'speed':0}));
|
||||
public.ExecShell('unzip -o '+filename+' -d ' + self.__tmp);
|
||||
self.WriteLogs(json.dumps({'name':'Unpacking the package...','total':0,'used':0,'pre':0,'speed':0}))
|
||||
public.ExecShell('unzip -o '+filename+' -d ' + self.__tmp)
|
||||
auto_config = 'auto_install.json'
|
||||
p_info = self.__tmp + '/' + auto_config
|
||||
p_tmp = self.__tmp
|
||||
@@ -475,33 +476,33 @@ class plugin_deployment:
|
||||
#获取进度
|
||||
def GetSpeed(self,get):
|
||||
try:
|
||||
if not os.path.exists(self.logPath):return public.returnMsg(False,'There are currently no deployment tasks!');
|
||||
return json.loads(public.readFile(self.logPath));
|
||||
if not os.path.exists(self.logPath):return public.returnMsg(False,'There are currently no deployment tasks!')
|
||||
return json.loads(public.readFile(self.logPath))
|
||||
except:
|
||||
return {'name':'Ready to deploy','total':0,'used':0,'pre':0,'speed':0}
|
||||
|
||||
#获取包信息
|
||||
def GetPackageInfo(self,name):
|
||||
data = self.GetDepList(None);
|
||||
if not data: return False;
|
||||
data = self.GetDepList(None)
|
||||
if not data: return False
|
||||
for info in data['list']:
|
||||
if info['name'] == name:
|
||||
return info;
|
||||
return False;
|
||||
return info
|
||||
return False
|
||||
|
||||
#检查指定包是否存在
|
||||
def CheckPackageExists(self,name):
|
||||
data = self.GetDepList(None);
|
||||
if not data: return False;
|
||||
data = self.GetDepList(None)
|
||||
if not data: return False
|
||||
for info in data['list']:
|
||||
if info['name'] == name: return True;
|
||||
if info['name'] == name: return True
|
||||
|
||||
return False;
|
||||
return False
|
||||
|
||||
#文件的MD5值
|
||||
def GetFileMd5(self,filename):
|
||||
if not os.path.isfile(filename): return False;
|
||||
import hashlib;
|
||||
if not os.path.isfile(filename): return False
|
||||
import hashlib
|
||||
myhash = hashlib.md5()
|
||||
f = open(filename,'rb')
|
||||
while True:
|
||||
@@ -510,8 +511,8 @@ class plugin_deployment:
|
||||
break
|
||||
myhash.update(b)
|
||||
f.close()
|
||||
return myhash.hexdigest();
|
||||
return myhash.hexdigest()
|
||||
|
||||
#获取站点标识
|
||||
def GetSiteId(self,get):
|
||||
return public.M('sites').where('name=?',(get.webname,)).getField('id');
|
||||
return public.M('sites').where('name=?',(get.webname,)).getField('id')
|
||||
|
||||
Reference in New Issue
Block a user