Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
aaPanel
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
Kulya
aaPanel
Commits
206af786
Commit
206af786
authored
Jun 26, 2019
by
jose
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add some features
parent
f99f486e
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
60 additions
and
27 deletions
+60
-27
common.py
class/common.py
+1
-1
files.py
class/files.py
+2
-1
plugin_deployment.py
class/plugin_deployment.py
+22
-10
public.py
class/public.py
+28
-10
system.py
class/system.py
+7
-5
No files found.
class/common.py
View file @
206af786
...
...
@@ -27,7 +27,7 @@ class panelSetup:
if
ua
:
ua
=
ua
.
lower
();
if
ua
.
find
(
'spider'
)
!=
-
1
or
ua
.
find
(
'bot'
)
!=
-
1
:
return
redirect
(
'https://www.baidu.com'
);
g
.
version
=
'6.
0.5
'
g
.
version
=
'6.
1.0
'
g
.
title
=
public
.
GetConfigValue
(
'title'
)
g
.
uri
=
request
.
path
session
[
'version'
]
=
g
.
version
;
...
...
class/files.py
View file @
206af786
...
...
@@ -1097,7 +1097,8 @@ cd %s
def
GetExecShellMsg
(
self
,
get
):
fileName
=
'/tmp/panelShell.pl'
;
if
not
os
.
path
.
exists
(
fileName
):
return
'FILE_SHELL_EMPTY'
;
return
public
.
readFile
(
'/tmp/panelShell.pl'
);
status
=
not
public
.
process_exists
(
'bash'
,
None
,
'/tmp/panelShell.sh'
)
return
public
.
returnMsg
(
status
,
public
.
GetNumLines
(
fileName
,
200
));
#文件搜索
def
GetSearch
(
self
,
get
):
...
...
class/plugin_deployment.py
View file @
206af786
#coding: utf-8
#-------------------------------------------------------------------
# 宝塔Linux面板
#-------------------------------------------------------------------
# Copyright (c) 2015-2099 宝塔软件(http:#bt.cn) All rights reserved.
#-------------------------------------------------------------------
# Author: 黄文良 <287962566@qq.com>
#-------------------------------------------------------------------
import
public
,
os
,
sys
,
json
,
time
# +-------------------------------------------------------------------
# | 宝塔Linux面板
# +-------------------------------------------------------------------
# | Copyright (c) 2015-2099 宝塔软件(http://bt.cn) All rights reserved.
# +-------------------------------------------------------------------
# | Author: 黄文良 <287962566@qq.com>
# +-------------------------------------------------------------------
#+--------------------------------------------------------------------
#| 自动部署网站
#+--------------------------------------------------------------------
import
public
,
json
,
os
,
time
,
sys
import
public
,
json
,
os
,
time
,
sys
,
re
from
BTPanel
import
session
class
obj
:
id
=
0
;
class
plugin_deployment
:
...
...
@@ -166,6 +165,17 @@ class plugin_deployment:
public
.
writeFile
(
jsonFile
,
json
.
dumps
(
data
));
return
public
.
returnMsg
(
True
,
'Import Success!'
);
#取本地包信息
def
GetPackageOther
(
self
,
get
):
jsonFile
=
self
.
__setupPath
+
'/deployment_list_other.json'
;
if
not
os
.
path
.
exists
(
jsonFile
):
public
.
returnMsg
(
False
,
'could not find [
%
s]'
%
p_name
)
data
=
json
.
loads
(
public
.
readFile
(
jsonFile
));
p_name
=
get
.
p_name
for
i
in
range
(
len
(
data
)):
if
data
[
i
][
'name'
]
==
p_name
:
return
data
[
i
]
return
public
.
returnMsg
(
False
,
'could not find [
%
s]'
%
p_name
)
#删除程序包
def
DelPackage
(
self
,
get
):
jsonFile
=
self
.
__setupPath
+
'/deployment_list_other.json'
;
...
...
@@ -274,6 +284,7 @@ class plugin_deployment:
self
.
WriteLogs
(
json
.
dumps
({
'name'
:
'Install the necessary PHP extensions'
,
'total'
:
0
,
'used'
:
0
,
'pre'
:
0
,
'speed'
:
0
}));
import
files
mfile
=
files
.
files
();
pinfo
[
'php_ext'
]
=
pinfo
[
'php_ext'
]
.
strip
()
.
split
(
','
)
for
ext
in
pinfo
[
'php_ext'
]:
if
ext
==
'pathinfo'
:
import
config
...
...
@@ -293,7 +304,7 @@ class plugin_deployment:
php_f
=
public
.
GetConfigValue
(
'setup_path'
)
+
'/php/'
+
php_version
+
'/etc/php.ini'
php_c
=
public
.
readFile
(
php_f
)
rep
=
"disable_functions
\
s*=
\
s{0,1}(.*)
\n
"
tmp
=
re
.
search
(
rep
,
php
ini
)
.
groups
();
tmp
=
re
.
search
(
rep
,
php
_c
)
.
groups
();
disable_functions
=
tmp
[
0
]
.
split
(
','
);
for
fun
in
pinfo
[
'enable_functions'
]:
fun
=
fun
.
strip
()
...
...
@@ -369,6 +380,7 @@ class plugin_deployment:
public
.
writeFile
(
siteConfigFile
,
siteConfig
)
#清理文件和目录
self
.
WriteLogs
(
json
.
dumps
({
'name'
:
'清理多余的文件'
,
'total'
:
0
,
'used'
:
0
,
'pre'
:
0
,
'speed'
:
0
}));
for
f_path
in
pinfo
[
'remove_file'
]:
filename
=
(
path
+
'/'
+
f_path
)
.
replace
(
'//'
,
'/'
)
if
os
.
path
.
exists
(
filename
):
...
...
class/public.py
View file @
206af786
...
...
@@ -537,6 +537,7 @@ def get_url(timeout = 0.5):
if
not
node
[
'ping'
]:
continue
;
if
not
mnode
:
mnode
=
node
;
if
node
[
'ping'
]
<
mnode
[
'ping'
]:
mnode
=
node
;
if
mnode
[
'ping'
]
<
50
:
break
return
mnode
[
'protocol'
]
+
mnode
[
'address'
]
+
':'
+
mnode
[
'port'
];
except
:
return
'http://download.bt.cn'
;
...
...
@@ -733,10 +734,10 @@ def checkWebConfig():
if
os
.
path
.
exists
(
f3
):
os
.
remove
(
f3
)
if
get_webserver
()
==
'nginx'
:
result
=
ExecShell
(
"ulimit -n
10240
&& /www/server/nginx/sbin/nginx -t -c /www/server/nginx/conf/nginx.conf"
);
result
=
ExecShell
(
"ulimit -n
8192
&& /www/server/nginx/sbin/nginx -t -c /www/server/nginx/conf/nginx.conf"
);
searchStr
=
'successful'
else
:
result
=
ExecShell
(
"ulimit -n
10240
&& /www/server/apache/bin/apachectl -t"
);
result
=
ExecShell
(
"ulimit -n
8192
&& /www/server/apache/bin/apachectl -t"
);
searchStr
=
'Syntax OK'
if
result
[
1
]
.
find
(
searchStr
)
==
-
1
:
...
...
@@ -792,10 +793,12 @@ def hasPwd(password):
return
crypt
.
crypt
(
password
,
password
);
def
get_timeout
(
url
,
timeout
=
3
):
start
=
time
.
time
();
result
=
httpGet
(
url
,
timeout
);
if
result
!=
'True'
:
return
False
;
return
int
((
time
.
time
()
-
start
)
*
1000
);
try
:
start
=
time
.
time
();
result
=
httpGet
(
url
,
timeout
);
if
result
!=
'True'
:
return
False
;
return
int
((
time
.
time
()
-
start
)
*
1000
);
except
:
return
False
def
getDate
(
format
=
'
%
Y-
%
m-
%
d
%
X'
):
#取格式时间
...
...
@@ -1075,7 +1078,7 @@ def get_uuid():
#进程是否存在
def
process_exists
(
pname
,
exe
=
None
):
def
process_exists
(
pname
,
exe
=
None
,
cmdline
=
None
):
try
:
import
psutil
pids
=
psutil
.
pids
()
...
...
@@ -1083,10 +1086,13 @@ def process_exists(pname,exe = None):
try
:
p
=
psutil
.
Process
(
pid
)
if
p
.
name
()
==
pname
:
if
not
exe
:
if
not
exe
and
not
cmdline
:
return
True
;
else
:
if
p
.
exe
()
==
exe
:
return
True
if
exe
:
if
p
.
exe
()
==
exe
:
return
True
if
cmdline
:
if
cmdline
in
p
.
cmdline
():
return
True
except
:
pass
return
False
except
:
return
True
...
...
@@ -1208,4 +1214,16 @@ def write_request_log():
log_data
[
'uri'
]
=
request
.
full_path
log_data
[
'user-agent'
]
=
request
.
headers
.
get
(
'User-Agent'
)
WriteFile
(
log_path
+
'/'
+
log_file
,
json
.
dumps
(
log_data
)
+
"
\n
"
,
'a+'
)
except
:
pass
\ No newline at end of file
except
:
pass
#重载模块
def
mod_reload
(
mode
):
if
not
mode
:
return
False
try
:
if
sys
.
version_info
[
0
]
==
2
:
reload
(
mode
)
else
:
import
imp
imp
.
reload
(
module
)
return
True
except
:
return
False
\ No newline at end of file
class/system.py
View file @
206af786
...
...
@@ -325,10 +325,9 @@ class system:
#取磁盘分区信息
diskIo
=
psutil
.
disk_partitions
();
diskInfo
=
[]
cuts
=
[
'/mnt/cdrom'
,
'/boot'
,
'/boot/efi'
,
'/dev'
,
'/dev/shm'
,
'/run/lock'
,
'/run'
,
'/run/shm'
,
'/run/user'
];
for
disk
in
diskIo
:
if
disk
[
1
]
==
'/mnt/cdrom'
:
continue
;
if
disk
[
1
]
==
'/boot'
:
continue
;
if
not
cuts
:
continue
tmp
=
{}
tmp
[
'path'
]
=
disk
[
1
]
tmp
[
'size'
]
=
psutil
.
disk_usage
(
disk
[
1
])
...
...
@@ -448,6 +447,9 @@ class system:
networkInfo
[
'cpu'
]
=
self
.
GetCpuInfo
()
networkInfo
[
'load'
]
=
self
.
GetLoadAverage
(
get
);
networkInfo
[
'mem'
]
=
self
.
GetMemInfo
(
get
)
networkInfo
[
'version'
]
=
session
[
'version'
]
#networkInfo['disk'] = self.GetDiskInfo2()
return
networkInfo
...
...
@@ -600,7 +602,7 @@ class system:
public
.
ExecShell
(
'/etc/init.d/httpd stop'
);
self
.
kill_port
()
result
=
public
.
ExecShell
(
'ulimit -n
10240
&& '
+
self
.
setupPath
+
'/apache/bin/apachectl -t'
);
result
=
public
.
ExecShell
(
'ulimit -n
8192
&& '
+
self
.
setupPath
+
'/apache/bin/apachectl -t'
);
if
result
[
1
]
.
find
(
'Syntax OK'
)
==
-
1
:
public
.
WriteLog
(
"TYPE_SOFT"
,
'SYS_EXEC_ERR'
,
(
str
(
result
),));
return
public
.
returnMsg
(
False
,
'SYS_CONF_APACHE_ERR'
,(
result
[
1
]
.
replace
(
"
\n
"
,
'<br>'
),));
...
...
@@ -619,7 +621,7 @@ class system:
public
.
ExecShell
(
'mkdir '
+
vhostPath
);
public
.
ExecShell
(
'/etc/init.d/nginx start'
);
result
=
public
.
ExecShell
(
'ulimit -n
10240
&& nginx -t -c '
+
self
.
setupPath
+
'/nginx/conf/nginx.conf'
);
result
=
public
.
ExecShell
(
'ulimit -n
8192
&& nginx -t -c '
+
self
.
setupPath
+
'/nginx/conf/nginx.conf'
);
if
result
[
1
]
.
find
(
'perserver'
)
!=
-
1
:
limit
=
self
.
setupPath
+
'/nginx/conf/nginx.conf'
;
nginxConf
=
public
.
readFile
(
limit
);
...
...
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