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
88928a50
Commit
88928a50
authored
May 27, 2020
by
tarak.li
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
20200527 提测
parent
2d39fb27
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
89 additions
and
34 deletions
+89
-34
auto_install.py
server/www/teleport/webroot/app/controller/auto_install.py
+33
-11
clash_refresh.py
server/www/teleport/webroot/app/controller/clash_refresh.py
+38
-2
install-bt.sh
server/www/teleport/webroot/app/controller/install-bt.sh
+0
-8
install-shop.sh
server/www/teleport/webroot/app/controller/install-shop.sh
+1
-0
plugin.py
server/www/teleport/webroot/app/controller/plugin.py
+9
-6
script.py
server/www/teleport/webroot/app/controller/script.py
+8
-7
No files found.
server/www/teleport/webroot/app/controller/auto_install.py
View file @
88928a50
...
@@ -120,6 +120,7 @@ def install_dbshop(site, host):
...
@@ -120,6 +120,7 @@ def install_dbshop(site, host):
break
break
time
.
sleep
(
10
)
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": ""}}
# {"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": ""}}
# {"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
# 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": 0, "total": 0, "speed": 0, "name": "\u5b89\u88c5\u5fc5\u8981\u7684PHP\u6269\u5c55", "used": 0}
...
@@ -194,8 +195,10 @@ def check_shop(site):
...
@@ -194,8 +195,10 @@ def check_shop(site):
url
=
"http://{}"
.
format
(
site
)
url
=
"http://{}"
.
format
(
site
)
try
:
try
:
resp
=
requests
.
get
(
url
)
resp
=
requests
.
get
(
url
)
resp
.
encoding
=
"utf-8"
code
=
resp
.
status_code
code
=
resp
.
status_code
return
code
==
200
and
len
(
resp
.
text
)
>
2000
print
(
"check_shop"
,
resp
.
content
)
return
code
==
200
and
'用户中心'
in
resp
.
content
and
'登录'
in
resp
.
content
except
:
except
:
code
=
0
code
=
0
return
False
return
False
...
@@ -311,6 +314,32 @@ server {
...
@@ -311,6 +314,32 @@ server {
return
True
return
True
def
install_shop
(
ip
,
site
,
webname
):
del_site
(
ip
,
site
)
add_site
(
site
,
ip
)
print
(
"添加站点成功"
)
install_dbshop
(
site
,
ip
)
print
(
"一键部署商城"
)
if
shop_config
(
ip
,
site
=
site
,
webname
=
webname
):
print
(
"配置商城成功"
)
update_nginx
(
ip
,
site
)
else
:
print
(
"一键配置商城信息失败"
)
def
add_site_domain
(
id
,
ip
,
site
,
webname
):
url
=
"http://{}/data?action=getData"
.
format
(
ip
)
data
=
{
"table"
:
"domain"
,
"list"
:
True
,
"search"
:
id
}
resp
=
session
.
post
(
url
,
data
)
# domain=121.196.33.88&webname=www.gingboutrade.com&id=13
url
=
"http://{}/site?action=AddDomain"
.
format
(
ip
)
data
=
{
"domain"
:
site
,
"webname"
:
webname
,
"id"
:
id
}
session
.
post
(
url
,
data
)
print
(
resp
.
text
)
return
def
main
():
def
main
():
parser
=
argparse
.
ArgumentParser
()
parser
=
argparse
.
ArgumentParser
()
# parser.add_argument("action", choices=['start', 'stop', 'restart'])
# parser.add_argument("action", choices=['start', 'stop', 'restart'])
...
@@ -329,19 +358,12 @@ def main():
...
@@ -329,19 +358,12 @@ def main():
path
=
args
.
path
or
''
path
=
args
.
path
or
''
print
(
login
(
path
,
args
.
user
,
args
.
pwd
,
ip
))
print
(
login
(
path
,
args
.
user
,
args
.
pwd
,
ip
))
print
(
"完成宝塔登录配置"
)
print
(
"完成宝塔登录配置"
)
if
check_shop
(
args
.
site
):
if
check_shop
(
args
.
site
):
print
(
"商城已存在"
)
print
(
"商城已存在"
)
return
return
del_site
(
ip
,
args
.
site
)
add_site
(
args
.
site
,
ip
)
install_shop
(
ip
,
args
.
site
,
args
.
webname
)
print
(
"添加站点成功"
)
install_dbshop
(
args
.
site
,
ip
)
print
(
"一键部署商城"
)
if
shop_config
(
ip
,
site
=
args
.
site
):
print
(
"配置商城成功"
)
update_nginx
(
ip
,
args
.
site
)
else
:
print
(
"一键配置商城信息失败"
)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
...
...
server/www/teleport/webroot/app/controller/clash_refresh.py
View file @
88928a50
...
@@ -31,8 +31,13 @@ def refre(path):
...
@@ -31,8 +31,13 @@ def refre(path):
print
(
resp
.
status_code
,
resp
.
text
)
print
(
resp
.
status_code
,
resp
.
text
)
def
min_proxy
():
def
min_proxy
(
new_proxy
):
_count
=
proxy_count
()
_count
=
proxy_count
()
for
proxy
in
new_proxy
:
name
=
proxy
.
get
(
"name"
,
""
)
if
name
not
in
_count
.
keys
():
_count
[
name
]
=
0
print
(
_count
)
min_key
=
min
(
_count
,
key
=
lambda
x
:
_count
[
x
])
min_key
=
min
(
_count
,
key
=
lambda
x
:
_count
[
x
])
return
min_key
return
min_key
...
@@ -48,6 +53,8 @@ def read_conf():
...
@@ -48,6 +53,8 @@ def read_conf():
def
read_local_ip
():
def
read_local_ip
():
local_proxy
=
{}
local_proxy
=
{}
dir_path
=
"/root/.config/clash/ip"
dir_path
=
"/root/.config/clash/ip"
if
not
os
.
path
.
exists
(
dir_path
):
return
local_proxy
for
root
,
dirs
,
files
in
os
.
walk
(
dir_path
,
topdown
=
False
):
for
root
,
dirs
,
files
in
os
.
walk
(
dir_path
,
topdown
=
False
):
print
(
root
,
dirs
,
files
)
print
(
root
,
dirs
,
files
)
for
file
in
files
:
for
file
in
files
:
...
@@ -58,14 +65,42 @@ def read_local_ip():
...
@@ -58,14 +65,42 @@ def read_local_ip():
return
local_proxy
return
local_proxy
def
update_local_proxy
(
conf
,
local
):
proxy
=
conf
.
get
(
"Proxy"
,
[])
proxys
=
[
item
.
get
(
"name"
,
""
)
for
item
in
proxy
]
print
(
"proxys"
,
proxys
)
print
(
local
)
_local
=
[]
for
k
,
v
in
local
.
items
():
if
k
not
in
proxys
and
len
(
v
.
split
(
":"
))
==
2
:
# {'cipher': 'aes-256-gcm', 'name': 'judy', 'password': '17ATvm1k', 'type': 'ss', 'port': '45678', 'server': '43.248.124.17'}
_p
=
{
'cipher'
:
'aes-256-gcm'
,
'name'
:
k
,
'password'
:
'17ATvm1k'
,
'type'
:
'ss'
,
'port'
:
v
.
split
(
":"
)[
1
],
'server'
:
v
.
split
(
":"
)[
0
]}
_local
.
append
(
_p
)
proxy
.
extend
(
_local
)
return
proxy
def
add_proxy
(
ip
):
def
add_proxy
(
ip
):
conf
=
read_conf
()
conf
=
read_conf
()
proxy_name
=
min_proxy
()
_local
=
read_local_ip
()
new_proxy
=
update_local_proxy
(
conf
,
_local
)
# proxys = proxy_count()
# 添加本地proxy,并获取使用最少的一个
proxy_name
=
min_proxy
(
new_proxy
)
rule
=
conf
.
get
(
"Rule"
,
[])
rule
=
conf
.
get
(
"Rule"
,
[])
if
not
[
r
for
r
in
rule
if
ip
in
r
]:
new_rule
=
"IP-CIDR,{}/32,{}"
.
format
(
ip
,
proxy_name
)
new_rule
=
"IP-CIDR,{}/32,{}"
.
format
(
ip
,
proxy_name
)
new_rule
=
[
new_rule
]
new_rule
=
[
new_rule
]
new_rule
.
extend
(
rule
)
new_rule
.
extend
(
rule
)
else
:
new_rule
=
rule
conf
[
"Rule"
]
=
new_rule
conf
[
"Rule"
]
=
new_rule
conf
[
"Proxy"
]
=
new_proxy
path
=
"/root/.config/clash/config.yaml"
path
=
"/root/.config/clash/config.yaml"
with
open
(
path
,
'w'
)
as
dumpfile
:
with
open
(
path
,
'w'
)
as
dumpfile
:
...
@@ -87,4 +122,5 @@ def main():
...
@@ -87,4 +122,5 @@ def main():
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
main
()
main
()
# add_proxy("127.0.0.1")
# print(read_local_ip())
# print(read_local_ip())
server/www/teleport/webroot/app/controller/install-bt.sh
View file @
88928a50
...
@@ -18,12 +18,4 @@ if [ ! -f "/usr/bin/pip" ];then
...
@@ -18,12 +18,4 @@ if [ ! -f "/usr/bin/pip" ];then
else
else
echo
"pip已安装"
echo
"pip已安装"
fi
fi
# /etc/init.d/bt default
# shell 脚本获取账户密码
var
=
$(
/etc/init.d/bt default
)
host
=
$(
echo
${
var
#*8888/
}
|
cut
-c
1-8
)
username
=
$(
echo
${
var
#*username
:
}
|
cut
-c
1-8
)
password
=
$(
echo
${
var
#*password
:
}
|
cut
-c
1-8
)
#/usr/bin/python /root/auto_install.py -u $username -p $password -s $1 --path $host --ip $2 -w $3 > /tmp/load.log 2>&1
/usr/bin/python /root/auto_install.py
-u
$username
-p
$password
-s
$1
--path
$host
--ip
$2
-w
$3
server/www/teleport/webroot/app/controller/install-shop.sh
View file @
88928a50
...
@@ -25,5 +25,6 @@ host=$(echo ${var#*8888/} | cut -c 1-8)
...
@@ -25,5 +25,6 @@ host=$(echo ${var#*8888/} | cut -c 1-8)
username
=
$(
echo
${
var
#*username
:
}
|
cut
-c
1-8
)
username
=
$(
echo
${
var
#*username
:
}
|
cut
-c
1-8
)
password
=
$(
echo
${
var
#*password
:
}
|
cut
-c
1-8
)
password
=
$(
echo
${
var
#*password
:
}
|
cut
-c
1-8
)
#/usr/bin/python /root/auto_install.py -u $username -p $password -s $1 --path $host --ip $2 -w $3 > /tmp/load.log 2>&1
#/usr/bin/python /root/auto_install.py -u $username -p $password -s $1 --path $host --ip $2 -w $3 > /tmp/load.log 2>&1
echo
-u
$username
-p
$password
-s
$1
--path
$host
--ip
$2
-w
$3
/usr/bin/python /root/auto_install.py
-u
$username
-p
$password
-s
$1
--path
$host
--ip
$2
-w
$3
/usr/bin/python /root/auto_install.py
-u
$username
-p
$password
-s
$1
--path
$host
--ip
$2
-w
$3
server/www/teleport/webroot/app/controller/plugin.py
View file @
88928a50
...
@@ -94,13 +94,15 @@ def is_ipv4(address):
...
@@ -94,13 +94,15 @@ def is_ipv4(address):
def
execute_auto_install_script
(
ip
,
usename
,
password
,
site
,
webname
,
host_id
):
def
execute_auto_install_script
(
ip
,
usename
,
password
,
site
,
webname
,
host_id
):
path
=
os
.
path
.
dirname
(
__file__
)
path
=
os
.
path
.
dirname
(
__file__
)
os
.
system
(
'nohup python3 {}/script.py --ip {} -u {} -p {} -s {} -w {} &'
.
format
(
path
,
ip
,
usename
,
password
,
site
,
cmd
=
'nohup /usr/bin/python3 {}/script.py --ip {} -u {} -p {} -s {} -w {} &'
.
format
(
path
,
ip
,
usename
,
password
,
webname
))
site
,
webname
)
os
.
system
(
cmd
)
return
cmd
def
execute_add_proxy
(
ip
):
def
execute_add_proxy
(
ip
):
path
=
os
.
path
.
dirname
(
__file__
)
path
=
os
.
path
.
dirname
(
__file__
)
os
.
system
(
'nohup python3 {}/clash_refresh.py --ip {} &'
.
format
(
path
,
ip
))
os
.
system
(
'nohup
/usr/bin/
python3 {}/clash_refresh.py --ip {} &'
.
format
(
path
,
ip
))
class
TPBasePluginHandler
(
TPBaseHandler
):
class
TPBasePluginHandler
(
TPBaseHandler
):
...
@@ -376,7 +378,7 @@ class GetHostListHandler(TPBasePluginHandler):
...
@@ -376,7 +378,7 @@ class GetHostListHandler(TPBasePluginHandler):
async
def
post
(
self
):
async
def
post
(
self
):
props
=
self
.
get_payload
()
props
=
self
.
get_payload
()
os_type
,
status
,
page_index
,
page_size
=
self
.
param_get
(
props
,
[
'os_type'
,
'status'
,
'page
_index'
,
'page_s
ize'
],
os_type
,
status
,
page_index
,
page_size
=
self
.
param_get
(
props
,
[
'os_type'
,
'status'
,
'page
Index'
,
'pageS
ize'
],
0
)
0
)
ip
,
name
=
self
.
param_get
(
props
,
[
'ip'
,
'name'
,
],
''
)
ip
,
name
=
self
.
param_get
(
props
,
[
'ip'
,
'name'
,
],
''
)
...
@@ -907,8 +909,9 @@ class ShopBindHandler(TPBasePluginHandler):
...
@@ -907,8 +909,9 @@ class ShopBindHandler(TPBasePluginHandler):
# finish 调用商城自动部署
# finish 调用商城自动部署
items
=
plugin
.
query_one
(
"remote_host"
,
[
'ip'
,
'username'
,
'password'
],
{
"id"
:
host_id
,
})
items
=
plugin
.
query_one
(
"remote_host"
,
[
'ip'
,
'username'
,
'password'
],
{
"id"
:
host_id
,
})
password
=
des_descrypt
(
items
.
get
(
"password"
,
""
))
.
decode
()
password
=
des_descrypt
(
items
.
get
(
"password"
,
""
))
.
decode
()
execute_auto_install_script
(
items
.
get
(
"ip"
,
""
),
items
.
get
(
"username"
,
""
),
password
,
domain
,
name
,
cmd
=
execute_auto_install_script
(
items
.
get
(
"ip"
,
""
),
items
.
get
(
"username"
,
""
),
password
,
domain
,
host_id
)
name
,
host_id
)
log
.
i
(
"自动部署商城:{}"
.
format
(
cmd
))
else
:
else
:
self
.
finish_json
(
1002
,
"绑定商城信息失败"
)
self
.
finish_json
(
1002
,
"绑定商城信息失败"
)
...
...
server/www/teleport/webroot/app/controller/script.py
View file @
88928a50
...
@@ -73,16 +73,18 @@ def auto_install_bt(ip, username, password, site, webname, host_id=0):
...
@@ -73,16 +73,18 @@ def auto_install_bt(ip, username, password, site, webname, host_id=0):
while
i
<
2
:
while
i
<
2
:
print
(
'*************************************************************************************'
)
print
(
'*************************************************************************************'
)
result
=
install_shop
(
ssh
,
site
,
ip
,
webname
)
result
=
install_shop
(
ssh
,
site
,
ip
,
webname
)
print
(
result
)
i
+=
1
i
+=
1
if
"配置商城成功"
in
result
:
print
(
"更新商城信息"
)
update_shop_info
(
site
,
webname
,
host_id
,
status
=
1
,
remark
=
"商城部署成功"
,
url
=
site
)
break
if
"商城已存在"
in
result
:
if
"商城已存在"
in
result
:
print
(
"商城已存在"
)
print
(
"商城已存在"
)
update_shop_info
(
site
,
webname
,
host_id
,
status
=
1
,
remark
=
"商城已存在"
,
url
=
site
)
update_shop_info
(
site
,
webname
,
host_id
,
status
=
1
,
remark
=
"商城已存在"
,
url
=
site
)
break
break
if
"配置商城成功"
in
result
:
print
(
"更新商城信息"
)
update_shop_info
(
site
,
webname
,
host_id
,
status
=
1
,
remark
=
"商城部署成功"
,
url
=
site
)
except
AuthenticationException
as
err
:
except
AuthenticationException
as
err
:
update_shop_info
(
site
,
webname
,
host_id
,
status
=
3
,
remark
=
"连接失败,请检查远程信息"
)
update_shop_info
(
site
,
webname
,
host_id
,
status
=
3
,
remark
=
"连接失败,请检查远程信息"
)
finally
:
finally
:
...
@@ -106,7 +108,6 @@ def main():
...
@@ -106,7 +108,6 @@ def main():
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
# push_file('121.196.33.88', 'root', 'Aa123456')
# push_file('121.196.33.88', 'root', 'Aa123456')
auto_install_bt
(
'121.196.33.88'
,
'root'
,
'Aa123456'
,
"121.196.33.88
"
,
"测试商城"
)
# auto_install_bt('121.196.33.88', 'root', 'Aa123456', "www.gingboutrade.com
", "测试商城")
# update_shop_info(site="www.test.com", webname="测试商城1", test="")
# update_shop_info(site="www.test.com", webname="测试商城1", test="")
# main()
main
()
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