Skip to content

Commit

Permalink
修正不能取消默认站点的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
showpy committed Jul 3, 2019
1 parent 10d7cbe commit 44a27bb
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
1 change: 1 addition & 0 deletions BTPanel/static/js/site.js
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ var site = {
set_default_site: function () {
bt.site.get_default_site(function (rdata) {
var arrs = [];
arrs.push({title:"未设置默认站点",value:'0'})
for (var i = 0; i < rdata.sites.length; i++) arrs.push({ title: rdata.sites[i].name, value: rdata.sites[i].name })
var form = {
title: lan.site.default_site_yes,
Expand Down
13 changes: 11 additions & 2 deletions class/panelSite.py
Original file line number Diff line number Diff line change
Expand Up @@ -3468,8 +3468,10 @@ def SetSiteRunPath(self,get):
#设置默认站点
def SetDefaultSite(self,get):
import time;

default_site_save = 'data/defaultSite.pl'
#清理旧的
defaultSite = public.readFile('data/defaultSite.pl');
defaultSite = public.readFile(default_site_save);
http2 = ''
versionStr = public.readFile('/www/server/nginx/version.pl');
if versionStr:
Expand All @@ -3487,6 +3489,13 @@ def SetDefaultSite(self,get):
rep = "listen\s+\[::\]:443.+;"
conf = re.sub(rep,'listen [::]:443 ssl'+http2+';',conf,1);
public.writeFile(path,conf);

path = self.setupPath + '/apache/htdocs/.htaccess'
if os.path.exists(path): os.remove(path)

if get.name == '0':
os.remove(default_site_save)
return public.returnMsg(True,'设置成功!')

#处理新的
path = self.setupPath + '/apache/htdocs';
Expand Down Expand Up @@ -3516,7 +3525,7 @@ def SetDefaultSite(self,get):

path = self.setupPath + '/panel/vhost/nginx/default.conf';
if os.path.exists(path): public.ExecShell('rm -f ' + path);
public.writeFile('data/defaultSite.pl',get.name);
public.writeFile(default_site_save,get.name);
public.serviceReload();
return public.returnMsg(True,'SET_SUCCESS');

Expand Down
4 changes: 2 additions & 2 deletions class/public.py
Original file line number Diff line number Diff line change
Expand Up @@ -734,10 +734,10 @@ def checkWebConfig():
if os.path.exists(f3): os.remove(f3)

if get_webserver() == 'nginx':
result = ExecShell("ulimit -n 8192 && /www/server/nginx/sbin/nginx -t -c /www/server/nginx/conf/nginx.conf");
result = ExecShell("ulimit -n 8192 ; /www/server/nginx/sbin/nginx -t -c /www/server/nginx/conf/nginx.conf");
searchStr = 'successful'
else:
result = ExecShell("ulimit -n 8192 && /www/server/apache/bin/apachectl -t");
result = ExecShell("ulimit -n 8192 ; /www/server/apache/bin/apachectl -t");
searchStr = 'Syntax OK'

if result[1].find(searchStr) == -1:
Expand Down
4 changes: 2 additions & 2 deletions class/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,7 @@ def ServiceAdmin(self,get=None):
public.ExecShell('/etc/init.d/httpd stop');
self.kill_port()

result = public.ExecShell('ulimit -n 8192 && ' + self.setupPath+'/apache/bin/apachectl -t');
result = public.ExecShell('ulimit -n 8192 ; ' + self.setupPath+'/apache/bin/apachectl -t');
if result[1].find('Syntax OK') == -1:
public.WriteLog("TYPE_SOFT",'SYS_EXEC_ERR', (str(result),));
return public.returnMsg(False,'SYS_CONF_APACHE_ERR',(result[1].replace("\n",'<br>'),));
Expand All @@ -621,7 +621,7 @@ def ServiceAdmin(self,get=None):
public.ExecShell('mkdir ' + vhostPath);
public.ExecShell('/etc/init.d/nginx start');

result = public.ExecShell('ulimit -n 8192 && nginx -t -c '+self.setupPath+'/nginx/conf/nginx.conf');
result = public.ExecShell('ulimit -n 8192 ; nginx -t -c '+self.setupPath+'/nginx/conf/nginx.conf');
if result[1].find('perserver') != -1:
limit = self.setupPath + '/nginx/conf/nginx.conf';
nginxConf = public.readFile(limit);
Expand Down

0 comments on commit 44a27bb

Please sign in to comment.