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
becb6663
Commit
becb6663
authored
Jun 04, 2020
by
tarak.li
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
20200604 pre测试版本
parent
3b512088
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
25 deletions
+28
-25
install-shop.sh
server/www/teleport/webroot/app/controller/install-shop.sh
+1
-1
plugin.py
server/www/teleport/webroot/app/controller/plugin.py
+8
-7
script.py
server/www/teleport/webroot/app/controller/script.py
+19
-17
No files found.
server/www/teleport/webroot/app/controller/install-shop.sh
View file @
becb6663
...
...
@@ -26,5 +26,5 @@ 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
echo
-u
$username
-p
$password
-s
$1
--path
$host
--ip
$2
-w
$3
--sub
$4
/usr/bin/python /root/auto_install.py
-u
$username
-p
$password
-s
$1
--path
$host
--ip
$2
-w
$3
--sub
$4
/usr/bin/python /root/auto_install.py
-u
$username
-p
$password
-s
$1
--path
$host
--ip
$2
-w
$3
--sub
"
$4
"
server/www/teleport/webroot/app/controller/plugin.py
View file @
becb6663
...
...
@@ -94,12 +94,13 @@ def is_ipv4(address):
def
execute_auto_install_script
(
ip
,
usename
,
password
,
site
,
webname
,
sub_domain
):
path
=
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
))
cmd
=
'nohup /usr/bin/python3 {}/script.py --ip {} -u {} -p {} -s {} -w {} --sub {}>> /auto.out &'
.
format
(
path
,
ip
,
usename
,
password
,
site
,
webname
,
sub_domain
)
cmd
=
"nohup /usr/bin/python3 {}/script.py --ip {} -u {} -p {} -s {} -w {} --sub '{}'>> /auto.out &"
.
format
(
path
,
ip
,
usename
,
password
,
site
,
webname
,
sub_domain
)
os
.
system
(
cmd
)
return
cmd
...
...
@@ -891,7 +892,7 @@ class ShopBindHandler(TPBasePluginHandler):
self
.
finish_json
(
1001
,
"请填写正确的域名信息"
)
return
if
not
is_domain
(
sub_domain
):
if
sub_domain
and
not
is_domain
(
sub_domain
):
self
.
finish_json
(
1001
,
"请填写正确的二级域名信息"
)
return
...
...
server/www/teleport/webroot/app/controller/script.py
View file @
becb6663
...
...
@@ -2,6 +2,7 @@
import
argparse
import
json
import
os
import
traceback
from
concurrent.futures.thread
import
ThreadPoolExecutor
import
paramiko
...
...
@@ -91,12 +92,12 @@ def auto_install_bt(ip, username, password, site, webname, sub="", host_id=0):
result
=
install_bt
(
ssh
)
url
,
username
,
password
=
get_bt_info
(
ssh
)
update_shop_info
(
site
,
webname
,
remark
=
"宝塔初始化完成"
,
url
=
url
,
username
=
username
,
password
=
password
)
print
(
result
)
print
(
"install_bt"
,
result
)
i
=
0
while
i
<
2
:
print
(
'*************************************************************************************'
)
result
=
install_shop
(
ssh
,
site
,
ip
,
webname
,
sub
)
print
(
result
)
print
(
"install_shop"
,
result
)
i
+=
1
if
"商城已存在"
in
result
:
...
...
@@ -126,6 +127,7 @@ def auto_install_bt(ip, username, password, site, webname, sub="", host_id=0):
except
AuthenticationException
as
err
:
update_shop_info
(
site
,
webname
,
host_id
,
status
=
3
,
remark
=
"连接失败,请检查远程信息"
)
except
Exception
as
err
:
print
(
traceback
.
format_exc
())
update_shop_info
(
site
,
webname
,
host_id
,
status
=
3
,
remark
=
"商城部署异常,请重试"
)
finally
:
# 关闭服务器连接
...
...
@@ -133,22 +135,22 @@ def auto_install_bt(ip, username, password, site, webname, sub="", host_id=0):
def
main
():
parser
=
argparse
.
ArgumentParser
()
# parser.add_argument("action", choices=['start', 'stop', 'restart'])
parser
.
add_argument
(
"--ip"
,
help
=
"ip"
)
parser
.
add_argument
(
"-u"
,
"--user"
,
help
=
"username"
)
parser
.
add_argument
(
"-p"
,
"--pwd"
,
help
=
"password"
)
parser
.
add_argument
(
"-s"
,
"--site"
,
help
=
"site info"
)
parser
.
add_argument
(
"-w"
,
"--webname"
,
help
=
"webname"
)
parser
.
add_argument
(
"--sub"
,
help
=
"sub webname"
)
args
=
parser
.
parse_args
()
print
(
args
)
auto_install_bt
(
args
.
ip
,
args
.
user
,
args
.
pwd
,
args
.
site
,
args
.
webname
,
args
.
sub
or
""
)
try
:
parser
=
argparse
.
ArgumentParser
()
# parser.add_argument("action", choices=['start', 'stop', 'restart'])
parser
.
add_argument
(
"--ip"
,
help
=
"ip"
)
parser
.
add_argument
(
"-u"
,
"--user"
,
help
=
"username"
)
parser
.
add_argument
(
"-p"
,
"--pwd"
,
help
=
"password"
)
parser
.
add_argument
(
"-s"
,
"--site"
,
help
=
"site info"
)
parser
.
add_argument
(
"-w"
,
"--webname"
,
help
=
"webname"
)
parser
.
add_argument
(
"--sub"
,
help
=
"sub webname"
)
args
=
parser
.
parse_args
()
print
(
args
)
auto_install_bt
(
args
.
ip
,
args
.
user
,
args
.
pwd
,
args
.
site
,
args
.
webname
,
args
.
sub
or
""
)
except
:
print
(
traceback
.
format_exc
())
if
__name__
==
'__main__'
:
# push_file('121.196.33.88', 'root', 'Aa123456')
# auto_install_bt('34.92.159.68', 'root', 'Aa@123321', "34.92.159.68", "测试商城", "test.xlfamily.top")
# update_shop_info(site="www.test.com", webname="测试商城1", test="")
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