diff --git a/app/common/__init__.py b/app/common/__init__.py
index 0b39d29a979a19d9e68eccea9b5235161a17291c..4c5d8937a923e5e96c9afeaee13305cbd476458c 100644
--- a/app/common/__init__.py
+++ b/app/common/__init__.py
@@ -21,19 +21,20 @@ def serlogin(username,sign,timestamp,random,types="session"):
types 登录类型 session浏览器默认会话登录 否则返回account_token
"""
+ account_token=''
if (times()-int(timestamp))>3600 or times()-int(timestamp)<-3600:
- return False,3,"时间戳错误"
+ return False,3,"时间戳错误",account_token
inifo=sqlite('admin',model_app_path).where([('username','eq',username),'or',('phone','eq',username)]).find()
if not inifo:
- return False,2,"用户名错误"
+ return False,2,"用户名错误",account_token
if inifo['id']>100:
return False,-1,"您不是管理员账号"
usign=md5(str(inifo['username'])+str(inifo['password'])+str(timestamp)+str(random))
if usign!=sign:
- return False,2,"密码错误"
+ return False,2,"密码错误",account_token
inifo['role']=sqlite("role",model_app_path).where('id',inifo['role']).find()
sqlite('admin',model_app_path).where('id',inifo['id']).update({'logintime':times()})
- account_token=''
+
if types=='session': #如果使用sess登录,要分配系统菜单权限
#根据权限给当前登录用户初始化菜单
systemrolelist=[ #系统菜单权限
@@ -105,9 +106,9 @@ def check_login():
G.userinfo=get_session("userinfo")
if not G.userinfo:
if 'GET' == request.HEADER.Method():
- return response.tpl('pub/login')
+ return response.tpl('/common/html/login.html')
else:
- return errorjson(code=-1,msg='登录失效,请重新登录')
+ return errorjson(code=-1,msg='登录失效,请登录后操作')
return check_role()
def before_request():
"""请求拦截,
@@ -214,40 +215,57 @@ def file_set_content(k,data):
f.write(data)
f.close()
return True
-def insert_Boot_up(cmd):
- "添加开机启动命令"
- if 'Linux' in get_sysinfo()['uname'][0]:
- f=open("/usr/bin/startkcweb","a")
- f.write("\n"+cmd+"\n")
- f.close()
- return True
- else:
- return False
-def del_Boot_up(cmd,vague=False):
- """删除开机启动命令
-
- vague 是否模糊匹配
- """
- if 'Linux' in get_sysinfo()['uname'][0]:
- if vague:
- f = open("/usr/bin/startkcweb")
- con=''
- while True:
- line = f.readline()
- if not line:
- break
- if 'cmd' in line:
- line=''
- con=con+line
+class system_start:
+ "系统启动项"
+ def lists(pagenow=1,pagesize=20,where=None):
+ "启动项列表"
+ lists=sqlite().connect(model_app_path).where(where).table("start").order("id asc").page(pagenow,pagesize).select()
+ count=sqlite().connect(model_app_path).where(where).table("start").count()
+ return lists,count
+ def insert_Boot_up(cmd,name="系统添加",types="shell",icon="",admin_id=0):
+ "添加开机启动命令"
+ if 'Linux' in get_sysinfo()['uname'][0]:
+ f=open("/usr/bin/startkcweb","a")
+ f.write("\n"+cmd+"\n")
f.close()
- file_set_content("/usr/bin/startkcweb",con)
+ if sqlite("start").connect(model_app_path).where("value",cmd).count():
+ return False
+ sqlite("start").connect(model_app_path).insert({"name":name,"types":types,"value":cmd,"icon":icon,"admin_id":admin_id,"addtime":times(),"updtime":times()})
+ return True
else:
- content=file_get_content("/usr/bin/startkcweb")
- content=content.replace("\n"+cmd+"\n","")
- file_set_content("/usr/bin/startkcweb",content)
- return True
- else:
- return False
+ return False
+ def del_Boot_up(cmd,vague=False,id=False):
+ """删除开机启动命令
+
+ vague 是否模糊匹配
+ """
+ if id:
+ where=[("id","eq",id),"and",("admin_id","gt",0)]
+ if 'Linux' in get_sysinfo()['uname'][0]:
+ if vague:
+ f = open("/usr/bin/startkcweb")
+ con=''
+ while True:
+ line = f.readline()
+ if not line:
+ break
+ if 'cmd' in line:
+ line='cmd'
+ con=con+line
+ f.close()
+ file_set_content("/usr/bin/startkcweb",con)
+ if not id:
+ where=[("value","like","%"+str(cmd)+"%")]
+ else:
+ content=file_get_content("/usr/bin/startkcweb")
+ content=content.replace("\n"+cmd+"\n","")
+ file_set_content("/usr/bin/startkcweb",content)
+ if not id:
+ where=[("value","eq",cmd)]
+ sqlite("start").connect(model_app_path).where(where).delete()
+ return True
+ else:
+ return False
g_local_ip=''
def get_local_ip():
"获取内网ip"
diff --git a/app/intapp/controller/soft/tpl/soft/git.html b/app/common/html/login.html
similarity index 39%
rename from app/intapp/controller/soft/tpl/soft/git.html
rename to app/common/html/login.html
index 9f6b6b0c2e3b8361183f526edd61e6341087ba10..09094684a4199a77c5826e6899730801536b3028 100644
--- a/app/intapp/controller/soft/tpl/soft/git.html
+++ b/app/common/html/login.html
@@ -1,15 +1,13 @@
-
-kcwebplus
+kcweb
-
@@ -17,53 +15,64 @@
-
-
-
-
-
-
-
- 您可以使用以下命令生成ssh密钥
-
+
+
+
+
+
+

kcweb   
+
+
+
+
+
+
+
+
+ 登录
+
+
+
-
-
+
+
-
\ No newline at end of file
+
diff --git a/app/common/model.py b/app/common/model.py
index 12897f1e00f1c62001a12ef9f6c71b6c534e5f75..7c60028f43c889376ec2e8e25647bcdb79235b1b 100644
--- a/app/common/model.py
+++ b/app/common/model.py
@@ -61,19 +61,22 @@ class model_intapp_menu(modelsqliteintapp):
"url":model.dbtype.varchar(LEN=32,DEFAULT=''), #菜单地址
"types":model.dbtype.varchar(LEN=11,DEFAULT=''), # left,header
}
- def add(title,icon,url,types='left',pid=0,admin_id=0):
+ def add(title,icon,url,types='left',pid=0,admin_id=0,sort=2000):
"添加菜单"
- sqlite('menu',model_app_path).insert({'title':title,'icon':icon,'url':url,"types":types,"pid":pid,"admin_id":admin_id,"sort":0})
- def delete(id='',title='',types="left",pid=0,admin_id=0):
+ sqlite('menu',model_app_path).insert({'title':title,'icon':icon,'url':url,"types":types,"pid":pid,"admin_id":admin_id,"sort":sort})
+ def delete(id='',title='',types="left",pid=0,admin_id=0,sort=2000):
"删除菜单"
if id:
sqlite('menu',model_app_path).where("id="+str(id)+"").delete()
elif title and pid:
sqlite('menu',model_app_path).where("title='"+title+"' and pid="+str(pid)).delete()
+ elif title and sort:
+ sqlite('menu',model_app_path).where("title='"+title+"' and sort='"+str(sort)+"'").delete()
elif title and types:
sqlite('menu',model_app_path).where("title='"+title+"' and types='"+types+"'").delete()
elif title and admin_id:
sqlite('menu',model_app_path).where("title='"+title+"' and admin_id='"+str(admin_id)+"'").delete()
+
try:
sqlite('menu',model_app_path).find()
@@ -123,4 +126,23 @@ except:
"icon":'',
"role":json_encode(role),
"addtime":times()
- })
\ No newline at end of file
+ })
+
+class model_app_start(modelsqliteintapp):
+ "启动项"
+ table="start"
+ fields={
+ "id":model.dbtype.int(LEN=11,PRI=True,A_L=True), #设置id为自增主键
+ "name":model.dbtype.varchar(LEN=128,DEFAULT=''), #名字
+ "icon":model.dbtype.varchar(LEN=128,DEFAULT=''),
+ "types":model.dbtype.varchar(LEN=128,DEFAULT='shell'), #类型
+ "value":model.dbtype.varchar(LEN=512,DEFAULT=''),
+ "admin_id":model.dbtype.int(LEN=11),
+ "updtime":model.dbtype.int(LEN=11,DEFAULT=0), #添加时间
+ "addtime":model.dbtype.int(LEN=11,DEFAULT=0), #添加时间
+ }
+try:
+ sqlite('start',model_app_path).find()
+except:
+ model_app_start=model_app_start()
+ model_app_start.create_table()
\ No newline at end of file
diff --git a/app/intapp/controller/__init__.py b/app/intapp/controller/__init__.py
index f4dbb41806865dbf404d8e22172a59b9a51cb25a..6a0389200c3dbfe0c77443814666268ed08060c3 100644
--- a/app/intapp/controller/__init__.py
+++ b/app/intapp/controller/__init__.py
@@ -1,3 +1,2 @@
-from . import index
-from . import soft
\ No newline at end of file
+from . import index
\ No newline at end of file
diff --git a/app/intapp/controller/index/common/plantask.py b/app/intapp/controller/index/common/plantask.py
index 017ed102283759bb7ffa0642497ddf05266e1fd9..65abec8df951af844231ac4b187204ec846d59f5 100644
--- a/app/intapp/controller/index/common/plantask.py
+++ b/app/intapp/controller/index/common/plantask.py
@@ -146,16 +146,18 @@ class PLANTASK():
try:
if not PLANTASK.BlockingSchedulers:
PLANTASK.BlockingSchedulers = BlockingScheduler()
- #进程可能影响cli运行
- multiprocessing.Process(target=PLANTASK.plantaskdsfsdfsafdsafsd,args=(PLANTASK.BlockingSchedulers,func,targger,args,year,month,week,day_of_week,day,hour,minute,second,iden)).start()
- # t=threading.Thread(target=PLANTASK.plantaskdsfsdfsafdsafsd,args=(PLANTASK.BlockingSchedulers,func,targger,args,year,month,week,day_of_week,day,hour,minute,second,iden))
- # t.daemon=True
- # t.start()
- # print("添加",data)
-
+ if 'Linux' in get_sysinfo()['platform']:
+ mu=multiprocessing.Process(target=PLANTASK.plantaskdsfsdfsafdsafsd,args=(PLANTASK.BlockingSchedulers,func,targger,args,year,month,week,day_of_week,day,hour,minute,second,iden))
+ mu.daemon=True
+ mu.start()
+ elif 'Windows' in get_sysinfo()['platform']:
+ t=threading.Thread(target=PLANTASK.plantaskdsfsdfsafdsafsd,args=(PLANTASK.BlockingSchedulers,func,targger,args,year,month,week,day_of_week,day,hour,minute,second,iden))
+ t.daemon=True
+ t.start()
except:
return False
- return True
+ else:
+ return True
#这里是初始化计划任务
if not config.app['cli']: #判断运行方式
try:
@@ -165,5 +167,4 @@ if not config.app['cli']: #判断运行方式
serverserverinterval['updtime']=times()
sqlite("interval",model_intapp_index_path).where("id",serverserverinterval['id']).update(serverserverinterval)
PLANTASK.plantask(serverserverinterval) #添加计划任务
- # print(serverserverinterval)
except:pass
\ No newline at end of file
diff --git a/app/intapp/controller/index/plug.py b/app/intapp/controller/index/plug.py
index b7e201331355f12995acb51fca562e5e626d6c75..eb3fd7133ee72b1678460aa369bf5146dc9f24a6 100644
--- a/app/intapp/controller/index/plug.py
+++ b/app/intapp/controller/index/plug.py
@@ -130,8 +130,8 @@ def uninstallplug():
dirname="app/"+arr['modular']+"/controller/"+arr['name']+"/common/file"
if not os.path.exists("backup/"+dirname):
os.makedirs("backup/"+dirname)
- zip.packzip(dirname,"backup/"+dirname+"/backup.zip")
- file_set_content("backup/"+dirname+"/time",str(times()))
+ zip.packzip(dirname,"backup/"+dirname+"/backup.zip")
+ file_set_content("backup/"+dirname+"/time",str(times()))
sqlite("menu",model_app_path).where("url='/"+arr['modular']+'/'+arr['name']+"'").delete()
sqlite('plug',model_app_path).where("name='"+arr['name']+"' and modular='"+arr['modular']+"'").delete()
diff --git a/app/intapp/controller/index/setup.py b/app/intapp/controller/index/setup.py
index 9294b0a7964e0c6d7e3953a485215bb7b42fbffa..261071256a92687821cad5d9255b30160953a511 100644
--- a/app/intapp/controller/index/setup.py
+++ b/app/intapp/controller/index/setup.py
@@ -1,7 +1,38 @@
from .common import *
def index():
return response.tpl()
-
+def addstart():
+ "添加启动项"
+ data=request.get_json()
+ if sqlite("start").connect(model_app_path).where("value",data['value']).count():
+ return errorjson(msg="禁止重复添加")
+ if system_start.insert_Boot_up(cmd=data['value'],name=data['name'],types=data['types'],admin_id=G.userinfo['id']):
+ return successjson()
+ else:
+ return errorjson(msg="添加失败,该系统支不支持")
+def delstart():
+ data=request.get_json()
+ if system_start.del_Boot_up(cmd=data['value'],id=data['id']):
+ return successjson()
+ else:
+ return errorjson()
+def startlist():
+ "启动项列表"
+ pagenow=request.args.get('pagenow')
+ pagesize=request.args.get('pagesize')
+ if not pagenow:
+ pagenow=1
+ else:
+ pagenow=int(pagenow)
+ if not pagesize:
+ pagesize=10
+ else:
+ pagesize=int(pagesize)
+ yz=system_start.lists(pagenow,pagesize)
+ lists=yz[0]
+ count=yz[1]
+ data=return_list(lists,count,pagenow,pagesize)
+ return successjson(data)
def backup():
"备份"
dirname=request.args.get("dirname")
@@ -56,7 +87,7 @@ def recovery():
return successjson()
else:
return errorjson(msg="备份文件不存在")
- else:
+ elif os.path.exists("backup"):
filelist=get_file("backup")
for k in filelist:
if k['type']=='file' and 'backup.zip' in k['path']:
@@ -64,6 +95,8 @@ def recovery():
dirname=re.sub("/backup.zip","",dirname)
zip.unzip_file("backup/"+dirname+"/backup.zip",dirname)
return successjson("恢复所有")
+ else:
+ return errorjson(msg="备份目录不存在")
def download(name=""):
"下载备份文件"
if os.path.exists("backup"):
diff --git a/app/intapp/controller/index/tpl/index/index.html b/app/intapp/controller/index/tpl/index/index.html
index 01010bd526429b57559a4799fd857f170b846da0..ee605a0afe13619a40ddf8bd978592ff67cf7b31 100644
--- a/app/intapp/controller/index/tpl/index/index.html
+++ b/app/intapp/controller/index/tpl/index/index.html
@@ -36,7 +36,7 @@
-
+
diff --git a/app/intapp/controller/index/tpl/setup/index.html b/app/intapp/controller/index/tpl/setup/index.html
index 1ff58d7e23ada8bc1ff681b4593b8470f9450682..8bf3c8c8bd124a5790336a174be1148a0a8b762a 100644
--- a/app/intapp/controller/index/tpl/setup/index.html
+++ b/app/intapp/controller/index/tpl/setup/index.html
@@ -23,22 +23,49 @@
+
+
+   
+
+ 添加启动项
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
恢复所有备份
@@ -53,6 +80,23 @@
+
+
+
+
+
+
+
+
+
+
+
@@ -71,7 +115,13 @@ Vues=new Vue({
el: '#app',
data:{
winheight:document.documentElement.clientHeight,winwidth:document.documentElement.clientWidth,
- activeName: 'pack'
+ activeName: 'start',
+ admin:{value:'',name:'',types:''},admindialog:{status:false,title:'添加启动项'},
+ data:{
+ 'count':0,
+ 'pagenow':1,
+ 'lists':[]
+ },
},
mounted:function(){
self=this
@@ -79,8 +129,36 @@ Vues=new Vue({
self.winheight=document.documentElement.clientHeight
self.winwidth=document.documentElement.clientWidth
}
+ self.obtain()
},
methods: {
+ obtain:function(){
+ self=this
+ self.get("/intapp/index/setup/startlist",{pagenow:self.data.pagenow},'获取中...').then(function(res){
+ self.data=res.data
+ })
+ },addstart:function(){
+ self=this
+ self.post("/intapp/index/setup/addstart",self.admin,"请稍后...").then(function(res){
+ self.admindialog.status=false
+ self.obtain()
+ }).catch(function(err){
+ self.admindialog.status=false
+ })
+ },delstart:function(item){
+ self=this
+ self=this
+ self.$confirm("警告", '该操作会上传启动项', {
+ confirmButtonText: '删除',
+ cancelButtonText: '取消',
+ type: 'warning'
+ }).then(function(){
+ self.post("/intapp/index/setup/delstart",item,"请稍后...").then(function(res){
+ self.obtain()
+ })
+ }).catch(function(){});
+
+ },
download:function(){
window.location.href="/intapp/index/setup/download/backup";
},
diff --git a/app/intapp/controller/index/tpl/task/index.html b/app/intapp/controller/index/tpl/task/index.html
index 2f5754e5a8aa180b191fb18fb78137943429c9c0..cf1d3d4e73bb6991b8342f14d2dbcb0b3cb880fb 100644
--- a/app/intapp/controller/index/tpl/task/index.html
+++ b/app/intapp/controller/index/tpl/task/index.html
@@ -45,7 +45,7 @@
- 执行完成,收到一个异常
+ 执行完成
等待排队中
进行中...
执行完成
diff --git a/app/intapp/controller/soft/__init__.py b/app/intapp/controller/soft/__init__.py
deleted file mode 100644
index f7a8da394010ab0235e518d5e493d9ba6763dc09..0000000000000000000000000000000000000000
--- a/app/intapp/controller/soft/__init__.py
+++ /dev/null
@@ -1,8 +0,0 @@
-from . import index
-from . import page
-from . import nginx
-from . import mysql
-from . import redis
-from . import mongodb
-from . import frp
-from . import php
\ No newline at end of file
diff --git a/app/intapp/controller/soft/common/SOFT.py b/app/intapp/controller/soft/common/SOFT.py
deleted file mode 100644
index d9a1ce6927f5aafcdabda7809f4b3c6853b65746..0000000000000000000000000000000000000000
--- a/app/intapp/controller/soft/common/SOFT.py
+++ /dev/null
@@ -1,213 +0,0 @@
-# -*- coding: utf-8 -*-
-from .model import *
-class SOFT:
- def softlist(kw,pagenow,pagesize):
- "软件列表"
- if config.app['appmode']=='develop':
- where="1=1"
- else:
- where="platform='"+get_sysinfo()['uname'][0]+"'"
- if kw:
- where+=" and title LIKE '%"+kw+"%' or describes LIKE '%"+kw+"%'"
- lists=sqlite("soft",model_intapp_soft_path).where(where).page(pagenow,pagesize).select()
- if len(lists) < 1:
- SOFT.updatesoftlist()
- lists=sqlite("soft",model_intapp_soft_path).where(where).page(pagenow,pagesize).select()
- if 'Linux' in get_sysinfo()['platform']:
- i=0
- for k in lists:
- if k['status'] == 0 and k['platform']=='Linux': #检查软件是否已经安装
- if (os.path.exists(k['paths']+k['title']+k['edition'])) :
- lists[i]['status']=4
- sqlite("soft",model_intapp_soft_path).where('id',k['id']).update({'status':lists[i]['status']})
- if (k['status'] == 10 or k['status'] == 4) and k['platform']=='Linux': #检查软件是否在运行中
- if 'nginx' in k['title'] :
- if not get_process_id('nginx'):
- if k['status'] == 10:
- lists[i]['status']=4
- sqlite("soft",model_intapp_soft_path).where('id',k['id']).update({'status':4}) #停止
- else:
- if k['status'] == 4:
- lists[i]['status']=10
- sqlite("soft",model_intapp_soft_path).where('id',k['id']).update({'status':10}) #运行中
- elif 'redis' in k['title']:
- if not get_process_id('redis'):
- if k['status'] == 10:
- lists[i]['status']=4
- sqlite("soft",model_intapp_soft_path).where('id',k['id']).update({'status':4}) #停止
- else:
- if k['status'] == 4:
- lists[i]['status']=10
- sqlite("soft",model_intapp_soft_path).where('id',k['id']).update({'status':10}) #运行中
- elif 'mysql' in k['title']:
- if not get_process_id('mysql'):
- if k['status'] == 10:
- lists[i]['status']=4
- sqlite("soft",model_intapp_soft_path).where('id',k['id']).update({'status':4}) #停止
- else:
- if k['status'] == 4:
- lists[i]['status']=10
- sqlite("soft",model_intapp_soft_path).where('id',k['id']).update({'status':10}) #运行中
- elif 'php5' in k['title']+k['edition'] or 'php7' in k['title']+k['edition']:
- title=k['title']+k['edition']
- # print("php",title,title.replace(".", "")+"-fpm")
- if not get_process_id(title):
- if k['status'] == 10:
- lists[i]['status']=4
- sqlite("soft",model_intapp_soft_path).where('id',k['id']).update({'status':4}) #停止
- else:
- if k['status'] == 4:
- lists[i]['status']=10
- sqlite("soft",model_intapp_soft_path).where('id',k['id']).update({'status':10}) #运行中
- i+=1
- count=sqlite("soft",model_intapp_soft_path).where(where).count()
- data=return_list(lists,count,pagenow,pagesize)
- return data
- def updatesoftlist():
- "更新软件列表"
- http=Http()
- sqlite("soft",model_intapp_soft_path).where("1=1").delete()
- def openkcweb(pagenow=1,pagesize=20):
- http.openurl(config.domain['kcwebapi']+"/pub/soft_list","POST",{
- "pagenow":pagenow,"pagesize":pagesize
- })
- res=json_decode(http.get_text)
- lists=[]
- if res['code']==0:
- for k in res['data']['lists']:
- k['status']=0
- k['msg']=''
- k['addtime']=times()
- lists.append(k)
- sqlite("soft",model_intapp_soft_path).insert(lists)
- if pagenow log 2>&1 &")
- return True
- elif 'mysql' == arr['title']:
- if os.path.isfile(arr['paths']+arr['title']+arr['edition']+"/support-files/mysql.server"):
- sqlite("soft",model_intapp_soft_path).where("id",id).update({"status":4,"msg":"安装成功"})
- insert_Boot_up("mysqld start")
- return True
- elif 'frp' == arr['title']:
- if os.path.isfile(arr['paths']+arr['title']+arr['edition']+"/frps") and os.path.isfile(arr['paths']+arr['title']+arr['edition']+"/frpc"):
- sqlite("soft",model_intapp_soft_path).where("id",id).update({"status":4,"msg":"安装成功"})
- return True
- else:
- if os.path.exists(arr['paths']+arr['title']+arr['edition']):
- sqlite("soft",model_intapp_soft_path).where("id",id).update({"status":4,"msg":"安装成功"})
- return True
- sqlite("soft",model_intapp_soft_path).where("id",id).update({"status":0,"msg":"安装失败,目录不存在"+arr['paths']+arr['title']+arr['edition']})
- else:
- sqlite("soft",model_intapp_soft_path).where("id",id).update({"status":0,"msg":"安装失败"})
- else:
- sqlite("soft",model_intapp_soft_path).where("id",id).update({"status":0,"msg":"下载失败"})
- except Exception as e:
- sqlite('soft',model_intapp_soft_path).where('id',id).update({'status':0,'msg':'安装失败'+str(e)})
- def start(id):
- "启动软件服务"
- arr=sqlite("soft",model_intapp_soft_path).where("id",id).find()
- if arr['platform']=='Linux': ###############################LINUX
- if 'nginx' == arr['title']:
- os.system("nginx")
- elif 'php' == arr['title']:
- titleedition=arr['title']+arr['edition']
- fpmname=titleedition.replace(".", "")+"-fpm"
- os.system(fpmname+" -c "+arr['paths']+arr['title']+arr['edition']+"/bin/php.ini -R")
- # print("php启动",fpmname+" -c "+arr['paths']+arr['title']+arr['edition']+"/bin/php.ini -R")
- elif 'redis' == arr['title']:
- os.system("nohup redis-server "+arr['paths']+arr['title']+arr['edition']+"/redis.conf > log 2>&1 &")
- elif 'mysql' == arr['title']:
- os.system("mysqld start")
- else:
- os.system("cd "+arr['paths']+arr['title']+arr['edition']+" && bash start.sh")
- sqlite("soft",model_intapp_soft_path).where("id",id).update({"status":10,"msg":"运行中"})
- else:
- sqlite("soft",model_intapp_soft_path).where("id",id).update({"status":4,"msg":""})
- def stop(id):
- arr=sqlite("soft",model_intapp_soft_path).where("id",id).find()
- if arr['platform']=='Linux': ###############################LINUX
- if 'nginx' == arr['title']:
- os.system("pkill nginx")
- elif 'php' == arr['title']:
- titleedition=arr['title']+arr['edition']
- fpmname=titleedition.replace(".", "")+"-fpm"
- os.system("pkill -9 "+fpmname)
- elif 'redis' == arr['title']:
- os.system("pkill redis")
- elif 'mysql' == arr['title']:
- os.system("mysqld stop")
- elif 'mongo' == arr['title']:
- os.system("pkill mongo")
- else:
- os.system("cd "+arr['paths']+arr['title']+arr['edition']+" && bash stop.sh")
- sqlite("soft",model_intapp_soft_path).where("id",id).update({"status":4,"msg":""})
- def uninstall(id):
- try:
- arr=sqlite("soft",model_intapp_soft_path).where("id",id).find()
- if arr['platform']=='Linux': ###############################LINUX
- os.system("rm -rf "+arr['paths']+arr['title']+arr['edition'])
- startpath="/usr/bin/"
- if 'nginx' == arr['title']:
- del_Boot_up("nginx")
- os.system("pkill -9 nginx")
- model_intapp_menu.delete(title="网站",types="left")
- os.system("rm -rf "+startpath+"nginx")
- elif 'redis' == arr['title']:
- del_Boot_up("nohup redis-server "+arr['paths']+arr['title']+arr['edition']+"/redis.conf > log 2>&1 &")
- os.system("rm -rf "+startpath+"redis-server")
- elif 'php' == arr['title']:
- titleedition=arr['title']+arr['edition']
- fpmname=titleedition.replace(".", "")+"-fpm"
- del_Boot_up(fpmname+" -c "+arr['paths']+arr['title']+arr['edition']+"/bin/php.ini -R")
-
-
- os.system("rm -rf "+startpath+fpmname)
- elif 'mysql' == arr['title']:
- del_Boot_up("mysqld start")
- os.system("rm -rf "+startpath+"mysqld && rm -rf "+startpath+"mysql && rm -rf /etc/my.cnf")
- elif 'mongodb' == arr['title']:
- del_Boot_up("mongo",True)
- os.system("pkill -9 mongo")
- os.system("rm -rf /data/mongodb")
- elif 'frp' == arr['title']:
- del_Boot_up("frps",True)
- del_Boot_up("frpc",True)
- os.system("pkill -9 frps")
- os.system("pkill -9 frpc")
- else:
- if os.path.exists(arr['paths']+arr['title']+arr['edition']):
- sqlite('soft',model_intapp_soft_path).where('id',id).update({'status':4,'msg':'卸载失败'})
- return
- except Exception as e:
- sqlite('soft',model_intapp_soft_path).where('id',id).update({'status':4,'msg':'卸载失败'+str(e)})
- else:
- sqlite("soft",model_intapp_soft_path).where("id",id).update({"status":0,"msg":"已卸载"})
\ No newline at end of file
diff --git a/app/intapp/controller/soft/common/__init__.py b/app/intapp/controller/soft/common/__init__.py
deleted file mode 100644
index 887982424ba2f56bea14c4ff7ecd71613a2dcbe0..0000000000000000000000000000000000000000
--- a/app/intapp/controller/soft/common/__init__.py
+++ /dev/null
@@ -1,2 +0,0 @@
-# -*- coding: utf-8 -*-
-from .SOFT import *
\ No newline at end of file
diff --git a/app/intapp/controller/soft/common/autoload.py b/app/intapp/controller/soft/common/autoload.py
deleted file mode 100644
index c4bee80b95d58a388e57e1188e329473a64d845a..0000000000000000000000000000000000000000
--- a/app/intapp/controller/soft/common/autoload.py
+++ /dev/null
@@ -1,10 +0,0 @@
-# -*- coding: utf-8 -*-
-from app.intapp.common import *
-import subprocess
-def get_process_id(name):
- try:
- child = subprocess.Popen(['pgrep', '-f', name],stdout=subprocess.PIPE, shell=False)
- response = child.communicate()[0]
- return [int(pid) for pid in response.split()]
- except:
- return []
diff --git a/app/intapp/controller/soft/common/file/soft b/app/intapp/controller/soft/common/file/soft
deleted file mode 100644
index 6653475e90ae0b4d5f804f4d9be25ea4ceadfde8..0000000000000000000000000000000000000000
Binary files a/app/intapp/controller/soft/common/file/soft and /dev/null differ
diff --git a/app/intapp/controller/soft/common/file/sqlite/.gitignore b/app/intapp/controller/soft/common/file/sqlite/.gitignore
deleted file mode 100644
index f3c316ee17c6039c18f8a88a66027233d569e495..0000000000000000000000000000000000000000
--- a/app/intapp/controller/soft/common/file/sqlite/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-soft
\ No newline at end of file
diff --git a/app/intapp/controller/soft/common/file/sqlite/php_exten b/app/intapp/controller/soft/common/file/sqlite/php_exten
deleted file mode 100644
index 643a9415b601d5c3a803687d93aa38c01a1857ef..0000000000000000000000000000000000000000
Binary files a/app/intapp/controller/soft/common/file/sqlite/php_exten and /dev/null differ
diff --git a/app/intapp/controller/soft/common/model.py b/app/intapp/controller/soft/common/model.py
deleted file mode 100644
index efcaf83432b02120386d2862939481a7780dbbcb..0000000000000000000000000000000000000000
--- a/app/intapp/controller/soft/common/model.py
+++ /dev/null
@@ -1,84 +0,0 @@
-# -*- coding: utf-8 -*-
-from .autoload import *
-# 初始化数据库
-model_intapp_soft_path=os.path.split(os.path.realpath(__file__))[0]+"/file/sqlite/soft"
-class modelsqlitesoft(model.model):
- config={'type':'sqlite'}
- config={'type':'sqlite','db':model_intapp_soft_path}
- model.dbtype.conf=config
-class model_intapp_soft(modelsqlitesoft):
- "软件表"
- table="soft"
- fields={
- "id":model.dbtype.int(LEN=11,PRI=True,A_L=True), #设置id为自增主键
- "icon":model.dbtype.varchar(LEN=128,DEFAULT=''), #图标
- "title":model.dbtype.varchar(LEN=128,DEFAULT=''), #软件名称
- "edition":model.dbtype.varchar(LEN=128,DEFAULT=''), #软件版本
- "shell":model.dbtype.varchar(LEN=128,DEFAULT=''), #shell 命令
- "describes":model.dbtype.varchar(LEN=256,DEFAULT=''), #软件描述
- "paths":model.dbtype.varchar(LEN=256,DEFAULT=''), #软件安装目录 卸载软件时用到
- "status":model.dbtype.int(LEN=2,DEFAULT=0), #0未安装 1等待中 2下载中 3安装中 4已安装 5卸载中 9启动中... 10运行中 11正在停止服务...
- "filename":model.dbtype.varchar(LEN=256,DEFAULT=''), #软件源文件地址
- "platform":model.dbtype.varchar(LEN=256,DEFAULT='Linux'),#支持的系统
- 'msg':model.dbtype.varchar(LEN=1024,DEFAULT=''), #最后一次执行结果信息
- "addtime":model.dbtype.int(LEN=11,DEFAULT=0), #添加时间
- "updtime":model.dbtype.int(LEN=11,DEFAULT=0) #更新时间
- }
-try:
- sqlite('soft',model_intapp_soft_path).find()
-except:
- model_soft=model_intapp_soft()
- model_soft.create_table()
-
-class model_intapp_web(modelsqlitesoft):
- "网站列表"
- table="web"
- fields={
- "id":model.dbtype.int(LEN=11,PRI=True,A_L=True), #设置id为自增主键
- "domain":model.dbtype.varchar(LEN=512,DEFAULT=''), #域名
- "port":model.dbtype.varchar(LEN=8,DEFAULT='80'), #端口
- "icon":model.dbtype.varchar(LEN=128,DEFAULT=''), #图标
- "title":model.dbtype.varchar(LEN=128,DEFAULT=''), #名称
- "describes":model.dbtype.varchar(LEN=256,DEFAULT=''), #描述
- "status":model.dbtype.int(LEN=1,DEFAULT=1), #网站状态 0停止 1开启
- "path":model.dbtype.varchar(LEN=256,DEFAULT=''), #网站目录
- "client_max_body_size":model.dbtype.int(LEN=11,DEFAULT=20),#上传限制
- "webtpl":model.dbtype.varchar(LEN=256,DEFAULT=''), #nginx配置文件模板名
- "servers":model.dbtype.varchar(LEN=256,DEFAULT=''), #服务器名字 nginx名字
- "only":model.dbtype.varchar(LEN=32,DEFAULT=''), #唯一字段
- "balancing":model.dbtype.varchar(LEN=2048,DEFAULT=''), #负载均衡服务器信息
- "proxy_set_header":model.dbtype.varchar(LEN=1024,DEFAULT=''),#自定义转发请求头
- "ssl_certificate":model.dbtype.varchar(LEN=1024,DEFAULT=''),
- "ssl_certificate_key":model.dbtype.varchar(LEN=1024,DEFAULT=''),
- "addtime":model.dbtype.int(LEN=11,DEFAULT=0), #添加时间
- "updtime":model.dbtype.int(LEN=11,DEFAULT=0) #更新时间
- }
-try:
- sqlite('web',model_intapp_soft_path).find()
-except:
- model_intapp_web=model_intapp_web()
- model_intapp_web.create_table()
-
-model_intapp_soft_php_exten_path=os.path.split(os.path.realpath(__file__))[0]+"/file/sqlite/php_exten"
-class model_intapp_php_exten(model.model):
- "php扩展表"
- config={'type':'sqlite'}
- config={'type':'sqlite','db':model_intapp_soft_php_exten_path}
- model.dbtype.conf=config
- table="php_exten"
- fields={
- "id":model.dbtype.int(LEN=11,PRI=True,A_L=True), #设置id为自增主键
- "pid":model.dbtype.int(LEN=11), #软件列表id
- "title":model.dbtype.varchar(LEN=128,DEFAULT=''), #扩展名称
- "describes":model.dbtype.varchar(LEN=256,DEFAULT=''), #扩展描述
- "status":model.dbtype.int(LEN=2,DEFAULT=0), #0未安装 1等待中 2下载中 3安装中 4已安装 5卸载中
- "filename":model.dbtype.varchar(LEN=256,DEFAULT=''), #软件源文件地址
- 'msg':model.dbtype.varchar(LEN=1024,DEFAULT=''), #最后一次执行结果信息
- "addtime":model.dbtype.int(LEN=11,DEFAULT=0), #添加时间
- "updtime":model.dbtype.int(LEN=11,DEFAULT=0) #更新时间
- }
-try:
- sqlite('php_exten',model_intapp_soft_php_exten_path).find()
-except:
- model_intapp_php_exten=model_intapp_php_exten()
- model_intapp_php_exten.create_table()
\ No newline at end of file
diff --git a/app/intapp/controller/soft/frp.py b/app/intapp/controller/soft/frp.py
deleted file mode 100644
index 677098bffd9fc9694615bec3a186865911cf6af9..0000000000000000000000000000000000000000
--- a/app/intapp/controller/soft/frp.py
+++ /dev/null
@@ -1,133 +0,0 @@
-from .common import *
-dar="/usr/local/frp/frp0.30"
-# pkill frps && cd /usr/local/frp/frp0.30 && ./frps -c frps_full.ini &
-def get_server():
- server={
- 'conf':file_get_content(dar+"/frps_full.ini"),
- 'base':json_decode(file_get_content(dar+"/frps_full.conf"))
- }
- return successjson(server)
-def run_status():
- "获取运行状态"
- data={"frpc":0,"frps":0}
- if get_process_id('frps'):
- data['frps']=1
- if get_process_id('frpc'):
- data['frpc']=1
- return successjson(data)
-def restart(types='frps'):
- "重启"
- if not os.path.exists(dar+"/log"):
- os.makedirs(dar+"/log")
- if types=='frps':
- cmd="cd "+dar +" && nohup ./frps -c frps_full.ini > "+dar+"/log/frpslog 2>&1 &"
- os.system("pkill -9 frps")
- del_Boot_up(cmd)
- time.sleep(1)
- os.system(cmd)
- time.sleep(1)
- if not get_process_id('frps'):
- return errorjson(msg="启动失败,请检查配置")
- insert_Boot_up(cmd)
- elif types=='frpc':
- cmd="cd "+dar +" && nohup ./frpc -c frps_full.ini > "+dar+"/log/frpslog 2>&1 &"
- os.system("pkill frpc")
- del_Boot_up(cmd)
- time.sleep(1)
- os.system(cmd)
- time.sleep(1)
- if not get_process_id('frpc'):
- return errorjson(msg="启动失败,请检查配置")
- insert_Boot_up(cmd)
- return successjson()
-def stop(types='all'):
- "停止"
- if types=='frps':
- del_Boot_up("cd "+dar +" && nohup ./frps -c frps_full.ini > "+dar+"/log/frpslog 2>&1 &")
- os.system("pkill -9 frps")
- elif types=='frpc':
- del_Boot_up("cd "+dar +" && nohup ./frpc -c frps_full.ini > "+dar+"/log/frpslog 2>&1 &")
- os.system("pkill -9 frpc")
- else:
- del_Boot_up("cd "+dar +" && nohup ./frps -c frps_full.ini > "+dar+"/log/frpslog 2>&1 &")
- del_Boot_up("cd "+dar +" && nohup ./frpc -c frps_full.ini > "+dar+"/log/frpslog 2>&1 &")
- os.system("pkill -9 frps")
- os.system("pkill -9 frpc")
- return successjson()
-def upd_server(types='ini'):
- server=request.get_json()
- if types=='ini':
- file_set_content(dar+"/frps_full.ini",server['conf'])
- elif types=='base':
- base=server['base']
- f = open(dar+"/frps_full.ini")
- con=''
- while True:
- line = f.readline()
- if not line:
- break
- elif 'bind_addr = ' in line:
- line="bind_addr = "+base['bind_addr']+"\n"
- elif 'bind_port = ' in line:
- line="bind_port = "+base['bind_port']+"\n"
- elif 'bind_udp_port = ' in line:
- line="bind_udp_port = "+base['bind_udp_port']+"\n"
- elif 'kcp_bind_port = ' in line:
- line="kcp_bind_port = "+base['kcp_bind_port']+"\n"
- elif 'vhost_http_port = ' in line:
- line="vhost_http_port = "+base['vhost_http_port']+"\n"
- elif 'vhost_https_port = ' in line:
- line="vhost_https_port = "+base['vhost_https_port']+"\n"
- elif 'dashboard_addr = ' in line:
- line="dashboard_addr = "+base['dashboard_addr']+"\n"
- elif 'dashboard_port = ' in line:
- line="dashboard_port = "+base['dashboard_port']+"\n"
- elif 'dashboard_user = ' in line:
- line="dashboard_user = "+base['dashboard_user']+"\n"
- elif 'dashboard_pwd = ' in line:
- line="dashboard_pwd = "+base['dashboard_pwd']+"\n"
- elif 'log_level = ' in line:
- line="log_level = "+base['log_level']+"\n"
- elif 'log_max_days = ' in line:
- line="log_max_days = "+base['log_max_days']+"\n"
- elif 'disable_log_color = ' in line:
- line="disable_log_color = "+base['disable_log_color']+"\n"
- elif 'token = ' in line:
- line="token = "+base['token']+"\n"
- elif 'allow_ports = ' in line:
- line="allow_ports = "+base['allow_ports']+"\n"
- elif 'max_pool_count = ' in line:
- line="max_pool_count = "+base['max_pool_count']+"\n"
- elif 'max_ports_per_client = ' in line:
- line="max_ports_per_client = "+base['max_ports_per_client']+"\n"
- elif 'subdomain_host = ' in line:
- line="subdomain_host = "+base['subdomain_host']+"\n"
- elif 'tcp_mux = ' in line:
- line="tcp_mux = "+base['tcp_mux']+"\n"
- con=con+line
- f.close()
- file_set_content(dar+"/frps_full.ini",con)
- file_set_content(dar+"/frps_full.conf",json_encode(base))
- os.system("pkill frps")
- time.sleep(1)
- os.system("cd "+dar +" && ./frps -c frps_full.ini &")
- time.sleep(1)
- if not get_process_id('frps'):
- return errorjson(msg="启动失败,请检查配置")
- return successjson()
-def get_client():
- client={
- 'conf':file_get_content(dar+"/frpc.ini"),
- 'base':json_decode(file_get_content(dar+"/frpc.conf"))
- }
- return successjson(client)
-def upd_client(type='ini'):
- server=request.get_json()
- file_set_content(dar+"/frpc.ini",server['conf'])
- os.system("pkill frpc")
- time.sleep(1)
- os.system("cd "+dar +" && ./frpc -c frpc.ini &")
- time.sleep(1)
- if not get_process_id('frpc'):
- return errorjson(code=1,msg="启动失败,请检查配置")
- return successjson()
\ No newline at end of file
diff --git a/app/intapp/controller/soft/index.py b/app/intapp/controller/soft/index.py
deleted file mode 100644
index 77bbc05aab1c6d2a3d7dd0beb71e37363b383db2..0000000000000000000000000000000000000000
--- a/app/intapp/controller/soft/index.py
+++ /dev/null
@@ -1,83 +0,0 @@
-from .common import *
-def index():
- return response.tpl('index/home')
-def gettitle(title,edition):
- "获取软件信息"
- return successjson(sqlite('soft',model_intapp_soft_path).where("title='"+title+"' and edition='"+edition+"' and platform='"+get_sysinfo()['uname'][0]+"' and status >=4").find())
-def softlist():
- kw=request.args.get("kw")
- pagenow=int(request.args.get("pagenow"))
- pagesize=int(request.args.get("pagesize"))
- return successjson(SOFT.softlist(kw,pagenow,pagesize))
-def updatesoftlist():
- "更新软件列表"
- SOFT.updatesoftlist()
- return successjson()
-def getstatus(id):
- "获取软件状态和描述"
- return successjson(sqlite("soft",model_intapp_soft_path).field("status,msg").where("id",id).find())
-def insert(id):
- "安装软件"
- title=sqlite('soft',model_intapp_soft_path).where("id",id).field("title").find()['title']
- if 'nginx' == title:
- ass=sqlite('soft',model_intapp_soft_path).where([('title','eq','nginx'),'and',('status','gt',0)]).find()
- if ass:
- return errorjson(msg="您已安装其他nginx版本,卸载其他nginx版本后可安装此版本")
- if 'kodexplorer' in title or 'phpmyadmin' in title:
- if not sqlite('soft',model_intapp_soft_path).where([('title','like','%php%'),'and',('status','egt','4')]).count() or not sqlite('soft',model_intapp_soft_path).where([('title','like','%nginx%'),'and',('status','egt','4')]).count():
- return errorjson(msg="先安装nginx和php")
- if 'phpmyadmin' in title:
- if not sqlite('soft',model_intapp_soft_path).where([('title','like','%mysql%'),'and',('status','egt','4')]).count() or not sqlite('soft',model_intapp_soft_path).where([('title','like','%nginx%'),'and',('status','egt','4')]).count():
- return errorjson(msg="先安装mysql")
- sqlite("soft",model_intapp_soft_path).where("id",id).update({"status":1,"msg":"安装中"})
- Queues.insert(target=SOFT.insert,args=(id,),title="安装软件:"+title)
- return successjson()
-def start(id):
- "启动软件"
- SOFT.start(id)
- return successjson()
-def stop(id):
- "停止软件"
- SOFT.stop(id)
- return successjson()
-def uninstall(id):
- "卸载软件"
- # title=request.args.get("title")
- title=sqlite('soft',model_intapp_soft_path).where("id",id).field("title").find()['title']
- if 'nginx' == title:
- sqlite("web",model_intapp_soft_path).where("1=1").update({"status":0})
- sqlite("soft",model_intapp_soft_path).where("id",id).update({"status":5,"msg":"卸载中"})
- Queues.insert(target=SOFT.uninstall,args=(id,),title="卸载软件:"+title)
- return successjson()
-
-
-def gitssh():
- 'gitssh公钥'
- data=file_get_content("/root/.ssh/id_rsa.pub")
- return successjson(data)
-
-
-
-def add():
- "添加内容"
- try:
- data=request.get_json()
- data.update(updtime=times(),addtime=times())
- # print(data)
- sqlite('software',config.sqlitesoftware).insert(data)
- except:
- return errorjson(msg="失败")
- else:
- return successjson()
-def update(id=0):
- "更新内容"
- data=request.get_json()
- if not id:
- id=data['id']
- try:
- data.pop('updtime')
- data.pop('addtime')
- except:pass
- else:
- sqlite('software',config.sqlitesoftware).where("id",id).update(data)
- return successjson()
\ No newline at end of file
diff --git a/app/intapp/controller/soft/install.txt b/app/intapp/controller/soft/install.txt
deleted file mode 100644
index 6b996d304745e93ee957e6d94c829f52f3cf530e..0000000000000000000000000000000000000000
--- a/app/intapp/controller/soft/install.txt
+++ /dev/null
@@ -1 +0,0 @@
-oss2>=2.11.0
\ No newline at end of file
diff --git a/app/intapp/controller/soft/mongodb.py b/app/intapp/controller/soft/mongodb.py
deleted file mode 100644
index f7223a10854c6df18ca3494583736490cf6fdc7e..0000000000000000000000000000000000000000
--- a/app/intapp/controller/soft/mongodb.py
+++ /dev/null
@@ -1,245 +0,0 @@
-from .common import *
-import base64
-WORK_DIR="/data/mongodb"
-if not os.path.exists(WORK_DIR):
- os.system("mkdir -p "+WORK_DIR)
-def get_config(id):
- '获取mongodb页面配置'
- data=json_decode(file_get_content(WORK_DIR+"/config.conf"))
- try:
- key=file_get_content(WORK_DIR+"/key/mongo.key")
- except:
- key=""
- if not data:
- data={}
- data['key']=key
- data['get_local_ip']=get_local_ip()
- data['WORK_DIR']=WORK_DIR
- data['configlist']=json_decode(file_get_content(WORK_DIR+"/serverconfig.conf"))
- return successjson(data)
-def upd_config(id):
- '修改mongodb页面配置'
- data=request.get_json()
- os.system("mkdir -p "+WORK_DIR+"/key")
- f=open(WORK_DIR+"/key/mongo.key","w")
- f.write(data['key'])
- f.close()
- os.system("chmod 600 "+WORK_DIR+"/key/mongo.key")
- data['key']=''
- file_set_content(WORK_DIR+"/config.conf",json_encode(data))
- return successjson()
-
-def start_config(types='restart'):
- '启动/停止config服务'
- data=request.get_json()
- data['key']=''
- os.system("mkdir -p "+WORK_DIR+"/conf")
- f=open(WORK_DIR+"/conf/config.conf","w")
- f.write("logappend=true\n"+
- "fork=true\n"+
- "maxConns=5000\n"+
- "replSet=configs\n"+
- "keyFile="+WORK_DIR+"/key/mongo.key\n"+
- "configsvr=true")
- f.close()
- os.system("chmod 777 "+WORK_DIR+"/conf/config.conf")
- # os.system("chmod 600 "+WORK_DIR+"/key/mongo.key")
- i=1
- for k in data['configs']['server']:
- os.system("mkdir -p "+WORK_DIR+"/config"+str(i)+"/data")
- i+=1
- if types=='restart' or types=='stop': #停止服务
- i=1
- for k in data['configs']['server']:
- pid=file_get_content(WORK_DIR+"/config"+str(i)+"/db.pid")
- os.system("kill -9 "+str(pid))
- time.sleep(0.1)
- i+=1
- data['configs']['serverstatus']=0
- if types=='restart' or types=='start': #启动服务
- i=1
- for k in data['configs']['server']:
- startstatus=False
- cmd="mongod --bind_ip "+str(k['ip'])+" --port "+str(k['port'])+" -f "+WORK_DIR+"/conf/config.conf --dbpath "+WORK_DIR+"/config"+str(i)+"/data --logpath "+WORK_DIR+"/config"+str(i)+"/log.log --pidfilepath "+WORK_DIR+"/config"+str(i)+"/db.pid"
- result=os.popen(cmd)
- res = result.read()
- for line in res.splitlines():
- print("line",line)
- if 'process started successfully' in line:
- startstatus=True
- break
- if not startstatus:
- return errorjson(code=1,msg="启动失败")
-
- i+=1
- data['configs']['serverstatus']=1
- file_set_content(WORK_DIR+"/config.conf",json_encode(data))
- return successjson()
-def start_mongos(types='restart'):
- '启动/停止路由服务'
- data=request.get_json()
- data['key']=''
- # for k in data
- #创建配置文件
- os.system("mkdir -p "+WORK_DIR+"/conf && mkdir -p "+WORK_DIR+"/mongos")
- f=open(WORK_DIR+"/conf/mongos.conf","w")
- f.write("logappend = true\n"+
- "fork=true\n"+
- data['mongos']['configdb']+" #这里必须是公共网ip或内网ip,千万不能是127.0.0.1\n"
- "keyFile="+WORK_DIR+"/key/mongo.key\n"+
- "maxConns=20000 #最大连接数")
- f.close()
- os.system("chmod 777 "+WORK_DIR+"/conf/mongos.conf")
- os.system("mkdir -p "+WORK_DIR+"/mongos")
- if types=='restart' or types=='stop': #停止服务
- i=1
- for k in data['mongos']['server']:
- pid=file_get_content(WORK_DIR+"/mongos/db"+str(i)+".pid")
- os.system("kill -9 "+str(pid))
- time.sleep(0.1)
- i+=1
- data['mongos']['serverstatus']=0
- if types=='restart' or types=='start': #启动服务
- i=1
- for k in data['mongos']['server']:
- startstatus=False
- cmd="mongos --bind_ip "+str(k['ip'])+" --port "+str(k['port'])+" -f "+WORK_DIR+"/conf/mongos.conf --logpath "+WORK_DIR+"/mongos/log"+str(i)+".log --pidfilepath "+WORK_DIR+"/mongos/db"+str(i)+".pid"
- print(cmd)
- result=os.popen(cmd)
- res = result.read()
- for line in res.splitlines():
- print("line",line)
- if 'process started successfully' in line:
- startstatus=True
- break
- if not startstatus:
- return errorjson(code=1,msg="启动失败")
- i+=1
- data['mongos']['serverstatus']=1
- file_set_content(WORK_DIR+"/config.conf",json_encode(data))
- return successjson()
-def start_shard(types='restart'):
- '启动/停止分片服务'
- data=request.get_json()
- data['key']=''
- os.system("mkdir -p "+WORK_DIR+"/conf")
-
- j=1
- for shard in data['shard']:#分片列表
- f=open(WORK_DIR+"/conf/shard"+str(j)+".conf","w")
- f.write("logappend=true\n"+
- "fork=true\n"+
- "maxConns=2000\n"+
- "storageEngine=mmapv1 #基于内存映射文件的存储引擎\n"+
- "shardsvr=true\n"+
- "replSet="+shard['servername']+"\n"+
- "keyFile="+WORK_DIR+"/key/mongo.key")
- f.close()
- i=1
- for k in shard['server']:
- os.system("mkdir -p "+WORK_DIR+"/shard"+str(j)+"/data"+str(i))
- i+=1
- if types=='restart' or types=='stop': #停止服务
- i=1
- for k in shard['server']:
- pid=file_get_content(WORK_DIR+"/shard"+str(j)+"/db"+str(i)+".pid")
- os.system("kill -9 "+str(pid))
- time.sleep(0.1)
- i+=1
- data['shard'][j-1]['serverstatus']=0
- if types=='restart' or types=='start': #启动服务
- i=1
- for k in shard['server']:#副本集列表
- startstatus=False
- cmd="mongod --bind_ip "+str(k['ip'])+" --port "+str(k['port'])+" -f "+WORK_DIR+"/conf/shard"+str(j)+".conf --dbpath "+WORK_DIR+"/shard"+str(j)+"/data"+str(i)+" --logpath "+WORK_DIR+"/shard"+str(j)+"/log"+str(i)+".log --pidfilepath "+WORK_DIR+"/shard"+str(j)+"/db"+str(i)+".pid"
- print("启动cmd:",cmd)
- result=os.popen(cmd)
- res = result.read()
- for line in res.splitlines():
- print("line",line)
- if 'process started successfully' in line:
- startstatus=True
- break
- if not startstatus:
- file_set_content(WORK_DIR+"/config.conf",json_encode(data))
- return errorjson(code=1,msg="启动失败")
- i+=1
- data['shard'][j-1]['serverstatus']=1
- j+=1
- file_set_content(WORK_DIR+"/config.conf",json_encode(data))
- return successjson()
-
-# def config_init(id):
-# "config副本集初始化,"
-# data=request.get_json()
-# port=data['configs']['server'][0]['port']
-# replicaset=data['configs']['replicaset']
-# members=[]
-# i=0
-# for k in replicaset:
-# zd={'_id':i,'host':k['ip']+':'+str(k['port'])}
-# members.append(zd)
-# i+=1
-# f=open(config.path['path']+"app/linuxweb/config_init.sh","w")
-# f.write("mongo --port "+str(port)+"\n"+
-# "use admin\n"+
-# "rs.initiate({_id:'configs',members:"+json_encode(members)+"})\n"+
-# "exit")
-# f.close()
-# os.system("cd "+config.path['path']+"app/linuxweb && bash config_init.sh")
-# return successjson()
-
-
-
-#mongodb独立部署 /data/mongodb/server1/
-def setserverconfig():
- configlist=request.get_json()
- for k in configlist:
- if not os.path.exists(WORK_DIR+k['path']):
- os.makedirs(WORK_DIR+k['path'])
- if not os.path.exists(WORK_DIR+k['path']+"/data"):
- os.makedirs(WORK_DIR+k['path']+"/data")
- file_set_content(WORK_DIR+k['path']+"/mongod.config",''+
- 'systemLog:\n'+
- ' destination: file\n'+
- ' logAppend: true\n'+
- ' path: '+WORK_DIR+k['path']+'/mongodb.log #mongodb的日志文件路径\n'+
- 'storage:\n'+
- ' dbPath: '+WORK_DIR+k['path']+'/data/ #mongodb的数据文件路径\n'+
- ' journal:\n'+
- ' enabled: true\n'+
- 'processManagement:\n'+
- ' fork: true # fork and run in background\n'+
- ' pidFilePath: '+WORK_DIR+k['path']+'/mongod.pid # location of pidfile\n'+
- ' timeZoneInfo: /usr/share/zoneinfo\n'+
- 'net:\n'+
- ' port: '+str(k['port'])+' #mongodb1的进程号\n'+
- ' bindIp: '+k['bindIp']+' # Listen to local interface only, comment to listen on all interfaces')
- file_set_content(WORK_DIR+"/serverconfig.conf",json_encode(configlist))
- return successjson()
-def restartserver(types='start',index=0):
- index=int(index)
- configlist=json_decode(file_get_content(WORK_DIR+"/serverconfig.conf"))
- cmd="mongod -f "+WORK_DIR+configlist[index]['path']+"/mongod.config" #启动命令
- if types=='start':
- configlist[index]['status']=1
- insert_Boot_up(cmd)
- # sqlite('start_command').insert({'title':'mongodb启动'+str(index),'describes':'系统创建,请务删除','status':0,'command':cmd,'addtime':times()})#添加自启
- elif types=='stop':
- # sqlite('start_command').where('title','mongodb启动'+str(index)).delete()#删除自启
- configlist[index]['status']=0
- del_Boot_up(cmd)
- cmd=cmd+" --shutdown" #停止命令
- result=os.popen(cmd)
- res = result.read()
- startstatus=False
- for line in res.splitlines():
- print("line",line)
- if 'process started successfully' in line or 'killing process with pid' in line:
- startstatus=True
- break
- if startstatus:
- file_set_content(WORK_DIR+"/serverconfig.conf",json_encode(configlist))
- return successjson()
- else:
- return errorjson(cmd,msg="失败")
diff --git a/app/intapp/controller/soft/mysql.py b/app/intapp/controller/soft/mysql.py
deleted file mode 100644
index 3abcb496e2f9fc9e350394edf137223f03540dd2..0000000000000000000000000000000000000000
--- a/app/intapp/controller/soft/mysql.py
+++ /dev/null
@@ -1,205 +0,0 @@
-from .common import *
-import oss2
-def get_data(id):
- ar=sqlite('soft',model_intapp_soft_path).where('id',id).find()
- text=file_get_content(ar['paths']+ar['title']+ar['edition']+"/config.conf")
- conf=json_decode(text)
- if not conf:
- conf={
- "base":{'rootpassword':'intapppasswordtest','path':ar['paths']+ar['title']+ar['edition']+'/data'},
- }
- data={
- 'conf':conf,
- 'ar':ar,
- "my":file_get_content("/etc/my.cnf")
- }
- return successjson(data)
-def upd_my():
- "修改配置文件"
- data=request.get_json()
- file_set_content("/etc/my.cnf",data['text'])
- return successjson()
-def upd_data(id):
- ar=sqlite('soft',model_intapp_soft_path).where('id',id).find()
- data=request.get_json()
- filetext=file_get_content(ar['paths']+ar['title']+ar['edition']+"/config.conf")
- filedata=json_decode(filetext)
- if not filedata or data['base']['rootpassword']!=filedata['base']['rootpassword']:#修改mysql密码
- os.system("mysqld restart --skip-grant-tables")
- cmd="mysql -uroot -e "
- cmd=cmd+'"use mysql;flush privileges;update user set authentication_string=password('
- cmd=cmd+"'"+str(data['base']['rootpassword'])
- cmd=cmd+"'"
- cmd=cmd+') where user='
- cmd=cmd+"'root';set password=password('"+str(data['base']['rootpassword'])+"');"
- cmd=cmd+'"'
- pi=subprocess.Popen(cmd,shell=True, stdout=subprocess.PIPE,stderr=subprocess.STDOUT)
- ars=pi.stdout.read().decode()
- ars=ars.split("\n")
- strs=ars[len(ars)-2]
- os.system("mysqld restart")
- print(type(strs),strs)
- if 'error' in strs:
- return errorjson(msg="密码修改失败"+strs)
-
- # mysqld restart --skip-grant-tables && mysql -uroot -e "flush privileges;update mysql.user set authentication_string=password('123456') where user = 'root'";
- # print(data['base']['rootpassword'],filedata['base']['rootpassword'])
- if not filedata or data['base']['path']!=filedata['base']['path']:
- os.system('mysqld stop')
- os.system("mkdir -p "+str(data['base']['path']))
- if not filedata:
- print("cp -r "+ar['paths']+ar['title']+ar['edition']+"/data/. "+data['base']['path']+"/")
- os.system("cp -r "+ar['paths']+ar['title']+ar['edition']+"/data/. "+data['base']['path']+"/")
- else:
- print("cp -r "+filedata['base']['path']+"/. "+data['base']['path']+"/")
- os.system("cp -r "+filedata['base']['path']+"/. "+data['base']['path']+"/")
- os.system("chown -R mysql "+str(data['base']['path'])+" && chgrp -R mysql "+str(data['base']['path']))
-
- f = open('/etc/my.cnf')
- con=''
- while True:
- line = f.readline()
- if not line:
- break
- elif 'datadir=' in line:
- line="datadir="+str(data['base']['path'])+"\n"
- con=con+line
- f.close()
- f= open('/etc/my.cnf', "w")
- f.write(con)
- f.close()
- time.sleep(1)
- os.system('mysqld start')
- text=json_encode(data)
- file_set_content(ar['paths']+ar['title']+ar['edition']+"/config.conf",text)
-
- return successjson()
-def backups(types='whole',db='bankup_all_databases',upload_aliyun=False):
- return BACKUP.backups(types,db,upload_aliyun)
- # title="备份数据库"
- # describes=""
- # if types=='whole' and db=='bankup_all_databases':
- # title="全量备份所有数据库:"+db+".sql.gz"
- # describes="全量备份所有数据库:"+db+".sql.gz"
- # elif types=='whole':
- # title="全量备份指定数据库:"+db+".sql.gz"
- # describes="全量备份指定数据库:"+db+".sql.gz"
- # else:
- # title="增量备份所有数据库:"+db+".sql.gz"
- # describes="增量备份所有数据库:"+db+".sql.gz"
- # Queues.insert(target=BACKUP.backups,args=(types,db,upload_aliyun),title=title,describes=describes)
- # return successjson()
-class BACKUP:
- def backups(types='whole',db='bankup_all_databases',upload_aliyun=False):
- """备份mysql --cli运行
- types whole表示全量备份。 increment表示增量备份所有
-
- db bankup_all_databases表示备份所有数据库。 否则备份指定数据库按逗号分隔 types=whole时有效
- """
- indexconfigpathfile=os.path.split(os.path.realpath(__file__))[0]+"/../index/common/file/sqlite/strconfig"
- configfile=json_decode(file_get_content(indexconfigpathfile))
- if not configfile:
- print("请先在计划中保存备份目录")
- return
- if configfile['backmysqlpath'][:1]=='/':
- backmysqlpath="backup"+configfile['backmysqlpath'] #mysql备份目录
- else:
- backmysqlpath="backup/"+configfile['backmysqlpath'] #mysql备份目录
- if backmysqlpath[-1]=='/':
- backmysqlpath=backmysqlpath[:-1]
- mysqldatapath="/usr/local/mysql/mysql5.7/data" #mysql数据库存放目
- mysqlpwd='intapppasswordtest'
- mysqlconf=json_decode(file_get_content("/usr/local/mysql/mysql5.7/config.conf")) #mysql信息
- if mysqlconf:
- mysqldatapath=mysqlconf['base']['path']
- mysqlpwd=mysqlconf['base']['rootpassword']
- conf={
- "mysql":{
- "username":"root","password":mysqlpwd,"host":"127.0.0.1",#mysql信息
- },
- }
- if upload_aliyun:
- auth = oss2.Auth(configfile['access_key_id'],configfile['access_key_secret'])
- bucket = oss2.Bucket(auth,configfile['endpoint'],configfile['Bucket'])
- if types=='whole': #全量备份
- if not os.path.exists(backmysqlpath):
- os.system("mkdir -p "+backmysqlpath)
- if db=='bankup_all_databases':#备份所有
- print("全量备份所有数据库:"+db+".sql.gz")
- os.system("mysqldump -u"+conf['mysql']['username']+" -p"+conf['mysql']['password']+" -h"+conf['mysql']['host']+" --all-databases --flush-logs --delete-master-logs --single-transaction | gzip >> "+backmysqlpath+"/"+db+".sql.gz")
- else:#备份指定数据库
- db=re.sub(","," ",db)
- print("全量备份指定数据库:"+db+".sql.gz")
- os.system("mysqldump -u"+conf['mysql']['username']+" -p"+conf['mysql']['password']+" -h"+conf['mysql']['host']+" --databases --flush-logs --delete-master-logs --single-transaction | gzip >> "+backmysqlpath+"/"+db+".sql.gz")
- if upload_aliyun:
- print(backmysqlpath+"/"+db+".sql.gz","上传mysql备份目录文件到阿里云oss...")
- oss2.resumable_upload(bucket, "backups/"+backmysqlpath+"/"+db+".sql.gz",backmysqlpath+"/"+db+".sql.gz")
-
-
- elif types=='increment': #增量备份所有
- if not os.path.exists(backmysqlpath) or not os.path.isfile(backmysqlpath+"/"+db+".sql.gz"):
- os.system("mkdir -p "+backmysqlpath)
- print("全量备份所有数据库:"+db+".sql.gz")
- os.system("mysqldump -u"+conf['mysql']['username']+" -p"+conf['mysql']['password']+" -h"+conf['mysql']['host']+" --all-databases --flush-logs --delete-master-logs --single-transaction | gzip >> "+backmysqlpath+"/increment_all_databases.sql.gz")
- print("备份mysql二进制文件...")
- t=os.listdir(backmysqlpath)
- lis=os.listdir(mysqldatapath)
- maxlist=[]
- for files in lis:
- if 'mysql-bin.' in files:
- try:
- a=int(files.replace("mysql-bin.", ""))
- maxlist.append(a)
- except:pass
- for files in lis:
- iscz=True #是否需要复制
- if iscz:
- for k in t:
- if mysqldatapath+"/"+k == mysqldatapath+"/"+files:
- iscz=False
- print(mysqldatapath+"/"+k+"已存在")
- break
- if not iscz:
- if 'mysql-bin.' in files:
- try:
- a=int(files.replace("mysql-bin.", ""))
- if max(maxlist) == a:
- iscz=True
- print(mysqldatapath+"/"+files+"该文件是最后一个日志,已备份,(最后一个文件可能不是完整的)")
- except:pass
- if iscz:
- if 'mysql-bin.' in files:
- try:
- a=int(files.replace("mysql-bin.", ""))
- os.system("cp -f "+mysqldatapath+"/"+files+" "+backmysqlpath+"/"+files)
- print("cp -f "+mysqldatapath+"/"+files+" "+backmysqlpath+"/"+files,"复制成功")
- except:pass
- if upload_aliyun:
- print("上传mysql备份目录文件到阿里云oss...")
- t=os.listdir(backmysqlpath)
- maxlist=[]
- for files in t:
- if 'mysql-bin.' in files:
- try:
- a=int(files.replace("mysql-bin.", ""))
- maxlist.append(a)
- except:pass
- path=get_file(backmysqlpath,is_folder=False)
- for files in path:
- sc=True #是否需要上传
- if bucket.object_exists("backups/"+files['path']):#如果文件已存在阿里云
- if 'mysql-bin.' in files['name']:
- try:
- a=int(files['name'].replace("mysql-bin.", ""))
- if max(maxlist) == a:
- print(backmysqlpath+"/"+files['name']+"该文件是最后一个日志,所以要上传阿里云")
- else:
- print("文件已在阿里云oss存在")
- sc=False
- except:pass
- else:
- print("文件已在阿里云oss存在")
- sc=False
- if sc:
- oss2.resumable_upload(bucket, "backups/"+files['path'], files['path'])
- print("备份完成")
diff --git a/app/intapp/controller/soft/nginx.py b/app/intapp/controller/soft/nginx.py
deleted file mode 100644
index 4a2c048f9fde66ceff99f74d6285beac70c3474c..0000000000000000000000000000000000000000
--- a/app/intapp/controller/soft/nginx.py
+++ /dev/null
@@ -1,331 +0,0 @@
-from .common import *
-import traceback
-def index(id='',types='getinfo'):
- "nginx配置文件"
- ar=sqlite('soft',model_intapp_soft_path).where('id',id).find()
- paths=ar['paths']
- filenames=ar['title']
- edition=ar['edition']
- if types=='getinfo':
- if os.path.isfile(paths+filenames+edition+'/logs/error.log'):
- # print(paths+filenames+'/logs/error.log')
- # f=open(paths+filenames+'/logs/error.log','r')
- # logserror=f.read()
- # f.close()
- logserror=''
- else:logserror=''
- if os.path.isfile(paths+filenames+edition+'/logs/access.log'):
- # f=open(paths+filenames+'/logs/access.log','r',encoding="utf-8")
- # logsaccess=f.read()
- # f.close()
- logsaccess=''
- else:logsaccess=''
- f=open(paths+filenames+edition+'/conf/nginx.conf','r',encoding="utf-8")
- confnginx=f.read()
- data={
- 'logs':{'error':logserror,'access':logsaccess},
- 'conf':{'nginx':confnginx},
- }
- return successjson(data)
- elif types=='updconf':
- con=request.get_json()
- f=open(paths+filenames+edition+'/conf/nginx.conf','w',encoding="utf-8")
- f.write(con['text'])
- f.close()
- return successjson()
- else:
- return errorjson(msg="未知类型")
-def anphp():
- "已安装的php以及伪静态模板"
- nginx=sqlite('soft',model_intapp_soft_path).where([('status','egt','4'),'and',('platform','eq',get_sysinfo()['uname'][0]),'and',('title','like','nginx%')]).find()
- pseudo_static_tpl=get_file(nginx['paths']+nginx['title']+nginx['edition']+'/conf/vhost/webtpl/rewrite') #伪静态模板
- rewr=[]
- for k in pseudo_static_tpl:
- rewr.append({'name':k['name'],'text':file_get_content(k['path'])})
- data={
- "php":sqlite('soft',model_intapp_soft_path).where("title like '%php%' and (status=4 or status=10) and title not like '%phpmyadmin%'").select(),
- "rewr":rewr
- }
- return successjson(data)
-def webdescribesfind():
- "获取指定网站信息"
- title=request.args.get("title")
- return successjson(sqlite("web",model_intapp_soft_path).where("title='"+title+"'").find())
-def weblist():
- "网站列表"
- where=False
- pagenow=int(request.args.get('pagenow'))
- pagesize=int(request.args.get('pagesize'))
- kw=request.args.get('kw')
- if kw:
- where=[("title","like","%"+str(kw)+"%"),'or',("describes","like","%"+str(kw)+"%"),'or',("domain","like","%"+str(kw)+"%")]
- if not pagenow:
- pagenow=1
- if not pagesize:
- pagesize=10
- lists=sqlite("web",model_intapp_soft_path).where(where).page(pagenow,pagesize).select()
- i=0
- for k in lists:
- # lists[i]['domain']=k['domain'].split("\n")
- lists[i]['balancing'] =json_decode(k['balancing'])
- lists[i]['proxy_set_header'] =json_decode(k['proxy_set_header'])
- i+=1
- count=sqlite("web",model_intapp_soft_path).where(where).count()
- return successjson(return_list(lists,count,pagenow,pagesize))
-def add_web():
- "添加或更新网站"
- nginx=sqlite('soft',model_intapp_soft_path).where([('status','egt','4'),'and',('platform','eq',get_sysinfo()['uname'][0]),'and',('title','like','nginx%')]).find()
- if not nginx:
- return errorjson(msg='安装nginx服务器后才创建网站')
- addtime=times()
- data=request.get_json()
- if data['domain']=='':
- return errorjson(msg="域名不能为空")
- if data['port']=='':
- return errorjson(msg="端口不能为空")
- if data['client_max_body_size']=='':
- return errorjson(msg="上传限制不能为空")
- if data['path']=='':
- return errorjson(msg="网站目录不能为空")
- paths=nginx['paths']
- try:
- ttt1=data['domain'].split("\n")
- if data['id']:
- where="port="+str(data['port'])+" and id != "+str(data['id'])+" and (" #[('port','eq',data['port'])]
- for kk in ttt1:
- where=where+"domain like '%"+kk+"%'"+" or "
- where=where[:-4]+")"
- ttt2=sqlite('web',model_intapp_soft_path).where(where).find()
- if ttt2:
- ttt2=ttt2['domain'].split("\n")
- for k in ttt2:
- for kk in ttt2:
- if k==kk:
- return errorjson(msg=k+"已在本服务器其他站点使用被使用")
- domains=sqlite('web',model_intapp_soft_path).where("id",data['id']).field("only").find()['only']
- else:
- where="port="+data['port']+" and ("
- for kk in ttt1:
- where=where+"domain like '%"+kk+"%'"+" or "
- where=where[:-4]+")"
- domains=ttt1[0]+":"+str(data['port'])
- data['only']=domains
- ttt=sqlite('web',model_intapp_soft_path).where(where).find()
- if ttt:
- ttt=ttt['domain'].split("\n")
- for k in ttt:
- for kk in ttt1:
- if k==kk:
- return errorjson(msg=k+"已被使用")
- ttt=data['domain'].split("\n")
- server_name=''
- for k in ttt:
- server_name=str(server_name)+" "+str(k)
-
- if nginx['platform']=='Linux':
- if data['webtpl']=='':
- return errorjson(msg="请选择配置文件模板")
- filenames=nginx['title']+nginx['edition']
- servertpl=paths+filenames+'/conf/vhost/webtpl/'+data['webtpl']
- ssl_certificate=data['ssl_certificate']
- ssl_certificate_key=data['ssl_certificate_key']
- if data['ssl']:
- ssl=443
- if len(data['ssl_certificate'])>5 and len(data['ssl_certificate_key'])>5:
- ssl_certificate=data['ssl_certificate']
- ssl_certificate_key=data['ssl_certificate_key']
- else:
- key=paths+filenames+'/conf/vhost/rewrite/'+domains+".key"
- pem=paths+filenames+'/conf/vhost/rewrite/'+domains+".pem"
- file_set_content(key,data['key'])
- file_set_content(pem,data['pem'])
- ssl_certificate=paths+filenames+"/conf/vhost/rewrite/"+domains+".pem"
- ssl_certificate_key=paths+filenames+"/conf/vhost/rewrite/"+domains+".key"
- else:
- if os.path.isfile(paths+filenames+'/conf/vhost/rewrite/'+domains+".key") and os.path.isfile(paths+filenames+'/conf/vhost/rewrite/'+domains+".pem"):
- sslttt1=file_get_content(paths+filenames+'/conf/vhost/rewrite/'+domains+".key")
- sslttt2=file_get_content(paths+filenames+'/conf/vhost/rewrite/'+domains+".pem")
- if len(sslttt1)>10 and len(sslttt2)>10:
- ssl=443
- else:
- ssl=False
- else:
- ssl=False
- if 'php' in data['webtpl'] and len(data['rewrite'])>4:#php伪静态
- file_set_content(paths+filenames+"/conf/vhost/rewrite/"+domains,data['rewrite'])
- elif not data['id']:
- file_set_content(paths+filenames+"/conf/vhost/rewrite/"+domains,'')
- if data['webtpl']=='static' or data['webtpl']=='vue' or 'php' in data['webtpl']:
- text=Templates(servertpl,client_max_body_size=data['client_max_body_size'],port=data['port'],ssl=ssl,ssl_certificate=ssl_certificate,ssl_certificate_key=ssl_certificate_key,
- server_name=server_name,webpath=data['path'],rewrite=paths+filenames+"/conf/vhost/rewrite/"+domains,domains=domains)
- elif data['webtpl']=='balancing':#添加负载均衡
- balancing=data['balancing'] #负载均衡列表
- proxy_set_header=data['proxy_set_header'] #自定义转发请求头列表
- for k in data['balancing']:
- if k['ip']=='' or k['port']=='':
- return errorjson(msg="请填写负载均衡ip和端口")
- text=Templates(servertpl,client_max_body_size=data['client_max_body_size'],port=data['port'],ssl=ssl,balancing=balancing,proxy_set_header=proxy_set_header,ssl_certificate=ssl_certificate,ssl_certificate_key=ssl_certificate_key,
- server_name=server_name,webpath=data['path'],rewrite=paths+filenames+"/conf/vhost/rewrite/"+domains,domains=domains)
- f=open(paths+filenames+"/conf/vhost/"+domains+'.conf','w',encoding="utf-8")
- f.write(text)
- f.close()
- os.system("nginx -s reload")
- if not os.path.exists(data['path']):
- os.makedirs(data['path'])
- f=open(data['path']+"/index.html",'w',encoding="utf-8")
- f.write('网站创建成功恭喜您!网站创建成功
')
- f.close()
- f=open(data['path']+"/index.php",'w',encoding="utf-8")
- f.write("")
- f.close()
- try:
- data['servers']=paths+filenames
- except:pass
- del data['ssl']
- del data['key']
- del data['pem']
- del data['rewrite']
- data['balancing'] =json_encode(data['balancing'])
- data['proxy_set_header'] =json_encode(data['proxy_set_header'])
- if data['id']:
- data['updtime']=addtime
- data['status']=1
- sqlite('web',model_intapp_soft_path).where("id",data['id']).update(data)
- pi=subprocess.Popen('nginx -s reload',shell=True, stdout=subprocess.PIPE,stderr=subprocess.STDOUT)
- ars=pi.stdout.read().decode()
- ars=ars.split("\n")
- strs=ars[len(ars)-2]
- if len(strs) > 1:
- return errorjson(msg=strs)
- else:
- del data['id']
- data['addtime']=addtime
- data['updtime']=addtime
- sqlite('web',model_intapp_soft_path).insert(data)
- except:
- print(traceback.format_exc())
- return errorjson(msg="失败,检查参数是否有误")
- else:
- return successjson()
-def del_web(id=0,path=0):
- #path=1 表示删除网站目录 ,linux和windows已完成
- "删除网站"
- title=request.args.get("title")
- if not id and title:
- where="title = '"+title+"'"
- else:
- where="id='"+str(id)+"'"
- nginx=sqlite('web',model_intapp_soft_path).where(where).find()
- if not nginx:
- return successjson(msg="不存在")
- print(nginx)
- filenames=nginx['servers']
- if get_sysinfo()['uname'][0]=='Linux':
- if os.path.isfile(filenames+"/conf/vhost/"+nginx['only']+'.conf'):
- os.remove(filenames+"/conf/vhost/"+nginx['only']+'.conf')
- if os.path.isfile(filenames+"/conf/vhost/rewrite/"+nginx['only']):
- os.remove(filenames+"/conf/vhost/rewrite/"+nginx['only'])
- if os.path.isfile(filenames+"/logs/"+nginx['only']+".access.log"):
- os.remove(filenames+"/logs/"+nginx['only']+".access.log")
- if os.path.isfile(filenames+'/conf/vhost/rewrite/'+nginx['only']+".key"):
- os.remove(filenames+'/conf/vhost/rewrite/'+nginx['only']+".key")
- if os.path.isfile(filenames+'/conf/vhost/rewrite/'+nginx['only']+".pem"):
- os.remove(filenames+'/conf/vhost/rewrite/'+nginx['only']+".pem")
- pi=subprocess.Popen('nginx -s reload',shell=True, stdout=subprocess.PIPE,stderr=subprocess.STDOUT)
- ars=pi.stdout.read().decode()
- ars=ars.split("\n")
- strs=ars[len(ars)-2]
- elif get_sysinfo()['uname'][0]=='Windows':
- if os.path.isfile(filenames+"/conf/vhost/"+nginx['only']+'.conf'):
- os.remove(filenames+"/conf/vhost/"+nginx['only']+'.conf')
- if os.path.isfile(filenames+"/conf/vhost/rewrite/"+nginx['only']):
- os.remove(filenames+"/conf/vhost/rewrite/"+nginx['only'])
- if os.path.isfile(filenames+"/logs/"+nginx['only']+".access.log"):
- os.remove(filenames+"/logs/"+nginx['only']+".access.log")
- os.system("cd "+filenames+" & stop.bat")
- time.sleep(3)
- os.system("cd "+filenames+" & start.bat")
- else:
- return errorjson(msg="无法匹配系统")
- if path=='1' and os.path.exists(nginx['path']):
- shutil.rmtree(nginx['path'])
- sqlite('web',model_intapp_soft_path).where(where).delete()
- pi=subprocess.Popen('nginx -s reload',shell=True, stdout=subprocess.PIPE,stderr=subprocess.STDOUT)
- ars=pi.stdout.read().decode()
- ars=ars.split("\n")
- strs=ars[len(ars)-2]
- if len(strs) > 1:
- return errorjson(msg=strs)
- return successjson()
-
-def getssl(id):
- ar=sqlite('web',model_intapp_soft_path).where('id',id).find()
- key=ar['servers']+'/conf/vhost/rewrite/'+ar['only']+".key"
- pem=ar['servers']+'/conf/vhost/rewrite/'+ar['only']+".pem"
- data={
- "key":file_get_content(key),
- "pem":file_get_content(pem)
- }
- return successjson(data)
-def getrewr(id):
- "获取伪静态"
- ar=sqlite('web',model_intapp_soft_path).where('id',id).find()
- return successjson(file_get_content(ar['servers']+'/conf/vhost/rewrite/'+ar['only']))
-def getconfig(id,types='get'):
- "获取配置文件"
- ar=sqlite('web',model_intapp_soft_path).where('id',id).find()
- if types=='get':
- return successjson(file_get_content(ar['servers']+'/conf/vhost/'+ar['only']+".conf"))
- elif types=='set':
- data=request.get_json()
- file_set_content(ar['servers']+'/conf/vhost/'+ar['only']+".conf",data['text'])
- pi=subprocess.Popen('nginx -s reload',shell=True, stdout=subprocess.PIPE,stderr=subprocess.STDOUT)
- ars=pi.stdout.read().decode()
- ars=ars.split("\n")
- strs=ars[len(ars)-2]
- if len(strs) > 1:
- return errorjson(msg=strs)
- return successjson()
-
-
-def sslfolde():
- "Let's Encrypt证书夹"
- paths="/etc/letsencrypt/live/"
- if not os.path.exists(paths):
- return errorjson(code=1,msg="Let's Encrypt证书夹不存在,在插件市场安装LetsEncrypt插件创建证书后再使用该功能")
- try:
- lis=os.listdir(paths)
- except:
- return errorjson(code=1,msg="无法打开"+str(paths))
- lists=[]
- for files in lis:
- types="folder"
- config={}
- if os.path.isfile(paths+"/"+files):
- types="file"
- else:
- config=file_get_content(paths+"/"+files+"/config.conf")
- if config:
- config=json_decode(config)
- zd={"name":files,"types":types,"config":config}
- lists.append(zd)
- data=return_list(lists,count=len(lis),pagenow=1,pagesize=len(lis))
- data['paths']=paths
- "文件列表"
- return successjson(data)
-def ssltpl():
- "Let's Encrypt证书内容"
- name=request.args.get("name")
- paths="/etc/letsencrypt/live/"+name
- chain=file_get_content(paths+"/chain.pem")
- fullchain=file_get_content(paths+"/fullchain.pem")
- privkey=file_get_content(paths+"/privkey.pem")
- cert=file_get_content(paths+"/cert.pem")
- data={
- "chain":chain,
- "fullchain":fullchain,
- "privkey":privkey,
- "cert":cert
- }
- return successjson(data)
-
\ No newline at end of file
diff --git a/app/intapp/controller/soft/page.py b/app/intapp/controller/soft/page.py
deleted file mode 100644
index 0dc48f6ff671c72661636725695ece962d3059b8..0000000000000000000000000000000000000000
--- a/app/intapp/controller/soft/page.py
+++ /dev/null
@@ -1,13 +0,0 @@
-from .common import *
-def home():
- return response.tpl("index/home")
-def pub(html):
- return response.tpl("page/%s" % html)
-def s(fun,html):
- id=request.args.get("id")
- return response.tpl("%s/%s" % (fun,html),id=id)
-def soft(html):
- id=request.args.get("id")
- types=request.args.get("types")
- data=sqlite("soft",model_intapp_soft_path).where("id",id).find()
- return response.tpl("soft/%s" % html,id=id,data=data,types=types)
\ No newline at end of file
diff --git a/app/intapp/controller/soft/php.py b/app/intapp/controller/soft/php.py
deleted file mode 100644
index 5c1e94b10e673f8109b7ebc04f00787d2db08b9f..0000000000000000000000000000000000000000
--- a/app/intapp/controller/soft/php.py
+++ /dev/null
@@ -1,266 +0,0 @@
-from .common import *
-def ini(id,is_upd=0):
- "php.ini配置文件"
- ar=sqlite('soft',model_intapp_soft_path).where('id',id).find()
- paths=ar['paths']
- filenames=ar['title']+ar['edition']
- if ar['platform']=='Linux':
- filepath=paths+filenames+"/bin/php.ini"
- elif ar['platform']=='Windows':
- filepath=paths+filenames+"/php.ini"
- else:
- return errorjson(code=1,msg="不支持此时平台")
- if is_upd: #修改配置
- data=request.get_json()
- file_set_content(filepath,data['text'])
- return successjson()
- else:
- data={
- 'ini':file_get_content(filepath),
- 'php':ar
- }
- return successjson(data)
-def www_conf(id,is_upd=0):
- "www.conf配置文件"
- ar=sqlite('soft',model_intapp_soft_path).where('id',id).find()
- paths=ar['paths']
- filenames=ar['title']+ar['edition']
- if ar['platform']=='Linux':
- filepath=paths+filenames+"/etc/php-fpm.d/www.conf"
- if 'php5.6' in filenames:
- filepath=paths+filenames+"/etc/php-fpm.conf"
- elif ar['platform']=='Windows':
- filepath=''
- else:
- return errorjson(code=1,msg="不支持此时平台")
- if is_upd: #修改配置
- data=request.get_json()
- file_set_content(filepath,data['text'])
- return successjson()
- else:
- data={
- 'www_conf':file_get_content(filepath),
- 'php':ar
- }
- return successjson(data)
-def phpfpm(id,is_upd=0):
- "phpfpm配置信息"
- ar=sqlite('soft',model_intapp_soft_path).where('id',id).find()
- paths=ar['paths']
- filenames=ar['title']+ar['edition']
- if ar['platform']=='Linux':
- if not os.path.exists(paths+filenames+"/bin/conf"):
- os.makedirs(paths+filenames+"/bin/conf")
- filepath=paths+filenames+"/bin/conf/phpfpm.conf"
- phpfpmpath=paths+filenames+"/etc/php-fpm.d/www.conf"
- if 'php5.6' in filenames:
- phpfpmpath=paths+filenames+"/etc/php-fpm.conf"
- else:
- filepath=''
- phpfpmpath=''
- if is_upd: #修改php-fpm配置信息
- data=request.get_json()
- f = open(phpfpmpath)
- con=''
- while True:
- line = f.readline()
- if not line:
- break
- elif 'pm = ' in line and '=' in line: #运行描述
- line="pm = "+data['text']['pm']+"\n"
- elif 'pm.max_children' in line and '=' in line:# 允许创建的最大子进程数
- line="pm.max_children = "+data['text']['max_children']+"\n"
- elif 'pm.start_servers' in line and '=' in line:# 起始进程数(服务启动后初始进程数量)
- line="pm.start_servers = "+data['text']['start_servers']+"\n"
- elif 'pm.min_spare_servers' in line and '=' in line:# 起始进程数(服务启动后初始进程数量)
- line="pm.min_spare_servers = "+data['text']['min_spare_servers']+"\n"
- elif 'pm.max_spare_servers' in line and '=' in line:# 最大空闲进程数(当空闲进程达到此值时清理)
- line="pm.max_spare_servers = "+data['text']['max_spare_servers']+"\n"
- con=con+line
- f.close()
- f= open(phpfpmpath, "w")
- f.write(con)
- f.close()
- file_set_content(filepath,json_encode(data['text']))
- return successjson()
- else:
- phpfpm=json_decode(file_get_content(filepath))
- if not phpfpm:
- phpfpm=''
- data={
- 'phpfpm':phpfpm,
- 'php':ar
- }
- return successjson(data)
-def base(id,is_upd=0):
- "基本配置信息"
- ar=sqlite('soft',model_intapp_soft_path).where('id',id).find()
- paths=ar['paths']
- filenames=ar['title']+ar['edition']
- if ar['platform']=='Linux':
- if not os.path.exists(paths+filenames+"/bin/conf"):
- os.makedirs(paths+filenames+"/bin/conf")
- filepath=paths+filenames+"/bin/conf/base.ini"
- phpinipath=paths+filenames+"/bin/php.ini"
- elif ar['platform']=='Windows':
- if not os.path.exists(paths+filenames+"/conf"):
- os.makedirs(paths+filenames+"/conf")
- filepath=paths+filenames+"/conf/base.ini"
- phpinipath=paths+filenames+"/php.ini"
- if is_upd: #修改基本配置信息
- #修改php.ini配置
- data=request.get_json()
- f = open(phpinipath)
- con=''
- while True:
- line = f.readline()
- if not line:
- break
- elif 'max_execution_time' in line and '=' in line:#最大执行时间
- line="max_execution_time = "+data['text']['max_execution_time']+"\n"
- elif 'max_input_time' in line and '=' in line:#最大输入时间
- line="max_input_time = "+data['text']['max_input_time']+"\n"
- elif 'memory_limit' in line and '=' in line:#内存限制
- line="memory_limit = "+data['text']['memory_limit']+"M\n"
- elif 'file_uploads' == line[0:12] and '=' in line:#是否允许文件上传
- line="file_uploads = "+data['text']['file_uploads']+"\n"
- elif 'upload_max_filesize' in line and '=' in line:#上传大小限制
- line="upload_max_filesize = "+data['text']['upload_max_filesize']+"M\n"
- elif 'max_file_uploads' in line and '=' in line:#上传数量限制
- line="max_file_uploads = "+data['text']['max_file_uploads']+"\n"
- elif 'post_max_size' in line and '=' in line:#上传数量限制
- line="post_max_size = "+data['text']['post_max_size']+"M\n"
- elif 'allow_url_fopen' in line and '=' in line:
- line="allow_url_fopen = "+data['text']['allow_url_fopen']+"\n"
- elif 'allow_url_include' in line and '=' in line:
- line="allow_url_include = "+data['text']['allow_url_include']+"\n"
- elif 'default_socket_timeout' in line and '=' in line:
- line="default_socket_timeout = "+data['text']['default_socket_timeout']+"\n"
- con=con+line
- f.close()
- f= open(phpinipath, "w")
- f.write(con)
- f.close()
- file_set_content(filepath,json_encode(data['text']))
- # print(data['text'])
- return successjson()
- else:
- base=json_decode(file_get_content(filepath))
- if not base:
- base=''
- data={
- 'base':base,
- 'php':ar
- }
- return successjson(data)
-def extenlist(id,is_upd=0):
- "php扩展信息列表"
- ar=sqlite('soft',model_intapp_soft_path).where('id',id).find()
- lists=sqlite('php_exten',model_intapp_soft_php_exten_path).where('pid',id).select()
- data={
- 'extenlist':lists,
- 'php':ar
- }
- return successjson(data)
-def log(id):
- "待完善"
- ar=sqlite('soft',model_intapp_soft_path).where('id',id).find()
- filename=ar['filename']
- paths=ar['paths']
- filenames=ar['title']+ar['edition']
- if ar['platform']=='Linux':
- filepath=paths+filenames+""
- elif ar['platform']=='Windows':
- filepath=paths+filenames+""
- data={
- 'log':file_get_content(filepath),
- 'php':ar
- }
- return successjson(data)
-
-def add_php_exten():
- "增加php扩展"
- data=request.get_json()
- data['addtime']=times()
- data['updtime']=times()
- sqlite('php_exten',model_intapp_soft_php_exten_path).insert(data)
- return successjson()
-def del_php_exten(id):
- "删除php扩展"
- sqlite('php_exten',model_intapp_soft_php_exten_path).where('id',id).delete()
- return successjson()
-
-def installext(id):
- is_del=False #是否删除成功
- "安装php扩展和下载扩展"
- ar=sqlite('php_exten',model_intapp_soft_php_exten_path).where('id',id).find()
- if ar['status']==0:
- sqlite('php_exten',model_intapp_soft_php_exten_path).where('id',ar['id']).update({'status':1,'msg':''})
- Queues.insert(target=__installextqu,args=(ar,),title="安装php-"+ar['title']+"扩展")
- elif ar['status']==4:
- "卸载扩展"
- paths=request.get_json()['paths']
- if get_sysinfo()['uname'][0]=='Linux':
- if os.path.exists(paths):
-
- confile=paths+"bin/php.ini"
- f= open(confile, "r")
- con=''
- while True:
- line = f.readline()
- if not line:
- break
- elif str(ar['title']) in line:
- line=""
- is_del=True
- con=con+line
- f.close()
- f= open(confile, "w")
- f.write(con)
- f.close()
-
- # confile=paths+"bin/php.ini"
- # f= open(confile, "r")
- # con=f.read()
- # f.close()
- # con=con.replace("extension="+str(ar['title'])+".so\n","")
- # f= open(confile, "w")
- # f.write(con)
- # f.close()
- if is_del:
- sqlite('php_exten',model_intapp_soft_php_exten_path).where('id',ar['id']).update({'status':0,'msg':''})
- if 'php7.0' in paths:
- os.system("pkill php70-fpm && php70-fpm -c "+paths+"php7.0/etc/php.ini")
- elif 'php7.1' in paths:
- os.system("pkill php71-fpm && php71-fpm -c "+paths+"php7.1/etc/php.ini")
- elif 'php7.2' in paths:
- os.system("pkill php72-fpm && php72-fpm -c "+paths+"php7.2/etc/php.ini")
- elif 'php7.3' in paths:
- os.system("pkill php73-fpm && php73-fpm -c "+paths+"php7.3/etc/php.ini")
- elif 'php7.4' in paths:
- os.system("pkill php74-fpm && php74-fpm -c "+paths+"php7.4/etc/php.ini")
- else:
- return errorjson(code=1,msg='卸载失败')
- else:
- return errorjson(code=1,msg='php文件夹错误')
- return successjson()
-def get_exten(id):
- return successjson(sqlite('php_exten',model_intapp_soft_php_exten_path).where('id',id).find())
-def __installextqu(ar):
- "安装php扩展"
- sqlite('php_exten',model_intapp_soft_php_exten_path).where('id',ar['id']).update({'status':3,'msg':''})
- try:
- cmd="wget "+config.domain['kcwebfile']+"/"+ar['filename']
- # os.system(cmd)
- print(cmd)
- pi=subprocess.Popen(cmd,shell=True, stdout=subprocess.PIPE,stderr=subprocess.STDOUT)
- ars=pi.stdout.read().decode()
- ars=ars.split("\n")
- strs=ars[len(ars)-2]
- if 'success' in strs:
- sqlite('php_exten',model_intapp_soft_php_exten_path).where('id',ar['id']).update({'status':4,'msg':''})
- else:
- sqlite('php_exten',model_intapp_soft_php_exten_path).where('id',ar['id']).update({'status':0,'msg':'安装失败'})
- # sqlite('php_exten',model_intapp_soft_php_exten_path).where('id',ar['id']).update({'status':4,'msg':''})
- except Exception as e:
- sqlite('php_exten',model_intapp_soft_php_exten_path).where('id',ar['id']).update({'status':0,'msg':'安装失败'+str(e)})
\ No newline at end of file
diff --git a/app/intapp/controller/soft/redis.py b/app/intapp/controller/soft/redis.py
deleted file mode 100644
index df44a4d3f7660ab7bfbb16db9a29adb8e3ebc258..0000000000000000000000000000000000000000
--- a/app/intapp/controller/soft/redis.py
+++ /dev/null
@@ -1,69 +0,0 @@
-from .common import *
-def conf(id,is_upd=0):
- "redis配置文件信息"
- is_upd=int(is_upd)
- ar=sqlite('soft',model_intapp_soft_path).where('id',id).find()
- paths=ar['paths']
- filenames=ar['title']+ar['edition']
- if ar['platform']=='Linux':
- filepath=paths+filenames+"/redis.conf"
- else:
- return errorjson(code=1,msg="不支持此时平台")
- if is_upd: #修改配置
- data=request.get_json()
- if not data['text']:
- return errorjson(code=1,msg='不允许清空配置文件')
- file_set_content(filepath,data['text'])
- return successjson()
- else:
- data=file_get_content(filepath)
- # print(filepath)
- return successjson(data)
-def base(id,is_upd=0):
- "redis配置文件信息"
- is_upd=int(is_upd)
- ar=sqlite('soft',model_intapp_soft_path).where('id',id).find()
- paths=ar['paths']
- filenames=ar['title']+ar['edition']
-
- if ar['platform']=='Linux':
- filepath=paths+filenames+"/redis.conf"
- jsonpath=paths+filenames+"/redis.json"
- else:
- return errorjson(code=1,msg="不支持此时平台")
- if is_upd: #修改配置
- data=request.get_json()
- f = open(filepath)
- con=''
- while True:
- line = f.readline()
- if not line:
- break
- elif 'bind ' in line and '\n' in line and '#' not in line:
- line="bind "+data['bind']+"\n"
- elif 'port ' in line and '\n' in line and '#' not in line:
- line="port "+data['port']+"\n"
- elif 'timeout ' in line and '\n' in line and '#' not in line:
- line="timeout "+data['timeout']+"\n"
- elif 'maxclients ' in line and '\n' in line:
- line="maxclients "+data['maxclients']+"\n"
- elif 'databases ' in line and '\n' in line and '#' not in line:
- line="databases "+data['databases']+"\n"
- elif 'requirepass ' in line and '\n' in line:
- if data['requirepass']:
- line="requirepass "+data['requirepass']+"\n"
- else:
- line="# requirepass "+data['requirepass']+"\n"
- elif 'maxmemory ' in line and '\n' in line and len(line)<20:
- line="maxmemory "+data['maxmemory']+"\n"
- con=con+line
- f.close()
- f= open(filepath, "w")
- f.write(con)
- f.close()
- file_set_content(jsonpath,json_encode(data))
- return successjson()
- else:
- v=file_get_content(jsonpath)
- data=json_decode(v)
- return successjson(data)
\ No newline at end of file
diff --git a/app/intapp/controller/soft/tpl/index/home.html b/app/intapp/controller/soft/tpl/index/home.html
deleted file mode 100644
index 3e542d22f9669aab08578aec44fc2aba407e04d6..0000000000000000000000000000000000000000
--- a/app/intapp/controller/soft/tpl/index/home.html
+++ /dev/null
@@ -1,420 +0,0 @@
-
-
-
-
-
-kcwebplus
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 搜索
-
- 备份、网站 、软件列表、php扩展
- 恢复
- 更新软件列表
-
-
-
-
- % if config.app['appmode']=='develop':
-
-
-
- % endif
-
-
-
-
-
-
-
-
- {{scope.row.title}}{{scope.row.edition}}
- {{scope.row.msg}}
-
-
-
-
-
-
-
-
-
- 安装
- 等待中...
- 下载中...
- 安装中...
- 卸载中...
- 正在启动...
- 正在停止服务
-
-
-
-
-
- 启动
- 设置
- 卸载
-
-
-
-
- 客户端
- 客户端
- 服务端
- 服务端
-
-
- 设置
- 卸载
-
-
-
-
- ssh密钥
- 初始化
-
- 分布式部署
- 独立部署
-
- 卸载
-
-
-
-
-
-
-
-
- 停止
- 重启
- 设置
-
-
-
- % if config.app['appmode']=='develop':
- 编辑
- % endif
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 如:/usr/local/php/
-
-
-
-
-
-
-
-
-
- 注:需要在后端接口上配置wget文件地址
-
-
-
- Linux
- Windows
-
-
-
-
-
-
-
-
-
-
diff --git a/app/intapp/controller/soft/tpl/index/web.html b/app/intapp/controller/soft/tpl/index/web.html
deleted file mode 100644
index 53d06a962960a465a2b0828fa273a605ea81aa32..0000000000000000000000000000000000000000
--- a/app/intapp/controller/soft/tpl/index/web.html
+++ /dev/null
@@ -1,479 +0,0 @@
-
-
-
-
-
-kcwebplus
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-   
-
-
- 搜索
- 添加网站
-
-
-
-
-
-
-
-
-
-
-
-
- 运行在负载均衡代理转发器中
- 点击打开:{{scope.row.describes}}
- {{scope.row.describes}}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 创建于
-
-
-
-
- 更新
-
-
-
-
-
-
-
-
-
- SSL配置
- 设置
-
- php伪静态配置
- 删除
-
-
-
-
-
-
-
-
-
-
-
- | 域名 | |
-
- | 端口 |
-
- 上传限制:MB |
-
-
- | 网站名 |
- |
-
-
- | 配置文件模板 |
-
-
-
-
-
- |
-
-
- | 备注 |
- |
-
-
- | 网站目录 |
- |
-
-
-
-
-
- | | | |
-
- |
- |
-
-
-
-
-
-
-
-
-
-
-  
- |
-
-
- |
-
-
- nginx负载均衡是一个代理均衡转发器
-
-
-
- |
-
-
-
- 取 消
- 修改添加
-
-
-
-
-
-
-
-
- 您已配置Let's证书
- ssl_certificate :{{admin.ssl_certificate}}
- ssl_certificate_key :{{admin.ssl_certificate_key}}
- 使用自有证书
-
-
-
- 密钥(KEY)
-
-
-
- 证书(PEM格式)
-
-
-
确定
-
-
-
-
-
-
-
-
-
-
-
- 保存
- 选择伪静态模板就可以了,修改了记得要保存哦!重启nginx生效
-
-
-
-
- 确定
-
-
-
-
-
- | 支持域名 | 有效期 | |
-
- |
-
- {{item1.domain}}    
-
- |
-
-
- {{time_date(item.config.createtime+7776000,true)}}
-
- |
-
-
- 使用
-
- |
-
-
-
-
-
-
-
-
diff --git a/app/intapp/controller/soft/tpl/soft/frp.html b/app/intapp/controller/soft/tpl/soft/frp.html
deleted file mode 100644
index c137b73fa594dc8e2d6120875746dc88d0e181b3..0000000000000000000000000000000000000000
--- a/app/intapp/controller/soft/tpl/soft/frp.html
+++ /dev/null
@@ -1,250 +0,0 @@
-
-
-
-
-
-kcwebplus
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 重启
- 停止
-
- 保存
-
-
-
-
-
-
-
- 重启
- 停止
-
-
-
- 这是服端监听的地址
-
-
-
- 这是服端监听的端口
-
-
-
- 这是upd监听的端口
-
-
-
- 这是kcp监听的端口
-
-
-
- 这是http监听的端口
-
-
-
- 这是https监听的端口
-
-
-
- 这是dashboard监听的ip地址
-
-
-
- 这是dashboard监听的端口
-
-
-
- 这是dashboard监听的用户名
-
-
-
- 这是dashboard监听的密码
-
-
-
- 这是frp的验证机制
-
-
-
- 这是frp的验证串的有效时间
-
-
-
-
-
-
-
- 日志保持多少天
-
-
-
-
-
-
-
- 白名单端口
-
-
-
- 最大值进程数
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 保存
-
-
-
-
-
-
-
- 保存
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/app/intapp/controller/soft/tpl/soft/kodexplorer.html b/app/intapp/controller/soft/tpl/soft/kodexplorer.html
deleted file mode 100644
index 6fb3f59b95946d8504b9f3fe4bf5c9a78b85169b..0000000000000000000000000000000000000000
--- a/app/intapp/controller/soft/tpl/soft/kodexplorer.html
+++ /dev/null
@@ -1,89 +0,0 @@
-
-
-
-
-
-kcwebplus
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/app/intapp/controller/soft/tpl/soft/mongodb.html b/app/intapp/controller/soft/tpl/soft/mongodb.html
deleted file mode 100644
index 417da13b4af6bd477526929f68caee0f9ac9015b..0000000000000000000000000000000000000000
--- a/app/intapp/controller/soft/tpl/soft/mongodb.html
+++ /dev/null
@@ -1,436 +0,0 @@
-
-
-
-
-
-kcwebplus
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- | 绑定ip |
- 端口 |
- 服务目录 |
- |
-
-
- |
- |
- |
-
-
- 运行中
- 停止
-
-
- 已停止
- 启动
-
-
- |
-
-
-
-
- 保存
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/app/intapp/controller/soft/tpl/soft/mysql.html b/app/intapp/controller/soft/tpl/soft/mysql.html
deleted file mode 100644
index ebeb98f3f6c12135106c911353e835173f336cc6..0000000000000000000000000000000000000000
--- a/app/intapp/controller/soft/tpl/soft/mysql.html
+++ /dev/null
@@ -1,106 +0,0 @@
-
-
-
-
-
-kcwebplus
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 建议与mysql安装目录分开
-
- 保存
-
-
-
-
-
- 保存
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/app/intapp/controller/soft/tpl/soft/nginx.html b/app/intapp/controller/soft/tpl/soft/nginx.html
deleted file mode 100644
index 8956ac72e8acef1bcbb5de4b3fef3b1d27bdc2fd..0000000000000000000000000000000000000000
--- a/app/intapp/controller/soft/tpl/soft/nginx.html
+++ /dev/null
@@ -1,113 +0,0 @@
-
-
-
-
-
-kcwebplus
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 保存
- 该配置文件只对该网站有效,修改后重启nginx生效
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/app/intapp/controller/soft/tpl/soft/php.html b/app/intapp/controller/soft/tpl/soft/php.html
deleted file mode 100644
index f281a401bfe1f0e1c50e3399e08feabe09d5e6fe..0000000000000000000000000000000000000000
--- a/app/intapp/controller/soft/tpl/soft/php.html
+++ /dev/null
@@ -1,331 +0,0 @@
-
-
-
-
-
-
kcwebplus
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- MB
-
-
- 单个请求上传的文件的最大数量
-
-
- 秒
-
-
- 秒
-
-
- MB
-
-
- MB
-
-
-
-
-
- 是否允许将url(如http://或 ftp://)作为文件处理。
-
-
-
-
-
- 是否允许include/require以文件形式打开url(如http://或 ftp://)。
-
-
-
- 基于套接字的流的默认超时(秒)
-
-
- 保存
-
-
-
-
-
-
-
-
-
-
-
-
-
- 允许创建的最大子进程数
-
-
-
- 起始进程数(服务启动后初始进程数量)
-
-
-
- 最小空闲进程数(清理空闲进程后的保留数量)
-
-
-
- 最大空闲进程数(当空闲进程达到此值时清理)
-
-
- 保存
-
-
-
-
- % if config.app['appmode']=='develop':
-
- % endif
-
- | 名称 | 说明 | 状态 | 操作 |
-
- | {{item.title}} |
- {{item.describes}}
- % if config.app['appmode']=='develop':
- {{item.filename}}
- % endif
- |
-
-
-
- |
-
-
- 安装
-
-
- 等待下载
-
-
- 正在下载
-
-
- 正在安装
-
-
- 卸载
-
-
- 正在卸载...
-
- % if config.app['appmode']=='develop':
- 删除
- % endif
- |
-
-
-
-
-
-
-
-
- 保存
- 该配置文件只对{{data.php.title}}有效,修改后重启{{data.php.title}}生效
-
-
-
-
- 保存
- 该配置文件只对{{data.php.title}}有效,修改后重启{{data.php.title}}生效
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 添加
-
-
-
-
-
\ No newline at end of file
diff --git a/app/intapp/controller/soft/tpl/soft/phpmyadmin.html b/app/intapp/controller/soft/tpl/soft/phpmyadmin.html
deleted file mode 100644
index 5dd49d6bdafd1c4864f98aaf6c71eb967fc0fcb8..0000000000000000000000000000000000000000
--- a/app/intapp/controller/soft/tpl/soft/phpmyadmin.html
+++ /dev/null
@@ -1,91 +0,0 @@
-
-
-
-
-
-
kcwebplus
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/app/intapp/controller/soft/tpl/soft/redis.html b/app/intapp/controller/soft/tpl/soft/redis.html
deleted file mode 100644
index 64eac893a14c59ec96efcf712ab918ef24a21f09..0000000000000000000000000000000000000000
--- a/app/intapp/controller/soft/tpl/soft/redis.html
+++ /dev/null
@@ -1,127 +0,0 @@
-
-
-
-
-
-
kcwebplus
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 绑定IP
-
-
- 端口
-
-
- 空闲连接超时时间,0表示不断开
-
-
- 最大连接数
-
-
- 数据库数量
-
-
- redis密码,留空代表没有设置密码
-
-
- MB,最大使用内存,0表示不限制
-
-
- 保存
-
-
-
-
-
-
- 保存
- 修改后重启redis生效
-
-
-
-
-
-
\ No newline at end of file
diff --git a/app/static/js/function.js b/app/static/js/function.js
index 5e7615e53fec6b440c63746b16d200e3cc2edbb5..d1d3c2c26fea23e80b60dbc9ddddb70980874cd8 100644
--- a/app/static/js/function.js
+++ b/app/static/js/function.js
@@ -41,6 +41,11 @@ axios_instance.interceptors.request.use(function(axiosconfig){
axios_instance.interceptors.response.use(function(res){
return res;
},function(error){
+ if(error.response.data){
+ if(error.response.data.code==-1||error.response.data.code==5){
+ window.location.href="/intapp"
+ }
+ }
return Promise.reject(error);
})
//get请求
diff --git a/kcweb/common/autoload.py b/kcweb/common/autoload.py
index 48fc6357b2004fa3e7f5ef5fd27bec975174980d..cb0bebede2097d44333ab323e021e18db2408fd7 100644
--- a/kcweb/common/autoload.py
+++ b/kcweb/common/autoload.py
@@ -493,7 +493,6 @@ class create:
if os.path.isfile(self.appname+"/"+self.modular+"/controller/"+plug+".zip"):#安装打包好的插件
zip.unzip_file(self.appname+"/"+self.modular+"/controller/"+plug+".zip",self.appname+"/"+self.modular+"/controller/"+plug+"/")
os.remove(self.appname+"/"+self.modular+"/controller/"+plug+".zip")
-
if os.path.isfile(self.appname+"/"+self.modular+"/controller/"+plug+"/install.txt"): #安装依赖包
install_requires=[]
try:
@@ -512,14 +511,13 @@ class create:
try:
install_requires.insert(0,"install")
if 0 != pip.main(install_requires):
- shutil.rmtree(self.appname+"."+self.modular+"/controller/"+plug)
+ shutil.rmtree(self.appname+"/"+self.modular+"/controller/"+plug)
return False,"error"
except AttributeError as e:
- shutil.rmtree(self.appname+"."+self.modular+"/controller/"+plug)
+ shutil.rmtree(self.appname+"/"+self.modular+"/controller/"+plug)
if config.app['app_debug']:
print("建议更新您的pip版本。参考命令:Python -m pip install --user --upgrade pip -i https://mirrors.aliyun.com/pypi/simple/")
return False,str(e)
-
# try:
# m=importlib.import_module(self.appname+"."+self.modular+"/controller/"+plug+".install")
# except:
diff --git a/kcweb/config/__init__.py b/kcweb/config/__init__.py
index 8c813499bd97507bb36c972478cbd2841dc94886..eef962f4cd8919031d5e35082486b967bdcdd1eb 100644
--- a/kcweb/config/__init__.py
+++ b/kcweb/config/__init__.py
@@ -98,7 +98,7 @@ email['recNick']='' #默认收件人昵称
kcweb={}
kcweb['name']='kcweb' #项目的名称
-kcweb['version']='4.11.7' #项目版本
+kcweb['version']='4.11.8' #项目版本
kcweb['description']='' #项目的简单描述
kcweb['long_description']='' #项目详细描述
kcweb['license']='MIT' #开源协议 mit开源
diff --git a/kcweb/setup.py b/kcweb/setup.py
index 8f2c47e27ca5618e7bbe39e2f2e07c8be68be41d..328b102071b3c9ef56e88ebfb831747042a870c8 100644
--- a/kcweb/setup.py
+++ b/kcweb/setup.py
@@ -16,7 +16,7 @@ def file_get_content(k):
return con
confkcw={}
confkcw['name']='kcweb' #项目的名称
-confkcw['version']='4.11.7' #项目版本
+confkcw['version']='4.11.8' #项目版本
confkcw['description']='' #项目的简单描述
confkcw['long_description']="" #项目详细描述
confkcw['license']='MIT License' #开源协议 mit开源
diff --git a/server.sh b/server.sh
index 852d2915ae74c900c816e594899fe5d929933db1..0ca827b33eb97955922cbe628ea8dabbb8f79bdf 100644
--- a/server.sh
+++ b/server.sh
@@ -1,6 +1,6 @@
chmod -R 777 /kcwebplus
./server stop
-nohup ./server --h 0.0.0.0 --p 39001 start > log 2>&1 &
+nohup ./server --h 0.0.0.0 --p 39001 --w 1 start > log 2>&1 &
sleep 2
-nohup ./server --h 0.0.0.0 --p 39002 --w 1 start > log 2>&1 &
-nohup ./server --h 0.0.0.0 --p 39003 --w 1 start > log 2>&1 &
\ No newline at end of file
+nohup ./server --h 0.0.0.0 --p 39002 --w 2 start > log 2>&1 &
+nohup ./server --h 0.0.0.0 --p 39003 --w 2 start > log 2>&1 &
\ No newline at end of file