Skip to content

Commit

Permalink
一键部署时.htaccess处理
Browse files Browse the repository at this point in the history
  • Loading branch information
showpy committed Jul 4, 2019
1 parent 73fe342 commit 7e581cf
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
4 changes: 3 additions & 1 deletion BTPanel/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,9 @@ def config(pdata = None):
workers_p = 'data/workers.pl'
if not os.path.exists(workers_p): public.writeFile(workers_p,'1')
data['workers'] = int(public.readFile(workers_p))
data['session_timeout'] = int(public.readFile(sess_out_path))
s_time_tmp = public.readFile(sess_out_path)
if not s_time_tmp: s_time_tmp = '0'
data['session_timeout'] = int(s_time_tmp)
if c_obj.get_ipv6_listen(None): data['ipv6'] = 'checked'
if c_obj.get_token(None)['open']: data['api'] = 'checked'
data['basic_auth'] = c_obj.get_basic_auth_stat(None)
Expand Down
4 changes: 3 additions & 1 deletion class/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ def setPanel(self,get):
sess_out_path = 'data/session_timeout.pl'
if 'session_timeout' in get:
session_timeout = int(get.session_timeout)
if int(public.readFile(sess_out_path)) != session_timeout:
s_time_tmp = public.readFile(sess_out_path)
if not s_time_tmp: s_time_tmp = '0'
if int(s_time_tmp) != session_timeout:
if session_timeout < 300: return public.returnMsg(False,'超时时间不能小于300秒')
public.writeFile(sess_out_path,str(session_timeout))
isReWeb = True
Expand Down
11 changes: 9 additions & 2 deletions class/plugin_deployment.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,13 @@ def SetupPackage(self,get):
rewriteConf = public.readFile(swfile);
dwfile = self.__panelPath + '/vhost/rewrite/' + site_name + '.conf';
public.writeFile(dwfile,rewriteConf);

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):
public.writeFile(swpath, public.readFile(swfile))


#删除伪静态文件
public.ExecShell("rm -f " + path + '/*.rewrite')
Expand Down Expand Up @@ -428,9 +435,9 @@ def set_temp_file(self,filename,path):
os.remove(p_info)
i_ndex_html = path + '/index.html'
if os.path.exists(i_ndex_html): os.remove(i_ndex_html)
public.ExecShell("\cp -a -r " + p_tmp + '/* ' + path + '/')
os.system("\cp -arf " + p_tmp + '/. ' + path + '/')
except: pass
public.ExecShell("rm -rf " + self.__tmp + '/*')
os.system("rm -rf " + self.__tmp + '/*')
return p_config


Expand Down
2 changes: 1 addition & 1 deletion runconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
if not os.path.exists(w_num): public.writeFile(w_num,'1')
workers = int(public.readFile(w_num))
if not workers: workers = 1
threads = 4
threads = 1
backlog = 512
reload = False
daemon = True
Expand Down

0 comments on commit 7e581cf

Please sign in to comment.