Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
M
micro-remote
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
tarak.li
micro-remote
Commits
b4c13ad8
Commit
b4c13ad8
authored
Dec 14, 2020
by
BH
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加入参解析方法
parent
3071123f
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
90 additions
and
35 deletions
+90
-35
configs.py
server/www/teleport/webroot/app/base/configs.py
+1
-1
__init__.py
server/www/teleport/webroot/app/controller/__init__.py
+1
-0
auto_install.py
server/www/teleport/webroot/app/controller/auto_install.py
+86
-26
plugin.py
server/www/teleport/webroot/app/controller/plugin.py
+0
-0
reqparse.py
server/www/teleport/webroot/app/controller/reqparse.py
+0
-0
script.py
server/www/teleport/webroot/app/controller/script.py
+2
-8
No files found.
server/www/teleport/webroot/app/base/configs.py
View file @
b4c13ad8
...
...
@@ -313,7 +313,7 @@ class AppConfig(BaseAppConfig):
self
.
set_default
(
'database::mysql-password'
,
'password'
,
'mysql-password=password'
)
self
.
set_default
(
'plugin::core_host'
,
'127.0.0.1'
,
'core_host=127.0.0.1'
)
self
.
set_default
(
'plugin::consul'
,
'127.0.0.1'
,
'consul=http://172.30.
1
0.128:6010'
)
self
.
set_default
(
'plugin::consul'
,
'127.0.0.1'
,
'consul=http://172.30.
2
0.128:6010'
)
self
.
set_default
(
'plugin::release_ip'
,
'127.0.0.1'
,
'release_ip=127.0.0.1'
)
self
.
set_default
(
'plugin::server'
,
'127.0.0.1'
,
'server=127.0.0.1'
)
self
.
set_default
(
'plugin::manager_host'
,
'http://121.196.33.88:5566'
,
'manager_host=http://121.196.33.88:5566'
)
...
...
server/www/teleport/webroot/app/controller/__init__.py
View file @
b4c13ad8
...
...
@@ -308,6 +308,7 @@ controllers = [
# websocket for real-time information
(
r'/plugin/exe_download_url'
,
plugin
.
ExeDownloadHandler
),
# ws-client call 'http://ip:7190/ws/action/'
(
r'/ws/(.*)'
,
ws
.
WebSocketHandler
),
(
r'/.*'
,
index
.
CatchAllHandler
),
]
...
...
server/www/teleport/webroot/app/controller/auto_install.py
View file @
b4c13ad8
...
...
@@ -52,7 +52,12 @@ def login(path, username, password, host):
def
add_site
(
site
,
host
):
# 添加站點
"""
添加站点
:param site: 站点名称
:param host: 站点地址
:return:
"""
url
=
"http://{}/site?action=AddSite"
.
format
(
host
)
user
=
'sql{}'
.
format
(
site
.
replace
(
"."
,
"_"
))
webname
=
json
.
dumps
({
"domain"
:
site
,
"domainlist"
:
[],
"count"
:
1
})
...
...
@@ -70,6 +75,12 @@ def add_site(site, host):
def
del_site
(
ip
,
site
):
"""
删除站点
:param ip:
:param site:
:return:
"""
url
=
"http://{}/data?action=getData"
.
format
(
ip
)
data
=
{
"tojs"
:
"site.get_list"
,
"table"
:
"sites"
,
"limit"
:
15
,
"p"
:
1
,
"search"
:
""
,
"order"
:
"id desc"
,
"type"
:
-
1
}
...
...
@@ -85,28 +96,32 @@ def del_site(ip, site):
def
install_dbshop
(
site
,
host
):
"""
安装 dbshop 商城
:param site:
:param host:
:return:
"""
url
=
"http://{}/deployment?action=GetList"
.
format
(
host
)
data
=
{
"type"
:
0
}
session
.
post
(
url
,
data
)
# 一键部署接口
url
=
"http://{}/deployment?action=SetupPackage"
.
format
(
host
)
data
=
{
"dname"
:
"DBShop"
,
"site_name"
:
site
,
"php_version"
:
"56"
}
i
=
0
while
True
:
for
i
in
range
(
3
)
:
resp
=
session
.
post
(
url
,
data
=
data
)
if
resp
.
status_code
==
200
:
break
i
+=
1
if
i
>
3
:
break
time
.
sleep
(
10
)
# {"status": true, "msg": {"db_config": "", "run_path": "/", "php_versions": "54,55,56,70,71,72,73", "admin_username": "", "success_url": "/install", "chmod": [], "remove_file": [], "php_ext": ["fileinfo"], "admin_password": ""}}
# http://121.196.33.88:8888/deployment?action=GetSpeed
# {"pre": 0, "total": 0, "speed": 0, "name": "\u5b89\u88c5\u5fc5\u8981\u7684PHP\u6269\u5c55", "used": 0}
pre
=
1
while
pre
!=
0
:
# 初次调用,下载文件包
for
i
in
range
(
20
):
url
=
"http://{}/deployment?action=GetSpeed"
.
format
(
host
)
resp
=
session
.
get
(
url
)
pre
=
resp
.
json
()
.
get
(
"pre"
,
1
)
...
...
@@ -119,6 +134,11 @@ def install_dbshop(site, host):
def
mysql_root_pwd
(
ip
):
"""
mysql root 密码获取
:param ip:
:return:
"""
url
=
"http://{}/data?action=getKey"
.
format
(
ip
)
data
=
{
"table"
:
"config"
,
"key"
:
"mysql_root"
,
"id"
:
"1"
}
resp
=
session
.
post
(
url
,
data
)
...
...
@@ -128,7 +148,13 @@ def mysql_root_pwd(ip):
def
shop_config
(
host
,
site
,
webname
=
"DBShop电子商务系统"
):
pwd
=
mysql_root_pwd
(
host
)
"""
商城初始化相关接口
:param host:
:param site:
:param webname:
:return:
"""
host
=
host
.
replace
(
":8888"
,
""
)
# 等待时间让网页进行加载
time
.
sleep
(
10
)
...
...
@@ -144,16 +170,11 @@ def shop_config(host, site, webname="DBShop电子商务系统"):
resp
=
session
.
post
(
url
,
data
)
i
=
0
while
True
:
for
i
in
range
(
5
)
:
resp
=
session
.
post
(
url
,
data
=
data
)
print
(
"check db"
,
url
,
data
,
resp
.
content
)
if
resp
.
text
!=
"false"
:
break
i
+=
1
if
i
>
5
:
break
time
.
sleep
(
10
)
if
resp
.
text
==
"false"
:
...
...
@@ -175,6 +196,11 @@ def shop_config(host, site, webname="DBShop电子商务系统"):
def
check_shop
(
site
):
"""
确认商城安装情况
:param site:
:return:
"""
url
=
"http://{}"
.
format
(
site
)
try
:
resp
=
requests
.
get
(
url
)
...
...
@@ -195,6 +221,11 @@ def get_domain(ip, id):
def
check_all_domain
(
ip
):
"""
检查宝塔下所有的站点
:param ip:
:return:
"""
url
=
"http://{}/data?action=getData"
.
format
(
ip
)
# tojs=site.get_list&table=sites&limit=15&p=1&search=&order=id desc&type=-1
data
=
{
"tojs"
:
"site.get_list"
,
"table"
:
"sites"
,
"limit"
:
15
,
"p"
:
1
,
"search"
:
""
,
"order"
:
"id desc"
,
...
...
@@ -219,6 +250,11 @@ def check_all_domain(ip):
def
sub_domain
(
site
):
"""
子域名处理
:param site:
:return:
"""
if
site
.
count
(
'.'
)
==
1
:
pay_site
=
'pay.'
+
site
else
:
...
...
@@ -377,6 +413,14 @@ def install_shop(ip, site, webname):
def
add_site_domain
(
id
,
ip
,
site
,
webname
):
"""
将域名添加至站点
:param id:
:param ip:
:param site:
:param webname:
:return:
"""
url
=
"http://{}/data?action=getData"
.
format
(
ip
)
data
=
{
"table"
:
"domain"
,
"list"
:
True
,
"search"
:
id
}
resp
=
session
.
post
(
url
,
data
)
...
...
@@ -389,6 +433,13 @@ def add_site_domain(id, ip, site, webname):
def
add_nginx
(
ip
,
id
,
site
):
"""
修改 nginx 配置
:param ip:
:param id:
:param site:
:return:
"""
sites
=
get_domain
(
ip
,
id
)
url
=
"http://{}/files?action=GetFileBody"
.
format
(
ip
)
...
...
@@ -410,7 +461,12 @@ def add_nginx(ip, id, site):
def
check_ssl
(
ip
,
sub_domain
):
# 获取已部署证书
"""
获取已部署证书
:param ip:
:param sub_domain:
:return:
"""
url
=
"http://{}/ssl?action=GetCertList"
.
format
(
ip
)
resp
=
session
.
post
(
url
)
...
...
@@ -421,7 +477,13 @@ def check_ssl(ip, sub_domain):
def
set_old_ssl
(
ip
,
site
,
cert_name
):
# 部署已存在证书
"""
已存在域名证书,直接使用
:param ip:
:param site:
:param cert_name:
:return:
"""
url
=
"http://{}/ssl?action=SetCertToSite"
.
format
(
ip
)
data
=
{
"certName"
:
cert_name
,
"siteName"
:
site
}
resp
=
session
.
post
(
url
,
data
)
...
...
@@ -449,7 +511,14 @@ def start_https(ip, site):
def
set_ssl
(
ip
,
site
,
id
,
sub_domain
):
# 已部署证书的不再部署
"""
部署 https 证书
:param ip:
:param site:
:param id:
:param sub_domain:
:return:
"""
if
ssl_status
(
ip
,
site
):
return
...
...
@@ -496,14 +565,9 @@ def run(ip, path, user, pwd, site, webname, sub_domain=""):
print
(
login
(
path
,
user
,
pwd
,
ip
))
print
(
"完成宝塔登录配置"
)
# if check_shop(site):
# print("商城已存在")
# return
shop_id
,
name
=
check_all_domain
(
ip
)
if
shop_id
:
print
(
"商城已存在"
,
shop_id
,
"name"
,
name
)
add_site_domain
(
shop_id
,
ip
,
ip
.
replace
(
":8888"
,
""
),
name
)
add_site_domain
(
shop_id
,
ip
,
site
,
name
)
if
sub_domain
:
add_site_domain
(
shop_id
,
ip
,
sub_domain
,
name
)
...
...
@@ -545,7 +609,3 @@ def main():
if
__name__
==
'__main__'
:
main
()
# run("34.92.159.68:8888", path='9f57b254', pwd='950bc7da', site='pay.xamsmsm.com', user='ppvtidah',
# webname='测试', sub_domain="pay.xamsmsm.com")
# print(login(path, user, pwd, ip))
# set_ssl(ip, "34.92.159.68", 5, "pay.xamsmsm.com")
server/www/teleport/webroot/app/controller/plugin.py
View file @
b4c13ad8
This diff is collapsed.
Click to expand it.
server/www/teleport/webroot/app/controller/reqparse.py
0 → 100644
View file @
b4c13ad8
This diff is collapsed.
Click to expand it.
server/www/teleport/webroot/app/controller/script.py
View file @
b4c13ad8
...
...
@@ -97,18 +97,15 @@ def auto_install_bt(ip, username, password, site, webname, sub="", host_id=0):
update_shop_info
(
site
,
webname
,
remark
=
"宝塔初始化完成"
,
url
=
url
,
username
=
username
,
password
=
password
)
print
(
"install_bt"
,
result
)
i
=
0
while
i
<
2
:
print
(
'*************************************************************************************'
)
for
i
in
range
(
2
):
result
=
install_shop
(
ssh
,
site
,
ip
,
webname
,
sub
)
print
(
"install_shop"
,
result
)
i
+=
1
if
"商城已存在"
in
result
:
print
(
"商城已存在"
)
update_shop_info
(
site
,
webname
,
host_id
,
status
=
1
,
remark
=
"商城已存在"
,
url
=
url
,
username
=
username
,
password
=
password
)
break
ssl_remark
,
ssl_status
=
""
,
0
if
"配置商城成功"
in
result
or
"商城已存在"
in
result
:
print
(
"更新商城信息"
)
if
"申请HTTPS证书成功"
in
result
or
"HTTPS证书已存在"
in
result
:
...
...
@@ -118,9 +115,6 @@ def auto_install_bt(ip, username, password, site, webname, sub="", host_id=0):
ssl_remark
=
between
(
result
,
"new ssl response:["
,
"]
\n
"
)
ssl_remark
=
json
.
loads
(
ssl_remark
)[
'msg'
][
0
]
ssl_status
=
2
else
:
ssl_remark
=
""
ssl_status
=
0
update_shop_info
(
site
,
webname
,
host_id
,
status
=
1
,
remark
=
"商城部署成功"
,
url
=
url
,
username
=
username
,
password
=
password
,
ssl_remark
=
ssl_remark
,
ssl_status
=
ssl_status
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment