站点配置保持优化

This commit is contained in:
midoks
2023-01-02 20:46:09 +08:00
parent 5958f6e067
commit f6e98ae286
4 changed files with 34 additions and 2 deletions
+12
View File
@@ -499,6 +499,18 @@ def backFile(file, act=None):
execShell("cp -p {0} {1}".format(file, file + file_type))
def removeBackFile(file, act=None):
"""
@name 删除备份配置文件
@param file 需要删除备份文件
@param act 如果存在,则还原默认配置
"""
file_type = "_bak"
if act:
file_type = "_def"
execShell("rm -rf {0}".format(file + file_type))
def restoreFile(file, act=None):
"""
@name 还原配置文件
+20
View File
@@ -1118,6 +1118,26 @@ class site_api:
host = self.getHostConf(siteName)
return mw.getJson({'host': host})
def saveHostConfApi(self):
path = request.form.get('path', '')
data = request.form.get('data', '')
encoding = request.form.get('encoding', '')
import files_api
mw.backFile(path)
save_ret_data = files_api.files_api().saveBody(path, data, encoding)
rdata = json.loads(save_ret_data)
if rdata['status']:
isError = mw.checkWebConfig()
if isError != True:
mw.restoreFile(path)
return mw.returnJson(False, 'ERROR: 检测到配置文件有错误,请先排除后再操作<br><br><a style="color:red;">' + isError.replace("\n", '<br>') + '</a>')
mw.restartWeb()
mw.removeBackFile(path)
return save_ret_data
def getRewriteConfApi(self):
siteName = request.form.get('siteName', '')
rewrite = self.getRewriteConf(siteName)
+1 -1
View File
@@ -2379,7 +2379,7 @@ function configFile(webSite){
function saveConfigFile(webSite,encoding,path){
var data = 'encoding='+encoding+'&data='+encodeURIComponent($("#configBody").val())+'&path='+path;
var loadT = layer.msg('保存中...',{icon:16,time:0,shade: [0.3, '#000']});
$.post('/files/save_body',data,function(rdata){
$.post('/site/save_host_conf',data,function(rdata){
layer.close(loadT);
if(rdata.status){
layer.msg(rdata.msg,{icon:1});
+1 -1
View File
@@ -6,7 +6,7 @@ is64bit=`getconf LONG_BIT`
echo -e "您正在安装的是\033[31mmdserver-web测试版\033[0m,非开发测试用途请使用正式版 install.sh !"
echo -e "You are installing\033[31mmdserver-web dev version\033[0m, normally use install.sh for production.\n"
sleep 2
sleep 1
{