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
3071123f
Commit
3071123f
authored
Jul 21, 2020
by
Administrator
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
20200721
parent
becb6663
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
46 additions
and
10 deletions
+46
-10
auto_install.py
server/www/teleport/webroot/app/controller/auto_install.py
+25
-3
plugin.py
server/www/teleport/webroot/app/controller/plugin.py
+13
-3
script.py
server/www/teleport/webroot/app/controller/script.py
+3
-0
plugin.py
server/www/teleport/webroot/app/model/plugin.py
+5
-4
No files found.
server/www/teleport/webroot/app/controller/auto_install.py
View file @
3071123f
...
...
@@ -110,8 +110,9 @@ def install_dbshop(site, host):
url
=
"http://{}/deployment?action=GetSpeed"
.
format
(
host
)
resp
=
session
.
get
(
url
)
pre
=
resp
.
json
()
.
get
(
"pre"
,
1
)
resp
.
encoding
=
'utf-8'
print
(
"GetSpeed"
,
resp
.
content
)
if
pre
==
0
:
if
pre
==
0
and
"正在下载文件"
not
in
resp
.
content
:
break
time
.
sleep
(
5
)
return
True
...
...
@@ -158,6 +159,9 @@ def shop_config(host, site, webname="DBShop电子商务系统"):
if
resp
.
text
==
"false"
:
print
(
"数据库配置失败"
)
return
False
elif
resp
.
status_code
!=
200
:
print
(
"请求安装页失败"
)
return
False
print
(
"数据库配置成功"
,
resp
.
content
)
...
...
@@ -217,8 +221,6 @@ def check_all_domain(ip):
def
sub_domain
(
site
):
if
site
.
count
(
'.'
)
==
1
:
pay_site
=
'pay.'
+
site
elif
site
.
count
(
'.'
)
==
2
:
pay_site
=
'pay.'
+
site
.
split
(
"."
,
1
)[
1
]
else
:
pay_site
=
site
return
pay_site
...
...
@@ -340,6 +342,19 @@ def update_nginx(ip, site):
return
True
def
add_ip_domain
(
ip
):
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"
,
"type"
:
-
1
}
resp
=
session
.
post
(
url
,
data
)
for
item
in
resp
.
json
()
.
get
(
"data"
,
[]):
id
=
item
.
get
(
"id"
,
0
)
name
=
item
.
get
(
"name"
,
""
)
add_site_domain
(
id
,
ip
,
ip
.
replace
(
":8888"
,
""
),
name
)
def
install_shop
(
ip
,
site
,
webname
):
# del_site(ip, site)
# 删除所有站点
...
...
@@ -348,9 +363,15 @@ def install_shop(ip, site, webname):
print
(
"添加站点成功"
)
install_dbshop
(
site
,
ip
)
print
(
"一键部署商城"
)
add_ip_domain
(
ip
)
time
.
sleep
(
5
)
if
shop_config
(
ip
,
site
=
site
,
webname
=
webname
):
print
(
"配置商城成功"
)
update_nginx
(
ip
,
site
)
elif
shop_config
(
site
,
site
=
site
,
webname
=
webname
):
print
(
"配置商城成功"
)
update_nginx
(
ip
,
site
)
else
:
print
(
"一键配置商城信息失败"
)
...
...
@@ -482,6 +503,7 @@ def run(ip, path, user, pwd, site, webname, sub_domain=""):
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
)
...
...
server/www/teleport/webroot/app/controller/plugin.py
View file @
3071123f
...
...
@@ -622,7 +622,11 @@ class BindPayAccountHandler(TPBasePluginHandler):
# password = password.replace("*", "")
host_password
=
host_password
.
replace
(
"*"
,
""
)
if
not
biz_id
or
not
mch_no
or
not
comp_id
or
not
account
:
if
not
biz_id
or
not
mch_no
or
not
comp_id
:
self
.
finish_json
(
1001
,
"缺少必填项"
)
return
if
host_id
and
not
account
:
self
.
finish_json
(
1001
,
"缺少必填项"
)
return
...
...
@@ -662,12 +666,14 @@ class BindPayAccountHandler(TPBasePluginHandler):
self
.
finish_json
(
1010
,
"无法找到对应主机信息"
)
return
status
=
self
.
query
(
"remote_host"
,
"status"
,
{
"id"
:
host_id
})
args
=
props
args
[
'host_id'
]
=
host_id
id
=
self
.
query
(
"remote_account_host_bind"
,
"id"
,
{
"host_id"
:
host_id
,
"mch_no"
:
mch_no
})
#
des_password = des_encrypt(password).decode()
des_password
=
des_encrypt
(
password
)
.
decode
()
args
=
{
"mch_no"
:
mch_no
,
"comp_id"
:
comp_id
,
"host_id"
:
host_id
,
"host_assigned"
:
host_assigned
,
"account_source"
:
1
,
"account"
:
account
,
"login_status"
:
0
,
"mch_name"
:
""
,
"biz_id"
:
biz_id
,
"ip"
:
ip
,
"host_password"
:
host_password
,
"username"
:
username
}
...
...
@@ -676,7 +682,7 @@ class BindPayAccountHandler(TPBasePluginHandler):
# xiugai
if
id
:
old_account
=
self
.
query
(
'remote_account_host_bind'
,
"account"
,
{
"id"
:
id
})
if
account
!=
old_account
:
if
account
and
old_account
and
account
!=
old_account
:
self
.
finish_json
(
1011
,
"不允许修改绑定账户"
)
host_id_lock
.
pop
(
host_id
,
None
)
return
...
...
@@ -686,6 +692,8 @@ class BindPayAccountHandler(TPBasePluginHandler):
self
.
finish_json
(
1011
,
"不允许修改公司资质"
)
elif
err
==
TPE_NOT_EXISTS
:
self
.
finish_json
(
1012
,
"设备不存在"
)
elif
int
(
status
)
!=
1
:
self
.
finish_json
(
2001
,
"请先初始化主机环境,再绑定操作"
)
elif
err
==
TPE_OK
:
self
.
finish_json
(
0
)
host_id_lock
.
pop
(
host_id
,
None
)
...
...
@@ -707,6 +715,8 @@ class BindPayAccountHandler(TPBasePluginHandler):
self
.
finish_json
(
1011
,
"绑定设备不存在"
)
elif
err
==
TPE_DATABASE
:
self
.
finish_json
(
1011
,
"绑定账户异常,请检查请求参数"
)
elif
int
(
status
)
!=
1
:
self
.
finish_json
(
2001
,
"请先初始化主机环境,再绑定操作"
)
else
:
self
.
finish_json
(
0
)
...
...
server/www/teleport/webroot/app/controller/script.py
View file @
3071123f
# coding: utf-8
import
argparse
import
datetime
import
json
import
os
import
traceback
...
...
@@ -79,6 +80,8 @@ def push_file(ip, username, password):
def
auto_install_bt
(
ip
,
username
,
password
,
site
,
webname
,
sub
=
""
,
host_id
=
0
):
transport
=
paramiko
.
Transport
((
ip
,
22
))
try
:
print
(
'****************************开始操作:{}************************'
.
format
(
datetime
.
datetime
.
now
()
.
strftime
(
'
%
Y-
%
m-
%
d
%
H:
%
M:
%
S'
)))
push_file
(
ip
,
username
,
password
)
transport
.
connect
(
username
=
username
,
password
=
password
)
...
...
server/www/teleport/webroot/app/model/plugin.py
View file @
3071123f
...
...
@@ -227,10 +227,11 @@ def add_account_host_bind(handler, args):
# 1. 判断账户是否已经存在了
# 1.1 todo 禁用主机可以重新绑定
sql
=
'SELECT id FROM tp_remote_account_host_bind WHERE account="{}" '
.
format
(
args
[
'account'
])
db_ret
=
db
.
query
(
sql
)
if
db_ret
is
not
None
and
len
(
db_ret
)
>
0
:
return
TPE_EXISTS
,
0
if
args
.
get
(
"account"
,
""
):
sql
=
'SELECT id FROM tp_remote_account_host_bind WHERE account="{}" '
.
format
(
args
[
'account'
])
db_ret
=
db
.
query
(
sql
)
if
db_ret
is
not
None
and
len
(
db_ret
)
>
0
:
return
TPE_EXISTS
,
0
# 2. 判断host_id 是否存在
sql
=
'SELECT id FROM tp_remote_host WHERE id="{}"'
.
format
(
args
[
'host_id'
])
...
...
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