mirror of
https://github.com/midoks/mdserver-web.git
synced 2026-10-10 05:09:27 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f8bea1c812 | ||
|
|
4a83cfba83 | ||
|
|
199aec01ca | ||
|
|
65d6b5e360 | ||
|
|
dac412ad4e | ||
|
|
0f3aaf015a | ||
|
|
d48be332ca | ||
|
|
c943034145 | ||
|
|
e453a8fa79 | ||
|
|
b84b7ec0d0 | ||
|
|
22b3b1e90f | ||
|
|
d1eb61bb84 | ||
|
|
aba61490d4 | ||
|
|
298023f283 | ||
|
|
e5e55431ed | ||
|
|
13c3a20e84 | ||
|
|
b5a15244b3 | ||
|
|
cb446ae89c | ||
|
|
83ccf6ff24 | ||
|
|
1eb20f7cb6 | ||
|
|
34574a36f1 | ||
|
|
91c8d1f47a | ||
|
|
0e5760eaa2 | ||
|
|
81a25eeedf | ||
|
|
627c9efb44 | ||
|
|
e76db6c669 | ||
|
|
c44e901992 | ||
|
|
b88d03f316 | ||
|
|
ede3872627 | ||
|
|
29b50e057c | ||
|
|
ff75e0440f | ||
|
|
4ab8d5854b | ||
|
|
d555cdacb8 | ||
|
|
c704184884 | ||
|
|
9e58352fad | ||
|
|
0c7a32f372 | ||
|
|
604c5bc8a0 | ||
|
|
87c97694f7 | ||
|
|
aee7c53729 | ||
|
|
22e0ba7043 | ||
|
|
280de58a54 | ||
|
|
b6774d8656 | ||
|
|
268eb0eb2d | ||
|
|
fac0e1179b | ||
|
|
985c6f0a67 | ||
|
|
db1d9320bd | ||
|
|
0a110c4afa | ||
|
|
e436375090 | ||
|
|
8723ad9577 | ||
|
|
f8693c8cc3 | ||
|
|
1a1b0a59ee | ||
|
|
af22a68540 | ||
|
|
696df06794 | ||
|
|
9886e43335 | ||
|
|
3bd5886a6c | ||
|
|
aa071bfb15 | ||
|
|
98d3001861 | ||
|
|
36b55cc73c | ||
|
|
80f64066a7 | ||
|
|
a5ce95d831 | ||
|
|
b07409050a | ||
|
|
a2ee7c9092 | ||
|
|
f9c9c91490 | ||
|
|
dca43f812d | ||
|
|
d93329478d | ||
|
|
3d296e4099 | ||
|
|
b7f9485ff6 | ||
|
|
65bd3fefa9 | ||
|
|
5a4c831809 | ||
|
|
3c6ce19b3a | ||
|
|
cdb6966455 | ||
|
|
27c8142602 | ||
|
|
c04779efe2 | ||
|
|
be5a9f7b4b | ||
|
|
1564047a26 | ||
|
|
e561a909e7 | ||
|
|
3e06062784 | ||
|
|
65a2af748b | ||
|
|
febd9de71b | ||
|
|
870808b31b | ||
|
|
debfdabde9 | ||
|
|
6cf7152478 | ||
|
|
f75d121a59 | ||
|
|
407b5a619a | ||
|
|
b46bc89cb9 | ||
|
|
cb587b18bd | ||
|
|
8b67421c0c | ||
|
|
64f882c6b8 | ||
|
|
eb6590a275 | ||
|
|
595c238fb5 | ||
|
|
80d1e4efe7 | ||
|
|
8ee6f9d190 | ||
|
|
94a2f88633 | ||
|
|
605cf36e9c | ||
|
|
21194aa285 | ||
|
|
e3876de3d2 | ||
|
|
1e054f9801 | ||
|
|
df048c6bd6 | ||
|
|
3056fb9ceb | ||
|
|
bb655b55e5 | ||
|
|
97ab18a771 | ||
|
|
26760502d0 | ||
|
|
126c7e08e3 | ||
|
|
5e55cf753e | ||
|
|
da8b0ccbfc | ||
|
|
c746e8e139 | ||
|
|
0e2df5620e | ||
|
|
b1b43120ea | ||
|
|
e854cc083f | ||
|
|
791f2b8ec9 | ||
|
|
0c6b293337 | ||
|
|
da9b3bf435 | ||
|
|
301086faa1 | ||
|
|
3b6b54103b | ||
|
|
6dda90b64f | ||
|
|
d28fcce8b6 | ||
|
|
ba2da974c9 | ||
|
|
024f8bd62f | ||
|
|
fe7853781b | ||
|
|
d92010bfe0 | ||
|
|
2631f1771c | ||
|
|
4cf7a6b8fe | ||
|
|
af460ffed6 | ||
|
|
a7982c4df3 | ||
|
|
0850654da8 | ||
|
|
086e050914 | ||
|
|
4c57b9a2e6 | ||
|
|
ca7095c65a | ||
|
|
2c3f2e797d | ||
|
|
cccd3ff7fc | ||
|
|
effc3ba296 | ||
|
|
e96fdea003 | ||
|
|
00a43549a2 | ||
|
|
ebd09842a2 | ||
|
|
1eccc9cb7c | ||
|
|
a44df8dd9a | ||
|
|
58d78d5c5d | ||
|
|
9babeb4373 | ||
|
|
8345bd8bb5 | ||
|
|
9106246891 | ||
|
|
21209a75d8 | ||
|
|
3b6d50661b | ||
|
|
295cc70e0a | ||
|
|
c7fa266ae1 | ||
|
|
8788afc35f | ||
|
|
44c55ee923 | ||
|
|
2073fbd680 | ||
|
|
1b876d4cac | ||
|
|
0961b233e0 | ||
|
|
184bcf88d7 | ||
|
|
3f07a11b53 | ||
|
|
aa3a66cf01 | ||
|
|
0bc8f670f5 | ||
|
|
63cb8f0e84 | ||
|
|
5a17df7c5c | ||
|
|
3ce9735ff8 | ||
|
|
1819b814a3 | ||
|
|
f5c5bd03e6 | ||
|
|
04c6d4b3cc | ||
|
|
7e5116ba59 | ||
|
|
44d254415e | ||
|
|
0efba47c53 | ||
|
|
c7be9b7230 | ||
|
|
311310e04c | ||
|
|
59ca997372 | ||
|
|
27a96495ae | ||
|
|
cd1662761b | ||
|
|
4995131e24 | ||
|
|
ae9989a13f | ||
|
|
db143ea39f | ||
|
|
7582b0e6ba | ||
|
|
1ce6cbef51 | ||
|
|
e136330e36 | ||
|
|
346f09dabd | ||
|
|
0d56f1ab5f | ||
|
|
2f771b1f05 | ||
|
|
1862e68c52 | ||
|
|
aaca9cc654 | ||
|
|
bda83eb434 | ||
|
|
6f5838306d | ||
|
|
615e1b60b7 | ||
|
|
4300a532ba | ||
|
|
52c92183f5 | ||
|
|
feda58b8c4 | ||
|
|
a41d0b4553 | ||
|
|
68e9fa157d | ||
|
|
81f79582b5 | ||
|
|
552aa85eb6 | ||
|
|
5119e522d4 | ||
|
|
46f112fe7f | ||
|
|
2215c1bd38 | ||
|
|
aa38037087 | ||
|
|
b48efb4607 | ||
|
|
3c22dd6380 | ||
|
|
9127ed5220 | ||
|
|
a04c6b46af | ||
|
|
ed7bc1cdf3 | ||
|
|
6d191fc162 | ||
|
|
b14f22a0cf | ||
|
|
bb9fe44a0f | ||
|
|
ee6adfa83c | ||
|
|
8d990b3f96 | ||
|
|
9b0b5d1504 | ||
|
|
aac1cc30a5 | ||
|
|
e8f1cb4e02 | ||
|
|
f973794e4a | ||
|
|
062a8917cb | ||
|
|
3c412c91f7 | ||
|
|
b3f338e4e0 | ||
|
|
78f422c64a | ||
|
|
6f76846497 | ||
|
|
638426b81b | ||
|
|
a982e8a0e2 | ||
|
|
79a2954486 | ||
|
|
3e73314cb1 | ||
|
|
92e94ab4e9 | ||
|
|
1e0ec8e17e | ||
|
|
a1e0e95925 | ||
|
|
ceb1a7828a | ||
|
|
02beb55896 | ||
|
|
f53377cc7d | ||
|
|
02fbb7cdcf | ||
|
|
58059111c1 | ||
|
|
f51cc16500 | ||
|
|
1d6fa13a94 | ||
|
|
6924adbda3 | ||
|
|
983dde38d2 | ||
|
|
bda0753b77 | ||
|
|
93d9dbfd20 | ||
|
|
0a277b7e52 | ||
|
|
4825a1ca09 | ||
|
|
21dd6f39a8 | ||
|
|
261b85dbda | ||
|
|
4716cff256 | ||
|
|
d86c6ad6ee | ||
|
|
bd7906595a | ||
|
|
f00478cf17 | ||
|
|
1a24d11137 | ||
|
|
b8185e042f | ||
|
|
318cc79b8e | ||
|
|
389abf794f | ||
|
|
1d37ec38ee | ||
|
|
fd2a9223ff | ||
|
|
84e7da76b5 | ||
|
|
90d30df686 | ||
|
|
9fa9ed9f6e | ||
|
|
c26867c80b | ||
|
|
221a005fc7 | ||
|
|
7fb61a5121 | ||
|
|
6eadbcd53e | ||
|
|
b43da4eea8 | ||
|
|
1590e1061c | ||
|
|
3ac32665b8 | ||
|
|
97f01aeb74 | ||
|
|
92e3bd82ef | ||
|
|
ad2ce68a49 | ||
|
|
75f212bec7 | ||
|
|
13f6ee18f9 | ||
|
|
571d2056fb | ||
|
|
08ef87c77e | ||
|
|
5d2e7acc95 | ||
|
|
58e18e3ebb | ||
|
|
a4731e0053 | ||
|
|
db22749219 | ||
|
|
942c0023fb | ||
|
|
0b4fa3ea5c | ||
|
|
e23b15ccd1 | ||
|
|
0f515829fe | ||
|
|
95a3de24b3 | ||
|
|
154b543f82 | ||
|
|
3b3f22f4fa | ||
|
|
6cce72c966 | ||
|
|
2309d07d26 | ||
|
|
3617eb6028 | ||
|
|
9ce4de6237 | ||
|
|
02e8c98de0 | ||
|
|
566c6d3b24 | ||
|
|
0b8d662be1 | ||
|
|
71602d2440 | ||
|
|
212aea1fc3 | ||
|
|
8a5d8236e9 | ||
|
|
ad484adf2a | ||
|
|
04c2f9d155 | ||
|
|
d387e0ef22 | ||
|
|
dc74db0313 | ||
|
|
2bc336ea7d | ||
|
|
5b13be2dd9 | ||
|
|
f94db9bcdc | ||
|
|
da599b3947 | ||
|
|
f559e19da8 | ||
|
|
866fc68a81 | ||
|
|
546bd4f577 | ||
|
|
37bc9a71b3 | ||
|
|
fab204143a | ||
|
|
46a7f8d754 | ||
|
|
e0b1f8b622 | ||
|
|
ebf63d0fae | ||
|
|
53ed086f84 | ||
|
|
44555af3da | ||
|
|
042880b115 | ||
|
|
eb99b18bd3 | ||
|
|
eda0911a2e | ||
|
|
4a92866138 | ||
|
|
32f64b3dab | ||
|
|
3f94905735 | ||
|
|
e7b69c46a3 | ||
|
|
f1695efa6e | ||
|
|
cd4996477b | ||
|
|
6490610c30 | ||
|
|
49e2eb47ef | ||
|
|
34504e80a8 | ||
|
|
dccf70fef9 | ||
|
|
d74ed17e9e | ||
|
|
72b2da6558 | ||
|
|
7cbc4e0d38 | ||
|
|
23889fbe29 | ||
|
|
c44d9b4a52 | ||
|
|
1f00ebeefb | ||
|
|
a06d55531e | ||
|
|
7f5dcc2667 | ||
|
|
f1ec8ad714 | ||
|
|
b1a03e50b2 | ||
|
|
85c80cfe28 | ||
|
|
89d15a2f10 | ||
|
|
6225e77eb8 | ||
|
|
a1f03de98d | ||
|
|
c8105363df | ||
|
|
5f416ba2d4 | ||
|
|
bd6cb8f029 | ||
|
|
03e2b95305 | ||
|
|
a9a26a3b84 | ||
|
|
c89c4963a2 | ||
|
|
ec83257a27 | ||
|
|
853234c4b6 | ||
|
|
29f2a3ce7e | ||
|
|
6da5641263 | ||
|
|
2b7514c5b4 | ||
|
|
65ba422c77 | ||
|
|
5edf8b8dda | ||
|
|
6384c1bd13 | ||
|
|
53398031b1 | ||
|
|
060b2160aa | ||
|
|
b0d1586d78 | ||
|
|
0838f759a1 | ||
|
|
d3a539638e | ||
|
|
59abf77572 | ||
|
|
1467efa015 | ||
|
|
56dca95325 | ||
|
|
5d705246b9 | ||
|
|
5423046937 | ||
|
|
3068007aa8 | ||
|
|
a8f8e84ae3 | ||
|
|
3d66bb47bd | ||
|
|
cc3757e869 | ||
|
|
f6b9e2da54 | ||
|
|
f752d99e8b | ||
|
|
69947f5353 | ||
|
|
4d73843e00 | ||
|
|
f882c85e83 | ||
|
|
d9c886ce95 | ||
|
|
200bf07644 | ||
|
|
b981d89077 | ||
|
|
8ab69bf40f | ||
|
|
b7a2b6cbf8 | ||
|
|
d740ca4d2e | ||
|
|
1bb9613de1 | ||
|
|
73cf09e75e | ||
|
|
fb5c483b22 | ||
|
|
8d9126ea80 | ||
|
|
81ddf69370 | ||
|
|
0545fffd8c | ||
|
|
8fa6060729 | ||
|
|
63c3e513be | ||
|
|
5249658207 | ||
|
|
10585f6406 | ||
|
|
72d5939ec3 | ||
|
|
6c65e45d00 | ||
|
|
89e3940771 | ||
|
|
f802cc36d3 | ||
|
|
d938affe9b | ||
|
|
c1af2aaa63 | ||
|
|
1fec620adb | ||
|
|
245ee059a1 | ||
|
|
b39bf7e4d7 | ||
|
|
9533cc3960 | ||
|
|
8eebaebdf6 | ||
|
|
6bde23e737 | ||
|
|
1a61754255 | ||
|
|
9496ee401b | ||
|
|
e35b0ecf76 | ||
|
|
f2505df3d7 | ||
|
|
45e8c22825 | ||
|
|
f7115481dd | ||
|
|
b728766677 | ||
|
|
6912798076 | ||
|
|
667210fc24 | ||
|
|
b42710c0ed | ||
|
|
490df14a0a | ||
|
|
8e174f837d | ||
|
|
48c24c0126 | ||
|
|
bd352d946e | ||
|
|
d956531421 | ||
|
|
679c74b15a | ||
|
|
907e1ca275 | ||
|
|
caefc23670 | ||
|
|
53510581aa | ||
|
|
27b1d94a86 | ||
|
|
8e6edf8cd7 | ||
|
|
2651ed8ecb | ||
|
|
bffe9547ff | ||
|
|
d6cae70249 | ||
|
|
ff7e063f09 | ||
|
|
3b53bcbcdb | ||
|
|
497d6dd961 | ||
|
|
41d33eef54 | ||
|
|
2ff18a9cf9 | ||
|
|
0c43fcda07 | ||
|
|
d0bb505b3f | ||
|
|
a21cca51c3 | ||
|
|
30cb7516b1 | ||
|
|
06e6deff87 | ||
|
|
a4ce338088 | ||
|
|
45c7430af3 | ||
|
|
b0b34a6ea1 | ||
|
|
0fcada900b | ||
|
|
ca5729e26d | ||
|
|
22eed3f67b | ||
|
|
cd0799cc15 | ||
|
|
a0724c4fa9 | ||
|
|
0145d8db47 | ||
|
|
7ba4d2332d | ||
|
|
fb5e522a81 | ||
|
|
71dae04946 | ||
|
|
8418c3c3a0 | ||
|
|
94ac06b35c | ||
|
|
9fd6160571 | ||
|
|
4b9ffbe71f | ||
|
|
8018682049 | ||
|
|
f44ff2fb0d | ||
|
|
7a79388978 | ||
|
|
0d5af34b19 | ||
|
|
d05f5ebff8 | ||
|
|
4c64feef62 | ||
|
|
0491503774 | ||
|
|
fa67ee7e71 | ||
|
|
1ae0682d77 | ||
|
|
357749f22d | ||
|
|
9a078193bd | ||
|
|
fd9746b7ef | ||
|
|
a2de2b6ff1 | ||
|
|
970706028a | ||
|
|
ced6c480d1 | ||
|
|
d795097290 | ||
|
|
084a21a071 | ||
|
|
590a13256d |
@@ -1,4 +1,4 @@
|
||||
### mdserver-web 0.8.0
|
||||
### mdserver-web 0.8.6
|
||||
简单的Linux面板,感谢BT.CN写出如此好的web管理软件。我一看到,就知道这是我一直想要的页面化管理方式。
|
||||
复制了后台管理界面,按照自己想要的方式写了一版。
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
### 主要插件介绍
|
||||
* OpenResty - 轻量级,占有内存少,并发能力强。
|
||||
* PHP[53-74] - PHP是世界上最好的编程语言。
|
||||
* PHP[52-80] - PHP是世界上最好的编程语言。
|
||||
* MySQL - MySQL是一种关系数据库管理系统。
|
||||
* phpMyAdmin - 著名Web端MySQL管理工具。
|
||||
* Memcached - 一个高性能的分布式内存对象缓存系统。
|
||||
@@ -23,9 +23,9 @@
|
||||
* Gogs - 一款极易搭建的自助Git服务。
|
||||
* Rsyncd - 通用同步服务。
|
||||
|
||||
### 版本更新 0.8.0
|
||||
* 添加PHP74版本
|
||||
* 优化PHP及扩展安装脚本
|
||||
### 版本更新 0.8.6
|
||||
* mysql主从配置。
|
||||
* swap插件[虚拟内存]。
|
||||
|
||||
### 自动安装
|
||||
```
|
||||
|
||||
+20
-18
@@ -13,7 +13,7 @@ import re
|
||||
import hashlib
|
||||
from random import Random
|
||||
|
||||
import public
|
||||
import mw
|
||||
import db
|
||||
|
||||
from flask import redirect
|
||||
@@ -41,7 +41,7 @@ def checkClose():
|
||||
def initDB():
|
||||
try:
|
||||
sql = db.Sql().dbfile('default')
|
||||
csql = public.readFile('data/sql/default.sql')
|
||||
csql = mw.readFile('data/sql/default.sql')
|
||||
csql_list = csql.split(';')
|
||||
for index in range(len(csql_list)):
|
||||
sql.execute(csql_list[index], ())
|
||||
@@ -51,33 +51,35 @@ def initDB():
|
||||
|
||||
|
||||
def initInitD():
|
||||
script = public.getRunDir() + '/scripts/init.d/mw.tpl'
|
||||
script_bin = public.getRunDir() + '/scripts/init.d/mw'
|
||||
script = mw.getRunDir() + '/scripts/init.d/mw.tpl'
|
||||
script_bin = mw.getRunDir() + '/scripts/init.d/mw'
|
||||
# if os.path.exists(script_bin):
|
||||
# return
|
||||
|
||||
content = public.readFile(script)
|
||||
content = content.replace("{$SERVER_PATH}", public.getRunDir())
|
||||
content = mw.readFile(script)
|
||||
content = content.replace("{$SERVER_PATH}", mw.getRunDir())
|
||||
|
||||
public.writeFile(script_bin, content)
|
||||
public.execShell('chmod +x ' + script_bin)
|
||||
mw.writeFile(script_bin, content)
|
||||
mw.execShell('chmod +x ' + script_bin)
|
||||
|
||||
if not public.isAppleSystem():
|
||||
mw.setHostAddr(mw.getLocalIp())
|
||||
|
||||
if not mw.isAppleSystem():
|
||||
initd_bin = '/etc/init.d/mw'
|
||||
if not os.path.exists(initd_bin):
|
||||
import shutil
|
||||
shutil.copyfile(script_bin, initd_bin)
|
||||
public.execShell('chmod +x ' + initd_bin)
|
||||
#加入自启动
|
||||
public.execShell('chkconfig --add mw')
|
||||
mw.execShell('chmod +x ' + initd_bin)
|
||||
# 加入自启动
|
||||
mw.execShell('chkconfig --add mw')
|
||||
|
||||
|
||||
def initUserInfo():
|
||||
|
||||
data = public.M('users').where('id=?', (1,)).getField('password')
|
||||
data = mw.M('users').where('id=?', (1,)).getField('password')
|
||||
if data == '21232f297a57a5a743894a0e4a801fc3':
|
||||
pwd = public.getRandomString(8).lower()
|
||||
file_pw = public.getRunDir() + '/data/default.pl'
|
||||
public.writeFile(file_pw, pwd)
|
||||
public.M('users').where('id=?', (1,)).setField(
|
||||
'password', public.md5(pwd))
|
||||
pwd = mw.getRandomString(8).lower()
|
||||
file_pw = mw.getRunDir() + '/data/default.pl'
|
||||
mw.writeFile(file_pw, pwd)
|
||||
mw.M('users').where('id=?', (1,)).setField(
|
||||
'password', mw.md5(pwd))
|
||||
|
||||
+97
-96
@@ -4,7 +4,7 @@ import psutil
|
||||
import time
|
||||
import os
|
||||
import sys
|
||||
import public
|
||||
import mw
|
||||
import re
|
||||
import json
|
||||
import pwd
|
||||
@@ -17,7 +17,8 @@ class config_api:
|
||||
|
||||
# 本版解决自启动问题
|
||||
# 文件管理重命名
|
||||
__version = '0.8.0'
|
||||
# 优化计划任务管理
|
||||
__version = '0.8.6'
|
||||
|
||||
def __init__(self):
|
||||
pass
|
||||
@@ -26,9 +27,9 @@ class config_api:
|
||||
|
||||
# 取面板列表
|
||||
def getPanelListApi(self):
|
||||
data = public.M('panel').field(
|
||||
data = mw.M('panel').field(
|
||||
'id,title,url,username,password,click,addtime').order('click desc').select()
|
||||
return public.getJson(data)
|
||||
return mw.getJson(data)
|
||||
|
||||
def addPanelInfoApi(self):
|
||||
title = request.form.get('title', '')
|
||||
@@ -36,24 +37,24 @@ class config_api:
|
||||
username = request.form.get('username', '')
|
||||
password = request.form.get('password', '')
|
||||
# 校验是还是重复
|
||||
isAdd = public.M('panel').where(
|
||||
isAdd = mw.M('panel').where(
|
||||
'title=? OR url=?', (title, url)).count()
|
||||
if isAdd:
|
||||
return public.returnJson(False, '备注或面板地址重复!')
|
||||
isRe = public.M('panel').add('title,url,username,password,click,addtime',
|
||||
(title, url, username, password, 0, int(time.time())))
|
||||
return mw.returnJson(False, '备注或面板地址重复!')
|
||||
isRe = mw.M('panel').add('title,url,username,password,click,addtime',
|
||||
(title, url, username, password, 0, int(time.time())))
|
||||
if isRe:
|
||||
return public.returnJson(True, '添加成功!')
|
||||
return public.returnJson(False, '添加失败!')
|
||||
return mw.returnJson(True, '添加成功!')
|
||||
return mw.returnJson(False, '添加失败!')
|
||||
|
||||
# 删除面板资料
|
||||
def delPanelInfoApi(self):
|
||||
mid = request.form.get('id', '')
|
||||
isExists = public.M('panel').where('id=?', (mid,)).count()
|
||||
isExists = mw.M('panel').where('id=?', (mid,)).count()
|
||||
if not isExists:
|
||||
return public.returnJson(False, '指定面板资料不存在!')
|
||||
public.M('panel').where('id=?', (mid,)).delete()
|
||||
return public.returnJson(True, '删除成功!')
|
||||
return mw.returnJson(False, '指定面板资料不存在!')
|
||||
mw.M('panel').where('id=?', (mid,)).delete()
|
||||
return mw.returnJson(True, '删除成功!')
|
||||
|
||||
# 修改面板资料
|
||||
def setPanelInfoApi(self):
|
||||
@@ -63,51 +64,51 @@ class config_api:
|
||||
password = request.form.get('password', '')
|
||||
mid = request.form.get('id', '')
|
||||
# 校验是还是重复
|
||||
isSave = public.M('panel').where(
|
||||
isSave = mw.M('panel').where(
|
||||
'(title=? OR url=?) AND id!=?', (title, url, mid)).count()
|
||||
if isSave:
|
||||
return public.returnJson(False, '备注或面板地址重复!')
|
||||
return mw.returnJson(False, '备注或面板地址重复!')
|
||||
|
||||
# 更新到数据库
|
||||
isRe = public.M('panel').where('id=?', (mid,)).save(
|
||||
isRe = mw.M('panel').where('id=?', (mid,)).save(
|
||||
'title,url,username,password', (title, url, username, password))
|
||||
if isRe:
|
||||
return public.returnJson(True, '修改成功!')
|
||||
return public.returnJson(False, '修改失败!')
|
||||
return mw.returnJson(True, '修改成功!')
|
||||
return mw.returnJson(False, '修改失败!')
|
||||
|
||||
def syncDateApi(self):
|
||||
if public.isAppleSystem():
|
||||
return public.returnJson(True, '开发系统不必同步时间!')
|
||||
if mw.isAppleSystem():
|
||||
return mw.returnJson(True, '开发系统不必同步时间!')
|
||||
|
||||
data = public.execShell('ntpdate -s time.nist.gov')
|
||||
data = mw.execShell('ntpdate -s time.nist.gov')
|
||||
if data[0] == '':
|
||||
return public.returnJson(True, '同步成功!')
|
||||
return public.returnJson(False, '同步失败:' + data[0])
|
||||
return mw.returnJson(True, '同步成功!')
|
||||
return mw.returnJson(False, '同步失败:' + data[0])
|
||||
|
||||
def setPasswordApi(self):
|
||||
password1 = request.form.get('password1', '')
|
||||
password2 = request.form.get('password2', '')
|
||||
if password1 != password2:
|
||||
return public.returnJson(False, '两次输入的密码不一致,请重新输入!')
|
||||
return mw.returnJson(False, '两次输入的密码不一致,请重新输入!')
|
||||
if len(password1) < 5:
|
||||
return public.returnJson(False, '用户密码不能小于5位!')
|
||||
public.M('users').where("username=?", (session['username'],)).setField(
|
||||
'password', public.md5(password1.strip()))
|
||||
return public.returnJson(True, '密码修改成功!')
|
||||
return mw.returnJson(False, '用户密码不能小于5位!')
|
||||
mw.M('users').where("username=?", (session['username'],)).setField(
|
||||
'password', mw.md5(password1.strip()))
|
||||
return mw.returnJson(True, '密码修改成功!')
|
||||
|
||||
def setNameApi(self):
|
||||
name1 = request.form.get('name1', '')
|
||||
name2 = request.form.get('name2', '')
|
||||
if name1 != name2:
|
||||
return public.returnJson(False, '两次输入的用户名不一致,请重新输入!')
|
||||
return mw.returnJson(False, '两次输入的用户名不一致,请重新输入!')
|
||||
if len(name1) < 3:
|
||||
return public.returnJson(False, '用户名长度不能少于3位')
|
||||
return mw.returnJson(False, '用户名长度不能少于3位')
|
||||
|
||||
public.M('users').where("username=?", (session['username'],)).setField(
|
||||
mw.M('users').where("username=?", (session['username'],)).setField(
|
||||
'username', name1.strip())
|
||||
|
||||
session['username'] = name1
|
||||
return public.returnJson(True, '用户修改成功!')
|
||||
return mw.returnJson(True, '用户修改成功!')
|
||||
|
||||
def setApi(self):
|
||||
webname = request.form.get('webname', '')
|
||||
@@ -120,34 +121,34 @@ class config_api:
|
||||
if domain != '':
|
||||
reg = "^([\w\-\*]{1,100}\.){1,4}(\w{1,10}|\w{1,10}\.\w{1,10})$"
|
||||
if not re.match(reg, domain):
|
||||
return public.returnJson(False, '主域名格式不正确')
|
||||
return mw.returnJson(False, '主域名格式不正确')
|
||||
|
||||
if int(port) >= 65535 or int(port) < 100:
|
||||
return public.returnJson(False, '端口范围不正确!')
|
||||
return mw.returnJson(False, '端口范围不正确!')
|
||||
|
||||
if webname != public.getConfig('title'):
|
||||
public.setConfig('title', webname)
|
||||
if webname != mw.getConfig('title'):
|
||||
mw.setConfig('title', webname)
|
||||
|
||||
if sites_path != public.getWwwDir():
|
||||
public.setWwwDir(sites_path)
|
||||
if sites_path != mw.getWwwDir():
|
||||
mw.setWwwDir(sites_path)
|
||||
|
||||
if backup_path != public.getWwwDir():
|
||||
public.setBackupDir(backup_path)
|
||||
if backup_path != mw.getWwwDir():
|
||||
mw.setBackupDir(backup_path)
|
||||
|
||||
if port != public.getHostPort():
|
||||
if port != mw.getHostPort():
|
||||
import system_api
|
||||
public.setHostPort(port)
|
||||
mw.setHostPort(port)
|
||||
system_api.system_api().restartMw()
|
||||
|
||||
if host_ip != public.getHostAddr():
|
||||
public.setHostAddr(host_ip)
|
||||
if host_ip != mw.getHostAddr():
|
||||
mw.setHostAddr(host_ip)
|
||||
|
||||
mhost = public.getHostAddr()
|
||||
mhost = mw.getHostAddr()
|
||||
info = {
|
||||
'uri': '/config',
|
||||
'host': mhost + ':' + port
|
||||
}
|
||||
return public.returnJson(True, '保存成功!', info)
|
||||
return mw.returnJson(True, '保存成功!', info)
|
||||
|
||||
def setAdminPathApi(self):
|
||||
admin_path = request.form.get('admin_path', '').strip()
|
||||
@@ -159,59 +160,59 @@ class config_api:
|
||||
admin_path = '/'
|
||||
if admin_path != '/':
|
||||
if len(admin_path) < 6:
|
||||
return public.returnJson(False, '安全入口地址长度不能小于6位!')
|
||||
return mw.returnJson(False, '安全入口地址长度不能小于6位!')
|
||||
if admin_path in admin_path_checks:
|
||||
return public.returnJson(False, '该入口已被面板占用,请使用其它入口!')
|
||||
return mw.returnJson(False, '该入口已被面板占用,请使用其它入口!')
|
||||
if not re.match("^/[\w\./-_]+$", admin_path):
|
||||
return public.returnJson(False, '入口地址格式不正确,示例: /my_panel')
|
||||
return mw.returnJson(False, '入口地址格式不正确,示例: /my_panel')
|
||||
else:
|
||||
domain = public.readFile('data/domain.conf')
|
||||
domain = mw.readFile('data/domain.conf')
|
||||
if not domain:
|
||||
domain = ''
|
||||
limitip = public.readFile('data/limitip.conf')
|
||||
limitip = mw.readFile('data/limitip.conf')
|
||||
if not limitip:
|
||||
limitip = ''
|
||||
if not domain.strip() and not limitip.strip():
|
||||
return public.returnJson(False, '警告,关闭安全入口等于直接暴露你的后台地址在外网,十分危险,至少开启以下一种安全方式才能关闭:<a style="color:red;"><br>1、绑定访问域名<br>2、绑定授权IP</a>')
|
||||
return mw.returnJson(False, '警告,关闭安全入口等于直接暴露你的后台地址在外网,十分危险,至少开启以下一种安全方式才能关闭:<a style="color:red;"><br>1、绑定访问域名<br>2、绑定授权IP</a>')
|
||||
|
||||
admin_path_file = 'data/admin_path.pl'
|
||||
admin_path_old = '/'
|
||||
if os.path.exists(admin_path_file):
|
||||
admin_path_old = public.readFile(admin_path_file).strip()
|
||||
admin_path_old = mw.readFile(admin_path_file).strip()
|
||||
|
||||
if admin_path_old != admin_path:
|
||||
public.writeFile(admin_path_file, admin_path)
|
||||
public.restartMw()
|
||||
return public.returnJson(True, '修改成功!')
|
||||
mw.writeFile(admin_path_file, admin_path)
|
||||
mw.restartMw()
|
||||
return mw.returnJson(True, '修改成功!')
|
||||
|
||||
def closePanelApi(self):
|
||||
filename = 'data/close.pl'
|
||||
if os.path.exists(filename):
|
||||
os.remove(filename)
|
||||
return public.returnJson(True, '开启成功')
|
||||
public.writeFile(filename, 'True')
|
||||
public.execShell("chmod 600 " + filename)
|
||||
public.execShell("chown root.root " + filename)
|
||||
return public.returnJson(True, '面板已关闭!')
|
||||
return mw.returnJson(True, '开启成功')
|
||||
mw.writeFile(filename, 'True')
|
||||
mw.execShell("chmod 600 " + filename)
|
||||
mw.execShell("chown root.root " + filename)
|
||||
return mw.returnJson(True, '面板已关闭!')
|
||||
|
||||
def setIpv6StatusApi(self):
|
||||
ipv6_file = 'data/ipv6.pl'
|
||||
if os.path.exists('data/ipv6.pl'):
|
||||
os.remove(ipv6_file)
|
||||
public.writeLog('面板设置', '关闭面板IPv6兼容!')
|
||||
mw.writeLog('面板设置', '关闭面板IPv6兼容!')
|
||||
else:
|
||||
public.writeFile(ipv6_file, 'True')
|
||||
public.writeLog('面板设置', '开启面板IPv6兼容!')
|
||||
public.restartMw()
|
||||
return public.returnJson(True, '设置成功!')
|
||||
mw.writeFile(ipv6_file, 'True')
|
||||
mw.writeLog('面板设置', '开启面板IPv6兼容!')
|
||||
mw.restartMw()
|
||||
return mw.returnJson(True, '设置成功!')
|
||||
|
||||
# 获取面板证书
|
||||
def getPanelSslApi(self):
|
||||
cert = {}
|
||||
cert['privateKey'] = public.readFile('ssl/privateKey.pem')
|
||||
cert['certPem'] = public.readFile('ssl/certificate.pem')
|
||||
cert['privateKey'] = mw.readFile('ssl/privateKey.pem')
|
||||
cert['certPem'] = mw.readFile('ssl/certificate.pem')
|
||||
cert['rep'] = os.path.exists('ssl/input.pl')
|
||||
return public.getJson(cert)
|
||||
return mw.getJson(cert)
|
||||
|
||||
# 保存面板证书
|
||||
def savePanelSslApi(self):
|
||||
@@ -222,37 +223,37 @@ class config_api:
|
||||
certPem = request.form.get('certPem', '').strip()
|
||||
privateKey = request.form.get('privateKey', '').strip()
|
||||
|
||||
public.writeFile(checkCert, certPem)
|
||||
mw.writeFile(checkCert, certPem)
|
||||
if privateKey:
|
||||
public.writeFile(keyPath, privateKey)
|
||||
mw.writeFile(keyPath, privateKey)
|
||||
if certPem:
|
||||
public.writeFile(certPath, certPem)
|
||||
if not public.checkCert(checkCert):
|
||||
return public.returnJson(False, '证书错误,请检查!')
|
||||
public.writeFile('ssl/input.pl', 'True')
|
||||
return public.returnJson(True, '证书已保存!')
|
||||
mw.writeFile(certPath, certPem)
|
||||
if not mw.checkCert(checkCert):
|
||||
return mw.returnJson(False, '证书错误,请检查!')
|
||||
mw.writeFile('ssl/input.pl', 'True')
|
||||
return mw.returnJson(True, '证书已保存!')
|
||||
|
||||
# 设置面板SSL
|
||||
def setPanelSslApi(self):
|
||||
sslConf = public.getRunDir() + '/data/ssl.pl'
|
||||
sslConf = mw.getRunDir() + '/data/ssl.pl'
|
||||
if os.path.exists(sslConf):
|
||||
os.system('rm -f ' + sslConf)
|
||||
return public.returnJson(True, 'SSL已关闭,请使用http协议访问面板!')
|
||||
return mw.returnJson(True, 'SSL已关闭,请使用http协议访问面板!')
|
||||
else:
|
||||
os.system('pip install cffi==1.10')
|
||||
os.system('pip install cryptography==2.1')
|
||||
os.system('pip install pyOpenSSL==16.2')
|
||||
try:
|
||||
if not self.createSSL():
|
||||
return public.returnJson(False, '开启失败,无法自动安装pyOpenSSL组件!<p>请尝试手动安装: pip install pyOpenSSL</p>')
|
||||
public.writeFile(sslConf, 'True')
|
||||
return mw.returnJson(False, '开启失败,无法自动安装pyOpenSSL组件!<p>请尝试手动安装: pip install pyOpenSSL</p>')
|
||||
mw.writeFile(sslConf, 'True')
|
||||
except Exception as ex:
|
||||
return public.returnJson(False, '开启失败,无法自动安装pyOpenSSL组件!<p>请尝试手动安装: pip install pyOpenSSL</p>')
|
||||
return public.returnJson(True, '开启成功,请使用https协议访问面板!')
|
||||
return mw.returnJson(False, '开启失败,无法自动安装pyOpenSSL组件!<p>请尝试手动安装: pip install pyOpenSSL</p>')
|
||||
return mw.returnJson(True, '开启成功,请使用https协议访问面板!')
|
||||
|
||||
def getApi(self):
|
||||
data = {}
|
||||
return public.getJson(data)
|
||||
return mw.getJson(data)
|
||||
##### ----- end ----- ###
|
||||
|
||||
# 自签证书
|
||||
@@ -264,7 +265,7 @@ class config_api:
|
||||
key.generate_key(OpenSSL.crypto.TYPE_RSA, 2048)
|
||||
cert = OpenSSL.crypto.X509()
|
||||
cert.set_serial_number(0)
|
||||
cert.get_subject().CN = '120.27.27.98'
|
||||
cert.get_subject().CN = mw.getLocalIp()
|
||||
cert.set_issuer(cert.get_subject())
|
||||
cert.gmtime_adj_notBefore(0)
|
||||
cert.gmtime_adj_notAfter(86400 * 3650)
|
||||
@@ -275,8 +276,8 @@ class config_api:
|
||||
private_key = OpenSSL.crypto.dump_privatekey(
|
||||
OpenSSL.crypto.FILETYPE_PEM, key)
|
||||
if len(cert_ca) > 100 and len(private_key) > 100:
|
||||
public.writeFile('ssl/certificate.pem', cert_ca)
|
||||
public.writeFile('ssl/privateKey.pem', private_key)
|
||||
mw.writeFile('ssl/certificate.pem', cert_ca)
|
||||
mw.writeFile('ssl/privateKey.pem', private_key)
|
||||
print cert_ca, private_key
|
||||
return True
|
||||
return False
|
||||
@@ -287,20 +288,20 @@ class config_api:
|
||||
def get(self):
|
||||
|
||||
data = {}
|
||||
data['title'] = public.getConfig('title')
|
||||
data['site_path'] = public.getWwwDir()
|
||||
data['backup_path'] = public.getBackupDir()
|
||||
data['title'] = mw.getConfig('title')
|
||||
data['site_path'] = mw.getWwwDir()
|
||||
data['backup_path'] = mw.getBackupDir()
|
||||
sformat = 'date +"%Y-%m-%d %H:%M:%S %Z %z"'
|
||||
data['systemdate'] = public.execShell(sformat)[0].strip()
|
||||
data['systemdate'] = mw.execShell(sformat)[0].strip()
|
||||
|
||||
data['port'] = public.getHostPort()
|
||||
data['ip'] = public.getHostAddr()
|
||||
data['port'] = mw.getHostPort()
|
||||
data['ip'] = mw.getHostAddr()
|
||||
|
||||
admin_path_file = 'data/admin_path.pl'
|
||||
if not os.path.exists(admin_path_file):
|
||||
data['admin_path'] = '/'
|
||||
else:
|
||||
data['admin_path'] = public.readFile(admin_path_file)
|
||||
data['admin_path'] = mw.readFile(admin_path_file)
|
||||
|
||||
ipv6_file = 'data/ipv6.pl'
|
||||
if os.path.exists('data/ipv6.pl'):
|
||||
@@ -314,9 +315,9 @@ class config_api:
|
||||
else:
|
||||
data['ssl'] = ''
|
||||
|
||||
data['site_count'] = public.M('sites').count()
|
||||
data['site_count'] = mw.M('sites').count()
|
||||
|
||||
data['username'] = public.M('users').where(
|
||||
data['username'] = mw.M('users').where(
|
||||
"id=?", (1,)).getField('username')
|
||||
|
||||
return data
|
||||
|
||||
+111
-101
@@ -4,7 +4,7 @@ import psutil
|
||||
import time
|
||||
import os
|
||||
import sys
|
||||
import public
|
||||
import mw
|
||||
import re
|
||||
import json
|
||||
import pwd
|
||||
@@ -21,62 +21,71 @@ class crontab_api:
|
||||
|
||||
##### ----- start ----- ###
|
||||
def listApi(self):
|
||||
_list = public.M('crontab').where('', ()).field(self.field).limit(
|
||||
'0,5').order('id desc').select()
|
||||
p = request.args.get('p', 1)
|
||||
psize = 10
|
||||
|
||||
startPage = (int(p) - 1) * psize
|
||||
pageInfo = str(startPage) + ',' + str(psize)
|
||||
|
||||
_list = mw.M('crontab').where('', ()).field(
|
||||
self.field).limit(pageInfo).order('id desc').select()
|
||||
|
||||
data = []
|
||||
for i in range(len(_list)):
|
||||
tmp = _list[i]
|
||||
if _list[i]['type'] == "day":
|
||||
tmp['type'] = '每天'
|
||||
tmp['cycle'] = public.getInfo('每天, {1}点{2}分 执行', (str(
|
||||
tmp['cycle'] = mw.getInfo('每天, {1}点{2}分 执行', (str(
|
||||
_list[i]['where_hour']), str(_list[i]['where_minute'])))
|
||||
elif _list[i]['type'] == "day-n":
|
||||
tmp['type'] = public.getInfo(
|
||||
tmp['type'] = mw.getInfo(
|
||||
'每{1}天', (str(_list[i]['where1']),))
|
||||
tmp['cycle'] = public.getInfo('每隔{1}天, {2}点{3}分 执行', (str(
|
||||
tmp['cycle'] = mw.getInfo('每隔{1}天, {2}点{3}分 执行', (str(
|
||||
_list[i]['where1']), str(_list[i]['where_hour']), str(_list[i]['where_minute'])))
|
||||
elif _list[i]['type'] == "hour":
|
||||
tmp['type'] = '每小时'
|
||||
tmp['cycle'] = public.getInfo(
|
||||
tmp['cycle'] = mw.getInfo(
|
||||
'每小时, 第{1}分钟 执行', (str(_list[i]['where_minute']),))
|
||||
elif _list[i]['type'] == "hour-n":
|
||||
tmp['type'] = public.getInfo(
|
||||
tmp['type'] = mw.getInfo(
|
||||
'每{1}小时', (str(_list[i]['where1']),))
|
||||
tmp['cycle'] = public.getInfo('每{1}小时, 第{2}分钟 执行', (str(
|
||||
tmp['cycle'] = mw.getInfo('每{1}小时, 第{2}分钟 执行', (str(
|
||||
_list[i]['where1']), str(_list[i]['where_minute'])))
|
||||
elif _list[i]['type'] == "minute-n":
|
||||
tmp['type'] = public.getInfo(
|
||||
tmp['type'] = mw.getInfo(
|
||||
'每{1}分钟', (str(_list[i]['where1']),))
|
||||
tmp['cycle'] = public.getInfo(
|
||||
tmp['cycle'] = mw.getInfo(
|
||||
'每隔{1}分钟执行', (str(_list[i]['where1']),))
|
||||
elif _list[i]['type'] == "week":
|
||||
tmp['type'] = '每周'
|
||||
if not _list[i]['where1']:
|
||||
_list[i]['where1'] = '0'
|
||||
tmp['cycle'] = public.getInfo('每周{1}, {2}点{3}分执行', (self.toWeek(int(
|
||||
tmp['cycle'] = mw.getInfo('每周{1}, {2}点{3}分执行', (self.toWeek(int(
|
||||
_list[i]['where1'])), str(_list[i]['where_hour']), str(_list[i]['where_minute'])))
|
||||
elif _list[i]['type'] == "month":
|
||||
tmp['type'] = '每月'
|
||||
tmp['cycle'] = public.getInfo('每月, {1}日 {2}点{3}分执行', (str(_list[i]['where1']), str(
|
||||
tmp['cycle'] = mw.getInfo('每月, {1}日 {2}点{3}分执行', (str(_list[i]['where1']), str(
|
||||
_list[i]['where_hour']), str(_list[i]['where_minute'])))
|
||||
data.append(tmp)
|
||||
|
||||
_ret = {}
|
||||
_ret['data'] = data
|
||||
|
||||
count = public.M('crontab').where('', ()).count()
|
||||
count = mw.M('crontab').where('', ()).count()
|
||||
_page = {}
|
||||
_page['count'] = count
|
||||
_page['tojs'] = 'remind'
|
||||
_page['p'] = p
|
||||
_page['row'] = psize
|
||||
_page['tojs'] = "getCronData"
|
||||
|
||||
_ret['page'] = public.getPage(_page)
|
||||
return public.getJson(_ret)
|
||||
_ret['list'] = mw.getPage(_page)
|
||||
_ret['p'] = p
|
||||
return mw.getJson(_ret)
|
||||
|
||||
# 设置计划任务状态
|
||||
def setCronStatusApi(self):
|
||||
mid = request.form.get('id', '')
|
||||
cronInfo = public.M('crontab').where(
|
||||
cronInfo = mw.M('crontab').where(
|
||||
'id=?', (mid,)).field(self.field).find()
|
||||
status = 1
|
||||
if cronInfo['status'] == status:
|
||||
@@ -86,17 +95,17 @@ class crontab_api:
|
||||
cronInfo['status'] = 1
|
||||
self.syncToCrond(cronInfo)
|
||||
|
||||
public.M('crontab').where('id=?', (mid,)).setField('status', status)
|
||||
public.writeLog(
|
||||
mw.M('crontab').where('id=?', (mid,)).setField('status', status)
|
||||
mw.writeLog(
|
||||
'计划任务', '修改计划任务[' + cronInfo['name'] + ']状态为[' + str(status) + ']')
|
||||
return public.returnJson(True, '设置成功')
|
||||
return mw.returnJson(True, '设置成功')
|
||||
|
||||
# 获取指定任务数据
|
||||
def getCrondFindApi(self):
|
||||
sid = request.form.get('id', '')
|
||||
data = public.M('crontab').where(
|
||||
data = mw.M('crontab').where(
|
||||
'id=?', (sid,)).field(self.field).find()
|
||||
return public.getJson(data)
|
||||
return mw.getJson(data)
|
||||
|
||||
def modifyCrondApi(self):
|
||||
sid = request.form.get('id', '')
|
||||
@@ -114,7 +123,7 @@ class crontab_api:
|
||||
urladdress = request.form.get('urladdress', '')
|
||||
|
||||
if len(iname) < 1:
|
||||
return public.returnJson(False, '任务名称不能为空!')
|
||||
return mw.returnJson(False, '任务名称不能为空!')
|
||||
|
||||
params = {
|
||||
'name': iname,
|
||||
@@ -131,7 +140,7 @@ class crontab_api:
|
||||
'urladdress': urladdress,
|
||||
}
|
||||
cuonConfig, get, name = self.getCrondCycle(params)
|
||||
cronInfo = public.M('crontab').where(
|
||||
cronInfo = mw.M('crontab').where(
|
||||
'id=?', (sid,)).field(self.field).find()
|
||||
del(cronInfo['id'])
|
||||
del(cronInfo['addtime'])
|
||||
@@ -145,21 +154,21 @@ class crontab_api:
|
||||
cronInfo['sbody'] = get['sbody']
|
||||
cronInfo['urladdress'] = get['urladdress']
|
||||
|
||||
addData = public.M('crontab').where('id=?', (sid,)).save('name,type,where1,where_hour,where_minute,save,backup_to,sbody,urladdress', (get[
|
||||
addData = mw.M('crontab').where('id=?', (sid,)).save('name,type,where1,where_hour,where_minute,save,backup_to,sbody,urladdress', (get[
|
||||
'name'], field_type, get['where1'], get['hour'], get['minute'], get['save'], get['backup_to'], get['sbody'], get['urladdress']))
|
||||
self.removeForCrond(cronInfo['echo'])
|
||||
self.syncToCrond(cronInfo)
|
||||
public.writeLog('计划任务', '修改计划任务[' + cronInfo['name'] + ']成功')
|
||||
return public.returnJson(True, '修改成功')
|
||||
mw.writeLog('计划任务', '修改计划任务[' + cronInfo['name'] + ']成功')
|
||||
return mw.returnJson(True, '修改成功')
|
||||
|
||||
def logsApi(self):
|
||||
sid = request.form.get('id', '')
|
||||
echo = public.M('crontab').where("id=?", (sid,)).field('echo').find()
|
||||
logFile = public.getServerDir() + '/cron/' + echo['echo'] + '.log'
|
||||
echo = mw.M('crontab').where("id=?", (sid,)).field('echo').find()
|
||||
logFile = mw.getServerDir() + '/cron/' + echo['echo'] + '.log'
|
||||
if not os.path.exists(logFile):
|
||||
return public.returnJson(False, '当前日志为空!')
|
||||
log = public.getNumLines(logFile, 2000)
|
||||
return public.returnJson(True, log)
|
||||
return mw.returnJson(False, '当前日志为空!')
|
||||
log = mw.getNumLines(logFile, 500)
|
||||
return mw.returnJson(True, log)
|
||||
|
||||
def addApi(self):
|
||||
iname = request.form.get('name', '')
|
||||
@@ -176,7 +185,7 @@ class crontab_api:
|
||||
urladdress = request.form.get('urladdress', '')
|
||||
|
||||
if len(iname) < 1:
|
||||
return public.returnJson(False, '任务名称不能为空!')
|
||||
return mw.returnJson(False, '任务名称不能为空!')
|
||||
|
||||
params = {
|
||||
'name': iname,
|
||||
@@ -194,49 +203,50 @@ class crontab_api:
|
||||
}
|
||||
|
||||
# print params
|
||||
cuonConfig, get, name = self.getCrondCycle(params)
|
||||
cronPath = public.getServerDir() + '/cron'
|
||||
cronConfig, get, name = self.getCrondCycle(params)
|
||||
cronPath = mw.getServerDir() + '/cron'
|
||||
|
||||
cronName = self.getShell(params)
|
||||
# print cuonConfig, _params, name
|
||||
# print cronPath, cronName
|
||||
# print stype
|
||||
# print cronConfig, _params, name
|
||||
# print 'vv', cronPath, cronName
|
||||
# print 'stype', stype
|
||||
|
||||
if type(cronName) == dict:
|
||||
return cronName
|
||||
|
||||
cuonConfig += ' ' + cronPath + '/' + cronName + \
|
||||
cronConfig += ' ' + cronPath + '/' + cronName + \
|
||||
' >> ' + cronPath + '/' + cronName + '.log 2>&1'
|
||||
wRes = self.writeShell(cuonConfig)
|
||||
|
||||
if type(wRes) != bool:
|
||||
return wRes
|
||||
if not mw.isAppleSystem():
|
||||
wRes = self.writeShell(cronConfig)
|
||||
if type(wRes) != bool:
|
||||
return wRes
|
||||
self.crondReload()
|
||||
|
||||
self.crondReload()
|
||||
addData = public.M('crontab').add('name,type,where1,where_hour,where_minute,echo,addtime,status,save,backup_to,stype,sname,sbody,urladdress', (iname, field_type, where1, hour, minute, cronName, time.strftime(
|
||||
addData = mw.M('crontab').add('name,type,where1,where_hour,where_minute,echo,addtime,status,save,backup_to,stype,sname,sbody,urladdress', (iname, field_type, where1, hour, minute, cronName, time.strftime(
|
||||
'%Y-%m-%d %X', time.localtime()), 1, save, backup_to, stype, sname, sbody, urladdress))
|
||||
|
||||
if addData > 0:
|
||||
return public.returnJson(True, '添加成功')
|
||||
return public.returnJson(False, '添加失败')
|
||||
return mw.returnJson(True, '添加成功')
|
||||
return mw.returnJson(False, '添加失败')
|
||||
|
||||
def startTaskApi(self):
|
||||
sid = request.form.get('id', '')
|
||||
echo = public.M('crontab').where('id=?', (sid,)).getField('echo')
|
||||
execstr = public.getServerDir() + '/cron/' + echo
|
||||
echo = mw.M('crontab').where('id=?', (sid,)).getField('echo')
|
||||
execstr = mw.getServerDir() + '/cron/' + echo
|
||||
os.system('chmod +x ' + execstr)
|
||||
os.system('nohup ' + execstr + ' >> ' + execstr + '.log 2>&1 &')
|
||||
return public.returnJson(True, '任务已执行!')
|
||||
return mw.returnJson(True, '任务已执行!')
|
||||
|
||||
def delApi(self):
|
||||
sid = request.form.get('id', '')
|
||||
try:
|
||||
find = public.M('crontab').where(
|
||||
find = mw.M('crontab').where(
|
||||
"id=?", (sid,)).field('name,echo').find()
|
||||
if not self.removeForCrond(find['echo']):
|
||||
return public.returnJson(False, '无法写入文件,请检查是否开启了系统加固功能!')
|
||||
return mw.returnJson(False, '无法写入文件,请检查是否开启了系统加固功能!')
|
||||
|
||||
cronPath = public.getServerDir() + '/cron'
|
||||
cronPath = mw.getServerDir() + '/cron'
|
||||
sfile = cronPath + '/' + find['echo']
|
||||
|
||||
if os.path.exists(sfile):
|
||||
@@ -245,22 +255,22 @@ class crontab_api:
|
||||
if os.path.exists(sfile):
|
||||
os.remove(sfile)
|
||||
|
||||
public.M('crontab').where("id=?", (sid,)).delete()
|
||||
public.writeLog('计划任务', public.getInfo(
|
||||
mw.M('crontab').where("id=?", (sid,)).delete()
|
||||
mw.writeLog('计划任务', mw.getInfo(
|
||||
'删除计划任务[{1}]成功!', (find['name'],)))
|
||||
return public.returnJson(True, '删除成功')
|
||||
return mw.returnJson(True, '删除成功')
|
||||
except Exception as e:
|
||||
return public.returnJson(False, '删除失败:' + str(e))
|
||||
return mw.returnJson(False, '删除失败:' + str(e))
|
||||
|
||||
def delLogsApi(self):
|
||||
sid = request.form.get('id', '')
|
||||
try:
|
||||
echo = public.M('crontab').where("id=?", (sid,)).getField('echo')
|
||||
logFile = public.getServerDir() + '/cron/' + echo + '.log'
|
||||
echo = mw.M('crontab').where("id=?", (sid,)).getField('echo')
|
||||
logFile = mw.getServerDir() + '/cron/' + echo + '.log'
|
||||
os.remove(logFile)
|
||||
return public.returnJson(True, '任务日志已清空!')
|
||||
return mw.returnJson(True, '任务日志已清空!')
|
||||
except:
|
||||
return public.returnJson(False, '任务日志清空失败!')
|
||||
return mw.returnJson(False, '任务日志清空失败!')
|
||||
|
||||
# 取数据列表
|
||||
def getDataListApi(self):
|
||||
@@ -268,19 +278,19 @@ class crontab_api:
|
||||
if stype == 'databases':
|
||||
db_list = {}
|
||||
db_list['orderOpt'] = []
|
||||
path = public.getServerDir() + '/mysql'
|
||||
path = mw.getServerDir() + '/mysql'
|
||||
if not os.path.exists(path + '/mysql.db'):
|
||||
db_list['data'] = []
|
||||
else:
|
||||
db_list['data'] = public.M('databases').dbPos(
|
||||
db_list['data'] = mw.M('databases').dbPos(
|
||||
path, 'mysql').field('name,ps').select()
|
||||
return public.getJson(db_list)
|
||||
return mw.getJson(db_list)
|
||||
|
||||
data = {}
|
||||
data['data'] = public.M(stype).field('name,ps').select()
|
||||
data['data'] = mw.M(stype).field('name,ps').select()
|
||||
data['orderOpt'] = []
|
||||
# try:
|
||||
# tmp = public.readFile('data/libList.conf')
|
||||
# tmp = mw.readFile('data/libList.conf')
|
||||
# libs = json.loads(tmp)
|
||||
# import imp
|
||||
# for lib in libs:
|
||||
@@ -291,7 +301,7 @@ class crontab_api:
|
||||
# data['orderOpt'].append(tmp)
|
||||
# except Exception as e:
|
||||
# print e
|
||||
return public.getJson(data)
|
||||
return mw.getJson(data)
|
||||
##### ----- start ----- ###
|
||||
|
||||
# 转换大写星期
|
||||
@@ -318,7 +328,7 @@ class crontab_api:
|
||||
name = '每天'
|
||||
elif params['type'] == "day-n":
|
||||
cuonConfig = self.getDay_N(params)
|
||||
name = public.getInfo('每{1}天', (params['where1'],))
|
||||
name = mw.getInfo('每{1}天', (params['where1'],))
|
||||
elif params['type'] == "hour":
|
||||
cuonConfig = self.getHour(params)
|
||||
name = '每小时'
|
||||
@@ -384,24 +394,24 @@ class crontab_api:
|
||||
log = '.log'
|
||||
|
||||
wheres = {
|
||||
'path': head + "python " + public.getServerDir() + "/mdserver-web/scripts/backup.py path " + param['sname'] + " " + str(param['save']),
|
||||
'site': head + "python " + public.getServerDir() + "/mdserver-web/scripts/backup.py site " + param['sname'] + " " + str(param['save']),
|
||||
'database': head + "python " + public.getServerDir() + "/mdserver-web/scripts/backup.py database " + param['sname'] + " " + str(param['save']),
|
||||
'logs': head + "python " + public.getServerDir() + "/mdserver-web/scripts/logs_backup.py " + param['sname'] + log + " " + str(param['save']),
|
||||
'rememory': head + "/bin/bash " + public.getServerDir() + '/mdserver-web/scripts/rememory.sh'
|
||||
'path': head + "python " + mw.getServerDir() + "/mdserver-web/scripts/backup.py path " + param['sname'] + " " + str(param['save']),
|
||||
'site': head + "python " + mw.getServerDir() + "/mdserver-web/scripts/backup.py site " + param['sname'] + " " + str(param['save']),
|
||||
'database': head + "python " + mw.getServerDir() + "/mdserver-web/scripts/backup.py database " + param['sname'] + " " + str(param['save']),
|
||||
'logs': head + "python " + mw.getServerDir() + "/mdserver-web/scripts/logs_backup.py " + param['sname'] + log + " " + str(param['save']),
|
||||
'rememory': head + "/bin/bash " + mw.getServerDir() + '/mdserver-web/scripts/rememory.sh'
|
||||
}
|
||||
if param['backup_to'] != 'localhost':
|
||||
cfile = public.getServerDir() + "/mdserver-web/plugin/" + param[
|
||||
cfile = mw.getServerDir() + "/mdserver-web/plugin/" + param[
|
||||
'backup_to'] + "/" + param['backup_to'] + "_main.py"
|
||||
if not os.path.exists(cfile):
|
||||
cfile = public.getServerDir() + "/mdserver-web/script/backup_" + \
|
||||
cfile = mw.getServerDir() + "/mdserver-web/script/backup_" + \
|
||||
param['backup_to'] + ".py"
|
||||
wheres = {
|
||||
'path': head + "python " + cfile + " path " + param['sname'] + " " + str(param['save']),
|
||||
'site': head + "python " + cfile + " site " + param['sname'] + " " + str(param['save']),
|
||||
'database': head + "python " + cfile + " database " + param['sname'] + " " + str(param['save']),
|
||||
'logs': head + "python " + public.getServerDir() + "/mdserver-web/scripts/logs_backup.py " + param['sname'] + log + " " + str(param['save']),
|
||||
'rememory': head + "/bin/bash " + public.getServerDir() + '/mdserver-web/scripts/rememory.sh'
|
||||
'logs': head + "python " + mw.getServerDir() + "/mdserver-web/scripts/logs_backup.py " + param['sname'] + log + " " + str(param['save']),
|
||||
'rememory': head + "/bin/bash " + mw.getServerDir() + '/mdserver-web/scripts/rememory.sh'
|
||||
}
|
||||
try:
|
||||
shell = wheres[stype]
|
||||
@@ -418,16 +428,16 @@ endDate=`date +"%Y-%m-%d %H:%M:%S"`
|
||||
echo "★[$endDate] Successful"
|
||||
echo "----------------------------------------------------------------------------"
|
||||
'''
|
||||
cronPath = public.getServerDir() + '/cron'
|
||||
cronPath = mw.getServerDir() + '/cron'
|
||||
if not os.path.exists(cronPath):
|
||||
public.execShell('mkdir -p ' + cronPath)
|
||||
mw.execShell('mkdir -p ' + cronPath)
|
||||
if not 'echo' in param:
|
||||
cronName = public.md5(public.md5(str(time.time()) + '_mw'))
|
||||
cronName = mw.md5(mw.md5(str(time.time()) + '_mw'))
|
||||
else:
|
||||
cronName = param['echo']
|
||||
file = cronPath + '/' + cronName
|
||||
public.writeFile(file, self.checkScript(shell))
|
||||
public.execShell('chmod 750 ' + file)
|
||||
mw.writeFile(file, self.checkScript(shell))
|
||||
mw.execShell('chmod 750 ' + file)
|
||||
return cronName
|
||||
|
||||
# 检查脚本
|
||||
@@ -443,52 +453,52 @@ echo "--------------------------------------------------------------------------
|
||||
u_file = '/var/spool/cron/crontabs/root'
|
||||
if not os.path.exists(u_file):
|
||||
file = '/var/spool/cron/root'
|
||||
if public.isAppleSystem():
|
||||
if mw.isAppleSystem():
|
||||
file = '/etc/crontab'
|
||||
else:
|
||||
file = u_file
|
||||
|
||||
if not os.path.exists(file):
|
||||
public.writeFile(file, '')
|
||||
conf = public.readFile(file)
|
||||
conf += config + "\n"
|
||||
if public.writeFile(file, conf):
|
||||
mw.writeFile(file, '')
|
||||
conf = mw.readFile(file)
|
||||
conf += str(config) + "\n"
|
||||
if mw.writeFile(file, conf):
|
||||
if not os.path.exists(u_file):
|
||||
public.execShell("chmod 600 '" + file +
|
||||
"' && chown root.root " + file)
|
||||
mw.execShell("chmod 600 '" + file +
|
||||
"' && chown root.root " + file)
|
||||
else:
|
||||
public.execShell("chmod 600 '" + file +
|
||||
"' && chown root.crontab " + file)
|
||||
mw.execShell("chmod 600 '" + file +
|
||||
"' && chown root.crontab " + file)
|
||||
return True
|
||||
return public.returnJson(False, '文件写入失败,请检查是否开启系统加固功能!')
|
||||
return mw.returnJson(False, '文件写入失败,请检查是否开启系统加固功能!')
|
||||
|
||||
# 重载配置
|
||||
def crondReload(self):
|
||||
if public.isAppleSystem():
|
||||
if mw.isAppleSystem():
|
||||
if os.path.exists('/etc/crontab'):
|
||||
pass
|
||||
# public.execShell('/usr/sbin/cron restart')
|
||||
# mw.execShell('/usr/sbin/cron restart')
|
||||
else:
|
||||
if os.path.exists('/etc/init.d/crond'):
|
||||
public.execShell('/etc/init.d/crond reload')
|
||||
mw.execShell('/etc/init.d/crond reload')
|
||||
elif os.path.exists('/etc/init.d/cron'):
|
||||
public.execShell('service cron restart')
|
||||
mw.execShell('service cron restart')
|
||||
else:
|
||||
public.execShell("systemctl reload crond")
|
||||
mw.execShell("systemctl reload crond")
|
||||
|
||||
# 从crond删除
|
||||
def removeForCrond(self, echo):
|
||||
u_file = '/var/spool/cron/crontabs/root'
|
||||
if not os.path.exists(u_file):
|
||||
file = '/var/spool/cron/root'
|
||||
if public.isAppleSystem():
|
||||
if mw.isAppleSystem():
|
||||
file = '/etc/crontab'
|
||||
else:
|
||||
file = u_file
|
||||
conf = public.readFile(file)
|
||||
conf = mw.readFile(file)
|
||||
rep = ".+" + str(echo) + ".+\n"
|
||||
conf = re.sub(rep, "", conf)
|
||||
if not public.writeFile(file, conf):
|
||||
if not mw.writeFile(file, conf):
|
||||
return False
|
||||
self.crondReload()
|
||||
return True
|
||||
@@ -502,7 +512,7 @@ echo "--------------------------------------------------------------------------
|
||||
cronInfo['minute'] = cronInfo['where_minute']
|
||||
cronInfo['week'] = cronInfo['where1']
|
||||
cuonConfig, cronInfo, name = self.getCrondCycle(cronInfo)
|
||||
cronPath = public.getServerDir() + '/cron'
|
||||
cronPath = mw.getServerDir() + '/cron'
|
||||
cronName = self.getShell(cronInfo)
|
||||
if type(cronName) == dict:
|
||||
return cronName
|
||||
|
||||
+6
-6
@@ -194,8 +194,8 @@ class Sql():
|
||||
opt = opt[0:len(opt) - 1]
|
||||
sql = "UPDATE " + self.__DB_TABLE + " SET " + opt + self.__OPT_WHERE
|
||||
|
||||
import public
|
||||
public.writeFile('/tmp/test.pl', sql)
|
||||
import mw
|
||||
mw.writeFile('/tmp/test.pl', sql)
|
||||
|
||||
# 处理拼接WHERE与UPDATE参数
|
||||
tmp = list(param)
|
||||
@@ -249,8 +249,8 @@ class Sql():
|
||||
def create(self, name):
|
||||
# 创建数据表
|
||||
self.__GetConn()
|
||||
import public
|
||||
script = public.readFile('data/' + name + '.sql')
|
||||
import mw
|
||||
script = mw.readFile('data/' + name + '.sql')
|
||||
result = self.__DB_CONN.executescript(script)
|
||||
self.__DB_CONN.commit()
|
||||
return result.rowcount
|
||||
@@ -258,8 +258,8 @@ class Sql():
|
||||
def fofile(self, filename):
|
||||
# 执行脚本
|
||||
self.__GetConn()
|
||||
import public
|
||||
script = public.readFile(filename)
|
||||
import mw
|
||||
script = mw.readFile(filename)
|
||||
result = self.__DB_CONN.executescript(script)
|
||||
self.__DB_CONN.commit()
|
||||
return result.rowcount
|
||||
|
||||
+143
-143
@@ -4,7 +4,7 @@ import psutil
|
||||
import time
|
||||
import os
|
||||
import sys
|
||||
import public
|
||||
import mw
|
||||
import re
|
||||
import json
|
||||
import pwd
|
||||
@@ -21,7 +21,7 @@ class files_api:
|
||||
rPath = None
|
||||
|
||||
def __init__(self):
|
||||
self.rPath = public.getRootDir() + '/recycle_bin/'
|
||||
self.rPath = mw.getRootDir() + '/recycle_bin/'
|
||||
|
||||
##### ----- start ----- ###
|
||||
def getBodyApi(self):
|
||||
@@ -33,13 +33,13 @@ class files_api:
|
||||
line = request.form.get('line', '100')
|
||||
|
||||
if not os.path.exists(path):
|
||||
return public.returnJson(False, '文件不存在', (path,))
|
||||
return mw.returnJson(False, '文件不存在', (path,))
|
||||
|
||||
try:
|
||||
data = public.getNumLines(path, int(line))
|
||||
return public.returnJson(True, 'OK', data)
|
||||
data = mw.getNumLines(path, int(line))
|
||||
return mw.returnJson(True, 'OK', data)
|
||||
except Exception as ex:
|
||||
return public.returnJson(False, u'无法正确读取文件!' + str(ex))
|
||||
return mw.returnJson(False, u'无法正确读取文件!' + str(ex))
|
||||
|
||||
def saveBodyApi(self):
|
||||
path = request.form.get('path', '').encode('utf-8')
|
||||
@@ -67,21 +67,21 @@ class files_api:
|
||||
sfile = request.form.get('sfile', '').encode('utf-8')
|
||||
dfile = request.form.get('dfile', '').encode('utf-8')
|
||||
if not self.checkFileName(dfile):
|
||||
return public.returnJson(False, '文件名中不能包含特殊字符!')
|
||||
return mw.returnJson(False, '文件名中不能包含特殊字符!')
|
||||
if not os.path.exists(sfile):
|
||||
return public.returnJson(False, '指定文件不存在!')
|
||||
return mw.returnJson(False, '指定文件不存在!')
|
||||
|
||||
if not self.checkDir(sfile):
|
||||
return public.returnJson(False, 'FILE_DANGER')
|
||||
return mw.returnJson(False, 'FILE_DANGER')
|
||||
|
||||
import shutil
|
||||
try:
|
||||
shutil.move(sfile, dfile)
|
||||
msg = public.getInfo('移动文件或目录[{1}]到[{2}]成功!', (sfile, dfile,))
|
||||
public.writeLog('文件管理', msg)
|
||||
return public.returnJson(True, '移动文件或目录成功!')
|
||||
msg = mw.getInfo('移动文件或目录[{1}]到[{2}]成功!', (sfile, dfile,))
|
||||
mw.writeLog('文件管理', msg)
|
||||
return mw.returnJson(True, '移动文件或目录成功!')
|
||||
except:
|
||||
return public.returnJson(False, '移动文件或目录失败!')
|
||||
return mw.returnJson(False, '移动文件或目录失败!')
|
||||
|
||||
def deleteApi(self):
|
||||
path = request.form.get('path', '').encode('utf-8')
|
||||
@@ -90,12 +90,12 @@ class files_api:
|
||||
def fileAccessApi(self):
|
||||
filename = request.form.get('filename', '').encode('utf-8')
|
||||
data = self.getAccess(filename)
|
||||
return public.getJson(data)
|
||||
return mw.getJson(data)
|
||||
|
||||
def setFileAccessApi(self):
|
||||
|
||||
if public.isAppleSystem():
|
||||
return public.returnJson(True, '开发机不设置!')
|
||||
if mw.isAppleSystem():
|
||||
return mw.returnJson(True, '开发机不设置!')
|
||||
|
||||
filename = request.form.get('filename', '').encode('utf-8')
|
||||
user = request.form.get('user', '').encode('utf-8')
|
||||
@@ -103,30 +103,30 @@ class files_api:
|
||||
sall = '-R'
|
||||
try:
|
||||
if not self.checkDir(filename):
|
||||
return public.returnJson(False, '请不要花样作死')
|
||||
return mw.returnJson(False, '请不要花样作死')
|
||||
|
||||
if not os.path.exists(filename):
|
||||
return public.returnJson(False, '指定文件不存在!')
|
||||
return mw.returnJson(False, '指定文件不存在!')
|
||||
|
||||
os.system('chmod ' + sall + ' ' + access + " '" + filename + "'")
|
||||
os.system('chown ' + sall + ' ' + user +
|
||||
':' + user + " '" + filename + "'")
|
||||
msg = public.getInfo(
|
||||
msg = mw.getInfo(
|
||||
'设置[{1}]权限为[{2}]所有者为[{3}]', (filename, access, user,))
|
||||
public.writeLog('文件管理', msg)
|
||||
return public.returnJson(True, '设置成功!')
|
||||
mw.writeLog('文件管理', msg)
|
||||
return mw.returnJson(True, '设置成功!')
|
||||
except:
|
||||
return public.returnJson(False, '设置失败!')
|
||||
return mw.returnJson(False, '设置失败!')
|
||||
|
||||
def getDirSizeApi(self):
|
||||
path = request.form.get('path', '').encode('utf-8')
|
||||
tmp = self.getDirSize(path)
|
||||
return public.returnJson(True, tmp[0].split()[0])
|
||||
return mw.returnJson(True, tmp[0].split()[0])
|
||||
|
||||
def getDirApi(self):
|
||||
path = request.form.get('path', '').encode('utf-8')
|
||||
if not os.path.exists(path):
|
||||
path = public.getRootDir() + "/wwwroot"
|
||||
path = mw.getRootDir() + "/wwwroot"
|
||||
search = request.args.get('search', '').strip().lower()
|
||||
page = request.args.get('p', '1').strip().lower()
|
||||
row = request.args.get('showRow', '10')
|
||||
@@ -140,35 +140,35 @@ class files_api:
|
||||
file = request.form.get('path', '').encode('utf-8')
|
||||
try:
|
||||
if not self.checkFileName(file):
|
||||
return public.returnJson(False, '文件名中不能包含特殊字符!')
|
||||
return mw.returnJson(False, '文件名中不能包含特殊字符!')
|
||||
if os.path.exists(file):
|
||||
return public.returnJson(False, '指定文件已存在!')
|
||||
return mw.returnJson(False, '指定文件已存在!')
|
||||
_path = os.path.dirname(file)
|
||||
if not os.path.exists(_path):
|
||||
os.makedirs(_path)
|
||||
open(file, 'w+').close()
|
||||
self.setFileAccept(file)
|
||||
msg = public.getInfo('创建文件[{1}]成功!', (file,))
|
||||
public.writeLog('文件管理', msg)
|
||||
return public.returnJson(True, '文件创建成功!')
|
||||
msg = mw.getInfo('创建文件[{1}]成功!', (file,))
|
||||
mw.writeLog('文件管理', msg)
|
||||
return mw.returnJson(True, '文件创建成功!')
|
||||
except Exception as e:
|
||||
# print str(e)
|
||||
return public.returnJson(True, '文件创建失败!')
|
||||
return mw.returnJson(True, '文件创建失败!')
|
||||
|
||||
def createDirApi(self):
|
||||
path = request.form.get('path', '').encode('utf-8')
|
||||
try:
|
||||
if not self.checkFileName(path):
|
||||
return public.returnJson(False, '目录名中不能包含特殊字符!')
|
||||
return mw.returnJson(False, '目录名中不能包含特殊字符!')
|
||||
if os.path.exists(path):
|
||||
return public.returnJson(False, '指定目录已存在!')
|
||||
return mw.returnJson(False, '指定目录已存在!')
|
||||
os.makedirs(path)
|
||||
self.setFileAccept(path)
|
||||
msg = public.getInfo('创建目录[{1}]成功!', (path,))
|
||||
public.writeLog('文件管理', msg)
|
||||
return public.returnJson(True, '目录创建成功!')
|
||||
msg = mw.getInfo('创建目录[{1}]成功!', (path,))
|
||||
mw.writeLog('文件管理', msg)
|
||||
return mw.returnJson(True, '目录创建成功!')
|
||||
except Exception as e:
|
||||
return public.returnJson(False, '目录创建失败!')
|
||||
return mw.returnJson(False, '目录创建失败!')
|
||||
|
||||
def downloadFileApi(self):
|
||||
import db
|
||||
@@ -177,20 +177,20 @@ class files_api:
|
||||
path = request.form.get('path', '').encode('utf-8')
|
||||
filename = request.form.get('filename', '').encode('utf-8')
|
||||
|
||||
isTask = public.getRootDir() + '/tmp/panelTask.pl'
|
||||
isTask = mw.getRootDir() + '/tmp/panelTask.pl'
|
||||
execstr = url + '|mw|' + path + '/' + filename
|
||||
public.M('tasks').add('name,type,status,addtime,execstr',
|
||||
('下载文件[' + filename + ']', 'download', '0', time.strftime('%Y-%m-%d %H:%M:%S'), execstr))
|
||||
public.writeFile(isTask, 'True')
|
||||
mw.M('tasks').add('name,type,status,addtime,execstr',
|
||||
('下载文件[' + filename + ']', 'download', '0', time.strftime('%Y-%m-%d %H:%M:%S'), execstr))
|
||||
mw.writeFile(isTask, 'True')
|
||||
# self.setFileAccept(path + '/' + filename)
|
||||
return public.returnJson(True, '已将下载任务添加到队列!')
|
||||
return mw.returnJson(True, '已将下载任务添加到队列!')
|
||||
|
||||
def removeTaskApi(self):
|
||||
mid = request.form.get('id', '').encode('utf-8')
|
||||
try:
|
||||
name = public.M('tasks').where('id=?', (mid,)).getField('name')
|
||||
status = public.M('tasks').where('id=?', (mid,)).getField('status')
|
||||
public.M('tasks').delete(mid)
|
||||
name = mw.M('tasks').where('id=?', (mid,)).getField('name')
|
||||
status = mw.M('tasks').where('id=?', (mid,)).getField('status')
|
||||
mw.M('tasks').delete(mid)
|
||||
if status == '-1':
|
||||
os.system(
|
||||
"kill `ps -ef |grep 'python panelSafe.pyc'|grep -v grep|grep -v panelExec|awk '{print $2}'`")
|
||||
@@ -208,12 +208,12 @@ done
|
||||
|
||||
os.system(
|
||||
'rm -f ' + name.replace('扫描目录[', '').replace(']', '') + '/scan.pl')
|
||||
isTask = public.getRootDir() + '/tmp/panelTask.pl'
|
||||
public.writeFile(isTask, 'True')
|
||||
isTask = mw.getRootDir() + '/tmp/panelTask.pl'
|
||||
mw.writeFile(isTask, 'True')
|
||||
os.system('/etc/init.d/mw start')
|
||||
except:
|
||||
os.system('/etc/init.d/mw start')
|
||||
return public.returnJson(True, '任务已删除!')
|
||||
return mw.returnJson(True, '任务已删除!')
|
||||
|
||||
# 上传文件
|
||||
def uploadFileApi(self):
|
||||
@@ -236,9 +236,9 @@ done
|
||||
os.chown(filename, p_stat.st_uid, p_stat.st_gid)
|
||||
os.chmod(filename, p_stat.st_mode)
|
||||
|
||||
msg = public.getInfo('上传文件[{1}] 到 [{2}]成功!', (filename, path))
|
||||
public.writeLog('文件管理', msg)
|
||||
return public.returnMsg(True, '上传成功!')
|
||||
msg = mw.getInfo('上传文件[{1}] 到 [{2}]成功!', (filename, path))
|
||||
mw.writeLog('文件管理', msg)
|
||||
return mw.returnMsg(True, '上传成功!')
|
||||
|
||||
def getRecycleBinApi(self):
|
||||
rPath = self.rPath
|
||||
@@ -274,7 +274,7 @@ done
|
||||
data['files'].append(tmp)
|
||||
except:
|
||||
continue
|
||||
return public.returnJson(True, 'OK', data)
|
||||
return mw.returnJson(True, 'OK', data)
|
||||
|
||||
# 回收站开关
|
||||
def recycleBinApi(self):
|
||||
@@ -284,12 +284,12 @@ done
|
||||
c = 'data/recycle_bin_db.pl'
|
||||
if os.path.exists(c):
|
||||
os.remove(c)
|
||||
public.writeLog('文件管理', '已关闭回收站功能!')
|
||||
return public.returnJson(True, '已关闭回收站功能!')
|
||||
mw.writeLog('文件管理', '已关闭回收站功能!')
|
||||
return mw.returnJson(True, '已关闭回收站功能!')
|
||||
else:
|
||||
public.writeFile(c, 'True')
|
||||
public.writeLog('文件管理', '已开启回收站功能!')
|
||||
return public.returnJson(True, '已开启回收站功能!')
|
||||
mw.writeFile(c, 'True')
|
||||
mw.writeLog('文件管理', '已开启回收站功能!')
|
||||
return mw.returnJson(True, '已开启回收站功能!')
|
||||
|
||||
def reRecycleBinApi(self):
|
||||
rPath = self.rPath
|
||||
@@ -298,13 +298,13 @@ done
|
||||
try:
|
||||
import shutil
|
||||
shutil.move(rPath + path, dFile)
|
||||
msg = public.getInfo('移动文件[{1}]到回收站成功!', (dFile,))
|
||||
public.writeLog('文件管理', msg)
|
||||
return public.returnJson(True, '恢复成功!')
|
||||
msg = mw.getInfo('移动文件[{1}]到回收站成功!', (dFile,))
|
||||
mw.writeLog('文件管理', msg)
|
||||
return mw.returnJson(True, '恢复成功!')
|
||||
except Exception as e:
|
||||
msg = public.getInfo('从回收站恢复[{1}]失败!', (dFile,))
|
||||
public.writeLog('文件管理', msg)
|
||||
return public.returnJson(False, '恢复失败!')
|
||||
msg = mw.getInfo('从回收站恢复[{1}]失败!', (dFile,))
|
||||
mw.writeLog('文件管理', msg)
|
||||
return mw.returnJson(False, '恢复失败!')
|
||||
|
||||
def delRecycleBinApi(self):
|
||||
rPath = self.rPath
|
||||
@@ -313,7 +313,7 @@ done
|
||||
dFile = path.split('_t_')[0]
|
||||
|
||||
if not self.checkDir(path):
|
||||
return public.returnJson(False, '敏感目录,请不要花样作死!')
|
||||
return mw.returnJson(False, '敏感目录,请不要花样作死!')
|
||||
|
||||
os.system('which chattr && chattr -R -i ' + rPath + path)
|
||||
if os.path.isdir(rPath + path):
|
||||
@@ -323,14 +323,14 @@ done
|
||||
os.remove(rPath + path)
|
||||
|
||||
tfile = path.replace('_mw_', '/').split('_t_')[0]
|
||||
msg = public.getInfo('已彻底从回收站删除{1}!', (tfile,))
|
||||
public.writeLog('文件管理', msg)
|
||||
return public.returnJson(True, msg)
|
||||
msg = mw.getInfo('已彻底从回收站删除{1}!', (tfile,))
|
||||
mw.writeLog('文件管理', msg)
|
||||
return mw.returnJson(True, msg)
|
||||
|
||||
# 获取进度
|
||||
def getSpeedApi(self):
|
||||
data = public.getSpeed()
|
||||
return public.returnJson(True, '已清空回收站!', data)
|
||||
data = mw.getSpeed()
|
||||
return mw.returnJson(True, '已清空回收站!', data)
|
||||
|
||||
def closeRecycleBinApi(self):
|
||||
rPath = self.rPath
|
||||
@@ -341,19 +341,19 @@ done
|
||||
for name in rlist:
|
||||
i += 1
|
||||
path = rPath + name
|
||||
public.writeSpeed(name, i, l)
|
||||
mw.writeSpeed(name, i, l)
|
||||
if os.path.isdir(path):
|
||||
shutil.rmtree(path)
|
||||
else:
|
||||
os.remove(path)
|
||||
public.writeSpeed(None, 0, 0)
|
||||
public.writeLog('文件管理', '已清空回收站!')
|
||||
return public.returnJson(True, '已清空回收站!')
|
||||
mw.writeSpeed(None, 0, 0)
|
||||
mw.writeLog('文件管理', '已清空回收站!')
|
||||
return mw.returnJson(True, '已清空回收站!')
|
||||
|
||||
def deleteDirApi(self):
|
||||
path = request.form.get('path', '').encode('utf-8')
|
||||
if not os.path.exists(path):
|
||||
return public.returnJson(False, '指定文件不存在!')
|
||||
return mw.returnJson(False, '指定文件不存在!')
|
||||
|
||||
# 检查是否为.user.ini
|
||||
if path.find('.user.ini'):
|
||||
@@ -361,21 +361,21 @@ done
|
||||
try:
|
||||
if os.path.exists('data/recycle_bin.pl'):
|
||||
if self.mvRecycleBin(path):
|
||||
return public.returnJson(True, '已将文件移动到回收站!')
|
||||
public.execShell('rm -rf ' + path)
|
||||
public.writeLog('文件管理', '删除文件成功!', (path,))
|
||||
return public.returnJson(True, '删除文件成功!')
|
||||
return mw.returnJson(True, '已将文件移动到回收站!')
|
||||
mw.execShell('rm -rf ' + path)
|
||||
mw.writeLog('文件管理', '删除文件成功!', (path,))
|
||||
return mw.returnJson(True, '删除文件成功!')
|
||||
except:
|
||||
return public.returnJson(False, '删除文件失败!')
|
||||
return mw.returnJson(False, '删除文件失败!')
|
||||
|
||||
def closeLogsApi(self):
|
||||
logPath = public.getLogsDir()
|
||||
logPath = mw.getLogsDir()
|
||||
os.system('rm -f ' + logPath + '/*')
|
||||
os.system('kill -USR1 `cat ' + public.getServerDir() +
|
||||
os.system('kill -USR1 `cat ' + mw.getServerDir() +
|
||||
'openresty/nginx/logs/nginx.pid`')
|
||||
public.writeLog('文件管理', '网站日志已被清空!')
|
||||
mw.writeLog('文件管理', '网站日志已被清空!')
|
||||
tmp = self.getDirSize(logPath)
|
||||
return public.returnJson(True, tmp[0].split()[0])
|
||||
return mw.returnJson(True, tmp[0].split()[0])
|
||||
|
||||
def setBatchDataApi(self):
|
||||
path = request.form.get('path', '').encode('utf-8')
|
||||
@@ -391,21 +391,21 @@ done
|
||||
'user': user,
|
||||
'data': data
|
||||
}
|
||||
return public.returnJson(True, '标记成功,请在目标目录点击粘贴所有按钮!')
|
||||
return mw.returnJson(True, '标记成功,请在目标目录点击粘贴所有按钮!')
|
||||
elif stype == '3':
|
||||
for key in json.loads(data):
|
||||
try:
|
||||
key = key.encode('utf-8')
|
||||
filename = path + '/' + key
|
||||
if not self.checkDir(filename):
|
||||
return public.returnJson(False, 'FILE_DANGER')
|
||||
return mw.returnJson(False, 'FILE_DANGER')
|
||||
os.system('chmod -R ' + access + " '" + filename + "'")
|
||||
os.system('chown -R ' + user + ':' +
|
||||
user + " '" + filename + "'")
|
||||
except:
|
||||
continue
|
||||
public.writeLog('文件管理', '批量设置权限成功!')
|
||||
return public.returnJson(True, '批量设置权限成功!')
|
||||
mw.writeLog('文件管理', '批量设置权限成功!')
|
||||
return mw.returnJson(True, '批量设置权限成功!')
|
||||
else:
|
||||
import shutil
|
||||
isRecyle = os.path.exists('data/recycle_bin.pl')
|
||||
@@ -420,10 +420,10 @@ done
|
||||
continue
|
||||
|
||||
i += 1
|
||||
public.writeSpeed(key, i, l)
|
||||
mw.writeSpeed(key, i, l)
|
||||
if os.path.isdir(filename):
|
||||
if not self.checkDir(filename):
|
||||
return public.returnJson(False, '请不要花样作死!')
|
||||
return mw.returnJson(False, '请不要花样作死!')
|
||||
if isRecyle:
|
||||
self.mvRecycleBin(topath)
|
||||
else:
|
||||
@@ -437,9 +437,9 @@ done
|
||||
os.remove(filename)
|
||||
except:
|
||||
continue
|
||||
public.writeSpeed(None, 0, 0)
|
||||
public.writeLog('文件管理', '批量删除成功!')
|
||||
return public.returnJson(True, '批量删除成功!')
|
||||
mw.writeSpeed(None, 0, 0)
|
||||
mw.writeLog('文件管理', '批量删除成功!')
|
||||
return mw.returnJson(True, '批量删除成功!')
|
||||
|
||||
def checkExistsFilesApi(self):
|
||||
dfile = request.form.get('dfile', '').encode('utf-8')
|
||||
@@ -464,7 +464,7 @@ done
|
||||
tmp['size'] = os.path.getsize(filename)
|
||||
tmp['mtime'] = str(int(stat.st_mtime))
|
||||
data.append(tmp)
|
||||
return public.returnJson(True, 'ok', data)
|
||||
return mw.returnJson(True, 'ok', data)
|
||||
|
||||
def batchPasteApi(self):
|
||||
path = request.form.get('path', '').encode('utf-8')
|
||||
@@ -472,14 +472,14 @@ done
|
||||
# filename = request.form.get('filename', '').encode('utf-8')
|
||||
import shutil
|
||||
if not self.checkDir(path):
|
||||
return public.returnJson(False, '请不要花样作死!')
|
||||
return mw.returnJson(False, '请不要花样作死!')
|
||||
i = 0
|
||||
myfiles = json.loads(session['selected']['data'])
|
||||
l = len(myfiles)
|
||||
if stype == '1':
|
||||
for key in myfiles:
|
||||
i += 1
|
||||
public.writeSpeed(key, i, l)
|
||||
mw.writeSpeed(key, i, l)
|
||||
try:
|
||||
|
||||
sfile = session['selected'][
|
||||
@@ -494,14 +494,14 @@ done
|
||||
os.chown(dfile, stat.st_uid, stat.st_gid)
|
||||
except:
|
||||
continue
|
||||
msg = public.getInfo('从[{1}]批量复制到[{2}]成功',
|
||||
(session['selected']['path'], path,))
|
||||
public.writeLog('文件管理', msg)
|
||||
msg = mw.getInfo('从[{1}]批量复制到[{2}]成功',
|
||||
(session['selected']['path'], path,))
|
||||
mw.writeLog('文件管理', msg)
|
||||
else:
|
||||
for key in myfiles:
|
||||
try:
|
||||
i += 1
|
||||
public.writeSpeed(key, i, l)
|
||||
mw.writeSpeed(key, i, l)
|
||||
|
||||
sfile = session['selected'][
|
||||
'path'] + '/' + key.encode('utf-8')
|
||||
@@ -510,21 +510,21 @@ done
|
||||
shutil.move(sfile, dfile)
|
||||
except:
|
||||
continue
|
||||
msg = public.getInfo('从[{1}]批量移动到[{2}]成功',
|
||||
(session['selected']['path'], path,))
|
||||
public.writeLog('文件管理', msg)
|
||||
public.writeSpeed(None, 0, 0)
|
||||
msg = mw.getInfo('从[{1}]批量移动到[{2}]成功',
|
||||
(session['selected']['path'], path,))
|
||||
mw.writeLog('文件管理', msg)
|
||||
mw.writeSpeed(None, 0, 0)
|
||||
errorCount = len(myfiles) - i
|
||||
del(session['selected'])
|
||||
msg = public.getInfo('批量操作成功[{1}],失败[{2}]', (str(i), str(errorCount)))
|
||||
return public.returnJson(True, msg)
|
||||
msg = mw.getInfo('批量操作成功[{1}],失败[{2}]', (str(i), str(errorCount)))
|
||||
return mw.returnJson(True, msg)
|
||||
|
||||
def copyFileApi(self):
|
||||
sfile = request.form.get('sfile', '').encode('utf-8')
|
||||
dfile = request.form.get('dfile', '').encode('utf-8')
|
||||
|
||||
if not os.path.exists(sfile):
|
||||
return public.returnJson(False, '指定文件不存在!')
|
||||
return mw.returnJson(False, '指定文件不存在!')
|
||||
|
||||
if os.path.isdir(sfile):
|
||||
return self.copyDir(sfile, dfile)
|
||||
@@ -532,33 +532,33 @@ done
|
||||
import shutil
|
||||
try:
|
||||
shutil.copyfile(sfile, dfile)
|
||||
msg = public.getInfo('复制文件[{1}]到[{2}]成功!', (sfile, dfile,))
|
||||
public.writeLog('文件管理', msg)
|
||||
msg = mw.getInfo('复制文件[{1}]到[{2}]成功!', (sfile, dfile,))
|
||||
mw.writeLog('文件管理', msg)
|
||||
stat = os.stat(sfile)
|
||||
os.chown(dfile, stat.st_uid, stat.st_gid)
|
||||
return public.returnJson(True, '文件复制成功!')
|
||||
return mw.returnJson(True, '文件复制成功!')
|
||||
except:
|
||||
return public.returnJson(False, '文件复制失败!')
|
||||
return mw.returnJson(False, '文件复制失败!')
|
||||
|
||||
##### ----- end ----- ###
|
||||
|
||||
def copyDir(self, sfile, dfile):
|
||||
|
||||
if not os.path.exists(sfile):
|
||||
return public.returnJson(False, '指定目录不存在!')
|
||||
return mw.returnJson(False, '指定目录不存在!')
|
||||
|
||||
if os.path.exists(dfile):
|
||||
return public.returnJson(False, '指定目录已存在!')
|
||||
return mw.returnJson(False, '指定目录已存在!')
|
||||
import shutil
|
||||
try:
|
||||
shutil.copytree(sfile, dfile)
|
||||
stat = os.stat(sfile)
|
||||
os.chown(dfile, stat.st_uid, stat.st_gid)
|
||||
msg = public.getInfo('复制目录[{1}]到[{2}]成功!', (sfile, dfile))
|
||||
public.writeLog('文件管理', msg)
|
||||
return public.returnJson(True, '目录复制成功!')
|
||||
msg = mw.getInfo('复制目录[{1}]到[{2}]成功!', (sfile, dfile))
|
||||
mw.writeLog('文件管理', msg)
|
||||
return mw.returnJson(True, '目录复制成功!')
|
||||
except:
|
||||
return public.returnJson(False, '目录复制失败!')
|
||||
return mw.returnJson(False, '目录复制失败!')
|
||||
|
||||
# 检查敏感目录
|
||||
def checkDir(self, path):
|
||||
@@ -590,15 +590,15 @@ done
|
||||
'/selinux',
|
||||
'/www/server',
|
||||
'/www/server/data',
|
||||
public.getRootDir())
|
||||
mw.getRootDir())
|
||||
|
||||
return not path in nDirs
|
||||
|
||||
def getDirSize(self, path):
|
||||
if public.getOs() == 'darwin':
|
||||
tmp = public.execShell('du -sh ' + path)
|
||||
if mw.getOs() == 'darwin':
|
||||
tmp = mw.execShell('du -sh ' + path)
|
||||
else:
|
||||
tmp = public.execShell('du -sbh ' + path)
|
||||
tmp = mw.execShell('du -sbh ' + path)
|
||||
return tmp
|
||||
|
||||
def checkFileName(self, filename):
|
||||
@@ -613,8 +613,8 @@ done
|
||||
|
||||
def setFileAccept(self, filename):
|
||||
auth = 'www:www'
|
||||
if public.getOs() == 'darwin':
|
||||
user = public.execShell(
|
||||
if mw.getOs() == 'darwin':
|
||||
user = mw.execShell(
|
||||
"who | sed -n '2, 1p' |awk '{print $1}'")[0].strip()
|
||||
auth = user + ':staff'
|
||||
os.system('chown -R ' + auth + ' ' + filename)
|
||||
@@ -630,20 +630,20 @@ done
|
||||
try:
|
||||
import shutil
|
||||
shutil.move(path, rFile)
|
||||
public.writeLog('文件管理', public.getInfo(
|
||||
mw.writeLog('文件管理', mw.getInfo(
|
||||
'移动文件[{1}]到回收站成功!', (path)))
|
||||
return True
|
||||
except:
|
||||
public.writeLog('文件管理', public.getInfo(
|
||||
mw.writeLog('文件管理', mw.getInfo(
|
||||
'移动文件[{1}]到回收站失败!', (path)))
|
||||
return False
|
||||
|
||||
def getBody(self, path):
|
||||
if not os.path.exists(path):
|
||||
return public.returnJson(False, '文件不存在', (path,))
|
||||
return mw.returnJson(False, '文件不存在', (path,))
|
||||
|
||||
if os.path.getsize(path) > 2097152:
|
||||
return public.returnJson(False, u'不能在线编辑大于2MB的文件!')
|
||||
return mw.returnJson(False, u'不能在线编辑大于2MB的文件!')
|
||||
|
||||
fp = open(path, 'rb')
|
||||
data = {}
|
||||
@@ -690,13 +690,13 @@ done
|
||||
data['data'] = srcBody.decode('utf-8')
|
||||
data['encoding'] = u'utf-8'
|
||||
|
||||
return public.returnJson(True, 'OK', data)
|
||||
return mw.returnJson(True, 'OK', data)
|
||||
except Exception as ex:
|
||||
return public.returnJson(False, u'文件编码不被兼容,无法正确读取文件!' + str(ex))
|
||||
return mw.returnJson(False, u'文件编码不被兼容,无法正确读取文件!' + str(ex))
|
||||
|
||||
def saveBody(self, path, data, encoding='utf-8'):
|
||||
if not os.path.exists(path):
|
||||
return public.returnJson(False, '文件不存在')
|
||||
return mw.returnJson(False, '文件不存在')
|
||||
try:
|
||||
if encoding == 'ascii':
|
||||
encoding = 'utf-8'
|
||||
@@ -710,18 +710,18 @@ done
|
||||
fp.write(data)
|
||||
fp.close()
|
||||
|
||||
public.writeLog('文件管理', '文件保存成功', (path,))
|
||||
return public.returnJson(True, '文件保存成功')
|
||||
mw.writeLog('文件管理', '文件保存成功', (path,))
|
||||
return mw.returnJson(True, '文件保存成功')
|
||||
except Exception as ex:
|
||||
return public.returnJson(False, 'FILE_SAVE_ERR:' + str(ex))
|
||||
return mw.returnJson(False, 'FILE_SAVE_ERR:' + str(ex))
|
||||
|
||||
def zip(self, sfile, dfile, stype, path):
|
||||
if sfile.find(',') == -1:
|
||||
if not os.path.exists(path + '/' + sfile):
|
||||
return public.returnMsg(False, '指定文件不存在!')
|
||||
return mw.returnMsg(False, '指定文件不存在!')
|
||||
|
||||
try:
|
||||
tmps = public.getRunDir() + '/tmp/panelExec.log'
|
||||
tmps = mw.getRunDir() + '/tmp/panelExec.log'
|
||||
if stype == 'zip':
|
||||
os.system("cd '" + path + "' && zip '" + dfile +
|
||||
"' -r '" + sfile + "' > " + tmps + " 2>&1")
|
||||
@@ -734,15 +734,15 @@ done
|
||||
os.system("cd '" + path + "' && tar -zcvf '" +
|
||||
dfile + "' " + sfiles + " > " + tmps + " 2>&1")
|
||||
self.setFileAccept(dfile)
|
||||
public.writeLog("文件管理", '文件压缩成功!', (sfile, dfile))
|
||||
return public.returnJson(True, '文件压缩成功!')
|
||||
mw.writeLog("文件管理", '文件压缩成功!', (sfile, dfile))
|
||||
return mw.returnJson(True, '文件压缩成功!')
|
||||
except:
|
||||
return public.returnJson(False, '文件压缩失败!')
|
||||
return mw.returnJson(False, '文件压缩失败!')
|
||||
|
||||
def delete(self, path):
|
||||
|
||||
if not os.path.exists(path):
|
||||
return public.returnJson(False, '指定文件不存在!')
|
||||
return mw.returnJson(False, '指定文件不存在!')
|
||||
|
||||
# 检查是否为.user.ini
|
||||
if path.find('.user.ini') >= 0:
|
||||
@@ -751,13 +751,13 @@ done
|
||||
try:
|
||||
if os.path.exists('data/recycle_bin.pl'):
|
||||
if self.mvRecycleBin(path):
|
||||
return public.returnJson(True, '已将文件移动到回收站!')
|
||||
return mw.returnJson(True, '已将文件移动到回收站!')
|
||||
os.remove(path)
|
||||
public.writeLog('文件管理', public.getInfo(
|
||||
mw.writeLog('文件管理', mw.getInfo(
|
||||
'删除文件[{1}]成功!', (path)))
|
||||
return public.returnJson(True, '删除文件成功!')
|
||||
return mw.returnJson(True, '删除文件成功!')
|
||||
except:
|
||||
return public.returnJson(False, '删除文件失败!')
|
||||
return mw.returnJson(False, '删除文件失败!')
|
||||
|
||||
def getAccess(self, filename):
|
||||
data = {}
|
||||
@@ -792,7 +792,7 @@ done
|
||||
info['row'] = page_size
|
||||
info['p'] = page
|
||||
info['tojs'] = 'getFiles'
|
||||
pageObj = public.getPageObject(info, '1,2,3,4,5,6,7,8')
|
||||
pageObj = mw.getPageObject(info, '1,2,3,4,5,6,7,8')
|
||||
data['PAGE'] = pageObj[0]
|
||||
|
||||
i = 0
|
||||
@@ -840,4 +840,4 @@ done
|
||||
data['DIR'] = sorted(dirnames)
|
||||
data['FILES'] = sorted(filenames)
|
||||
data['PATH'] = path.replace('//', '/')
|
||||
return public.getJson(data)
|
||||
return mw.getJson(data)
|
||||
|
||||
+118
-111
@@ -4,7 +4,7 @@ import psutil
|
||||
import time
|
||||
import os
|
||||
import sys
|
||||
import public
|
||||
import mw
|
||||
import re
|
||||
import json
|
||||
import pwd
|
||||
@@ -23,7 +23,7 @@ class firewall_api:
|
||||
self.__isFirewalld = True
|
||||
if os.path.exists('/usr/sbin/ufw'):
|
||||
self.__isUfw = True
|
||||
if public.isAppleSystem():
|
||||
if mw.isAppleSystem():
|
||||
self.__isMac = True
|
||||
|
||||
##### ----- start ----- ###
|
||||
@@ -35,30 +35,34 @@ class firewall_api:
|
||||
|
||||
rep = "^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}(\/\d{1,2})?$"
|
||||
if not re.search(rep, port):
|
||||
return public.returnJson(False, '您输入的IP地址不合法!')
|
||||
return mw.returnJson(False, '您输入的IP地址不合法!')
|
||||
address = port
|
||||
if public.M('firewall').where("port=?", (address,)).count() > 0:
|
||||
return public.returnJson(False, '您要放屏蔽的IP已存在屏蔽列表,无需重复处理!')
|
||||
if mw.M('firewall').where("port=?", (address,)).count() > 0:
|
||||
return mw.returnJson(False, '您要放屏蔽的IP已存在屏蔽列表,无需重复处理!')
|
||||
if self.__isUfw:
|
||||
public.execShell('ufw deny from ' + address + ' to any')
|
||||
mw.execShell('ufw deny from ' + address + ' to any')
|
||||
else:
|
||||
if self.__isFirewalld:
|
||||
cmd = 'firewall-cmd --permanent --add-rich-rule=\'rule family=ipv4 source address="' + \
|
||||
address + '" drop\''
|
||||
public.execShell(cmd)
|
||||
mw.execShell(cmd)
|
||||
else:
|
||||
cmd = 'iptables -I INPUT -s ' + address + ' -j DROP'
|
||||
public.execShell(cmd)
|
||||
mw.execShell(cmd)
|
||||
|
||||
msg = public.getInfo('屏蔽IP[{1}]成功!', (address,))
|
||||
public.writeLog("防火墙管理", msg)
|
||||
msg = mw.getInfo('屏蔽IP[{1}]成功!', (address,))
|
||||
mw.writeLog("防火墙管理", msg)
|
||||
addtime = time.strftime('%Y-%m-%d %X', time.localtime())
|
||||
public.M('firewall').add('port,ps,addtime', (address, ps, addtime))
|
||||
mw.M('firewall').add('port,ps,addtime', (address, ps, addtime))
|
||||
self.firewallReload()
|
||||
return public.returnJson(True, '添加成功!')
|
||||
return mw.returnJson(True, '添加成功!')
|
||||
|
||||
# 添加放行端口
|
||||
def addAcceptPortApi(self):
|
||||
|
||||
if not self.getFwStatus():
|
||||
return mw.returnJson(False, '防火墙启动时,才能添加规则!')
|
||||
|
||||
import re
|
||||
import time
|
||||
port = request.form.get('port', '').strip()
|
||||
@@ -67,76 +71,79 @@ class firewall_api:
|
||||
|
||||
rep = "^\d{1,5}(:\d{1,5})?$"
|
||||
if not re.search(rep, port):
|
||||
return public.returnJson(False, '端口范围不正确!')
|
||||
return mw.returnJson(False, '端口范围不正确!')
|
||||
|
||||
if public.M('firewall').where("port=?", (port,)).count() > 0:
|
||||
return public.returnJson(False, '您要放行的端口已存在,无需重复放行!')
|
||||
if mw.M('firewall').where("port=?", (port,)).count() > 0:
|
||||
return mw.returnJson(False, '您要放行的端口已存在,无需重复放行!')
|
||||
|
||||
msg = public.getInfo('放行端口[{1}]成功', (port,))
|
||||
public.writeLog("防火墙管理", msg)
|
||||
msg = mw.getInfo('放行端口[{1}]成功', (port,))
|
||||
mw.writeLog("防火墙管理", msg)
|
||||
addtime = time.strftime('%Y-%m-%d %X', time.localtime())
|
||||
public.M('firewall').add('port,ps,addtime', (port, ps, addtime))
|
||||
mw.M('firewall').add('port,ps,addtime', (port, ps, addtime))
|
||||
|
||||
self.addAcceptPort(port)
|
||||
self.firewallReload()
|
||||
return public.returnJson(True, '添加放行(' + port + ')端口成功!')
|
||||
return mw.returnJson(True, '添加放行(' + port + ')端口成功!')
|
||||
|
||||
# 删除IP屏蔽
|
||||
def delDropAddressApi(self):
|
||||
if not self.getFwStatus():
|
||||
return mw.returnJson(False, '防火墙启动时,才能删除规则!')
|
||||
|
||||
port = request.form.get('port', '').strip()
|
||||
ps = request.form.get('ps', '').strip()
|
||||
sid = request.form.get('id', '').strip()
|
||||
address = port
|
||||
if self.__isUfw:
|
||||
public.execShell('ufw delete deny from ' + address + ' to any')
|
||||
mw.execShell('ufw delete deny from ' + address + ' to any')
|
||||
else:
|
||||
if self.__isFirewalld:
|
||||
public.execShell(
|
||||
mw.execShell(
|
||||
'firewall-cmd --permanent --remove-rich-rule=\'rule family=ipv4 source address="' + address + '" drop\'')
|
||||
elif self.__isMac:
|
||||
pass
|
||||
else:
|
||||
cmd = 'iptables -D INPUT -s ' + address + ' -j DROP'
|
||||
public.execShell(cmd)
|
||||
mw.execShell(cmd)
|
||||
|
||||
msg = public.getInfo('解除IP[{1}]的屏蔽!', (address,))
|
||||
public.writeLog("防火墙管理", msg)
|
||||
public.M('firewall').where("id=?", (sid,)).delete()
|
||||
msg = mw.getInfo('解除IP[{1}]的屏蔽!', (address,))
|
||||
mw.writeLog("防火墙管理", msg)
|
||||
mw.M('firewall').where("id=?", (sid,)).delete()
|
||||
|
||||
self.firewallReload()
|
||||
return public.returnJson(True, '删除成功!')
|
||||
return mw.returnJson(True, '删除成功!')
|
||||
|
||||
# 删除放行端口
|
||||
def delAcceptPortApi(self):
|
||||
port = request.form.get('port', '').strip()
|
||||
sid = request.form.get('id', '').strip()
|
||||
mw_port = public.readFile('data/port.pl')
|
||||
mw_port = mw.readFile('data/port.pl')
|
||||
try:
|
||||
if(port == mw_port):
|
||||
return public.returnJson(False, '失败,不能删除当前面板端口!')
|
||||
return mw.returnJson(False, '失败,不能删除当前面板端口!')
|
||||
if self.__isUfw:
|
||||
public.execShell('ufw delete allow ' + port + '/tcp')
|
||||
mw.execShell('ufw delete allow ' + port + '/tcp')
|
||||
else:
|
||||
if self.__isFirewalld:
|
||||
public.execShell(
|
||||
mw.execShell(
|
||||
'firewall-cmd --permanent --zone=public --remove-port=' + port + '/tcp')
|
||||
public.execShell(
|
||||
mw.execShell(
|
||||
'firewall-cmd --permanent --zone=public --remove-port=' + port + '/udp')
|
||||
else:
|
||||
public.execShell(
|
||||
mw.execShell(
|
||||
'iptables -D INPUT -p tcp -m state --state NEW -m tcp --dport ' + port + ' -j ACCEPT')
|
||||
msg = public.getInfo('删除防火墙放行端口[{1}]成功!', (port,))
|
||||
public.writeLog("防火墙管理", msg)
|
||||
public.M('firewall').where("id=?", (sid,)).delete()
|
||||
msg = mw.getInfo('删除防火墙放行端口[{1}]成功!', (port,))
|
||||
mw.writeLog("防火墙管理", msg)
|
||||
mw.M('firewall').where("id=?", (sid,)).delete()
|
||||
|
||||
self.firewallReload()
|
||||
return public.returnJson(True, '删除成功!')
|
||||
return mw.returnJson(True, '删除成功!')
|
||||
except Exception as e:
|
||||
return public.returnJson(False, '删除失败!:' + str(e))
|
||||
return mw.returnJson(False, '删除失败!:' + str(e))
|
||||
|
||||
def getWwwPathApi(self):
|
||||
path = public.getLogsDir()
|
||||
return public.getJson({'path': path})
|
||||
path = mw.getLogsDir()
|
||||
return mw.getJson({'path': path})
|
||||
|
||||
def getListApi(self):
|
||||
p = request.form.get('p', '1').strip()
|
||||
@@ -151,17 +158,17 @@ class firewall_api:
|
||||
|
||||
def getSshInfoApi(self):
|
||||
file = '/etc/ssh/sshd_config'
|
||||
conf = public.readFile(file)
|
||||
conf = mw.readFile(file)
|
||||
rep = "#*Port\s+([0-9]+)\s*\n"
|
||||
port = re.search(rep, conf).groups(0)[0]
|
||||
|
||||
isPing = True
|
||||
try:
|
||||
if public.isAppleSystem():
|
||||
if mw.isAppleSystem():
|
||||
isPing = True
|
||||
else:
|
||||
file = '/etc/sysctl.conf'
|
||||
conf = public.readFile(file)
|
||||
conf = mw.readFile(file)
|
||||
rep = "#*net\.ipv4\.icmp_echo_ignore_all\s*=\s*([0-9]+)"
|
||||
tmp = re.search(rep, conf).groups(0)[0]
|
||||
if tmp == '1':
|
||||
@@ -175,17 +182,17 @@ class firewall_api:
|
||||
if os.path.exists('/usr/bin/apt-get'):
|
||||
if os.path.exists('/etc/init.d/sshd'):
|
||||
cmd = "service sshd status | grep -P '(dead|stop)'|grep -v grep"
|
||||
status = public.execShell(cmd)
|
||||
status = mw.execShell(cmd)
|
||||
else:
|
||||
cmd = "service ssh status | grep -P '(dead|stop)'|grep -v grep"
|
||||
status = public.execShell(cmd)
|
||||
status = mw.execShell(cmd)
|
||||
else:
|
||||
if version.find(' 7.') != -1:
|
||||
cmd = "systemctl status sshd.service | grep 'dead'|grep -v grep"
|
||||
status = public.execShell(cmd)
|
||||
status = mw.execShell(cmd)
|
||||
else:
|
||||
cmd = "/etc/init.d/sshd status | grep -e 'stopped' -e '已停'|grep -v grep"
|
||||
status = public.execShell(cmd)
|
||||
status = mw.execShell(cmd)
|
||||
if len(status[0]) > 3:
|
||||
status = False
|
||||
else:
|
||||
@@ -196,54 +203,54 @@ class firewall_api:
|
||||
|
||||
data['status'] = status
|
||||
data['ping'] = isPing
|
||||
if public.isAppleSystem():
|
||||
if mw.isAppleSystem():
|
||||
data['firewall_status'] = False
|
||||
else:
|
||||
data['firewall_status'] = self.getFwStatus()
|
||||
return public.getJson(data)
|
||||
return mw.getJson(data)
|
||||
|
||||
def setSshPortApi(self):
|
||||
port = request.form.get('port', '1').strip()
|
||||
if int(port) < 22 or int(port) > 65535:
|
||||
return public.returnJson(False, '端口范围必需在22-65535之间!')
|
||||
return mw.returnJson(False, '端口范围必需在22-65535之间!')
|
||||
|
||||
ports = ['21', '25', '80', '443', '7200', '8080', '888', '8888']
|
||||
if port in ports:
|
||||
return public.returnJson(False, '(' + port + ')' + '特殊端口不可设置!')
|
||||
return mw.returnJson(False, '(' + port + ')' + '特殊端口不可设置!')
|
||||
|
||||
file = '/etc/ssh/sshd_config'
|
||||
conf = public.readFile(file)
|
||||
conf = mw.readFile(file)
|
||||
|
||||
rep = "#*Port\s+([0-9]+)\s*\n"
|
||||
conf = re.sub(rep, "Port " + port + "\n", conf)
|
||||
public.writeFile(file, conf)
|
||||
mw.writeFile(file, conf)
|
||||
|
||||
if self.__isFirewalld:
|
||||
public.execShell('setenforce 0')
|
||||
public.execShell(
|
||||
mw.execShell('setenforce 0')
|
||||
mw.execShell(
|
||||
'sed -i "s#SELINUX=enforcing#SELINUX=disabled#" /etc/selinux/config')
|
||||
public.execShell("systemctl restart sshd.service")
|
||||
mw.execShell("systemctl restart sshd.service")
|
||||
elif self.__isUfw:
|
||||
public.execShell('ufw allow ' + port + '/tcp')
|
||||
public.execShell("service ssh restart")
|
||||
mw.execShell('ufw allow ' + port + '/tcp')
|
||||
mw.execShell("service ssh restart")
|
||||
else:
|
||||
public.execShell(
|
||||
mw.execShell(
|
||||
'iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport ' + port + ' -j ACCEPT')
|
||||
public.execShell("/etc/init.d/sshd restart")
|
||||
mw.execShell("/etc/init.d/sshd restart")
|
||||
|
||||
self.firewallReload()
|
||||
# public.M('firewall').where(
|
||||
# mw.M('firewall').where(
|
||||
# "ps=?", ('SSH远程管理服务',)).setField('port', port)
|
||||
msg = public.getInfo('改SSH端口为[{1}]成功!', port)
|
||||
public.writeLog("防火墙管理", msg)
|
||||
return public.returnJson(True, '修改成功!')
|
||||
msg = mw.getInfo('改SSH端口为[{1}]成功!', port)
|
||||
mw.writeLog("防火墙管理", msg)
|
||||
return mw.returnJson(True, '修改成功!')
|
||||
|
||||
def setSshStatusApi(self):
|
||||
if public.isAppleSystem():
|
||||
return public.returnJson(True, '开发机不能操作!')
|
||||
if mw.isAppleSystem():
|
||||
return mw.returnJson(True, '开发机不能操作!')
|
||||
|
||||
status = request.form.get('status', '1').strip()
|
||||
version = public.readFile('/etc/redhat-release')
|
||||
version = mw.readFile('/etc/redhat-release')
|
||||
if int(status) == 1:
|
||||
msg = 'SSH服务已停用'
|
||||
act = 'stop'
|
||||
@@ -252,68 +259,68 @@ class firewall_api:
|
||||
act = 'start'
|
||||
|
||||
if not os.path.exists('/etc/redhat-release'):
|
||||
public.execShell('service ssh ' + act)
|
||||
mw.execShell('service ssh ' + act)
|
||||
elif version.find(' 7.') != -1:
|
||||
public.execShell("systemctl " + act + " sshd.service")
|
||||
mw.execShell("systemctl " + act + " sshd.service")
|
||||
else:
|
||||
public.execShell("/etc/init.d/sshd " + act)
|
||||
mw.execShell("/etc/init.d/sshd " + act)
|
||||
|
||||
public.writeLog("防火墙管理", msg)
|
||||
return public.returnJson(True, '操作成功!')
|
||||
mw.writeLog("防火墙管理", msg)
|
||||
return mw.returnJson(True, '操作成功!')
|
||||
|
||||
def setPingApi(self):
|
||||
if public.isAppleSystem():
|
||||
return public.returnJson(True, '开发机不能操作!')
|
||||
if mw.isAppleSystem():
|
||||
return mw.returnJson(True, '开发机不能操作!')
|
||||
|
||||
status = request.form.get('status')
|
||||
filename = '/etc/sysctl.conf'
|
||||
conf = public.readFile(filename)
|
||||
conf = mw.readFile(filename)
|
||||
if conf.find('net.ipv4.icmp_echo') != -1:
|
||||
rep = u"net\.ipv4\.icmp_echo.*"
|
||||
conf = re.sub(rep, 'net.ipv4.icmp_echo_ignore_all=' + status, conf)
|
||||
else:
|
||||
conf += "\nnet.ipv4.icmp_echo_ignore_all=" + status
|
||||
|
||||
public.writeFile(filename, conf)
|
||||
public.execShell('sysctl -p')
|
||||
return public.returnJson(True, '设置成功!')
|
||||
mw.writeFile(filename, conf)
|
||||
mw.execShell('sysctl -p')
|
||||
return mw.returnJson(True, '设置成功!')
|
||||
|
||||
def setFwApi(self):
|
||||
if public.isAppleSystem():
|
||||
return public.returnJson(True, '开发机不能设置!')
|
||||
if mw.isAppleSystem():
|
||||
return mw.returnJson(True, '开发机不能设置!')
|
||||
|
||||
status = request.form.get('status', '1')
|
||||
if status == '1':
|
||||
if self.__isUfw:
|
||||
public.execShell('/usr/sbin/ufw stop')
|
||||
mw.execShell('/usr/sbin/ufw stop')
|
||||
return
|
||||
if self.__isFirewalld:
|
||||
public.execShell('systemctl stop firewalld.service')
|
||||
public.execShell('systemctl disable firewalld.service')
|
||||
mw.execShell('systemctl stop firewalld.service')
|
||||
mw.execShell('systemctl disable firewalld.service')
|
||||
elif self.__isMac:
|
||||
pass
|
||||
else:
|
||||
public.execShell('/etc/init.d/iptables save')
|
||||
public.execShell('/etc/init.d/iptables stop')
|
||||
mw.execShell('/etc/init.d/iptables save')
|
||||
mw.execShell('/etc/init.d/iptables stop')
|
||||
else:
|
||||
if self.__isUfw:
|
||||
public.execShell('/usr/sbin/ufw start')
|
||||
mw.execShell('/usr/sbin/ufw start')
|
||||
return
|
||||
if self.__isFirewalld:
|
||||
public.execShell('systemctl start firewalld.service')
|
||||
public.execShell('systemctl enable firewalld.service')
|
||||
mw.execShell('systemctl start firewalld.service')
|
||||
mw.execShell('systemctl enable firewalld.service')
|
||||
elif self.__isMac:
|
||||
pass
|
||||
else:
|
||||
public.execShell('/etc/init.d/iptables save')
|
||||
public.execShell('/etc/init.d/iptables restart')
|
||||
mw.execShell('/etc/init.d/iptables save')
|
||||
mw.execShell('/etc/init.d/iptables restart')
|
||||
|
||||
return public.returnJson(True, '设置成功!')
|
||||
return mw.returnJson(True, '设置成功!')
|
||||
|
||||
def delPanelLogsApi(self):
|
||||
public.M('logs').where('id>?', (0,)).delete()
|
||||
public.writeLog('面板设置', '面板操作日志已清空!')
|
||||
return public.returnJson(True, '面板操作日志已清空!')
|
||||
mw.M('logs').where('id>?', (0,)).delete()
|
||||
mw.writeLog('面板设置', '面板操作日志已清空!')
|
||||
return mw.returnJson(True, '面板操作日志已清空!')
|
||||
|
||||
##### ----- start ----- ###
|
||||
|
||||
@@ -321,19 +328,19 @@ class firewall_api:
|
||||
|
||||
start = (page - 1) * limit
|
||||
|
||||
_list = public.M('firewall').field('id,port,ps,addtime').limit(
|
||||
_list = mw.M('firewall').field('id,port,ps,addtime').limit(
|
||||
str(start) + ',' + str(limit)).order('id desc').select()
|
||||
data = {}
|
||||
data['data'] = _list
|
||||
|
||||
count = public.M('firewall').count()
|
||||
count = mw.M('firewall').count()
|
||||
_page = {}
|
||||
_page['count'] = count
|
||||
_page['tojs'] = 'showAccept'
|
||||
_page['p'] = page
|
||||
|
||||
data['page'] = public.getPage(_page)
|
||||
return public.getJson(data)
|
||||
data['page'] = mw.getPage(_page)
|
||||
return mw.getJson(data)
|
||||
|
||||
def getLogList(self, page, limit, search=''):
|
||||
find_search = ''
|
||||
@@ -343,56 +350,56 @@ class firewall_api:
|
||||
|
||||
start = (page - 1) * limit
|
||||
|
||||
_list = public.M('logs').where(find_search, ()).field(
|
||||
_list = mw.M('logs').where(find_search, ()).field(
|
||||
'id,type,log,addtime').limit(str(start) + ',' + str(limit)).order('id desc').select()
|
||||
data = {}
|
||||
data['data'] = _list
|
||||
|
||||
count = public.M('logs').where(find_search, ()).count()
|
||||
count = mw.M('logs').where(find_search, ()).count()
|
||||
_page = {}
|
||||
_page['count'] = count
|
||||
_page['tojs'] = 'getLogs'
|
||||
_page['p'] = page
|
||||
|
||||
data['page'] = public.getPage(_page)
|
||||
return public.getJson(data)
|
||||
data['page'] = mw.getPage(_page)
|
||||
return mw.getJson(data)
|
||||
|
||||
def addAcceptPort(self, port):
|
||||
if self.__isUfw:
|
||||
public.execShell('ufw allow ' + port + '/tcp')
|
||||
mw.execShell('ufw allow ' + port + '/tcp')
|
||||
else:
|
||||
if self.__isFirewalld:
|
||||
port = port.replace(':', '-')
|
||||
cmd = 'firewall-cmd --permanent --zone=public --add-port=' + port + '/tcp'
|
||||
public.execShell(cmd)
|
||||
mw.execShell(cmd)
|
||||
elif self.__isMac:
|
||||
pass
|
||||
else:
|
||||
cmd = 'iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport ' + port + ' -j ACCEPT'
|
||||
public.execShell(cmd)
|
||||
mw.execShell(cmd)
|
||||
|
||||
def firewallReload(self):
|
||||
if self.__isUfw:
|
||||
public.execShell('/usr/sbin/ufw reload')
|
||||
mw.execShell('/usr/sbin/ufw reload')
|
||||
return
|
||||
if self.__isFirewalld:
|
||||
public.execShell('firewall-cmd --reload')
|
||||
mw.execShell('firewall-cmd --reload')
|
||||
elif self.__isMac:
|
||||
pass
|
||||
else:
|
||||
public.execShell('/etc/init.d/iptables save')
|
||||
public.execShell('/etc/init.d/iptables restart')
|
||||
mw.execShell('/etc/init.d/iptables save')
|
||||
mw.execShell('/etc/init.d/iptables restart')
|
||||
|
||||
def getFwStatus(self):
|
||||
if self.__isUfw:
|
||||
cmd = "ps -ef|grep ufw |grep -v grep | awk '{print $2}'"
|
||||
data = public.execShell(cmd)
|
||||
data = mw.execShell(cmd)
|
||||
if data[0] == '':
|
||||
return False
|
||||
return True
|
||||
if self.__isFirewalld:
|
||||
cmd = "ps -ef|grep firewalld |grep -v grep | awk '{print $2}'"
|
||||
data = public.execShell(cmd)
|
||||
data = mw.execShell(cmd)
|
||||
if data[0] == '':
|
||||
return False
|
||||
return True
|
||||
@@ -400,7 +407,7 @@ class firewall_api:
|
||||
return False
|
||||
else:
|
||||
cmd = "ps -ef|grep iptables |grep -v grep | awk '{print $2}'"
|
||||
data = public.execShell(cmd)
|
||||
data = mw.execShell(cmd)
|
||||
if data[0] == '':
|
||||
return False
|
||||
return True
|
||||
|
||||
@@ -882,7 +882,7 @@ def get_string_arr(t):
|
||||
def getSSHPort():
|
||||
try:
|
||||
file = '/etc/ssh/sshd_config'
|
||||
conf = ReadFile(file)
|
||||
conf = readFile(file)
|
||||
rep = "#*Port\s+([0-9]+)\s*\n"
|
||||
port = re.search(rep, conf).groups(0)[0]
|
||||
return int(port)
|
||||
+2
-2
@@ -2,7 +2,7 @@
|
||||
|
||||
import math
|
||||
import string
|
||||
import public
|
||||
import mw
|
||||
|
||||
|
||||
class Page():
|
||||
@@ -29,7 +29,7 @@ class Page():
|
||||
__END_NUM = None # 结束行
|
||||
|
||||
def __init__(self):
|
||||
# tmp = public.getMsg('PAGE')
|
||||
# tmp = mw.getMsg('PAGE')
|
||||
if False:
|
||||
self.__PREV = tmp['PREV']
|
||||
self.__NEXT = tmp['NEXT']
|
||||
|
||||
+95
-95
@@ -3,7 +3,7 @@
|
||||
import psutil
|
||||
import time
|
||||
import os
|
||||
import public
|
||||
import mw
|
||||
import re
|
||||
import json
|
||||
|
||||
@@ -50,7 +50,7 @@ class plugins_api:
|
||||
sPage = request.args.get('p', '1')
|
||||
# print sPage
|
||||
data = self.getPluginList(sType, int(sPage))
|
||||
return public.getJson(data)
|
||||
return mw.getJson(data)
|
||||
|
||||
def fileApi(self):
|
||||
name = request.args.get('name', '')
|
||||
@@ -65,24 +65,24 @@ class plugins_api:
|
||||
if not os.path.exists(file):
|
||||
return ''
|
||||
|
||||
c = public.readFile(file)
|
||||
c = mw.readFile(file)
|
||||
return c
|
||||
|
||||
def indexListApi(self):
|
||||
data = self.getIndexList()
|
||||
return public.getJson(data)
|
||||
return mw.getJson(data)
|
||||
|
||||
def indexSortApi(self):
|
||||
sort = request.form.get('ssort', '')
|
||||
if sort.strip() == '':
|
||||
return public.returnJson(False, '排序数据不能为空!')
|
||||
return mw.returnJson(False, '排序数据不能为空!')
|
||||
data = self.setIndexSort(sort)
|
||||
if data:
|
||||
return public.returnJson(True, '成功!')
|
||||
return public.returnJson(False, '失败!')
|
||||
return mw.returnJson(True, '成功!')
|
||||
return mw.returnJson(False, '失败!')
|
||||
|
||||
def installApi(self):
|
||||
rundir = public.getRunDir()
|
||||
rundir = mw.getRunDir()
|
||||
name = request.form.get('name', '')
|
||||
version = request.form.get('version', '')
|
||||
|
||||
@@ -92,18 +92,18 @@ class plugins_api:
|
||||
mmsg = 'upgrade'
|
||||
|
||||
if name.strip() == '':
|
||||
return public.returnJson(False, '缺少插件名称!', ())
|
||||
return mw.returnJson(False, '缺少插件名称!', ())
|
||||
|
||||
if version.strip() == '':
|
||||
return public.returnJson(False, '缺少版本信息!', ())
|
||||
return mw.returnJson(False, '缺少版本信息!', ())
|
||||
|
||||
infoJsonPos = self.__plugin_dir + '/' + name + '/' + 'info.json'
|
||||
# print infoJsonPos
|
||||
|
||||
if not os.path.exists(infoJsonPos):
|
||||
return public.returnJson(False, '配置文件不存在!', ())
|
||||
return mw.returnJson(False, '配置文件不存在!', ())
|
||||
|
||||
pluginInfo = json.loads(public.readFile(infoJsonPos))
|
||||
pluginInfo = json.loads(mw.readFile(infoJsonPos))
|
||||
|
||||
execstr = "cd " + os.getcwd() + "/plugins/" + \
|
||||
name + " && /bin/bash " + pluginInfo["shell"] \
|
||||
@@ -112,25 +112,25 @@ class plugins_api:
|
||||
taskAdd = (None, mmsg + '[' + name + '-' + version + ']',
|
||||
'execshell', '0', time.strftime('%Y-%m-%d %H:%M:%S'), execstr)
|
||||
|
||||
public.M('tasks').add('id,name,type,status,addtime, execstr', taskAdd)
|
||||
return public.returnJson(True, '已将安装任务添加到队列!')
|
||||
mw.M('tasks').add('id,name,type,status,addtime, execstr', taskAdd)
|
||||
return mw.returnJson(True, '已将安装任务添加到队列!')
|
||||
|
||||
def uninstallOldApi(self):
|
||||
rundir = public.getRunDir()
|
||||
rundir = mw.getRunDir()
|
||||
name = request.form.get('name', '')
|
||||
version = request.form.get('version', '')
|
||||
if name.strip() == '':
|
||||
return public.returnJson(False, "缺少插件名称!", ())
|
||||
return mw.returnJson(False, "缺少插件名称!", ())
|
||||
|
||||
if version.strip() == '':
|
||||
return public.returnJson(False, "缺少版本信息!", ())
|
||||
return mw.returnJson(False, "缺少版本信息!", ())
|
||||
|
||||
infoJsonPos = self.__plugin_dir + '/' + name + '/' + 'info.json'
|
||||
|
||||
if not os.path.exists(infoJsonPos):
|
||||
return public.returnJson(False, "配置文件不存在!", ())
|
||||
return mw.returnJson(False, "配置文件不存在!", ())
|
||||
|
||||
pluginInfo = json.loads(public.readFile(infoJsonPos))
|
||||
pluginInfo = json.loads(mw.readFile(infoJsonPos))
|
||||
|
||||
execstr = "cd " + os.getcwd() + "/plugins/" + \
|
||||
name + " && /bin/bash " + pluginInfo["shell"] \
|
||||
@@ -139,50 +139,50 @@ class plugins_api:
|
||||
taskAdd = (None, '卸载[' + name + '-' + version + ']',
|
||||
'execshell', '0', time.strftime('%Y-%m-%d %H:%M:%S'), execstr)
|
||||
|
||||
public.M('tasks').add('id,name,type,status,addtime, execstr', taskAdd)
|
||||
return public.returnJson(True, '已将卸载任务添加到队列!')
|
||||
mw.M('tasks').add('id,name,type,status,addtime, execstr', taskAdd)
|
||||
return mw.returnJson(True, '已将卸载任务添加到队列!')
|
||||
|
||||
# 卸载时间短,不加入任务中...
|
||||
def uninstallApi(self):
|
||||
rundir = public.getRunDir()
|
||||
rundir = mw.getRunDir()
|
||||
name = request.form.get('name', '')
|
||||
version = request.form.get('version', '')
|
||||
if name.strip() == '':
|
||||
return public.returnJson(False, "缺少插件名称!", ())
|
||||
return mw.returnJson(False, "缺少插件名称!", ())
|
||||
|
||||
if version.strip() == '':
|
||||
return public.returnJson(False, "缺少版本信息!", ())
|
||||
return mw.returnJson(False, "缺少版本信息!", ())
|
||||
|
||||
infoJsonPos = self.__plugin_dir + '/' + name + '/' + 'info.json'
|
||||
|
||||
if not os.path.exists(infoJsonPos):
|
||||
return public.returnJson(False, "配置文件不存在!", ())
|
||||
return mw.returnJson(False, "配置文件不存在!", ())
|
||||
|
||||
pluginInfo = json.loads(public.readFile(infoJsonPos))
|
||||
pluginInfo = json.loads(mw.readFile(infoJsonPos))
|
||||
|
||||
execstr = "cd " + os.getcwd() + "/plugins/" + \
|
||||
name + " && /bin/bash " + pluginInfo["shell"] \
|
||||
+ " uninstall " + version
|
||||
|
||||
data = public.execShell(execstr)
|
||||
if public.isAppleSystem():
|
||||
data = mw.execShell(execstr)
|
||||
if mw.isAppleSystem():
|
||||
print execstr
|
||||
print data[0], data[1]
|
||||
return public.returnJson(True, '卸载执行成功!')
|
||||
return mw.returnJson(True, '卸载执行成功!')
|
||||
# if data[1] == '':
|
||||
# return public.returnJson(True, '已将卸载成功!')
|
||||
# return mw.returnJson(True, '已将卸载成功!')
|
||||
# else:
|
||||
# return public.returnJson(False, '卸载出现错误信息!' + data[1])
|
||||
# return mw.returnJson(False, '卸载出现错误信息!' + data[1])
|
||||
|
||||
def checkApi(self):
|
||||
name = request.form.get('name', '')
|
||||
if name.strip() == '':
|
||||
return public.returnJson(False, "缺少插件名称!", ())
|
||||
return mw.returnJson(False, "缺少插件名称!", ())
|
||||
|
||||
infoJsonPos = self.__plugin_dir + '/' + name + '/' + 'info.json'
|
||||
if not os.path.exists(infoJsonPos):
|
||||
return public.returnJson(False, "配置文件不存在!", ())
|
||||
return public.returnJson(True, "插件存在!", ())
|
||||
return mw.returnJson(False, "配置文件不存在!", ())
|
||||
return mw.returnJson(True, "插件存在!", ())
|
||||
|
||||
def setIndexApi(self):
|
||||
name = request.form.get('name', '')
|
||||
@@ -195,7 +195,7 @@ class plugins_api:
|
||||
def settingApi(self):
|
||||
name = request.args.get('name', '')
|
||||
html = self.__plugin_dir + '/' + name + '/index.html'
|
||||
return public.readFile(html)
|
||||
return mw.readFile(html)
|
||||
|
||||
def runApi(self):
|
||||
name = request.form.get('name', '')
|
||||
@@ -206,8 +206,8 @@ class plugins_api:
|
||||
|
||||
data = self.run(name, func, version, args, script)
|
||||
if data[1] == '':
|
||||
return public.returnJson(True, "OK", data[0].strip())
|
||||
return public.returnJson(False, data[1].strip())
|
||||
return mw.returnJson(True, "OK", data[0].strip())
|
||||
return mw.returnJson(False, data[1].strip())
|
||||
|
||||
def callbackApi(self):
|
||||
name = request.form.get('name', '')
|
||||
@@ -217,23 +217,23 @@ class plugins_api:
|
||||
|
||||
data = self.callback(name, func, args, script)
|
||||
if data[0]:
|
||||
return public.returnJson(True, "OK", data[1])
|
||||
return public.returnJson(False, data[1])
|
||||
return mw.returnJson(True, "OK", data[1])
|
||||
return mw.returnJson(False, data[1])
|
||||
|
||||
def updateZipApi(self):
|
||||
tmp_path = public.getRootDir() + '/temp'
|
||||
tmp_path = mw.getRootDir() + '/temp'
|
||||
if not os.path.exists(tmp_path):
|
||||
os.makedirs(tmp_path)
|
||||
public.execShell("rm -rf " + tmp_path + '/*')
|
||||
mw.execShell("rm -rf " + tmp_path + '/*')
|
||||
|
||||
tmp_file = tmp_path + '/plugin_tmp.zip'
|
||||
from werkzeug.utils import secure_filename
|
||||
from flask import request
|
||||
f = request.files['plugin_zip']
|
||||
if f.filename[-4:] != '.zip':
|
||||
return public.returnJson(False, '仅支持zip文件!')
|
||||
return mw.returnJson(False, '仅支持zip文件!')
|
||||
f.save(tmp_file)
|
||||
public.execShell('cd ' + tmp_path + ' && unzip ' + tmp_file)
|
||||
mw.execShell('cd ' + tmp_path + ' && unzip ' + tmp_file)
|
||||
os.remove(tmp_file)
|
||||
|
||||
p_info = tmp_path + '/info.json'
|
||||
@@ -253,47 +253,47 @@ class plugins_api:
|
||||
tmp_path = d_path
|
||||
p_info = tmp_path + '/info.json'
|
||||
try:
|
||||
data = json.loads(public.readFile(p_info))
|
||||
data['size'] = public.getPathSize(tmp_path)
|
||||
data = json.loads(mw.readFile(p_info))
|
||||
data['size'] = mw.getPathSize(tmp_path)
|
||||
if not 'author' in data:
|
||||
data['author'] = '未知'
|
||||
if not 'home' in data:
|
||||
data['home'] = 'https://www.bt.cn/bbs/forum-40-1.html'
|
||||
plugin_path = public.getPluginDir() + data['name'] + '/info.json'
|
||||
plugin_path = mw.getPluginDir() + data['name'] + '/info.json'
|
||||
data['old_version'] = '0'
|
||||
data['tmp_path'] = tmp_path
|
||||
if os.path.exists(plugin_path):
|
||||
try:
|
||||
old_info = json.loads(public.ReadFile(plugin_path))
|
||||
old_info = json.loads(mw.ReadFile(plugin_path))
|
||||
data['old_version'] = old_info['versions']
|
||||
except:
|
||||
pass
|
||||
except:
|
||||
public.execShell("rm -rf " + tmp_path)
|
||||
return public.returnJson(False, '在压缩包中没有找到插件信息,请检查插件包!')
|
||||
mw.execShell("rm -rf " + tmp_path)
|
||||
return mw.returnJson(False, '在压缩包中没有找到插件信息,请检查插件包!')
|
||||
protectPlist = ('openresty', 'mysql', 'php', 'csvn', 'gogs', 'pureftp')
|
||||
if data['name'] in protectPlist:
|
||||
return public.returnJson(False, '[' + data['name'] + '],重要插件不可修改!')
|
||||
return public.getJson(data)
|
||||
return mw.returnJson(False, '[' + data['name'] + '],重要插件不可修改!')
|
||||
return mw.getJson(data)
|
||||
|
||||
def inputZipApi(self):
|
||||
plugin_name = request.form.get('plugin_name', '')
|
||||
tmp_path = request.form.get('tmp_path', '')
|
||||
|
||||
if not os.path.exists(tmp_path):
|
||||
return public.returnJson(False, '临时文件不存在,请重新上传!')
|
||||
plugin_path = public.getPluginDir() + '/' + plugin_name
|
||||
return mw.returnJson(False, '临时文件不存在,请重新上传!')
|
||||
plugin_path = mw.getPluginDir() + '/' + plugin_name
|
||||
if not os.path.exists(plugin_path):
|
||||
print public.execShell('mkdir -p ' + plugin_path)
|
||||
public.execShell("\cp -rf " + tmp_path + '/* ' + plugin_path + '/')
|
||||
public.execShell('chmod -R 755 ' + plugin_path)
|
||||
p_info = public.readFile(plugin_path + '/info.json')
|
||||
print mw.execShell('mkdir -p ' + plugin_path)
|
||||
mw.execShell("\cp -rf " + tmp_path + '/* ' + plugin_path + '/')
|
||||
mw.execShell('chmod -R 755 ' + plugin_path)
|
||||
p_info = mw.readFile(plugin_path + '/info.json')
|
||||
if p_info:
|
||||
public.writeLog('软件管理', '安装第三方插件[%s]' %
|
||||
json.loads(p_info)['title'])
|
||||
return public.returnJson(True, '安装成功!')
|
||||
public.execShell("rm -rf " + plugin_path)
|
||||
return public.returnJson(False, '安装失败!')
|
||||
mw.writeLog('软件管理', '安装第三方插件[%s]' %
|
||||
json.loads(p_info)['title'])
|
||||
return mw.returnJson(True, '安装成功!')
|
||||
mw.execShell("rm -rf " + plugin_path)
|
||||
return mw.returnJson(False, '安装失败!')
|
||||
##### ----- end ----- ###
|
||||
|
||||
# 进程是否存在
|
||||
@@ -319,11 +319,11 @@ class plugins_api:
|
||||
# 检查是否正在安装
|
||||
def checkSetupTask(self, sName, sVer, sCoexist):
|
||||
if not self.__tasks:
|
||||
self.__tasks = public.M('tasks').where(
|
||||
self.__tasks = mw.M('tasks').where(
|
||||
"status!=?", ('1',)).field('status,name').select()
|
||||
isTask = '1'
|
||||
for task in self.__tasks:
|
||||
tmpt = public.getStrBetween('[', ']', task['name'])
|
||||
tmpt = mw.getStrBetween('[', ']', task['name'])
|
||||
if not tmpt:
|
||||
continue
|
||||
tmp1 = tmpt.split('-')
|
||||
@@ -407,9 +407,9 @@ class plugins_api:
|
||||
|
||||
def checkDisplayIndex(self, name, version):
|
||||
if not os.path.exists(self.__index):
|
||||
public.writeFile(self.__index, '[]')
|
||||
mw.writeFile(self.__index, '[]')
|
||||
|
||||
indexList = json.loads(public.readFile(self.__index))
|
||||
indexList = json.loads(mw.readFile(self.__index))
|
||||
if type(version) == list:
|
||||
for index in range(len(version)):
|
||||
vname = name + '-' + version[index]
|
||||
@@ -424,7 +424,7 @@ class plugins_api:
|
||||
def getVersion(self, path):
|
||||
version_f = path + '/version.pl'
|
||||
if os.path.exists(version_f):
|
||||
return public.readFile(version_f).strip()
|
||||
return mw.readFile(version_f).strip()
|
||||
return ''
|
||||
|
||||
# 构造本地插件信息
|
||||
@@ -436,13 +436,13 @@ class plugins_api:
|
||||
if info["checks"][0:1] == '/':
|
||||
checks = info["checks"]
|
||||
else:
|
||||
checks = public.getRootDir() + '/' + info['checks']
|
||||
checks = mw.getRootDir() + '/' + info['checks']
|
||||
|
||||
if info.has_key('path'):
|
||||
path = info['path']
|
||||
|
||||
if path[0:1] != '/':
|
||||
path = public.getRootDir() + '/' + path
|
||||
path = mw.getRootDir() + '/' + path
|
||||
|
||||
if info.has_key('coexist') and info['coexist']:
|
||||
coexist = True
|
||||
@@ -538,7 +538,7 @@ class plugins_api:
|
||||
json_file = path + '/info.json'
|
||||
if os.path.exists(json_file):
|
||||
try:
|
||||
data = json.loads(public.readFile(json_file))
|
||||
data = json.loads(mw.readFile(json_file))
|
||||
tmp_data = self.makeList(data, sType)
|
||||
for index in range(len(tmp_data)):
|
||||
plugins_info.append(tmp_data[index])
|
||||
@@ -556,7 +556,7 @@ class plugins_api:
|
||||
json_file = path + '/info.json'
|
||||
if os.path.exists(json_file):
|
||||
try:
|
||||
data = json.loads(public.readFile(json_file))
|
||||
data = json.loads(mw.readFile(json_file))
|
||||
tmp_data = self.makeList(data, sType)
|
||||
for index in range(len(tmp_data)):
|
||||
plugins_info.append(tmp_data[index])
|
||||
@@ -606,7 +606,7 @@ class plugins_api:
|
||||
if os.path.isdir(path):
|
||||
json_file = path + '/info.json'
|
||||
if os.path.exists(json_file):
|
||||
data = json.loads(public.readFile(json_file))
|
||||
data = json.loads(mw.readFile(json_file))
|
||||
if sType == '0':
|
||||
tmp_list.append(data)
|
||||
|
||||
@@ -667,7 +667,7 @@ class plugins_api:
|
||||
if os.path.isdir(path):
|
||||
json_file = path + '/info.json'
|
||||
if os.path.exists(json_file):
|
||||
data = json.loads(public.readFile(json_file))
|
||||
data = json.loads(mw.readFile(json_file))
|
||||
if sType == '0':
|
||||
tmp_list.append(data)
|
||||
|
||||
@@ -695,7 +695,7 @@ class plugins_api:
|
||||
# print sType, sPage, sPageSize
|
||||
|
||||
ret = {}
|
||||
ret['type'] = json.loads(public.readFile(self.__type))
|
||||
ret['type'] = json.loads(mw.readFile(self.__type))
|
||||
# plugins_info = self.getAllListThread(sType)
|
||||
# plugins_info = self.getAllListProcess(sType)
|
||||
data = self.getAllListPage(sType, sPage, sPageSize)
|
||||
@@ -707,14 +707,14 @@ class plugins_api:
|
||||
args['tojs'] = 'getSList'
|
||||
args['row'] = sPageSize
|
||||
|
||||
ret['list'] = public.getPage(args)
|
||||
ret['list'] = mw.getPage(args)
|
||||
return ret
|
||||
|
||||
def getIndexList(self):
|
||||
if not os.path.exists(self.__index):
|
||||
public.writeFile(self.__index, '[]')
|
||||
mw.writeFile(self.__index, '[]')
|
||||
|
||||
indexList = json.loads(public.readFile(self.__index))
|
||||
indexList = json.loads(mw.readFile(self.__index))
|
||||
plist = []
|
||||
app = []
|
||||
for i in indexList:
|
||||
@@ -726,7 +726,7 @@ class plugins_api:
|
||||
json_file = path + '/info.json'
|
||||
if os.path.exists(json_file):
|
||||
try:
|
||||
data = json.loads(public.readFile(json_file))
|
||||
data = json.loads(mw.readFile(json_file))
|
||||
tmp_data = self.makeList(data)
|
||||
for index in range(len(tmp_data)):
|
||||
if tmp_data[index]['versions'] == info[1] or info[1] in tmp_data[index]['versions']:
|
||||
@@ -743,40 +743,40 @@ class plugins_api:
|
||||
|
||||
def setIndexSort(self, sort):
|
||||
data = sort.split('|')
|
||||
public.writeFile(self.__index, json.dumps(data))
|
||||
mw.writeFile(self.__index, json.dumps(data))
|
||||
return True
|
||||
|
||||
def addIndex(self, name, version):
|
||||
if not os.path.exists(self.__index):
|
||||
public.writeFile(self.__index, '[]')
|
||||
mw.writeFile(self.__index, '[]')
|
||||
|
||||
indexList = json.loads(public.readFile(self.__index))
|
||||
indexList = json.loads(mw.readFile(self.__index))
|
||||
vname = name + '-' + version
|
||||
|
||||
if vname in indexList:
|
||||
return public.returnJson(False, '请不要重复添加!')
|
||||
return mw.returnJson(False, '请不要重复添加!')
|
||||
if len(indexList) >= 12:
|
||||
return public.returnJson(False, '首页最多只能显示12个软件!')
|
||||
return mw.returnJson(False, '首页最多只能显示12个软件!')
|
||||
|
||||
indexList.append(vname)
|
||||
public.writeFile(self.__index, json.dumps(indexList))
|
||||
return public.returnJson(True, '添加成功!')
|
||||
mw.writeFile(self.__index, json.dumps(indexList))
|
||||
return mw.returnJson(True, '添加成功!')
|
||||
|
||||
def removeIndex(self, name, version):
|
||||
if not os.path.exists(self.__index):
|
||||
public.writeFile(self.__index, '[]')
|
||||
mw.writeFile(self.__index, '[]')
|
||||
|
||||
indexList = json.loads(public.readFile(self.__index))
|
||||
indexList = json.loads(mw.readFile(self.__index))
|
||||
vname = name + '-' + version
|
||||
if not vname in indexList:
|
||||
return public.returnJson(True, '删除成功!')
|
||||
return mw.returnJson(True, '删除成功!')
|
||||
indexList.remove(vname)
|
||||
public.writeFile(self.__index, json.dumps(indexList))
|
||||
return public.returnJson(True, '删除成功!')
|
||||
mw.writeFile(self.__index, json.dumps(indexList))
|
||||
return mw.returnJson(True, '删除成功!')
|
||||
|
||||
# shell 调用
|
||||
def run(self, name, func, version, args='', script='index'):
|
||||
path = public.getRunDir() + '/' + self.__plugin_dir + \
|
||||
path = mw.getRunDir() + '/' + self.__plugin_dir + \
|
||||
'/' + name + '/' + script + '.py'
|
||||
py = 'python ' + path
|
||||
|
||||
@@ -787,24 +787,24 @@ class plugins_api:
|
||||
|
||||
if not os.path.exists(path):
|
||||
return ('', '')
|
||||
data = public.execShell(py_cmd)
|
||||
data = mw.execShell(py_cmd)
|
||||
# data = os.popen(py_cmd).read()
|
||||
|
||||
if public.isAppleSystem():
|
||||
if mw.isAppleSystem():
|
||||
print 'run', py_cmd
|
||||
# print os.path.exists(py_cmd)
|
||||
return (data[0].strip(), data[1].strip())
|
||||
|
||||
# 映射包调用
|
||||
def callback(self, name, func, args='', script='index'):
|
||||
package = public.getRunDir() + '/plugins/' + name
|
||||
package = mw.getRunDir() + '/plugins/' + name
|
||||
if not os.path.exists(package):
|
||||
return (False, "插件不存在!")
|
||||
|
||||
sys.path.append(package)
|
||||
eval_str = "__import__('" + script + "')." + func + '(' + args + ')'
|
||||
newRet = eval(eval_str)
|
||||
if public.isAppleSystem():
|
||||
if mw.isAppleSystem():
|
||||
print 'callback', eval_str
|
||||
|
||||
return (True, newRet)
|
||||
|
||||
+453
-453
File diff suppressed because it is too large
Load Diff
+89
-93
@@ -11,7 +11,8 @@ from flask import Flask, session
|
||||
from flask import request
|
||||
|
||||
import db
|
||||
import public
|
||||
import mw
|
||||
import requests
|
||||
import config_api
|
||||
|
||||
|
||||
@@ -31,12 +32,12 @@ class system_api:
|
||||
pids = None
|
||||
|
||||
def __init__(self):
|
||||
self.setupPath = public.getServerDir()
|
||||
self.setupPath = mw.getServerDir()
|
||||
|
||||
##### ----- start ----- ###
|
||||
def networkApi(self):
|
||||
data = self.getNetWork()
|
||||
return public.getJson(data)
|
||||
return mw.getJson(data)
|
||||
|
||||
def updateServerApi(self):
|
||||
stype = request.args.get('type', 'check')
|
||||
@@ -45,11 +46,11 @@ class system_api:
|
||||
|
||||
def systemTotalApi(self):
|
||||
data = self.getSystemTotal()
|
||||
return public.getJson(data)
|
||||
return mw.getJson(data)
|
||||
|
||||
def diskInfoApi(self):
|
||||
diskInfo = self.getDiskInfo()
|
||||
return public.getJson(diskInfo)
|
||||
return mw.getJson(diskInfo)
|
||||
|
||||
def setControlApi(self):
|
||||
stype = request.form.get('type', '')
|
||||
@@ -61,58 +62,58 @@ class system_api:
|
||||
start = request.args.get('start', '')
|
||||
end = request.args.get('end', '')
|
||||
data = self.getLoadAverageData(start, end)
|
||||
return public.getJson(data)
|
||||
return mw.getJson(data)
|
||||
|
||||
def getCpuIoApi(self):
|
||||
start = request.args.get('start', '')
|
||||
end = request.args.get('end', '')
|
||||
data = self.getCpuIoData(start, end)
|
||||
return public.getJson(data)
|
||||
return mw.getJson(data)
|
||||
|
||||
def getDiskIoApi(self):
|
||||
start = request.args.get('start', '')
|
||||
end = request.args.get('end', '')
|
||||
data = self.getDiskIoData(start, end)
|
||||
return public.getJson(data)
|
||||
return mw.getJson(data)
|
||||
|
||||
def getNetworkIoApi(self):
|
||||
start = request.args.get('start', '')
|
||||
end = request.args.get('end', '')
|
||||
data = self.getNetWorkIoData(start, end)
|
||||
return public.getJson(data)
|
||||
return mw.getJson(data)
|
||||
|
||||
def rememoryApi(self):
|
||||
os.system('sync')
|
||||
scriptFile = public.getRunDir() + '/script/rememory.sh'
|
||||
public.execShell("/bin/bash " + scriptFile)
|
||||
scriptFile = mw.getRunDir() + '/script/rememory.sh'
|
||||
mw.execShell("/bin/bash " + scriptFile)
|
||||
data = self.getMemInfo()
|
||||
return public.getJson(data)
|
||||
return mw.getJson(data)
|
||||
|
||||
# 重启面板
|
||||
def restartApi(self):
|
||||
self.restartMw()
|
||||
return public.returnJson(True, '面板已重启!')
|
||||
return mw.returnJson(True, '面板已重启!')
|
||||
|
||||
def restartServerApi(self):
|
||||
if public.isAppleSystem():
|
||||
return public.returnJson(False, "开发环境不可重起")
|
||||
if mw.isAppleSystem():
|
||||
return mw.returnJson(False, "开发环境不可重起")
|
||||
self.restartServer()
|
||||
return public.returnJson(True, '正在重启服务器!')
|
||||
return mw.returnJson(True, '正在重启服务器!')
|
||||
##### ----- end ----- ###
|
||||
|
||||
@async
|
||||
def restartMw(self):
|
||||
sleep(1)
|
||||
cmd = public.getRunDir() + '/scripts/init.d/mw restart'
|
||||
#print cmd
|
||||
public.execShell(cmd)
|
||||
sleep(0.3)
|
||||
# cmd = mw.getRunDir() + '/scripts/init.d/mw restart'
|
||||
# print cmd
|
||||
mw.execShell('service mw restart')
|
||||
|
||||
@async
|
||||
def restartServer(self):
|
||||
if not public.isRestart():
|
||||
return public.returnJson(False, '请等待所有安装任务完成再执行!')
|
||||
public.execShell("sync && init 6 &")
|
||||
return public.returnJson(True, '命令发送成功!')
|
||||
if not mw.isRestart():
|
||||
return mw.returnJson(False, '请等待所有安装任务完成再执行!')
|
||||
mw.execShell("sync && init 6 &")
|
||||
return mw.returnJson(True, '命令发送成功!')
|
||||
|
||||
# 名取PID
|
||||
def getPid(self, pname):
|
||||
@@ -150,30 +151,30 @@ class system_api:
|
||||
|
||||
def getPanelInfo(self, get=None):
|
||||
# 取面板配置
|
||||
address = public.GetLocalIp()
|
||||
address = mw.GetLocalIp()
|
||||
try:
|
||||
try:
|
||||
port = web.ctx.host.split(':')[1]
|
||||
except:
|
||||
port = public.readFile('data/port.pl')
|
||||
port = mw.readFile('data/port.pl')
|
||||
except:
|
||||
port = '8888'
|
||||
domain = ''
|
||||
if os.path.exists('data/domain.conf'):
|
||||
domain = public.readFile('data/domain.conf')
|
||||
domain = mw.readFile('data/domain.conf')
|
||||
|
||||
autoUpdate = ''
|
||||
if os.path.exists('data/autoUpdate.pl'):
|
||||
autoUpdate = 'checked'
|
||||
limitip = ''
|
||||
if os.path.exists('data/limitip.conf'):
|
||||
limitip = public.readFile('data/limitip.conf')
|
||||
limitip = mw.readFile('data/limitip.conf')
|
||||
|
||||
templates = []
|
||||
for template in os.listdir('templates/'):
|
||||
if os.path.isdir('templates/' + template):
|
||||
templates.append(template)
|
||||
template = public.readFile('data/templates.pl')
|
||||
template = mw.readFile('data/templates.pl')
|
||||
|
||||
check502 = ''
|
||||
if os.path.exists('data/502Task.pl'):
|
||||
@@ -188,7 +189,7 @@ class system_api:
|
||||
data['cpuRealUsed'] = cpu[0]
|
||||
data['time'] = self.getBootTime()
|
||||
data['system'] = self.getSystemVersion()
|
||||
data['isuser'] = public.M('users').where(
|
||||
data['isuser'] = mw.M('users').where(
|
||||
'username=?', ('admin',)).count()
|
||||
data['version'] = '0.0.1'
|
||||
return data
|
||||
@@ -225,22 +226,22 @@ class system_api:
|
||||
titlePl = 'data/title.pl'
|
||||
title = 'Linux面板'
|
||||
if os.path.exists(titlePl):
|
||||
title = public.readFile(titlePl).strip()
|
||||
title = mw.readFile(titlePl).strip()
|
||||
return title
|
||||
|
||||
def getSystemVersion(self):
|
||||
# 取操作系统版本
|
||||
if public.getOs() == 'darwin':
|
||||
data = public.execShell('sw_vers')[0]
|
||||
if mw.getOs() == 'darwin':
|
||||
data = mw.execShell('sw_vers')[0]
|
||||
data_list = data.strip().split("\n")
|
||||
mac_version = ''
|
||||
for x in data_list:
|
||||
mac_version += x.split("\t")[1] + ' '
|
||||
return mac_version
|
||||
|
||||
version = public.readFile('/etc/redhat-release')
|
||||
version = mw.readFile('/etc/redhat-release')
|
||||
if not version:
|
||||
version = public.readFile(
|
||||
version = mw.readFile(
|
||||
'/etc/issue').strip().split("\n")[0].replace('\\n', '').replace('\l', '').strip()
|
||||
else:
|
||||
version = version.replace('release ', '').strip()
|
||||
@@ -250,14 +251,14 @@ class system_api:
|
||||
# 取系统启动时间
|
||||
start_time = psutil.boot_time()
|
||||
run_time = time.time() - start_time
|
||||
# conf = public.readFile('/proc/uptime').split()
|
||||
# conf = mw.readFile('/proc/uptime').split()
|
||||
tStr = float(run_time)
|
||||
min = tStr / 60
|
||||
hours = min / 60
|
||||
days = math.floor(hours / 24)
|
||||
hours = math.floor(hours - (days * 24))
|
||||
min = math.floor(min - (days * 60 * 24) - (hours * 60))
|
||||
return public.getInfo('已不间断运行: {1}天{2}小时{3}分钟', (str(int(days)), str(int(hours)), str(int(min))))
|
||||
return mw.getInfo('已不间断运行: {1}天{2}小时{3}分钟', (str(int(days)), str(int(hours)), str(int(min))))
|
||||
|
||||
def getCpuInfo(self, interval=1):
|
||||
# 取CPU信息
|
||||
@@ -268,7 +269,7 @@ class system_api:
|
||||
def getMemInfo(self):
|
||||
# 取内存信息
|
||||
mem = psutil.virtual_memory()
|
||||
if public.getOs() == 'darwin':
|
||||
if mw.getOs() == 'darwin':
|
||||
memInfo = {
|
||||
'memTotal': mem.total / 1024 / 1024
|
||||
}
|
||||
@@ -292,7 +293,7 @@ class system_api:
|
||||
import psutil
|
||||
mem = psutil.virtual_memory()
|
||||
|
||||
if public.getOs() == 'darwin':
|
||||
if mw.getOs() == 'darwin':
|
||||
return mem.percent
|
||||
|
||||
memInfo = {'memTotal': mem.total / 1024 / 1024, 'memFree': mem.free / 1024 / 1024,
|
||||
@@ -323,9 +324,9 @@ class system_api:
|
||||
|
||||
def getDiskInfo2(self):
|
||||
# 取磁盘分区信息
|
||||
temp = public.execShell(
|
||||
temp = mw.execShell(
|
||||
"df -h -P|grep '/'|grep -v tmpfs | grep -v devfs")[0]
|
||||
tempInodes = public.execShell(
|
||||
tempInodes = mw.execShell(
|
||||
"df -i -P|grep '/'|grep -v tmpfs | grep -v devfs")[0]
|
||||
temp1 = temp.split('\n')
|
||||
tempInodes1 = tempInodes.split('\n')
|
||||
@@ -423,7 +424,7 @@ class system_api:
|
||||
else:
|
||||
os.remove(filename)
|
||||
count += 1
|
||||
public.serviceReload()
|
||||
mw.serviceReload()
|
||||
os.system('echo > /tmp/panelBoot.pl')
|
||||
return total, count
|
||||
|
||||
@@ -470,10 +471,10 @@ class system_api:
|
||||
networkIo = psutil.net_io_counters()[:4]
|
||||
|
||||
if not os.path.exists(tmpfile):
|
||||
public.writeFile(tmpfile, str(
|
||||
mw.writeFile(tmpfile, str(
|
||||
networkIo[0]) + '|' + str(networkIo[1]) + '|' + str(int(time.time())))
|
||||
|
||||
lastValue = public.readFile(tmpfile).split('|')
|
||||
lastValue = mw.readFile(tmpfile).split('|')
|
||||
|
||||
ntime = time.time()
|
||||
networkInfo = {}
|
||||
@@ -486,7 +487,7 @@ class system_api:
|
||||
networkInfo['downPackets'] = networkIo[3]
|
||||
networkInfo['upPackets'] = networkIo[2]
|
||||
|
||||
public.writeFile(tmpfile, str(
|
||||
mw.writeFile(tmpfile, str(
|
||||
networkIo[0]) + '|' + str(networkIo[1]) + '|' + str(int(time.time())))
|
||||
|
||||
# networkInfo['cpu'] = self.GetCpuInfo(0.1)
|
||||
@@ -496,24 +497,24 @@ class system_api:
|
||||
|
||||
def getNetWorkIoData(self, start, end):
|
||||
# 取指定时间段的网络Io
|
||||
data = public.M('network').dbfile('system').where("addtime>=? AND addtime<=?", (start, end)).field(
|
||||
data = mw.M('network').dbfile('system').where("addtime>=? AND addtime<=?", (start, end)).field(
|
||||
'id,up,down,total_up,total_down,down_packets,up_packets,addtime').order('id asc').select()
|
||||
return self.toAddtime(data)
|
||||
|
||||
def getDiskIoData(self, start, end):
|
||||
# 取指定时间段的磁盘Io
|
||||
data = public.M('diskio').dbfile('system').where("addtime>=? AND addtime<=?", (start, end)).field(
|
||||
data = mw.M('diskio').dbfile('system').where("addtime>=? AND addtime<=?", (start, end)).field(
|
||||
'id,read_count,write_count,read_bytes,write_bytes,read_time,write_time,addtime').order('id asc').select()
|
||||
return self.toAddtime(data)
|
||||
|
||||
def getCpuIoData(self, start, end):
|
||||
# 取指定时间段的CpuIo
|
||||
data = public.M('cpuio').dbfile('system').where("addtime>=? AND addtime<=?",
|
||||
(start, end)).field('id,pro,mem,addtime').order('id asc').select()
|
||||
data = mw.M('cpuio').dbfile('system').where("addtime>=? AND addtime<=?",
|
||||
(start, end)).field('id,pro,mem,addtime').order('id asc').select()
|
||||
return self.toAddtime(data, True)
|
||||
|
||||
def getLoadAverageData(self, start, end):
|
||||
data = public.M('load_average').dbfile('system').where("addtime>=? AND addtime<=?", (
|
||||
data = mw.M('load_average').dbfile('system').where("addtime>=? AND addtime<=?", (
|
||||
start, end)).field('id,pro,one,five,fifteen,addtime').order('id asc').select()
|
||||
return self.toAddtime(data)
|
||||
|
||||
@@ -559,37 +560,37 @@ class system_api:
|
||||
filename = 'data/control.conf'
|
||||
|
||||
if stype == '0':
|
||||
public.execShell("rm -f " + filename)
|
||||
mw.execShell("rm -f " + filename)
|
||||
elif stype == '1':
|
||||
_day = int(day)
|
||||
if _day < 1:
|
||||
return public.returnJson(False, "设置失败!")
|
||||
public.writeFile(filename, day)
|
||||
return mw.returnJson(False, "设置失败!")
|
||||
mw.writeFile(filename, day)
|
||||
elif stype == 'del':
|
||||
if not public.isRestart():
|
||||
return public.returnJson(False, '请等待所有安装任务完成再执行')
|
||||
if not mw.isRestart():
|
||||
return mw.returnJson(False, '请等待所有安装任务完成再执行')
|
||||
os.remove("data/system.db")
|
||||
|
||||
sql = db.Sql().dbfile('system')
|
||||
csql = public.readFile('data/sql/system.sql')
|
||||
csql = mw.readFile('data/sql/system.sql')
|
||||
csql_list = csql.split(';')
|
||||
for index in range(len(csql_list)):
|
||||
sql.execute(csql_list[index], ())
|
||||
return public.returnJson(True, "监控服务已关闭")
|
||||
return mw.returnJson(True, "监控服务已关闭")
|
||||
else:
|
||||
data = {}
|
||||
if os.path.exists(filename):
|
||||
try:
|
||||
data['day'] = int(public.readFile(filename))
|
||||
data['day'] = int(mw.readFile(filename))
|
||||
except:
|
||||
data['day'] = 30
|
||||
data['status'] = True
|
||||
else:
|
||||
data['day'] = 30
|
||||
data['status'] = False
|
||||
return public.getJson(data)
|
||||
return mw.getJson(data)
|
||||
|
||||
return public.returnJson(True, "设置成功!")
|
||||
return mw.returnJson(True, "设置成功!")
|
||||
|
||||
def versionDiff(self, old, new):
|
||||
'''
|
||||
@@ -604,13 +605,9 @@ class system_api:
|
||||
old_list = old.split('.')
|
||||
ret = 'none'
|
||||
|
||||
# t = [0] * 3
|
||||
isHasNew = True
|
||||
for i in range(3):
|
||||
if int(new_list[i]) > int(old_list[i]):
|
||||
pass
|
||||
else:
|
||||
isHasNew = False
|
||||
if int(new_list[0]) == int(old_list[0]) and int(new_list[1]) == int(old_list[1]) and int(new_list[2]) == int(old_list[2]):
|
||||
isHasNew = False
|
||||
|
||||
if isHasNew:
|
||||
return 'new'
|
||||
@@ -619,8 +616,9 @@ class system_api:
|
||||
def getServerInfo(self):
|
||||
upAddr = 'https://raw.githubusercontent.com/midoks/mdserver-web/master/version/info.json'
|
||||
try:
|
||||
version = public.httpGet(upAddr)
|
||||
version = json.loads(version)
|
||||
requests.adapters.DEFAULT_RETRIES = 2
|
||||
r = requests.get(upAddr, verify=False)
|
||||
version = json.loads(r.content)
|
||||
return version[0]
|
||||
except Exception as e:
|
||||
print 'getServerInfo', e
|
||||
@@ -629,71 +627,69 @@ class system_api:
|
||||
def updateServer(self, stype, version=''):
|
||||
# 更新服务
|
||||
try:
|
||||
if not public.isRestart():
|
||||
return public.returnJson(False, '请等待所有安装任务完成再执行!')
|
||||
if not mw.isRestart():
|
||||
return mw.returnJson(False, '请等待所有安装任务完成再执行!')
|
||||
|
||||
if stype == 'check':
|
||||
version_now = config_api.config_api().getVersion()
|
||||
version_new_info = self.getServerInfo()
|
||||
if not 'version' in version_new_info:
|
||||
return public.returnJson(False, '服务器数据有问题!')
|
||||
return mw.returnJson(False, '服务器数据或网络有问题!')
|
||||
|
||||
diff = self.versionDiff(
|
||||
version_now, version_new_info['version'])
|
||||
print diff
|
||||
if diff == 'new':
|
||||
return public.returnJson(True, '有新版本!', version_new_info['version'])
|
||||
return mw.returnJson(True, '有新版本!', version_new_info['version'])
|
||||
elif diff == 'test':
|
||||
return public.returnJson(True, '有测试版本!', version_new_info['version'])
|
||||
return mw.returnJson(True, '有测试版本!', version_new_info['version'])
|
||||
else:
|
||||
return public.returnJson(False, '已经是最新,无需更新!')
|
||||
return mw.returnJson(False, '已经是最新,无需更新!')
|
||||
|
||||
if stype == 'info':
|
||||
version_new_info = self.getServerInfo()
|
||||
version_now = config_api.config_api().getVersion()
|
||||
|
||||
if not 'version' in version_new_info:
|
||||
return public.returnJson(False, '服务器数据有问题!')
|
||||
return mw.returnJson(False, '服务器数据有问题!')
|
||||
diff = self.versionDiff(
|
||||
version_now, version_new_info['version'])
|
||||
return public.returnJson(True, '更新信息!', version_new_info)
|
||||
return mw.returnJson(True, '更新信息!', version_new_info)
|
||||
|
||||
if stype == 'update':
|
||||
if version == '':
|
||||
return public.returnJson(False, '缺少版本信息!')
|
||||
return mw.returnJson(False, '缺少版本信息!')
|
||||
|
||||
v_new_info = self.getServerInfo()
|
||||
if v_new_info['version'] != version:
|
||||
return public.returnJson(False, '更新失败,请重试!')
|
||||
return mw.returnJson(False, '更新失败,请重试!')
|
||||
|
||||
if not 'path' in v_new_info or v_new_info['path'] == '':
|
||||
return public.returnJson(False, '下载地址不存在!')
|
||||
return mw.returnJson(False, '下载地址不存在!')
|
||||
|
||||
newUrl = v_new_info['path']
|
||||
toPath = public.getRootDir() + '/temp'
|
||||
toPath = mw.getRootDir() + '/temp'
|
||||
if not os.path.exists(toPath):
|
||||
public.execShell('mkdir -p ' + toPath)
|
||||
mw.execShell('mkdir -p ' + toPath)
|
||||
|
||||
if not os.path.exists(toPath + '/mw.zip'):
|
||||
public.execShell('wget -O ' + toPath + '/mw.zip ' + newUrl)
|
||||
mw.execShell('wget -O ' + toPath + '/mw.zip ' + newUrl)
|
||||
|
||||
public.execShell('unzip -o ' + toPath + '/mw.zip' + ' -d ./')
|
||||
public.execShell('unzip -o mdserver-web.zip -d ./')
|
||||
public.execShell('rm -f mdserver-web.zip')
|
||||
return public.returnJson(True, '安装更新成功!')
|
||||
mw.execShell('unzip -o ' + toPath + '/mw.zip' + ' -d ./')
|
||||
mw.execShell('unzip -o mw.zip -d ./')
|
||||
mw.execShell('rm -f mw.zip')
|
||||
return mw.returnJson(True, '安装更新成功,需自己重启!')
|
||||
|
||||
return public.returnJson(False, '已经是最新,无需更新!')
|
||||
return mw.returnJson(False, '已经是最新,无需更新!')
|
||||
except Exception as ex:
|
||||
print 'updateServer', ex
|
||||
return public.returnJson(False, "连接服务器失败!")
|
||||
return mw.returnJson(False, "连接服务器失败!")
|
||||
|
||||
# 修复面板
|
||||
def repPanel(self, get):
|
||||
vp = ''
|
||||
if public.readFile('/www/server/mdserver-web/class/common.py').find('checkSafe') != -1:
|
||||
if mw.readFile('/www/server/mdserver-web/class/common.py').find('checkSafe') != -1:
|
||||
vp = '_pro'
|
||||
public.ExecShell("wget -O update.sh " + public.get_url() +
|
||||
"/install/update" + vp + ".sh && bash update.sh")
|
||||
mw.ExecShell("wget -O update.sh " + mw.get_url() +
|
||||
"/install/update" + vp + ".sh && bash update.sh")
|
||||
if hasattr(web.ctx.session, 'getCloudPlugin'):
|
||||
del(web.ctx.session['getCloudPlugin'])
|
||||
return True
|
||||
|
||||
+18
-18
@@ -4,7 +4,7 @@ import psutil
|
||||
import time
|
||||
import os
|
||||
import sys
|
||||
import public
|
||||
import mw
|
||||
import re
|
||||
import json
|
||||
import pwd
|
||||
@@ -19,7 +19,7 @@ class task_api:
|
||||
pass
|
||||
|
||||
def countApi(self):
|
||||
c = public.M('tasks').where("status!=?", ('1',)).count()
|
||||
c = mw.M('tasks').where("status!=?", ('1',)).count()
|
||||
return str(c)
|
||||
|
||||
def listApi(self):
|
||||
@@ -31,36 +31,36 @@ class task_api:
|
||||
start = (int(p) - 1) * int(limit)
|
||||
limit_str = str(start) + ',' + str(limit)
|
||||
|
||||
_list = public.M('tasks').where('', ()).field(
|
||||
_list = mw.M('tasks').where('', ()).field(
|
||||
'id,name,type,status,addtime,start,end').limit(limit_str).order('id desc').select()
|
||||
_ret = {}
|
||||
_ret['data'] = _list
|
||||
|
||||
count = public.M('tasks').where('', ()).count()
|
||||
count = mw.M('tasks').where('', ()).count()
|
||||
_page = {}
|
||||
_page['count'] = count
|
||||
_page['tojs'] = 'remind'
|
||||
_page['p'] = p
|
||||
|
||||
_ret['page'] = public.getPage(_page)
|
||||
return public.getJson(_ret)
|
||||
_ret['page'] = mw.getPage(_page)
|
||||
return mw.getJson(_ret)
|
||||
|
||||
def getExecLogApi(self):
|
||||
file = os.getcwd() + "/tmp/panelExec.log"
|
||||
v = public.getLastLine(file, 100)
|
||||
v = mw.getLastLine(file, 100)
|
||||
return v
|
||||
|
||||
def getTaskSpeedApi(self):
|
||||
tempFile = os.getcwd() + '/tmp/panelExec.log'
|
||||
freshFile = os.getcwd() + '/tmp/panelFresh'
|
||||
|
||||
find = public.M('tasks').where('status=? OR status=?',
|
||||
('-1', '0')).field('id,type,name,execstr').find()
|
||||
find = mw.M('tasks').where('status=? OR status=?',
|
||||
('-1', '0')).field('id,type,name,execstr').find()
|
||||
if not len(find):
|
||||
return public.returnJson(False, '当前没有任务队列在执行-2!')
|
||||
return mw.returnJson(False, '当前没有任务队列在执行-2!')
|
||||
|
||||
isTask = os.getcwd() + '/tmp/panelTask.pl'
|
||||
public.writeFile(isTask, 'True')
|
||||
mw.writeFile(isTask, 'True')
|
||||
|
||||
echoMsg = {}
|
||||
echoMsg['name'] = find['name']
|
||||
@@ -68,19 +68,19 @@ class task_api:
|
||||
if find['type'] == 'download':
|
||||
import json
|
||||
try:
|
||||
tmp = public.readFile(tempFile)
|
||||
tmp = mw.readFile(tempFile)
|
||||
if len(tmp) < 10:
|
||||
return public.returnJson(False, '当前没有任务队列在执行-3!')
|
||||
return mw.returnJson(False, '当前没有任务队列在执行-3!')
|
||||
echoMsg['msg'] = json.loads(tmp)
|
||||
echoMsg['isDownload'] = True
|
||||
except:
|
||||
public.M('tasks').where(
|
||||
mw.M('tasks').where(
|
||||
"id=?", (find['id'],)).save('status', ('0',))
|
||||
return public.returnJson(False, '当前没有任务队列在执行-4!')
|
||||
return mw.returnJson(False, '当前没有任务队列在执行-4!')
|
||||
else:
|
||||
echoMsg['msg'] = public.getLastLine(tempFile, 10)
|
||||
echoMsg['msg'] = mw.getLastLine(tempFile, 10)
|
||||
echoMsg['isDownload'] = False
|
||||
|
||||
echoMsg['task'] = public.M('tasks').where("status!=?", ('1',)).field(
|
||||
echoMsg['task'] = mw.M('tasks').where("status!=?", ('1',)).field(
|
||||
'id,status,name,type').order("id asc").select()
|
||||
return public.getJson(echoMsg)
|
||||
return mw.getJson(echoMsg)
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
#!/bin/bash
|
||||
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin:/usr/local/lib/python2.7/bin
|
||||
|
||||
|
||||
|
||||
find . -name .DS_Store | xargs rm -rf
|
||||
find . -type d -name "*.pyc" | xargs rm -rf
|
||||
@@ -47,8 +47,9 @@ CREATE TABLE IF NOT EXISTS `firewall` (
|
||||
INSERT INTO `firewall` (`id`, `port`, `ps`, `addtime`) VALUES
|
||||
(1, '80', '网站默认端口', '0000-00-00 00:00:00'),
|
||||
(2, '7200', 'WEB面板', '0000-00-00 00:00:00'),
|
||||
(3, '22', 'SSH远程管理服务', '0000-00-00 00:00:00')
|
||||
(3, '888', 'phpMyAdmin默认端口', '0000-00-00 00:00:00');
|
||||
(3, '22', 'SSH远程管理服务', '0000-00-00 00:00:00'),
|
||||
(4, '888', 'phpMyAdmin默认端口', '0000-00-00 00:00:00'),
|
||||
(5, '3306', 'MySQL端口', '0000-00-00 00:00:00');
|
||||
|
||||
|
||||
|
||||
|
||||
+1
-1
@@ -47,6 +47,6 @@ server
|
||||
access_log /dev/null;
|
||||
}
|
||||
|
||||
access_log {$LOGPATH}/{$SERVER_NAME}.log;
|
||||
access_log {$LOGPATH}/{$SERVER_NAME}.log main;
|
||||
error_log {$LOGPATH}/{$SERVER_NAME}.error.log;
|
||||
}
|
||||
+14
-14
@@ -8,11 +8,11 @@ import re
|
||||
import sys
|
||||
|
||||
sys.path.append(os.getcwd() + "/class/core")
|
||||
import public
|
||||
import mw
|
||||
|
||||
|
||||
app_debug = False
|
||||
if public.isAppleSystem():
|
||||
if mw.isAppleSystem():
|
||||
app_debug = True
|
||||
|
||||
|
||||
@@ -21,11 +21,11 @@ def getPluginName():
|
||||
|
||||
|
||||
def getPluginDir():
|
||||
return public.getPluginDir() + '/' + getPluginName()
|
||||
return mw.getPluginDir() + '/' + getPluginName()
|
||||
|
||||
|
||||
def getServerDir():
|
||||
return public.getServerDir() + '/' + getPluginName()
|
||||
return mw.getServerDir() + '/' + getPluginName()
|
||||
|
||||
|
||||
def getInitDFile():
|
||||
@@ -53,10 +53,10 @@ def getArgs():
|
||||
|
||||
def status():
|
||||
if not app_debug:
|
||||
if public.isAppleSystem():
|
||||
if mw.isAppleSystem():
|
||||
return "stop"
|
||||
|
||||
data = public.execShell('sudo sysctl -n net.ipv4.tcp_congestion_control')
|
||||
data = mw.execShell('sudo sysctl -n net.ipv4.tcp_congestion_control')
|
||||
r = data[0].strip()
|
||||
if r == 'bbr':
|
||||
return 'start'
|
||||
@@ -65,26 +65,26 @@ def status():
|
||||
|
||||
def start():
|
||||
if not app_debug:
|
||||
if public.isAppleSystem():
|
||||
if mw.isAppleSystem():
|
||||
return "Apple Computer does not support"
|
||||
|
||||
public.execShell('echo "net.core.default_qdisc=fq" >> /etc/sysctl.conf')
|
||||
mw.execShell('echo "net.core.default_qdisc=fq" >> /etc/sysctl.conf')
|
||||
cmd = 'echo "net.ipv4.tcp_congestion_control=bbr" >> /etc/sysctl.conf'
|
||||
public.execShell(cmd)
|
||||
public.execShell('sysctl -p')
|
||||
mw.execShell(cmd)
|
||||
mw.execShell('sysctl -p')
|
||||
return '执行成功!重启系统生效'
|
||||
|
||||
|
||||
def stop():
|
||||
if not app_debug:
|
||||
if public.isAppleSystem():
|
||||
if mw.isAppleSystem():
|
||||
return "Apple Computer does not support"
|
||||
|
||||
cmd1 = "sed -i '/net\.core\.default_qdisc/d' /etc/sysctl.conf"
|
||||
public.execShell(cmd1)
|
||||
mw.execShell(cmd1)
|
||||
cmd2 = "sed -i '/net\.ipv4\.tcp_congestion_control/d' /etc/sysctl.conf"
|
||||
public.execShell(cmd2)
|
||||
public.execShell("sysctl -p")
|
||||
mw.execShell(cmd2)
|
||||
mw.execShell("sysctl -p")
|
||||
return '执行成功!重启系统生效'
|
||||
|
||||
|
||||
|
||||
+51
-51
@@ -11,11 +11,11 @@ import sys
|
||||
import subprocess
|
||||
|
||||
sys.path.append(os.getcwd() + "/class/core")
|
||||
import public
|
||||
import mw
|
||||
|
||||
|
||||
app_debug = False
|
||||
if public.isAppleSystem():
|
||||
if mw.isAppleSystem():
|
||||
app_debug = True
|
||||
|
||||
|
||||
@@ -24,11 +24,11 @@ def getPluginName():
|
||||
|
||||
|
||||
def getPluginDir():
|
||||
return public.getPluginDir() + '/' + getPluginName()
|
||||
return mw.getPluginDir() + '/' + getPluginName()
|
||||
|
||||
|
||||
def getServerDir():
|
||||
return public.getServerDir() + '/' + getPluginName()
|
||||
return mw.getServerDir() + '/' + getPluginName()
|
||||
|
||||
|
||||
def getInitDFile():
|
||||
@@ -64,7 +64,7 @@ def initDreplace():
|
||||
|
||||
|
||||
def status():
|
||||
data = public.execShell(
|
||||
data = mw.execShell(
|
||||
"ps -ef|grep " + getPluginName() + " |grep -v grep | grep -v python | awk '{print $2}'")
|
||||
if data[0] == '':
|
||||
return 'stop'
|
||||
@@ -74,7 +74,7 @@ def status():
|
||||
def csvnOp(method):
|
||||
|
||||
if app_debug:
|
||||
os_name = public.getOs()
|
||||
os_name = mw.getOs()
|
||||
if os_name == 'darwin':
|
||||
return "Apple Computer does not support"
|
||||
|
||||
@@ -83,8 +83,8 @@ def csvnOp(method):
|
||||
#_csvn = getServerDir() + '/bin/csvn'
|
||||
#_csvn_httpd = getServerDir() + '/bin/csvn-httpd'
|
||||
|
||||
ret_csvn_httpd = public.execShell(_initd_csvn_httpd + ' ' + method)
|
||||
# ret_csvn = public.execShell(_initd_csvn + ' ' + method)
|
||||
ret_csvn_httpd = mw.execShell(_initd_csvn_httpd + ' ' + method)
|
||||
# ret_csvn = mw.execShell(_initd_csvn + ' ' + method)
|
||||
subprocess.Popen(_initd_csvn + ' ' + method,
|
||||
stdout=subprocess.PIPE, shell=True)
|
||||
if ret_csvn_httpd[1] == '':
|
||||
@@ -110,7 +110,7 @@ def reload():
|
||||
|
||||
def initdStatus():
|
||||
if not app_debug:
|
||||
if public.isAppleSystem():
|
||||
if mw.isAppleSystem():
|
||||
return "Apple Computer does not support"
|
||||
|
||||
_initd_csvn = '/etc/init.d/csvn'
|
||||
@@ -124,14 +124,14 @@ def initdStatus():
|
||||
def initdInstall():
|
||||
import shutil
|
||||
if not app_debug:
|
||||
if public.isAppleSystem():
|
||||
if mw.isAppleSystem():
|
||||
return "Apple Computer does not support"
|
||||
|
||||
_csvn = getServerDir() + '/bin/csvn'
|
||||
_csvn_httpd = getServerDir() + '/bin/csvn-httpd'
|
||||
|
||||
ret_csvn = public.execShell(_csvn + ' install')
|
||||
ret_csvn_httpd = public.execShell(_csvn_httpd + ' install')
|
||||
ret_csvn = mw.execShell(_csvn + ' install')
|
||||
ret_csvn_httpd = mw.execShell(_csvn_httpd + ' install')
|
||||
if ret_csvn[1] == '' and ret_csvn_httpd[1] == '':
|
||||
return 'ok'
|
||||
return 'fail'
|
||||
@@ -139,14 +139,14 @@ def initdInstall():
|
||||
|
||||
def initdUinstall():
|
||||
if not app_debug:
|
||||
if public.isAppleSystem():
|
||||
if mw.isAppleSystem():
|
||||
return "Apple Computer does not support"
|
||||
|
||||
_csvn = getServerDir() + '/bin/csvn'
|
||||
_csvn_httpd = getServerDir() + '/bin/csvn-httpd'
|
||||
|
||||
ret_csvn = public.execShell(_csvn + ' remove')
|
||||
ret_csvn_httpd = public.execShell(_csvn_httpd + ' remove')
|
||||
ret_csvn = mw.execShell(_csvn + ' remove')
|
||||
ret_csvn_httpd = mw.execShell(_csvn_httpd + ' remove')
|
||||
return 'ok'
|
||||
|
||||
|
||||
@@ -155,7 +155,7 @@ def csvnEdit():
|
||||
data['svn_access_file'] = getServerDir() + '/data/conf/svn_access_file'
|
||||
data['commit_tpl'] = getPluginDir() + '/hook/commit.tpl'
|
||||
data['post_commit_tpl'] = getPluginDir() + '/hook/post-commit.tpl'
|
||||
return public.getJson(data)
|
||||
return mw.getJson(data)
|
||||
|
||||
|
||||
def userAdd():
|
||||
@@ -170,7 +170,7 @@ def userAdd():
|
||||
svn_auth_file = getServerDir() + "/data/conf/svn_auth_file"
|
||||
cmd = htpasswd + ' -b ' + svn_auth_file + ' ' + \
|
||||
args['username'] + ' ' + args['password']
|
||||
data = public.execShell(cmd)
|
||||
data = mw.execShell(cmd)
|
||||
# print data
|
||||
if data[0] == '':
|
||||
return 'ok'
|
||||
@@ -185,7 +185,7 @@ def userDel():
|
||||
htpasswd = getServerDir() + "/bin/htpasswd"
|
||||
svn_auth_file = getServerDir() + "/data/conf/svn_auth_file"
|
||||
cmd = htpasswd + ' -D ' + svn_auth_file + ' ' + args['username']
|
||||
data = public.execShell(cmd)
|
||||
data = mw.execShell(cmd)
|
||||
if data[0] == '':
|
||||
return 'ok'
|
||||
return 'fail'
|
||||
@@ -194,8 +194,8 @@ def userDel():
|
||||
def getAllUser(search=''):
|
||||
svn_auth_file = getServerDir() + '/data/conf/svn_auth_file'
|
||||
if not os.path.exists(svn_auth_file):
|
||||
return public.getJson([])
|
||||
auth = public.readFile(svn_auth_file)
|
||||
return mw.getJson([])
|
||||
auth = mw.readFile(svn_auth_file)
|
||||
auth = auth.strip()
|
||||
auth_list = auth.split("\n")
|
||||
|
||||
@@ -232,14 +232,14 @@ def userList():
|
||||
page_info = {'count': ulist_sum, 'p': page,
|
||||
'row': 10, 'tojs': 'csvnUserList'}
|
||||
data = {}
|
||||
data['list'] = public.getPage(page_info)
|
||||
data['list'] = mw.getPage(page_info)
|
||||
data['page'] = page
|
||||
data['page_size'] = page_size
|
||||
data['page_count'] = int(math.ceil(ulist_sum / page_size))
|
||||
start = (page - 1) * page_size
|
||||
|
||||
data['data'] = ulist[start:start + page_size]
|
||||
return public.getJson(data)
|
||||
return mw.getJson(data)
|
||||
|
||||
|
||||
def projectAdd():
|
||||
@@ -249,9 +249,9 @@ def projectAdd():
|
||||
path = getServerDir() + '/bin/svnadmin'
|
||||
dest = getServerDir() + '/data/repositories/' + args['name']
|
||||
cmd = path + ' create ' + dest
|
||||
data = public.execShell(cmd)
|
||||
data = mw.execShell(cmd)
|
||||
if data[1] == '':
|
||||
public.execShell('chown -R csvn:csvn ' + dest)
|
||||
mw.execShell('chown -R csvn:csvn ' + dest)
|
||||
return 'ok'
|
||||
return 'fail'
|
||||
|
||||
@@ -263,7 +263,7 @@ def projectDel():
|
||||
|
||||
dest = getServerDir() + '/data/repositories/' + args['name']
|
||||
cmd = 'rm -rf ' + dest
|
||||
data = public.execShell(cmd)
|
||||
data = mw.execShell(cmd)
|
||||
if data[0] == '':
|
||||
return 'ok'
|
||||
return 'fail'
|
||||
@@ -273,7 +273,7 @@ def getHttpPort():
|
||||
http_main_conf = getServerDir() + '/data/conf/csvn_main_httpd.conf'
|
||||
try:
|
||||
if os.path.exists(http_main_conf):
|
||||
content = public.readFile(http_main_conf)
|
||||
content = mw.readFile(http_main_conf)
|
||||
return re.search('Listen\s(\d+)', content).groups()[0]
|
||||
except Exception as e:
|
||||
pass # print e
|
||||
@@ -284,7 +284,7 @@ def getCsvnPort():
|
||||
http_main_conf = getServerDir() + '/data/conf/csvn-wrapper.conf'
|
||||
try:
|
||||
if os.path.exists(http_main_conf):
|
||||
content = public.readFile(http_main_conf)
|
||||
content = mw.readFile(http_main_conf)
|
||||
return re.search('wrapper.java.additional.3=-Djetty.port=(\d+)', content).groups()[0]
|
||||
except Exception as e:
|
||||
pass # print e
|
||||
@@ -347,18 +347,18 @@ def projectList():
|
||||
|
||||
data = {}
|
||||
data['data'] = ret_data
|
||||
data['list'] = public.getPage(
|
||||
data['list'] = mw.getPage(
|
||||
{'count': dlist_sum, 'p': page, 'row': 10, 'tojs': 'csvnProjectList'})
|
||||
data['ip'] = public.getLocalIp()
|
||||
data['ip'] = mw.getLocalIp()
|
||||
data['port'] = getHttpPort()
|
||||
data['csvn_port'] = getCsvnPort()
|
||||
|
||||
return public.getJson(data)
|
||||
return mw.getJson(data)
|
||||
|
||||
|
||||
def getAllAclList():
|
||||
svn_access_file = getServerDir() + '/data/conf/svn_access_file'
|
||||
aData = public.readFile(svn_access_file)
|
||||
aData = mw.readFile(svn_access_file)
|
||||
aData = re.sub('#.*', '', aData)
|
||||
aData = aData.strip().split('[')[1:]
|
||||
allAcl = {}
|
||||
@@ -394,7 +394,7 @@ def makeAclFile(content):
|
||||
tmp += v[iv]['user'] + ' = ' + v[iv]['acl'] + "\n"
|
||||
tmp += "\n"
|
||||
# svn_tmp_path = getServerDir() + '/data/conf/svn_access_file.log'
|
||||
return public.writeFile(svn_access_file, tmp)
|
||||
return mw.writeFile(svn_access_file, tmp)
|
||||
|
||||
|
||||
def projectAclList():
|
||||
@@ -405,7 +405,7 @@ def projectAclList():
|
||||
acl = getAllAclList()
|
||||
|
||||
if name in acl:
|
||||
return public.getJson(acl[name])
|
||||
return mw.getJson(acl[name])
|
||||
else:
|
||||
return 'fail'
|
||||
|
||||
@@ -543,19 +543,19 @@ def getCsvnPwd(user):
|
||||
pwd_file = 'data/csvn_sync.pl'
|
||||
|
||||
if os.path.exists(pwd_file):
|
||||
return public.readFile(pwd_file).strip()
|
||||
return mw.readFile(pwd_file).strip()
|
||||
|
||||
import time
|
||||
cur_time = time.time()
|
||||
rand_pwd = public.md5(str(cur_time))
|
||||
rand_pwd = mw.md5(str(cur_time))
|
||||
pwd = user + rand_pwd[:5]
|
||||
|
||||
htpasswd = getServerDir() + "/bin/htpasswd"
|
||||
svn_auth_file = getServerDir() + "/data/conf/svn_auth_file"
|
||||
cmd = htpasswd + ' -b ' + svn_auth_file + ' ' + user + ' ' + pwd
|
||||
data = public.execShell(cmd)
|
||||
data = mw.execShell(cmd)
|
||||
|
||||
public.writeFile(pwd_file, pwd)
|
||||
mw.writeFile(pwd_file, pwd)
|
||||
return pwd
|
||||
|
||||
|
||||
@@ -570,21 +570,21 @@ def projectScriptLoad():
|
||||
args['pname'] + '/hooks'
|
||||
post_commit_file = hook_path + '/post-commit'
|
||||
|
||||
pct_content = public.readFile(post_commit_tpl)
|
||||
public.writeFile(post_commit_file, pct_content)
|
||||
public.execShell('chmod 777 ' + post_commit_file)
|
||||
pct_content = mw.readFile(post_commit_tpl)
|
||||
mw.writeFile(post_commit_file, pct_content)
|
||||
mw.execShell('chmod 777 ' + post_commit_file)
|
||||
|
||||
commit_tpl = getPluginDir() + '/hook/commit.tpl'
|
||||
commit_file = hook_path + '/commit'
|
||||
|
||||
ct_content = public.readFile(commit_tpl)
|
||||
ct_content = ct_content.replace('{$PROJECT_DIR}', public.getRootDir())
|
||||
ct_content = mw.readFile(commit_tpl)
|
||||
ct_content = ct_content.replace('{$PROJECT_DIR}', mw.getRootDir())
|
||||
ct_content = ct_content.replace('{$PORT}', getHttpPort())
|
||||
ct_content = ct_content.replace('{$CSVN_USER}', getCsvnUser())
|
||||
ct_content = ct_content.replace('{$CSVN_PWD}', getCsvnPwd(getCsvnUser()))
|
||||
|
||||
public.writeFile(commit_file, ct_content)
|
||||
public.execShell('chmod 777 ' + commit_file)
|
||||
mw.writeFile(commit_file, ct_content)
|
||||
mw.execShell('chmod 777 ' + commit_file)
|
||||
|
||||
return 'ok'
|
||||
|
||||
@@ -596,11 +596,11 @@ def projectScriptUnload():
|
||||
|
||||
post_commit_file = getServerDir() + '/data/repositories/' + '/' + \
|
||||
args['pname'] + '/hooks/post-commit'
|
||||
public.execShell('rm -f ' + post_commit_file)
|
||||
mw.execShell('rm -f ' + post_commit_file)
|
||||
|
||||
commit_file = getServerDir() + '/data/repositories/' + '/' + \
|
||||
args['pname'] + '/hooks/commit'
|
||||
public.execShell('rm -f ' + commit_file)
|
||||
mw.execShell('rm -f ' + commit_file)
|
||||
return 'ok'
|
||||
|
||||
|
||||
@@ -619,7 +619,7 @@ def projectScriptEdit():
|
||||
data['status'] = False
|
||||
data['msg'] = 'file does not exist'
|
||||
|
||||
return public.getJson(data)
|
||||
return mw.getJson(data)
|
||||
|
||||
|
||||
def projectScriptDebug():
|
||||
@@ -637,7 +637,7 @@ def projectScriptDebug():
|
||||
data['status'] = False
|
||||
data['msg'] = 'file does not exist'
|
||||
|
||||
return public.getJson(data)
|
||||
return mw.getJson(data)
|
||||
|
||||
|
||||
def getTotalStatistics():
|
||||
@@ -647,12 +647,12 @@ def getTotalStatistics():
|
||||
svn_path = getServerDir() + '/data/repositories'
|
||||
data['status'] = True
|
||||
data['count'] = len(os.listdir(svn_path))
|
||||
data['ver'] = public.readFile(getServerDir() + '/version.pl').strip()
|
||||
return public.returnJson(True, 'ok', data)
|
||||
data['ver'] = mw.readFile(getServerDir() + '/version.pl').strip()
|
||||
return mw.returnJson(True, 'ok', data)
|
||||
else:
|
||||
data['status'] = False
|
||||
data['count'] = 0
|
||||
return public.returnJson(False, 'fail', data)
|
||||
return mw.returnJson(False, 'fail', data)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
+18
-18
@@ -8,7 +8,7 @@ import re
|
||||
import sys
|
||||
|
||||
sys.path.append(os.getcwd() + "/class/core")
|
||||
import public
|
||||
import mw
|
||||
|
||||
|
||||
def getPluginName():
|
||||
@@ -16,11 +16,11 @@ def getPluginName():
|
||||
|
||||
|
||||
def getPluginDir():
|
||||
return public.getPluginDir() + '/' + getPluginName()
|
||||
return mw.getPluginDir() + '/' + getPluginName()
|
||||
|
||||
|
||||
def getServerDir():
|
||||
return public.getServerDir() + '/' + getPluginName()
|
||||
return mw.getServerDir() + '/' + getPluginName()
|
||||
|
||||
|
||||
def getInitDFile():
|
||||
@@ -51,7 +51,7 @@ def status():
|
||||
|
||||
|
||||
def getAllProjectList(search):
|
||||
path = public.getWwwDir()
|
||||
path = mw.getWwwDir()
|
||||
dlist = []
|
||||
if os.path.exists(path):
|
||||
for filename in os.listdir(path):
|
||||
@@ -92,7 +92,7 @@ def projectListEdit():
|
||||
|
||||
file = getServerDir() + '/' + args['name'] + '.json'
|
||||
if not os.path.exists(file):
|
||||
public.execShell('touch ' + file)
|
||||
mw.execShell('touch ' + file)
|
||||
return file
|
||||
|
||||
|
||||
@@ -103,17 +103,17 @@ def projectListDel():
|
||||
|
||||
file = getServerDir() + '/' + args['name'] + '.json'
|
||||
if os.path.exists(file):
|
||||
content = public.readFile(file)
|
||||
content = mw.readFile(file)
|
||||
contentObj = json.loads(content)
|
||||
asyncUser = contentObj['client_email']
|
||||
cmd = getServerDir() + '/google-cloud-sdk/bin/'
|
||||
public.execShell(cmd + 'gcloud auth revoke ' + asyncUser)
|
||||
public.execShell('rm -rf ' + file)
|
||||
mw.execShell(cmd + 'gcloud auth revoke ' + asyncUser)
|
||||
mw.execShell('rm -rf ' + file)
|
||||
return 'ok'
|
||||
|
||||
|
||||
def checkUserExist(cmd, user):
|
||||
data = public.execShell(cmd + 'gcloud auth list | grep ' + user)
|
||||
data = mw.execShell(cmd + 'gcloud auth list | grep ' + user)
|
||||
if data[0] == '':
|
||||
return False
|
||||
return True
|
||||
@@ -129,14 +129,14 @@ def projectListAsync():
|
||||
if not os.path.exists(file):
|
||||
return 'not configured file!'
|
||||
|
||||
content = public.readFile(file)
|
||||
content = mw.readFile(file)
|
||||
contentObj = json.loads(content)
|
||||
asyncUser = contentObj['client_email']
|
||||
cmd = getServerDir() + '/google-cloud-sdk/bin/'
|
||||
projectDir = public.getWwwDir() + '/' + args['name']
|
||||
projectDir = mw.getWwwDir() + '/' + args['name']
|
||||
|
||||
if not checkUserExist(cmd, asyncUser):
|
||||
public.execShell(
|
||||
mw.execShell(
|
||||
cmd + 'gcloud auth activate-service-account --key-file ' + file)
|
||||
|
||||
pName = contentObj['project_id']
|
||||
@@ -147,7 +147,7 @@ def projectListAsync():
|
||||
|
||||
taskAdd = (None, 'gae[async]',
|
||||
'execshell', '0', time.strftime('%Y-%m-%d %H:%M:%S'), asyncCmd)
|
||||
public.M('tasks').add('id,name,type,status,addtime, execstr', taskAdd)
|
||||
mw.M('tasks').add('id,name,type,status,addtime, execstr', taskAdd)
|
||||
return 'ok'
|
||||
|
||||
|
||||
@@ -160,12 +160,12 @@ def projectListCmd():
|
||||
if not os.path.exists(file):
|
||||
return 'not configured file!'
|
||||
|
||||
content = public.readFile(file)
|
||||
content = mw.readFile(file)
|
||||
contentObj = json.loads(content)
|
||||
asyncUser = contentObj['client_email']
|
||||
cmd = getServerDir() + '/google-cloud-sdk/bin/'
|
||||
pName = contentObj['project_id']
|
||||
projectDir = public.getWwwDir() + '/' + args['name']
|
||||
projectDir = mw.getWwwDir() + '/' + args['name']
|
||||
|
||||
setUserCmd = 'sudo ' + cmd + 'gcloud config set account ' + asyncUser
|
||||
setUserCmd += ' && sudo ' + cmd + 'gcloud config set project ' + pName
|
||||
@@ -183,7 +183,7 @@ def projectListUrl():
|
||||
if not os.path.exists(file):
|
||||
return 'not configured file!'
|
||||
|
||||
content = public.readFile(file)
|
||||
content = mw.readFile(file)
|
||||
contentObj = json.loads(content)
|
||||
asyncUser = contentObj['client_email']
|
||||
plist = asyncUser.split('@')
|
||||
@@ -216,9 +216,9 @@ def projectList():
|
||||
|
||||
data = {}
|
||||
data['data'] = ret_data
|
||||
data['list'] = public.getPage(
|
||||
data['list'] = mw.getPage(
|
||||
{'count': dlist_sum, 'p': page, 'row': 10, 'tojs': 'projectList'})
|
||||
return public.getJson(data)
|
||||
return mw.getJson(data)
|
||||
|
||||
if __name__ == "__main__":
|
||||
func = sys.argv[1]
|
||||
|
||||
@@ -10,10 +10,10 @@ import subprocess
|
||||
import threading
|
||||
|
||||
sys.path.append(os.getcwd() + "/class/core")
|
||||
import public
|
||||
import mw
|
||||
|
||||
app_debug = False
|
||||
if public.isAppleSystem():
|
||||
if mw.isAppleSystem():
|
||||
app_debug = True
|
||||
|
||||
|
||||
@@ -22,11 +22,11 @@ def getPluginName():
|
||||
|
||||
|
||||
def getPluginDir():
|
||||
return public.getPluginDir() + '/' + getPluginName()
|
||||
return mw.getPluginDir() + '/' + getPluginName()
|
||||
|
||||
|
||||
def getServerDir():
|
||||
return public.getServerDir() + '/' + getPluginName()
|
||||
return mw.getServerDir() + '/' + getPluginName()
|
||||
|
||||
|
||||
def getInitDFile():
|
||||
@@ -67,13 +67,13 @@ def getArgs():
|
||||
def checkArgs(data, ck=[]):
|
||||
for i in range(len(ck)):
|
||||
if not ck[i] in data:
|
||||
return (False, public.returnJson(False, '参数:(' + ck[i] + ')没有!'))
|
||||
return (True, public.returnJson(True, 'ok'))
|
||||
return (False, mw.returnJson(False, '参数:(' + ck[i] + ')没有!'))
|
||||
return (True, mw.returnJson(True, 'ok'))
|
||||
|
||||
|
||||
def status():
|
||||
pn = getPluginName()
|
||||
data = public.execShell(
|
||||
data = mw.execShell(
|
||||
"ps -ef|grep " + pn + " | grep -v grep | grep -v python | awk '{print $2}'")
|
||||
if data[0] == '':
|
||||
return 'stop'
|
||||
@@ -91,17 +91,17 @@ def initDreplace():
|
||||
|
||||
file_bin = initD_path + '/' + getPluginName()
|
||||
if not os.path.exists(file_bin):
|
||||
content = public.readFile(file_tpl)
|
||||
content = mw.readFile(file_tpl)
|
||||
content = content.replace('{$SERVER_PATH}', service_path)
|
||||
public.writeFile(file_bin, content)
|
||||
public.execShell('chmod +x ' + file_bin)
|
||||
mw.writeFile(file_bin, content)
|
||||
mw.execShell('chmod +x ' + file_bin)
|
||||
|
||||
return file_bin
|
||||
|
||||
|
||||
def start():
|
||||
file = initDreplace()
|
||||
data = public.execShell(file + ' start')
|
||||
data = mw.execShell(file + ' start')
|
||||
if data[1] == '':
|
||||
return 'ok'
|
||||
return 'fail'
|
||||
@@ -109,7 +109,7 @@ def start():
|
||||
|
||||
def stop():
|
||||
file = initDreplace()
|
||||
data = public.execShell(file + ' stop')
|
||||
data = mw.execShell(file + ' stop')
|
||||
if data[1] == '':
|
||||
return 'ok'
|
||||
return 'fail'
|
||||
@@ -117,7 +117,7 @@ def stop():
|
||||
|
||||
def restart():
|
||||
file = initDreplace()
|
||||
data = public.execShell(file + ' restart')
|
||||
data = mw.execShell(file + ' restart')
|
||||
if data[1] == '':
|
||||
return 'ok'
|
||||
return 'fail'
|
||||
@@ -125,7 +125,7 @@ def restart():
|
||||
|
||||
def reload():
|
||||
file = initDreplace()
|
||||
data = public.execShell(file + ' reload')
|
||||
data = mw.execShell(file + ' reload')
|
||||
if data[1] == '':
|
||||
return 'ok'
|
||||
return 'fail'
|
||||
@@ -144,16 +144,16 @@ def initdInstall():
|
||||
source_bin = initDreplace()
|
||||
initd_bin = getInitDFile()
|
||||
shutil.copyfile(source_bin, initd_bin)
|
||||
public.execShell('chmod +x ' + initd_bin)
|
||||
mw.execShell('chmod +x ' + initd_bin)
|
||||
|
||||
if not app_debug:
|
||||
public.execShell('chkconfig --add ' + getPluginName())
|
||||
mw.execShell('chkconfig --add ' + getPluginName())
|
||||
return 'ok'
|
||||
|
||||
|
||||
def initdUinstall():
|
||||
if not app_debug:
|
||||
public.execShell('chkconfig --del ' + getPluginName())
|
||||
mw.execShell('chkconfig --del ' + getPluginName())
|
||||
|
||||
initd_bin = getInitDFile()
|
||||
|
||||
@@ -165,6 +165,7 @@ def initdUinstall():
|
||||
def gfConf():
|
||||
return getServerDir() + "/config/application-prod.properties"
|
||||
|
||||
|
||||
def getLog():
|
||||
return getServerDir() + "/logs/go-fastdfs-web.log"
|
||||
|
||||
|
||||
+19
-19
@@ -10,10 +10,10 @@ import subprocess
|
||||
import threading
|
||||
|
||||
sys.path.append(os.getcwd() + "/class/core")
|
||||
import public
|
||||
import mw
|
||||
|
||||
app_debug = False
|
||||
if public.isAppleSystem():
|
||||
if mw.isAppleSystem():
|
||||
app_debug = True
|
||||
|
||||
|
||||
@@ -22,11 +22,11 @@ def getPluginName():
|
||||
|
||||
|
||||
def getPluginDir():
|
||||
return public.getPluginDir() + '/' + getPluginName()
|
||||
return mw.getPluginDir() + '/' + getPluginName()
|
||||
|
||||
|
||||
def getServerDir():
|
||||
return public.getServerDir() + '/' + getPluginName()
|
||||
return mw.getServerDir() + '/' + getPluginName()
|
||||
|
||||
|
||||
def getInitDFile():
|
||||
@@ -67,13 +67,13 @@ def getArgs():
|
||||
def checkArgs(data, ck=[]):
|
||||
for i in range(len(ck)):
|
||||
if not ck[i] in data:
|
||||
return (False, public.returnJson(False, '参数:(' + ck[i] + ')没有!'))
|
||||
return (True, public.returnJson(True, 'ok'))
|
||||
return (False, mw.returnJson(False, '参数:(' + ck[i] + ')没有!'))
|
||||
return (True, mw.returnJson(True, 'ok'))
|
||||
|
||||
|
||||
def status():
|
||||
pn = getPluginName()
|
||||
data = public.execShell(
|
||||
data = mw.execShell(
|
||||
"ps -ef|grep " + pn + " |grep -v grep |grep -v .jar | grep -v python | awk '{print $2}'")
|
||||
if data[0] == '':
|
||||
return 'stop'
|
||||
@@ -91,17 +91,17 @@ def initDreplace():
|
||||
|
||||
file_bin = initD_path + '/' + getPluginName()
|
||||
if not os.path.exists(file_bin):
|
||||
content = public.readFile(file_tpl)
|
||||
content = mw.readFile(file_tpl)
|
||||
content = content.replace('{$SERVER_PATH}', service_path)
|
||||
public.writeFile(file_bin, content)
|
||||
public.execShell('chmod +x ' + file_bin)
|
||||
mw.writeFile(file_bin, content)
|
||||
mw.execShell('chmod +x ' + file_bin)
|
||||
|
||||
return file_bin
|
||||
|
||||
|
||||
def start():
|
||||
file = initDreplace()
|
||||
data = public.execShell(file + ' start')
|
||||
data = mw.execShell(file + ' start')
|
||||
if data[1] == '':
|
||||
return 'ok'
|
||||
return 'fail'
|
||||
@@ -109,7 +109,7 @@ def start():
|
||||
|
||||
def stop():
|
||||
file = initDreplace()
|
||||
data = public.execShell(file + ' stop')
|
||||
data = mw.execShell(file + ' stop')
|
||||
if data[1] == '':
|
||||
return 'ok'
|
||||
return 'fail'
|
||||
@@ -117,7 +117,7 @@ def stop():
|
||||
|
||||
def restart():
|
||||
file = initDreplace()
|
||||
data = public.execShell(file + ' restart')
|
||||
data = mw.execShell(file + ' restart')
|
||||
if data[1] == '':
|
||||
return 'ok'
|
||||
return 'fail'
|
||||
@@ -125,7 +125,7 @@ def restart():
|
||||
|
||||
def reload():
|
||||
file = initDreplace()
|
||||
data = public.execShell(file + ' reload')
|
||||
data = mw.execShell(file + ' reload')
|
||||
if data[1] == '':
|
||||
return 'ok'
|
||||
return 'fail'
|
||||
@@ -144,16 +144,16 @@ def initdInstall():
|
||||
source_bin = initDreplace()
|
||||
initd_bin = getInitDFile()
|
||||
shutil.copyfile(source_bin, initd_bin)
|
||||
public.execShell('chmod +x ' + initd_bin)
|
||||
mw.execShell('chmod +x ' + initd_bin)
|
||||
|
||||
if not app_debug:
|
||||
public.execShell('chkconfig --add ' + getPluginName())
|
||||
mw.execShell('chkconfig --add ' + getPluginName())
|
||||
return 'ok'
|
||||
|
||||
|
||||
def initdUinstall():
|
||||
if not app_debug:
|
||||
public.execShell('chkconfig --del ' + getPluginName())
|
||||
mw.execShell('chkconfig --del ' + getPluginName())
|
||||
|
||||
initd_bin = getInitDFile()
|
||||
|
||||
@@ -182,7 +182,7 @@ def gfConfSet():
|
||||
{'name': 'enable_cross_origin', 'type': 0, 'ps': '是否开启跨站访问'},
|
||||
{'name': 'enable_tus', 'type': 0, 'ps': '是否开启断点续传'}
|
||||
]
|
||||
file = public.readFile(gfConf())
|
||||
file = mw.readFile(gfConf())
|
||||
data = json.loads(file)
|
||||
|
||||
result = []
|
||||
@@ -191,7 +191,7 @@ def gfConfSet():
|
||||
g['value'] = data[g['name']]
|
||||
result.append(g)
|
||||
|
||||
return public.getJson(result)
|
||||
return mw.getJson(result)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Executable
+91
@@ -0,0 +1,91 @@
|
||||
# coding: utf-8
|
||||
|
||||
import re
|
||||
import os
|
||||
import sys
|
||||
|
||||
sys.path.append("/usr/local/lib/python2.7/site-packages")
|
||||
|
||||
|
||||
class mysqlDb:
|
||||
__DB_PASS = None
|
||||
__DB_USER = 'root'
|
||||
__DB_PORT = 3306
|
||||
__DB_HOST = 'localhost'
|
||||
__DB_NAME = 'test'
|
||||
__DB_CONN = None
|
||||
__DB_CUR = None
|
||||
__DB_ERR = None
|
||||
__DB_CNF = '/etc/my.cnf'
|
||||
|
||||
def __Conn(self):
|
||||
'''连接MYSQL数据库'''
|
||||
try:
|
||||
socket = '/tmp/mysql.sock'
|
||||
try:
|
||||
import MySQLdb
|
||||
except Exception, ex:
|
||||
self.__DB_ERR = ex
|
||||
return False
|
||||
try:
|
||||
self.__DB_CONN = MySQLdb.connect(host=self.__DB_HOST, user=self.__DB_USER, passwd=self.__DB_PASS,
|
||||
port=self.__DB_PORT, db=self.__DB_NAME, charset="utf8", connect_timeout=10, unix_socket=socket)
|
||||
except MySQLdb.Error, e:
|
||||
self.__DB_HOST = '127.0.0.1'
|
||||
self.__DB_CONN = MySQLdb.connect(host=self.__DB_HOST, user=self.__DB_USER, passwd=self.__DB_PASS,
|
||||
port=self.__DB_PORT, db=self.__DB_NAME, charset="utf8", connect_timeout=10, unix_socket=socket)
|
||||
self.__DB_CUR = self.__DB_CONN.cursor()
|
||||
return True
|
||||
|
||||
except MySQLdb.Error, e:
|
||||
self.__DB_ERR = e
|
||||
return False
|
||||
|
||||
def setHost(self, host):
|
||||
self.__DB_HOST = host
|
||||
|
||||
def setPwd(self, pwd):
|
||||
self.__DB_PASS = pwd
|
||||
|
||||
def setUser(self, user):
|
||||
self.__DB_USER = user
|
||||
|
||||
def setPort(self, port):
|
||||
self.__DB_PORT = port
|
||||
|
||||
def setDb(self, name):
|
||||
self.__DB_NAME = name
|
||||
|
||||
def getPwd(self):
|
||||
return self.__DB_PASS
|
||||
|
||||
def execute(self, sql):
|
||||
# 执行SQL语句返回受影响行
|
||||
if not self.__Conn():
|
||||
return self.__DB_ERR
|
||||
try:
|
||||
result = self.__DB_CUR.execute(sql)
|
||||
self.__DB_CONN.commit()
|
||||
self.__Close()
|
||||
return result
|
||||
except Exception, ex:
|
||||
return ex
|
||||
|
||||
def query(self, sql):
|
||||
# 执行SQL语句返回数据集
|
||||
if not self.__Conn():
|
||||
return self.__DB_ERR
|
||||
try:
|
||||
self.__DB_CUR.execute(sql)
|
||||
result = self.__DB_CUR.fetchall()
|
||||
# 将元组转换成列表
|
||||
data = map(list, result)
|
||||
self.__Close()
|
||||
return data
|
||||
except Exception, ex:
|
||||
return ex
|
||||
|
||||
# 关闭连接
|
||||
def __Close(self):
|
||||
self.__DB_CUR.close()
|
||||
self.__DB_CONN.close()
|
||||
@@ -1,5 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
echo `date`
|
||||
|
||||
GITADDR="{$GITROOTURL}/{$USERNAME}/{$PROJECT}"
|
||||
GIT_SDIR="{$CODE_DIR}"
|
||||
|
||||
|
||||
+82
-82
@@ -10,11 +10,11 @@ sys.path.append("/usr/local/lib/python2.7/site-packages")
|
||||
import psutil
|
||||
|
||||
sys.path.append(os.getcwd() + "/class/core")
|
||||
import public
|
||||
import mw
|
||||
|
||||
|
||||
app_debug = False
|
||||
if public.isAppleSystem():
|
||||
if mw.isAppleSystem():
|
||||
app_debug = True
|
||||
|
||||
|
||||
@@ -23,14 +23,14 @@ def getPluginName():
|
||||
|
||||
|
||||
def getPluginDir():
|
||||
return public.getPluginDir() + '/' + getPluginName()
|
||||
return mw.getPluginDir() + '/' + getPluginName()
|
||||
|
||||
sys.path.append(getPluginDir() + "/class")
|
||||
import mysql
|
||||
import mysqlDb
|
||||
|
||||
|
||||
def getServerDir():
|
||||
return public.getServerDir() + '/' + getPluginName()
|
||||
return mw.getServerDir() + '/' + getPluginName()
|
||||
|
||||
|
||||
def getInitDFile():
|
||||
@@ -77,7 +77,7 @@ def getConfTpl():
|
||||
|
||||
|
||||
def status():
|
||||
data = public.execShell(
|
||||
data = mw.execShell(
|
||||
"ps -ef|grep " + getPluginName() + " |grep -v grep | grep -v python | awk '{print $2}'")
|
||||
if data[0] == '':
|
||||
return 'stop'
|
||||
@@ -85,8 +85,8 @@ def status():
|
||||
|
||||
|
||||
def getHomeDir():
|
||||
if public.isAppleSystem():
|
||||
user = public.execShell(
|
||||
if mw.isAppleSystem():
|
||||
user = mw.execShell(
|
||||
"who | sed -n '2, 1p' |awk '{print $1}'")[0].strip()
|
||||
return '/Users/' + user
|
||||
else:
|
||||
@@ -94,8 +94,8 @@ def getHomeDir():
|
||||
|
||||
|
||||
def getRunUser():
|
||||
if public.isAppleSystem():
|
||||
user = public.execShell(
|
||||
if mw.isAppleSystem():
|
||||
user = mw.execShell(
|
||||
"who | sed -n '2, 1p' |awk '{print $1}'")[0].strip()
|
||||
return user
|
||||
else:
|
||||
@@ -110,8 +110,8 @@ export HOME=%s && ''' % ( getRunUser(), getHomeDir())
|
||||
|
||||
def contentReplace(content):
|
||||
|
||||
service_path = public.getServerDir()
|
||||
content = content.replace('{$ROOT_PATH}', public.getRootDir())
|
||||
service_path = mw.getServerDir()
|
||||
content = content.replace('{$ROOT_PATH}', mw.getRootDir())
|
||||
content = content.replace('{$SERVER_PATH}', service_path)
|
||||
content = content.replace('{$RUN_USER}', getRunUser())
|
||||
content = content.replace('{$HOME_DIR}', getHomeDir())
|
||||
@@ -122,7 +122,7 @@ def contentReplace(content):
|
||||
def initDreplace():
|
||||
|
||||
file_tpl = getInitdConfTpl()
|
||||
service_path = public.getServerDir()
|
||||
service_path = mw.getServerDir()
|
||||
|
||||
initD_path = getServerDir() + '/init.d'
|
||||
if not os.path.exists(initD_path):
|
||||
@@ -130,18 +130,18 @@ def initDreplace():
|
||||
file_bin = initD_path + '/' + getPluginName()
|
||||
|
||||
if not os.path.exists(file_bin):
|
||||
content = public.readFile(file_tpl)
|
||||
content = mw.readFile(file_tpl)
|
||||
content = contentReplace(content)
|
||||
public.writeFile(file_bin, content)
|
||||
public.execShell('chmod +x ' + file_bin)
|
||||
mw.writeFile(file_bin, content)
|
||||
mw.execShell('chmod +x ' + file_bin)
|
||||
|
||||
conf_bin = getConf()
|
||||
if not os.path.exists(conf_bin):
|
||||
public.execShell('mkdir -p ' + getServerDir() + '/custom/conf')
|
||||
mw.execShell('mkdir -p ' + getServerDir() + '/custom/conf')
|
||||
conf_tpl = getConfTpl()
|
||||
content = public.readFile(conf_tpl)
|
||||
content = mw.readFile(conf_tpl)
|
||||
content = contentReplace(content)
|
||||
public.writeFile(conf_bin, content)
|
||||
mw.writeFile(conf_bin, content)
|
||||
|
||||
log_path = getServerDir() + '/log'
|
||||
if not os.path.exists(log_path):
|
||||
@@ -151,7 +151,7 @@ def initDreplace():
|
||||
|
||||
|
||||
def getRootUrl():
|
||||
content = public.readFile(getConf())
|
||||
content = mw.readFile(getConf())
|
||||
rep = 'ROOT_URL\s*=\s*(.*)'
|
||||
tmp = re.search(rep, content)
|
||||
if not tmp:
|
||||
@@ -160,7 +160,7 @@ def getRootUrl():
|
||||
|
||||
|
||||
def getSshPort():
|
||||
content = public.readFile(getConf())
|
||||
content = mw.readFile(getConf())
|
||||
rep = 'SSH_PORT\s*=\s*(.*)'
|
||||
tmp = re.search(rep, content)
|
||||
if not tmp:
|
||||
@@ -169,7 +169,7 @@ def getSshPort():
|
||||
|
||||
|
||||
def getRootPath():
|
||||
content = public.readFile(getConf())
|
||||
content = mw.readFile(getConf())
|
||||
rep = 'ROOT\s*=\s*(.*)'
|
||||
tmp = re.search(rep, content)
|
||||
if not tmp:
|
||||
@@ -178,7 +178,7 @@ def getRootPath():
|
||||
|
||||
|
||||
def getDbConfValue():
|
||||
content = public.readFile(getConf())
|
||||
content = mw.readFile(getConf())
|
||||
|
||||
rep_scope = "\[database\](.*?)\["
|
||||
tmp = re.findall(rep_scope, content, re.S)
|
||||
@@ -197,7 +197,7 @@ def pMysqlDb():
|
||||
conf = getDbConfValue()
|
||||
|
||||
host = conf['HOST'].split(':')
|
||||
conn = mysql.mysql()
|
||||
conn = mysqlDb.mysqlDb()
|
||||
|
||||
conn.setHost(host[0])
|
||||
conn.setUser(conf['USER'])
|
||||
@@ -212,22 +212,22 @@ def isSqlError(mysqlMsg):
|
||||
_mysqlMsg = str(mysqlMsg)
|
||||
# print _mysqlMsg
|
||||
if "MySQLdb" in _mysqlMsg:
|
||||
return public.returnData(False, 'MySQLdb组件缺失! <br>进入SSH命令行输入: pip install mysql-python')
|
||||
return mw.returnData(False, 'MySQLdb组件缺失! <br>进入SSH命令行输入: pip install mysql-python')
|
||||
if "2002," in _mysqlMsg:
|
||||
return public.returnData(False, '数据库连接失败,请检查数据库服务是否启动!')
|
||||
return mw.returnData(False, '数据库连接失败,请检查数据库服务是否启动!')
|
||||
if "using password:" in _mysqlMsg:
|
||||
return public.returnData(False, '数据库管理密码错误!')
|
||||
return mw.returnData(False, '数据库管理密码错误!')
|
||||
if "Connection refused" in _mysqlMsg:
|
||||
return public.returnData(False, '数据库连接失败,请检查数据库服务是否启动!')
|
||||
return mw.returnData(False, '数据库连接失败,请检查数据库服务是否启动!')
|
||||
if "1133," in _mysqlMsg:
|
||||
return public.returnData(False, '数据库用户不存在!')
|
||||
return mw.returnData(False, '数据库用户不存在!')
|
||||
if "1007," in _mysqlMsg:
|
||||
return public.returnData(False, '数据库已经存在!')
|
||||
return mw.returnData(False, '数据库已经存在!')
|
||||
if "1044," in _mysqlMsg:
|
||||
return public.returnData(False, mysqlMsg[1])
|
||||
return mw.returnData(False, mysqlMsg[1])
|
||||
if "2003," in _mysqlMsg:
|
||||
return public.returnData(False, mysqlMsg[1])
|
||||
return public.returnData(True, 'OK')
|
||||
return mw.returnData(False, mysqlMsg[1])
|
||||
return mw.returnData(True, 'OK')
|
||||
|
||||
|
||||
def start():
|
||||
@@ -248,7 +248,7 @@ def start():
|
||||
if not data['status']:
|
||||
return data['msg']
|
||||
|
||||
data = public.execShell(__SR + file + ' start')
|
||||
data = mw.execShell(__SR + file + ' start')
|
||||
if data[1] == '':
|
||||
return 'ok'
|
||||
return data[0]
|
||||
@@ -256,7 +256,7 @@ def start():
|
||||
|
||||
def stop():
|
||||
file = initDreplace()
|
||||
data = public.execShell(__SR + file + ' stop')
|
||||
data = mw.execShell(__SR + file + ' stop')
|
||||
if data[1] == '':
|
||||
return 'ok'
|
||||
return data[1]
|
||||
@@ -264,7 +264,7 @@ def stop():
|
||||
|
||||
def restart():
|
||||
file = initDreplace()
|
||||
data = public.execShell(__SR + file + ' restart')
|
||||
data = mw.execShell(__SR + file + ' restart')
|
||||
if data[1] == '':
|
||||
return 'ok'
|
||||
return data[1]
|
||||
@@ -272,7 +272,7 @@ def restart():
|
||||
|
||||
def reload():
|
||||
file = initDreplace()
|
||||
data = public.execShell(__SR + file + ' reload')
|
||||
data = mw.execShell(__SR + file + ' reload')
|
||||
if data[1] == '':
|
||||
return 'ok'
|
||||
return data[1]
|
||||
@@ -280,7 +280,7 @@ def reload():
|
||||
|
||||
def initdStatus():
|
||||
if not app_debug:
|
||||
os_name = public.getOs()
|
||||
os_name = mw.getOs()
|
||||
if os_name == 'darwin':
|
||||
return "Apple Computer does not support"
|
||||
initd_bin = getInitDFile()
|
||||
@@ -292,26 +292,26 @@ def initdStatus():
|
||||
def initdInstall():
|
||||
import shutil
|
||||
if not app_debug:
|
||||
os_name = public.getOs()
|
||||
os_name = mw.getOs()
|
||||
if os_name == 'darwin':
|
||||
return "Apple Computer does not support"
|
||||
|
||||
mem_bin = initDreplace()
|
||||
initd_bin = getInitDFile()
|
||||
shutil.copyfile(mem_bin, initd_bin)
|
||||
public.execShell('chmod +x ' + initd_bin)
|
||||
public.execShell('chkconfig --add ' + getPluginName())
|
||||
mw.execShell('chmod +x ' + initd_bin)
|
||||
mw.execShell('chkconfig --add ' + getPluginName())
|
||||
return 'ok'
|
||||
|
||||
|
||||
def initdUinstall():
|
||||
if not app_debug:
|
||||
os_name = public.getOs()
|
||||
os_name = mw.getOs()
|
||||
if os_name == 'darwin':
|
||||
return "Apple Computer does not support"
|
||||
initd_bin = getInitDFile()
|
||||
os.remove(initd_bin)
|
||||
public.execShell('chkconfig --del ' + getPluginName())
|
||||
mw.execShell('chkconfig --del ' + getPluginName())
|
||||
return 'ok'
|
||||
|
||||
|
||||
@@ -346,7 +346,7 @@ def getGogsConf():
|
||||
{'name': 'SHOW_FOOTER_VERSION', 'type': 2, 'ps': 'Gogs版本信息'},
|
||||
{'name': 'SHOW_FOOTER_TEMPLATE_LOAD_TIME', 'type': 2, 'ps': 'Gogs模板加载时间'},
|
||||
]
|
||||
conf = public.readFile(getConf())
|
||||
conf = mw.readFile(getConf())
|
||||
result = []
|
||||
|
||||
for g in gets:
|
||||
@@ -356,7 +356,7 @@ def getGogsConf():
|
||||
continue
|
||||
g['value'] = tmp.groups()[0]
|
||||
result.append(g)
|
||||
return public.getJson(result)
|
||||
return mw.getJson(result)
|
||||
|
||||
|
||||
def submitGogsConf():
|
||||
@@ -376,15 +376,15 @@ def submitGogsConf():
|
||||
'SHOW_FOOTER_TEMPLATE_LOAD_TIME']
|
||||
args = getArgs()
|
||||
filename = getConf()
|
||||
conf = public.readFile(filename)
|
||||
conf = mw.readFile(filename)
|
||||
for g in gets:
|
||||
if g in args:
|
||||
rep = g + '\s*=\s*(.*)'
|
||||
val = g + ' = ' + args[g]
|
||||
conf = re.sub(rep, val, conf)
|
||||
public.writeFile(filename, conf)
|
||||
mw.writeFile(filename, conf)
|
||||
reload()
|
||||
return public.returnJson(True, '设置成功')
|
||||
return mw.returnJson(True, '设置成功')
|
||||
|
||||
|
||||
def userList():
|
||||
@@ -417,12 +417,12 @@ def userList():
|
||||
|
||||
page_info = {'count': count, 'p': page,
|
||||
'row': page_size, 'tojs': 'gogsUserList'}
|
||||
data['list'] = public.getPage(page_info)
|
||||
data['list'] = mw.getPage(page_info)
|
||||
data['page'] = page
|
||||
data['page_size'] = page_size
|
||||
data['page_count'] = int(math.ceil(count / page_size))
|
||||
data['data'] = list_data
|
||||
return public.returnJson(True, 'OK', data)
|
||||
return mw.returnJson(True, 'OK', data)
|
||||
|
||||
|
||||
def getAllUserProject(user, search=''):
|
||||
@@ -465,7 +465,7 @@ def userProjectList():
|
||||
search = ''
|
||||
|
||||
if not 'name' in args:
|
||||
return public.returnJson(False, '缺少参数name')
|
||||
return mw.returnJson(False, '缺少参数name')
|
||||
if 'page' in args:
|
||||
page = int(args['page'])
|
||||
|
||||
@@ -487,38 +487,38 @@ def userProjectList():
|
||||
data['root_url'] = getRootUrl()
|
||||
data['data'] = ret_data
|
||||
data['args'] = args
|
||||
data['list'] = public.getPage(
|
||||
data['list'] = mw.getPage(
|
||||
{'count': dlist_sum, 'p': page, 'row': page_size, 'tojs': 'userProjectList'})
|
||||
|
||||
return public.returnJson(True, 'OK', data)
|
||||
return mw.returnJson(True, 'OK', data)
|
||||
|
||||
|
||||
def projectScriptEdit():
|
||||
args = getArgs()
|
||||
|
||||
if not 'user' in args:
|
||||
return public.returnJson(True, 'username missing')
|
||||
return mw.returnJson(True, 'username missing')
|
||||
|
||||
if not 'name' in args:
|
||||
return public.returnJson(True, 'project name missing')
|
||||
return mw.returnJson(True, 'project name missing')
|
||||
|
||||
user = args['user']
|
||||
name = args['name'] + '.git'
|
||||
post_receive = getRootPath() + '/' + user + '/' + name + \
|
||||
'/custom_hooks/commit'
|
||||
if os.path.exists(post_receive):
|
||||
return public.returnJson(True, 'OK', {'path': post_receive})
|
||||
return mw.returnJson(True, 'OK', {'path': post_receive})
|
||||
else:
|
||||
return public.returnJson(False, 'file does not exist')
|
||||
return mw.returnJson(False, 'file does not exist')
|
||||
|
||||
|
||||
def projectScriptLoad():
|
||||
args = getArgs()
|
||||
if not 'user' in args:
|
||||
return public.returnJson(True, 'username missing')
|
||||
return mw.returnJson(True, 'username missing')
|
||||
|
||||
if not 'name' in args:
|
||||
return public.returnJson(True, 'project name missing')
|
||||
return mw.returnJson(True, 'project name missing')
|
||||
|
||||
user = args['user']
|
||||
name = args['name'] + '.git'
|
||||
@@ -528,28 +528,28 @@ def projectScriptLoad():
|
||||
post_receive = path + '/custom_hooks/post-receive'
|
||||
|
||||
if not os.path.exists(path + '/custom_hooks'):
|
||||
public.execShell('mkdir -p ' + path + '/custom_hooks')
|
||||
mw.execShell('mkdir -p ' + path + '/custom_hooks')
|
||||
|
||||
pct_content = public.readFile(post_receive_tpl)
|
||||
pct_content = mw.readFile(post_receive_tpl)
|
||||
pct_content = pct_content.replace('{$PATH}', path + '/custom_hooks')
|
||||
public.writeFile(post_receive, pct_content)
|
||||
public.execShell('chmod 777 ' + post_receive)
|
||||
mw.writeFile(post_receive, pct_content)
|
||||
mw.execShell('chmod 777 ' + post_receive)
|
||||
|
||||
commit_tpl = getPluginDir() + '/hook/commit.tpl'
|
||||
commit = path + '/custom_hooks/commit'
|
||||
|
||||
codeDir = public.getRootDir() + '/git'
|
||||
codeDir = mw.getRootDir() + '/git'
|
||||
|
||||
cc_content = public.readFile(commit_tpl)
|
||||
cc_content = mw.readFile(commit_tpl)
|
||||
|
||||
sshUrl = 'ssh://127.0.0.1:' + getSshPort()
|
||||
cc_content = cc_content.replace('{$GITROOTURL}', sshUrl)
|
||||
cc_content = cc_content.replace('{$CODE_DIR}', codeDir)
|
||||
cc_content = cc_content.replace('{$USERNAME}', user)
|
||||
cc_content = cc_content.replace('{$PROJECT}', args['name'])
|
||||
cc_content = cc_content.replace('{$WEB_ROOT}', public.getWwwDir())
|
||||
public.writeFile(commit, cc_content)
|
||||
public.execShell('chmod 777 ' + commit)
|
||||
cc_content = cc_content.replace('{$WEB_ROOT}', mw.getWwwDir())
|
||||
mw.writeFile(commit, cc_content)
|
||||
mw.execShell('chmod 777 ' + commit)
|
||||
|
||||
return 'ok'
|
||||
|
||||
@@ -557,31 +557,31 @@ def projectScriptLoad():
|
||||
def projectScriptUnload():
|
||||
args = getArgs()
|
||||
if not 'user' in args:
|
||||
return public.returnJson(True, 'username missing')
|
||||
return mw.returnJson(True, 'username missing')
|
||||
|
||||
if not 'name' in args:
|
||||
return public.returnJson(True, 'project name missing')
|
||||
return mw.returnJson(True, 'project name missing')
|
||||
|
||||
user = args['user']
|
||||
name = args['name'] + '.git'
|
||||
|
||||
post_receive = getRootPath() + '/' + user + '/' + name + \
|
||||
'/custom_hooks/post-receive'
|
||||
public.execShell('rm -f ' + post_receive)
|
||||
mw.execShell('rm -f ' + post_receive)
|
||||
|
||||
commit = getRootPath() + '/' + user + '/' + name + \
|
||||
'/custom_hooks/commit'
|
||||
public.execShell('rm -f ' + commit)
|
||||
mw.execShell('rm -f ' + commit)
|
||||
return 'ok'
|
||||
|
||||
|
||||
def projectScriptDebug():
|
||||
args = getArgs()
|
||||
if not 'user' in args:
|
||||
return public.returnJson(True, 'username missing')
|
||||
return mw.returnJson(True, 'username missing')
|
||||
|
||||
if not 'name' in args:
|
||||
return public.returnJson(True, 'project name missing')
|
||||
return mw.returnJson(True, 'project name missing')
|
||||
user = args['user']
|
||||
name = args['name'] + '.git'
|
||||
commit_log = getRootPath() + '/' + user + '/' + name + \
|
||||
@@ -595,25 +595,25 @@ def projectScriptDebug():
|
||||
data['status'] = False
|
||||
data['msg'] = '没有日志文件'
|
||||
|
||||
return public.getJson(data)
|
||||
return mw.getJson(data)
|
||||
|
||||
|
||||
def gogsEdit():
|
||||
data = {}
|
||||
data['post_receive'] = getPluginDir() + '/hook/post-receive.tpl'
|
||||
data['commit'] = getPluginDir() + '/hook/commit.tpl'
|
||||
return public.getJson(data)
|
||||
return mw.getJson(data)
|
||||
|
||||
|
||||
def getRsaPublic():
|
||||
path = getHomeDir()
|
||||
path += '/.ssh/id_rsa.pub'
|
||||
|
||||
content = public.readFile(path)
|
||||
content = mw.readFile(path)
|
||||
|
||||
data = {}
|
||||
data['public'] = content
|
||||
return public.getJson(data)
|
||||
data['mw'] = content
|
||||
return mw.getJson(data)
|
||||
|
||||
|
||||
def getTotalStatistics():
|
||||
@@ -626,12 +626,12 @@ def getTotalStatistics():
|
||||
|
||||
data['status'] = True
|
||||
data['count'] = count
|
||||
data['ver'] = public.readFile(getServerDir() + '/version.pl').strip()
|
||||
return public.returnJson(True, 'ok', data)
|
||||
data['ver'] = mw.readFile(getServerDir() + '/version.pl').strip()
|
||||
return mw.returnJson(True, 'ok', data)
|
||||
else:
|
||||
data['status'] = False
|
||||
data['count'] = 0
|
||||
return public.returnJson(False, 'fail', data)
|
||||
return mw.returnJson(False, 'fail', data)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -227,7 +227,7 @@ function userProjectList(user, search){
|
||||
var loadOpen = layer.open({
|
||||
type: 1,
|
||||
title: '用户('+user+')项目列表',
|
||||
area: '300px',
|
||||
area: '500px',
|
||||
content:"<div class='bt-form pd20 c6'>\
|
||||
<div>\
|
||||
<div class='divtable' style='margin-top:5px;'>\
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 17 KiB |
Executable
+20
@@ -0,0 +1,20 @@
|
||||
<div class="bt-form">
|
||||
<div class="bt-w-main">
|
||||
<div class="bt-w-menu">
|
||||
<p class="bgw" onclick="pluginService('jenkins');">服务</p>
|
||||
<p onclick="pluginInitD('jenkins');">自启动</p>
|
||||
<p onclick="pluginLogs('jenkins','','run_log');">日志</p>
|
||||
<p onclick="pRead()">说明</p>
|
||||
</div>
|
||||
<div class="bt-w-con pd15">
|
||||
<div class="soft-man-con"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
resetPluginWinWidth(700);
|
||||
$.getScript( "/plugins/file?name=jenkins&f=js/jenkins.js", function() {
|
||||
pluginService('walle');
|
||||
});
|
||||
</script>
|
||||
Executable
+154
@@ -0,0 +1,154 @@
|
||||
# coding: utf-8
|
||||
|
||||
import time
|
||||
import random
|
||||
import os
|
||||
import json
|
||||
import re
|
||||
import sys
|
||||
import subprocess
|
||||
|
||||
sys.path.append(os.getcwd() + "/class/core")
|
||||
import mw
|
||||
|
||||
app_debug = False
|
||||
if mw.isAppleSystem():
|
||||
app_debug = True
|
||||
|
||||
|
||||
def getPluginName():
|
||||
return 'jenkins'
|
||||
|
||||
|
||||
def getPluginDir():
|
||||
return mw.getPluginDir() + '/' + getPluginName()
|
||||
|
||||
|
||||
def getServerDir():
|
||||
return mw.getServerDir() + '/' + getPluginName()
|
||||
|
||||
|
||||
def getInitDFile():
|
||||
if app_debug:
|
||||
return '/tmp/' + getPluginName()
|
||||
return '/etc/init.d/' + getPluginName()
|
||||
|
||||
|
||||
def getInitDTpl():
|
||||
return getPluginDir() + "/init.d/" + getPluginName() + ".tpl"
|
||||
|
||||
|
||||
def getLog():
|
||||
return "/var/log/jenkins/jenkins.log"
|
||||
|
||||
|
||||
def getArgs():
|
||||
args = sys.argv[2:]
|
||||
tmp = {}
|
||||
args_len = len(args)
|
||||
|
||||
if args_len == 1:
|
||||
t = args[0].strip('{').strip('}')
|
||||
t = t.split(':')
|
||||
tmp[t[0]] = t[1]
|
||||
elif args_len > 1:
|
||||
for i in range(len(args)):
|
||||
t = args[i].split(':')
|
||||
tmp[t[0]] = t[1]
|
||||
|
||||
return tmp
|
||||
|
||||
|
||||
def checkArgs(data, ck=[]):
|
||||
for i in range(len(ck)):
|
||||
if not ck[i] in data:
|
||||
return (False, mw.returnJson(False, '参数:(' + ck[i] + ')没有!'))
|
||||
return (True, mw.returnJson(True, 'ok'))
|
||||
|
||||
|
||||
def status():
|
||||
pn = getPluginName()
|
||||
cmd = "ps -ef|grep 'jenkins.war' | grep -v grep | awk '{print $2}'"
|
||||
data = mw.execShell(cmd)
|
||||
if data[0] == '':
|
||||
return 'stop'
|
||||
return 'start'
|
||||
|
||||
|
||||
def start():
|
||||
if mw.isAppleSystem():
|
||||
return "Apple Computer does not support"
|
||||
|
||||
data = mw.execShell('service jenkins start')
|
||||
if data[1] == '':
|
||||
return 'ok'
|
||||
return 'fail'
|
||||
|
||||
|
||||
def stop():
|
||||
if mw.isAppleSystem():
|
||||
return "Apple Computer does not support"
|
||||
|
||||
data = mw.execShell('service jenkins stop')
|
||||
if data[1] == '':
|
||||
return 'ok'
|
||||
return 'fail'
|
||||
|
||||
|
||||
def restart():
|
||||
data = mw.execShell('service jenkins restart')
|
||||
if data[1] == '':
|
||||
return 'ok'
|
||||
return 'fail'
|
||||
|
||||
|
||||
def reload():
|
||||
data = mw.execShell('service jenkins restart')
|
||||
if data[1] == '':
|
||||
return 'ok'
|
||||
return 'fail'
|
||||
|
||||
|
||||
def initdStatus():
|
||||
initd_bin = getInitDFile()
|
||||
if os.path.exists(initd_bin):
|
||||
return 'ok'
|
||||
return 'fail'
|
||||
|
||||
|
||||
def initdInstall():
|
||||
|
||||
if not app_debug:
|
||||
mw.execShell('chkconfig --add ' + getPluginName())
|
||||
return 'ok'
|
||||
|
||||
|
||||
def initdUinstall():
|
||||
if not app_debug:
|
||||
mw.execShell('chkconfig --del ' + getPluginName())
|
||||
return 'ok'
|
||||
|
||||
|
||||
# rsyncdReceive
|
||||
if __name__ == "__main__":
|
||||
func = sys.argv[1]
|
||||
if func == 'status':
|
||||
print status()
|
||||
elif func == 'start':
|
||||
print start()
|
||||
elif func == 'stop':
|
||||
print stop()
|
||||
elif func == 'restart':
|
||||
print restart()
|
||||
elif func == 'reload':
|
||||
print reload()
|
||||
elif func == 'initd_status':
|
||||
print initdStatus()
|
||||
elif func == 'initd_install':
|
||||
print initdInstall()
|
||||
elif func == 'initd_uninstall':
|
||||
print initdUinstall()
|
||||
elif func == 'run_log':
|
||||
print getLog()
|
||||
else:
|
||||
print 'error'
|
||||
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"id":13,
|
||||
"title":"jenkins",
|
||||
"tip":"soft",
|
||||
"name":"jenkins",
|
||||
"type":"扩展",
|
||||
"ps":"开源CI&CD软件领导者",
|
||||
"versions":"1.0",
|
||||
"shell":"install.sh",
|
||||
"checks":"server/jenkins",
|
||||
"path": "server/jenkins",
|
||||
"author":"midoks",
|
||||
"home":"https://jenkins.io/zh/",
|
||||
"date":"2019-12-06",
|
||||
"pid":"3"
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
#!/bin/bash
|
||||
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
|
||||
export PATH
|
||||
|
||||
|
||||
curPath=`pwd`
|
||||
rootPath=$(dirname "$curPath")
|
||||
rootPath=$(dirname "$rootPath")
|
||||
serverPath=$(dirname "$rootPath")
|
||||
install_tmp=${rootPath}/tmp/mw_install.pl
|
||||
sysName=`uname`
|
||||
|
||||
Install_walle()
|
||||
{
|
||||
echo '正在安装脚本文件...' > $install_tmp
|
||||
mkdir -p $serverPath/jenkins
|
||||
echo '1.0' > $serverPath/jenkins/version.pl
|
||||
|
||||
|
||||
if [ $sysName == 'Darwin' ]; then
|
||||
echo "jenkins mac no install!"
|
||||
else
|
||||
wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo
|
||||
rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key
|
||||
yum -y install jenkins
|
||||
fi
|
||||
|
||||
echo '安装完成' > $install_tmp
|
||||
|
||||
}
|
||||
|
||||
Uninstall_walle()
|
||||
{
|
||||
rm -rf $serverPath/jenkins
|
||||
echo "卸载完成" > $install_tmp
|
||||
}
|
||||
|
||||
action=$1
|
||||
if [ "${1}" == 'install' ];then
|
||||
Install_walle
|
||||
else
|
||||
Uninstall_walle
|
||||
fi
|
||||
Executable
+74
@@ -0,0 +1,74 @@
|
||||
function str2Obj(str){
|
||||
var data = {};
|
||||
kv = str.split('&');
|
||||
for(i in kv){
|
||||
v = kv[i].split('=');
|
||||
data[v[0]] = v[1];
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
function pPost(method,args,callback, title){
|
||||
var _args = null;
|
||||
if (typeof(args) == 'string'){
|
||||
_args = JSON.stringify(str2Obj(args));
|
||||
} else {
|
||||
_args = JSON.stringify(args);
|
||||
}
|
||||
|
||||
var _title = '正在获取...';
|
||||
if (typeof(title) != 'undefined'){
|
||||
_title = title;
|
||||
}
|
||||
|
||||
var loadT = layer.msg(_title, { icon: 16, time: 0, shade: 0.3 });
|
||||
$.post('/plugins/run', {name:'walle', func:method, args:_args}, function(data) {
|
||||
layer.close(loadT);
|
||||
if (!data.status){
|
||||
layer.msg(data.msg,{icon:0,time:2000,shade: [0.3, '#000']});
|
||||
return;
|
||||
}
|
||||
if(typeof(callback) == 'function'){
|
||||
callback(data);
|
||||
}
|
||||
},'json');
|
||||
}
|
||||
|
||||
function pPostCallbak(method, version, args,callback){
|
||||
var loadT = layer.msg('正在获取...', { icon: 16, time: 0, shade: 0.3 });
|
||||
|
||||
var req_data = {};
|
||||
req_data['name'] = 'walle';
|
||||
req_data['func'] = method;
|
||||
args['version'] = version;
|
||||
|
||||
if (typeof(args) == 'string'){
|
||||
req_data['args'] = JSON.stringify(str2Obj(args));
|
||||
} else {
|
||||
req_data['args'] = JSON.stringify(args);
|
||||
}
|
||||
|
||||
$.post('/plugins/callback', req_data, function(data) {
|
||||
layer.close(loadT);
|
||||
if (!data.status){
|
||||
layer.msg(data.msg,{icon:0,time:2000,shade: [0.3, '#000']});
|
||||
return;
|
||||
}
|
||||
|
||||
if(typeof(callback) == 'function'){
|
||||
callback(data);
|
||||
}
|
||||
},'json');
|
||||
}
|
||||
|
||||
|
||||
|
||||
function pRead(){
|
||||
var readme = '<ul class="help-info-text c7">';
|
||||
readme += '<li>修改配置正确后:</li>';
|
||||
readme += '<li>手动[初始化环境]:cat /var/lib/jenkins/secrets/initialAdminPassword</li>';
|
||||
readme += '<li><a target="_blank" href="https://jenkins.io/zh/doc/">官方文档</a></li>';
|
||||
readme += '</ul>';
|
||||
|
||||
$('.soft-man-con').html(readme);
|
||||
}
|
||||
+41
-41
@@ -7,10 +7,10 @@ import time
|
||||
import shutil
|
||||
|
||||
sys.path.append(os.getcwd() + "/class/core")
|
||||
import public
|
||||
import mw
|
||||
|
||||
app_debug = False
|
||||
if public.isAppleSystem():
|
||||
if mw.isAppleSystem():
|
||||
app_debug = True
|
||||
|
||||
|
||||
@@ -19,11 +19,11 @@ def getPluginName():
|
||||
|
||||
|
||||
def getPluginDir():
|
||||
return public.getPluginDir() + '/' + getPluginName()
|
||||
return mw.getPluginDir() + '/' + getPluginName()
|
||||
|
||||
|
||||
def getServerDir():
|
||||
return public.getServerDir() + '/' + getPluginName()
|
||||
return mw.getServerDir() + '/' + getPluginName()
|
||||
|
||||
|
||||
def getArgs():
|
||||
@@ -46,13 +46,13 @@ def getArgs():
|
||||
def checkArgs(data, ck=[]):
|
||||
for i in range(len(ck)):
|
||||
if not ck[i] in data:
|
||||
return (False, public.returnJson(False, '参数:(' + ck[i] + ')没有!'))
|
||||
return (True, public.returnJson(True, 'ok'))
|
||||
return (False, mw.returnJson(False, '参数:(' + ck[i] + ')没有!'))
|
||||
return (True, mw.returnJson(True, 'ok'))
|
||||
|
||||
|
||||
def status():
|
||||
cmd = "ps -ef|grep xl2tpd |grep -v grep | grep -v python | awk '{print $2}'"
|
||||
data = public.execShell(cmd)
|
||||
data = mw.execShell(cmd)
|
||||
if data[0] == '':
|
||||
return 'stop'
|
||||
return 'start'
|
||||
@@ -61,62 +61,62 @@ def status():
|
||||
def initConf():
|
||||
l2tp_cs = getServerDir() + '/chap-secrets'
|
||||
if not os.path.exists(l2tp_cs):
|
||||
public.execShell('cp -rf ' + getPluginDir() +
|
||||
'/tmp/chap-secrets' + ' ' + getServerDir())
|
||||
mw.execShell('cp -rf ' + getPluginDir() +
|
||||
'/tmp/chap-secrets' + ' ' + getServerDir())
|
||||
|
||||
l2tp_is = getServerDir() + '/ipsec.secrets'
|
||||
if not os.path.exists(l2tp_is):
|
||||
public.execShell('cp -rf ' + getPluginDir() +
|
||||
'/tmp/ipsec.secrets' + ' ' + getServerDir())
|
||||
mw.execShell('cp -rf ' + getPluginDir() +
|
||||
'/tmp/ipsec.secrets' + ' ' + getServerDir())
|
||||
|
||||
|
||||
def start():
|
||||
initConf()
|
||||
|
||||
if public.isAppleSystem():
|
||||
if mw.isAppleSystem():
|
||||
return "Apple Computer does not support"
|
||||
|
||||
data = public.execShell('service xl2tpd start')
|
||||
data = mw.execShell('service xl2tpd start')
|
||||
if data[0] == '':
|
||||
return 'ok'
|
||||
return data[1]
|
||||
|
||||
|
||||
def stop():
|
||||
if public.isAppleSystem():
|
||||
if mw.isAppleSystem():
|
||||
return "Apple Computer does not support"
|
||||
|
||||
data = public.execShell('service xl2tpd stop')
|
||||
data = mw.execShell('service xl2tpd stop')
|
||||
if data[0] == '':
|
||||
return 'ok'
|
||||
return data[1]
|
||||
|
||||
|
||||
def restart():
|
||||
if public.isAppleSystem():
|
||||
if mw.isAppleSystem():
|
||||
return "Apple Computer does not support"
|
||||
|
||||
data = public.execShell('service xl2tpd restart')
|
||||
data = mw.execShell('service xl2tpd restart')
|
||||
if data[0] == '':
|
||||
return 'ok'
|
||||
return data[1]
|
||||
|
||||
|
||||
def reload():
|
||||
data = public.execShell('service xl2tpd reload')
|
||||
data = mw.execShell('service xl2tpd reload')
|
||||
if data[0] == '':
|
||||
return 'ok'
|
||||
return data[1]
|
||||
|
||||
|
||||
def getPathFile():
|
||||
if public.isAppleSystem():
|
||||
if mw.isAppleSystem():
|
||||
return getServerDir() + '/chap-secrets'
|
||||
return '/etc/ppp/chap-secrets'
|
||||
|
||||
|
||||
def getPathFilePsk():
|
||||
if public.isAppleSystem():
|
||||
if mw.isAppleSystem():
|
||||
return getServerDir() + '/ipsec.secrets'
|
||||
return '/etc/ipsec.secrets'
|
||||
|
||||
@@ -125,13 +125,13 @@ def getUserList():
|
||||
import re
|
||||
path = getPathFile()
|
||||
if not os.path.exists(path):
|
||||
return public.returnJson(False, '密码配置文件不存在!')
|
||||
conf = public.readFile(path)
|
||||
return mw.returnJson(False, '密码配置文件不存在!')
|
||||
conf = mw.readFile(path)
|
||||
|
||||
conf = re.sub('#(.*)\n', '', conf)
|
||||
|
||||
if conf.strip() == '':
|
||||
return public.returnJson(True, 'ok', [])
|
||||
return mw.returnJson(True, 'ok', [])
|
||||
|
||||
ulist = conf.strip().split('\n')
|
||||
|
||||
@@ -146,36 +146,36 @@ def getUserList():
|
||||
line_info['ip'] = line[3]
|
||||
user.append(line_info)
|
||||
|
||||
return public.returnJson(True, 'ok', user)
|
||||
return mw.returnJson(True, 'ok', user)
|
||||
|
||||
|
||||
def addUser():
|
||||
if public.isAppleSystem():
|
||||
return public.returnJson(False, "Apple Computer does not support")
|
||||
if mw.isAppleSystem():
|
||||
return mw.returnJson(False, "Apple Computer does not support")
|
||||
|
||||
args = getArgs()
|
||||
data = checkArgs(args, ['username'])
|
||||
if not data[0]:
|
||||
return data[1]
|
||||
ret = public.execShell('echo ' + args['username'] + '|l2tp -a')
|
||||
ret = mw.execShell('echo ' + args['username'] + '|l2tp -a')
|
||||
if ret[1] == '':
|
||||
return public.returnJson(True, '添加成功!:' + ret[0])
|
||||
return public.returnJson(False, '添加失败:' + ret[0])
|
||||
return mw.returnJson(True, '添加成功!:' + ret[0])
|
||||
return mw.returnJson(False, '添加失败:' + ret[0])
|
||||
|
||||
|
||||
def delUser():
|
||||
if public.isAppleSystem():
|
||||
return public.returnJson(False, "Apple Computer does not support")
|
||||
if mw.isAppleSystem():
|
||||
return mw.returnJson(False, "Apple Computer does not support")
|
||||
|
||||
args = getArgs()
|
||||
data = checkArgs(args, ['username'])
|
||||
if not data[0]:
|
||||
return data[1]
|
||||
|
||||
ret = public.execShell('echo ' + args['username'] + '|l2tp -d')
|
||||
ret = mw.execShell('echo ' + args['username'] + '|l2tp -d')
|
||||
if ret[1] == '':
|
||||
return public.returnJson(True, '删除成功!:' + ret[0])
|
||||
return public.returnJson(False, '删除失败:' + ret[0])
|
||||
return mw.returnJson(True, '删除成功!:' + ret[0])
|
||||
return mw.returnJson(False, '删除失败:' + ret[0])
|
||||
|
||||
|
||||
def modUser():
|
||||
@@ -192,17 +192,17 @@ def modUser():
|
||||
# sed -i "/^\<${user}\>/d" /etc/ppp/chap-secrets
|
||||
# echo "${user} l2tpd ${pass} *" >> /etc/ppp/chap-secrets
|
||||
|
||||
if public.isAppleSystem():
|
||||
public.execShell("sed -i .bak '/^\(" + username + "\)/d' " + path)
|
||||
if mw.isAppleSystem():
|
||||
mw.execShell("sed -i .bak '/^\(" + username + "\)/d' " + path)
|
||||
else:
|
||||
public.execShell("sed -i '/^\(" + username + "\)/d' " + path)
|
||||
mw.execShell("sed -i '/^\(" + username + "\)/d' " + path)
|
||||
# print 'echo "' + username + " l2tpd " + password + " *\" >>"
|
||||
# + path
|
||||
ret = public.execShell("echo \"" + username +
|
||||
" l2tpd " + password + " *\" >>" + path)
|
||||
ret = mw.execShell("echo \"" + username +
|
||||
" l2tpd " + password + " *\" >>" + path)
|
||||
if ret[1] == '':
|
||||
return public.returnJson(True, '修改成功!')
|
||||
return public.returnJson(False, '修改失败')
|
||||
return mw.returnJson(True, '修改成功!')
|
||||
return mw.returnJson(False, '修改失败')
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
+22
-23
@@ -7,10 +7,10 @@ import time
|
||||
import re
|
||||
|
||||
sys.path.append(os.getcwd() + "/class/core")
|
||||
import public
|
||||
import mw
|
||||
|
||||
app_debug = False
|
||||
if public.isAppleSystem():
|
||||
if mw.isAppleSystem():
|
||||
app_debug = True
|
||||
|
||||
|
||||
@@ -19,11 +19,11 @@ def getPluginName():
|
||||
|
||||
|
||||
def getPluginDir():
|
||||
return public.getPluginDir() + '/' + getPluginName()
|
||||
return mw.getPluginDir() + '/' + getPluginName()
|
||||
|
||||
|
||||
def getServerDir():
|
||||
return public.getServerDir() + '/' + getPluginName()
|
||||
return mw.getServerDir() + '/' + getPluginName()
|
||||
|
||||
|
||||
def getInitDFile():
|
||||
@@ -44,7 +44,7 @@ def getConfTpl():
|
||||
|
||||
def getMemPort():
|
||||
path = getConf()
|
||||
content = public.readFile(path)
|
||||
content = mw.readFile(path)
|
||||
rep = 'PORT\s*=\s*(\d*)'
|
||||
tmp = re.search(rep, content)
|
||||
return tmp.groups()[0]
|
||||
@@ -68,7 +68,7 @@ def getArgs():
|
||||
|
||||
|
||||
def status():
|
||||
data = public.execShell(
|
||||
data = mw.execShell(
|
||||
"ps -ef|grep " + getPluginName() + " |grep -v grep | grep -v python | awk '{print $2}'")
|
||||
if data[0] == '':
|
||||
return 'stop'
|
||||
@@ -78,7 +78,7 @@ def status():
|
||||
def initDreplace():
|
||||
|
||||
file_tpl = getConfTpl()
|
||||
service_path = public.getServerDir()
|
||||
service_path = mw.getServerDir()
|
||||
|
||||
initD_path = getServerDir() + '/init.d'
|
||||
if not os.path.exists(initD_path):
|
||||
@@ -86,17 +86,17 @@ def initDreplace():
|
||||
file_bin = initD_path + '/memcached'
|
||||
|
||||
if not os.path.exists(file_bin):
|
||||
content = public.readFile(file_tpl)
|
||||
content = mw.readFile(file_tpl)
|
||||
content = content.replace('{$SERVER_PATH}', service_path)
|
||||
public.writeFile(file_bin, content)
|
||||
public.execShell('chmod +x ' + file_bin)
|
||||
mw.writeFile(file_bin, content)
|
||||
mw.execShell('chmod +x ' + file_bin)
|
||||
|
||||
return file_bin
|
||||
|
||||
|
||||
def memOp(method):
|
||||
file = initDreplace()
|
||||
data = public.execShell(file + ' ' + method)
|
||||
data = mw.execShell(file + ' ' + method)
|
||||
if data[1] == '':
|
||||
return 'ok'
|
||||
return data[1]
|
||||
@@ -146,15 +146,15 @@ def runInfo():
|
||||
result['hit'] = float(result['get_hits']) / \
|
||||
float(result['cmd_get']) * 100
|
||||
|
||||
conf = public.readFile(getConf())
|
||||
conf = mw.readFile(getConf())
|
||||
result['bind'] = re.search('IP=(.+)', conf).groups()[0]
|
||||
result['port'] = int(re.search('PORT=(\d+)', conf).groups()[0])
|
||||
result['maxconn'] = int(re.search('MAXCONN=(\d+)', conf).groups()[0])
|
||||
result['cachesize'] = int(
|
||||
re.search('CACHESIZE=(\d+)', conf).groups()[0])
|
||||
return public.getJson(result)
|
||||
return mw.getJson(result)
|
||||
except Exception, e:
|
||||
return public.getJson({})
|
||||
return mw.getJson({})
|
||||
|
||||
|
||||
def saveConf():
|
||||
@@ -164,13 +164,13 @@ def saveConf():
|
||||
print confFile
|
||||
try:
|
||||
args = getArgs()
|
||||
content = public.readFile(confFile)
|
||||
content = mw.readFile(confFile)
|
||||
content = re.sub('IP=.+', 'IP=' + args['ip'], content)
|
||||
content = re.sub('PORT=\d+', 'PORT=' + args['port'], content)
|
||||
content = re.sub('MAXCONN=\d+', 'MAXCONN=' + args['maxconn'], content)
|
||||
content = re.sub('CACHESIZE=\d+', 'CACHESIZE=' +
|
||||
args['cachesize'], content)
|
||||
public.writeFile(confFile, content)
|
||||
mw.writeFile(confFile, content)
|
||||
restart()
|
||||
return 'save ok'
|
||||
except Exception as e:
|
||||
@@ -180,7 +180,7 @@ def saveConf():
|
||||
|
||||
def initdStatus():
|
||||
if not app_debug:
|
||||
if public.isAppleSystem():
|
||||
if mw.isAppleSystem():
|
||||
return "Apple Computer does not support"
|
||||
initd_bin = getInitDFile()
|
||||
if os.path.exists(initd_bin):
|
||||
@@ -191,24 +191,23 @@ def initdStatus():
|
||||
def initdInstall():
|
||||
import shutil
|
||||
if not app_debug:
|
||||
if public.isAppleSystem():
|
||||
if mw.isAppleSystem():
|
||||
return "Apple Computer does not support"
|
||||
|
||||
|
||||
mem_bin = initDreplace()
|
||||
initd_bin = getInitDFile()
|
||||
shutil.copyfile(mem_bin, initd_bin)
|
||||
public.execShell('chmod +x ' + initd_bin)
|
||||
public.execShell('chkconfig --add ' + getPluginName())
|
||||
mw.execShell('chmod +x ' + initd_bin)
|
||||
mw.execShell('chkconfig --add ' + getPluginName())
|
||||
return 'ok'
|
||||
|
||||
|
||||
def initdUinstall():
|
||||
if not app_debug:
|
||||
if public.isAppleSystem():
|
||||
if mw.isAppleSystem():
|
||||
return "Apple Computer does not support"
|
||||
|
||||
public.execShell('chkconfig --del ' + getPluginName())
|
||||
mw.execShell('chkconfig --del ' + getPluginName())
|
||||
initd_bin = getInitDFile()
|
||||
os.remove(initd_bin)
|
||||
return 'ok'
|
||||
|
||||
@@ -7,7 +7,7 @@ import sys
|
||||
sys.path.append("/usr/local/lib/python2.7/site-packages")
|
||||
|
||||
|
||||
class mysql:
|
||||
class mysqlDb:
|
||||
__DB_PASS = None
|
||||
__DB_USER = 'root'
|
||||
__DB_PORT = 3306
|
||||
@@ -20,7 +20,7 @@ class mysql:
|
||||
def __Conn(self):
|
||||
'''连接MYSQL数据库'''
|
||||
try:
|
||||
import public
|
||||
import mw
|
||||
socket = '/tmp/mysql.sock'
|
||||
try:
|
||||
import MySQLdb
|
||||
@@ -28,13 +28,13 @@ class mysql:
|
||||
self.__DB_ERR = ex
|
||||
return False
|
||||
try:
|
||||
myconf = public.readFile(self.__DB_CNF)
|
||||
myconf = mw.readFile(self.__DB_CNF)
|
||||
rep = "port\s*=\s*([0-9]+)"
|
||||
self.__DB_PORT = int(re.search(rep, myconf).groups()[0])
|
||||
except:
|
||||
self.__DB_PORT = 3306
|
||||
# print self.__DB_PASS
|
||||
#self.__DB_PASS = public.M('config').where('id=?', (1,)).getField('mysql_root')
|
||||
#self.__DB_PASS = mw.M('config').where('id=?', (1,)).getField('mysql_root')
|
||||
try:
|
||||
self.__DB_CONN = MySQLdb.connect(host=self.__DB_HOST, user=self.__DB_USER, passwd=self.__DB_PASS,
|
||||
port=self.__DB_PORT, charset="utf8", connect_timeout=1, unix_socket=socket)
|
||||
@@ -48,6 +48,9 @@ class mysql:
|
||||
self.__DB_ERR = e
|
||||
return False
|
||||
|
||||
def setDbConf(self, conf):
|
||||
self.__DB_CNF = conf
|
||||
|
||||
def setPwd(self, pwd):
|
||||
self.__DB_PASS = pwd
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
[client]
|
||||
#password = your_password
|
||||
port = 3306
|
||||
socket = /tmp/mysql.sock
|
||||
socket = {$SERVER_APP_PATH}/mysql.sock
|
||||
|
||||
[mysqld]
|
||||
# 5.6
|
||||
#default-authentication-plugin=sha256_password
|
||||
port = 3306
|
||||
socket = /tmp/mysql.sock
|
||||
socket = {$SERVER_APP_PATH}/mysql.sock
|
||||
datadir = {$SERVER_APP_PATH}/data
|
||||
log-error = {$SERVER_APP_PATH}/data/error.log
|
||||
default_storage_engine = MyISAM
|
||||
#skip-external-locking
|
||||
#loose-skip-innodb
|
||||
key_buffer_size = 8M
|
||||
max_allowed_packet = 100G
|
||||
max_allowed_packet = 100M
|
||||
table_open_cache = 32
|
||||
sort_buffer_size = 256K
|
||||
net_buffer_length = 4K
|
||||
@@ -20,15 +20,21 @@ read_buffer_size = 128K
|
||||
read_rnd_buffer_size = 256K
|
||||
myisam_sort_buffer_size = 4M
|
||||
thread_cache_size = 4
|
||||
lower_case_table_names=2
|
||||
query_cache_size = 4M
|
||||
tmp_table_size = 8M
|
||||
|
||||
#skip-networking
|
||||
#skip-name-resolve
|
||||
max_connections = 500
|
||||
max_connect_errors = 100
|
||||
open_files_limit = 65535
|
||||
|
||||
#skip-networking
|
||||
#skip-name-resolve
|
||||
#skip-external-locking
|
||||
#loose-skip-innodb
|
||||
#skip-grant-tables
|
||||
|
||||
|
||||
log-bin=mysql-bin
|
||||
binlog_format=mixed
|
||||
server-id = 1
|
||||
@@ -38,6 +44,24 @@ slow-query-log-file={$SERVER_APP_PATH}/data/mysql-slow.log
|
||||
long_query_time=3
|
||||
#log_queries_not_using_indexes=on
|
||||
|
||||
relay-log=mdserver
|
||||
relay-log-index=mdserver
|
||||
|
||||
#master
|
||||
#binlog-do-db
|
||||
binlog-ignore-db = test
|
||||
binlog-ignore-db = mysql
|
||||
binlog-ignore-db = information_schema
|
||||
binlog-ignore-db = performance_schema
|
||||
|
||||
#slave
|
||||
log-slave-updates
|
||||
#replicate-do-db
|
||||
replicate-ignore-db = information_schema
|
||||
replicate-ignore-db = performance_schema
|
||||
replicate-ignore-db = mysql
|
||||
replicate-ignore-db = test
|
||||
|
||||
default_storage_engine = InnoDB
|
||||
innodb_data_home_dir = {$SERVER_APP_PATH}/data
|
||||
innodb_data_file_path = ibdata1:10M:autoextend
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
[client]
|
||||
#password = your_password
|
||||
port = 3306
|
||||
socket = {$SERVER_APP_PATH}/mysql.sock
|
||||
default-character-set = UTF8MB4
|
||||
|
||||
[mysqld]
|
||||
port = 3306
|
||||
socket = {$SERVER_APP_PATH}/mysql.sock
|
||||
datadir = {$SERVER_APP_PATH}/data
|
||||
log-error = {$SERVER_APP_PATH}/data/error.log
|
||||
default_storage_engine = MyISAM
|
||||
|
||||
key_buffer_size = 8M
|
||||
table_open_cache = 32
|
||||
sort_buffer_size = 256K
|
||||
net_buffer_length = 4K
|
||||
read_buffer_size = 128K
|
||||
read_rnd_buffer_size = 256K
|
||||
myisam_sort_buffer_size = 4M
|
||||
thread_cache_size = 4
|
||||
lower_case_table_names=2
|
||||
tmp_table_size = 8M
|
||||
character-set-server = UTF8MB4
|
||||
|
||||
max_connections = 500
|
||||
max_connect_errors = 100
|
||||
open_files_limit = 2560
|
||||
max_allowed_packet = 128M
|
||||
|
||||
#skip-external-locking
|
||||
#skip-grant-tables
|
||||
#loose-skip-innodb
|
||||
#skip-networking
|
||||
#skip-name-resolve
|
||||
|
||||
log-bin=mysql-bin
|
||||
binlog_format=mixed
|
||||
server-id = 1
|
||||
slow_query_log=1
|
||||
slow-query-log-file={$SERVER_APP_PATH}/data/mysql-slow.log
|
||||
long_query_time=3
|
||||
#log_queries_not_using_indexes=on
|
||||
|
||||
relay-log=mdserver
|
||||
relay-log-index=mdserver
|
||||
|
||||
#master
|
||||
#binlog-do-db
|
||||
binlog-ignore-db = test
|
||||
binlog-ignore-db = mysql
|
||||
binlog-ignore-db = information_schema
|
||||
binlog-ignore-db = performance_schema
|
||||
|
||||
#slave
|
||||
log-slave-updates
|
||||
#replicate-do-db
|
||||
replicate-ignore-db = information_schema
|
||||
replicate-ignore-db = performance_schema
|
||||
replicate-ignore-db = mysql
|
||||
replicate-ignore-db = test
|
||||
|
||||
default_storage_engine = InnoDB
|
||||
innodb_data_home_dir = {$SERVER_APP_PATH}/data
|
||||
innodb_data_file_path = ibdata1:10M:autoextend
|
||||
innodb_log_group_home_dir = {$SERVER_APP_PATH}/data
|
||||
innodb_buffer_pool_size = 16M
|
||||
innodb_log_file_size = 5M
|
||||
innodb_log_buffer_size = 8M
|
||||
innodb_flush_log_at_trx_commit = 1
|
||||
innodb_lock_wait_timeout = 120
|
||||
innodb_max_dirty_pages_pct = 90
|
||||
innodb_read_io_threads = 1
|
||||
innodb_write_io_threads = 1
|
||||
innodb_file_per_table=1
|
||||
binlog_expire_logs_seconds=2592000
|
||||
|
||||
[mysqldump]
|
||||
quick
|
||||
|
||||
[mysql]
|
||||
no-auto-rehash
|
||||
|
||||
[myisamchk]
|
||||
key_buffer_size = 20M
|
||||
sort_buffer_size = 20M
|
||||
read_buffer = 2M
|
||||
write_buffer = 2M
|
||||
|
||||
[mysqlhotcopy]
|
||||
interactive-timeout
|
||||
@@ -15,3 +15,14 @@ CREATE TABLE IF NOT EXISTS `databases` (
|
||||
`ps` TEXT,
|
||||
`addtime` TEXT
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `master_replication_user` (
|
||||
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
`username` TEXT,
|
||||
`password` TEXT,
|
||||
`accept` TEXT,
|
||||
`ps` TEXT,
|
||||
`addtime` TEXT
|
||||
);
|
||||
|
||||
|
||||
|
||||
+28
-23
@@ -1,3 +1,28 @@
|
||||
<div class="bt-form">
|
||||
<div class='plugin_version'></div>
|
||||
<div class="bt-w-main">
|
||||
<div class="bt-w-menu">
|
||||
<script type="text/javascript">console.log($('.plugin_version').attr('version'));</script>
|
||||
<p class="bgw" onclick="pluginService('mysql', $('.plugin_version').attr('version'));">服务</p>
|
||||
<p onclick="pluginInitD('mysql', $('.plugin_version').attr('version'));">自启动</p>
|
||||
<p onclick="pluginConfig('mysql', $('.plugin_version').attr('version'));">配置文件</p>
|
||||
<p onclick="myDbPos();">存储位置</p>
|
||||
<p onclick="myPort();">端口</p>
|
||||
<p onclick="runInfo();">当前状态</p>
|
||||
<p onclick="myPerfOpt();">性能优化</p>
|
||||
<p onclick="myLogs();">日志</p>
|
||||
<p onclick="pluginLogs('mysql',$('.plugin_version').attr('version'),'show_log');">慢日志</p>
|
||||
<p onclick="dbList()">管理列表</p>
|
||||
<p onclick="masterOrSlaveConf($('.plugin_version').attr('version'))">主从配置</p>
|
||||
</div>
|
||||
<div class="bt-w-con pd15">
|
||||
<div class="soft-man-con"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<style type="text/css">
|
||||
.db_list{
|
||||
padding: 0px 0 10px 0;
|
||||
@@ -25,29 +50,9 @@
|
||||
margin-right: 0;
|
||||
}
|
||||
</style>
|
||||
<div class="bt-form">
|
||||
<div class="bt-w-main">
|
||||
<div class="bt-w-menu">
|
||||
<p class="bgw" onclick="pluginService('mysql');">服务</p>
|
||||
<p onclick="pluginInitD('mysql');">自启动</p>
|
||||
<p onclick="pluginConfig('mysql');">配置文件</p>
|
||||
<p onclick="myDbPos();">存储位置</p>
|
||||
<p onclick="myPort();">端口</p>
|
||||
<p onclick="runInfo();">当前状态</p>
|
||||
<p onclick="myPerfOpt();">性能优化</p>
|
||||
<p onclick="myLogs();">日志</p>
|
||||
<p onclick="pluginLogs('mysql','','show_log');">慢日志</p>
|
||||
<p onclick="dbList()">管理列表</p>
|
||||
</div>
|
||||
<div class="bt-w-con pd15">
|
||||
<div class="soft-man-con"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
resetPluginWinWidth(800);
|
||||
pluginService('mysql');
|
||||
$.getScript( "/plugins/file?name=mysql&f=js/mysql.js");
|
||||
$.getScript( "/plugins/file?name=mysql&f=js/mysql.js", function(){
|
||||
pluginService('mysql',$('.plugin_version').attr('version'));
|
||||
});
|
||||
</script>
|
||||
+999
-180
File diff suppressed because it is too large
Load Diff
@@ -4,9 +4,12 @@
|
||||
"name":"mysql",
|
||||
"type":"运行环境",
|
||||
"ps":"一种关系数据库管理系统!",
|
||||
"coexist": false,
|
||||
"checks": "server/mysql/VERSION/bin/mysql",
|
||||
"path": "server/mysql/VERSION",
|
||||
"todo_versions":["5.6","5.7","8.0"],
|
||||
"versions":["5.5"],
|
||||
"updates":["5.5.62"],
|
||||
"versions":["5.5", "5.6", "5.7","8.0"],
|
||||
"updates":["5.5.62","5.6.50", "5.7.32","8.0.22"],
|
||||
"shell":"install.sh",
|
||||
"checks":"server/mysql",
|
||||
"path":"server/mysql",
|
||||
|
||||
Executable
+376
@@ -0,0 +1,376 @@
|
||||
#!/bin/sh
|
||||
# Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
|
||||
# This file is public domain and comes with NO WARRANTY of any kind
|
||||
|
||||
# MySQL daemon start/stop script.
|
||||
|
||||
# Usually this is put in /etc/init.d (at least on machines SYSV R4 based
|
||||
# systems) and linked to /etc/rc3.d/S99mysql and /etc/rc0.d/K01mysql.
|
||||
# When this is done the mysql server will be started when the machine is
|
||||
# started and shut down when the systems goes down.
|
||||
|
||||
# Comments to support chkconfig on RedHat Linux
|
||||
# chkconfig: 2345 64 36
|
||||
# description: A very fast and reliable SQL database engine.
|
||||
|
||||
# Comments to support LSB init script conventions
|
||||
### BEGIN INIT INFO
|
||||
# Provides: mysql
|
||||
# Required-Start: $local_fs $network $remote_fs
|
||||
# Should-Start: ypbind nscd ldap ntpd xntpd
|
||||
# Required-Stop: $local_fs $network $remote_fs
|
||||
# Default-Start: 2 3 4 5
|
||||
# Default-Stop: 0 1 6
|
||||
# Short-Description: start and stop MySQL
|
||||
# Description: MySQL is a very fast and reliable SQL database engine.
|
||||
### END INIT INFO
|
||||
|
||||
# If you install MySQL on some other places than /Users/midoks/Desktop/fwww/server/mysql, then you
|
||||
# have to do one of the following things for this script to work:
|
||||
#
|
||||
# - Run this script from within the MySQL installation directory
|
||||
# - Create a /etc/my.cnf file with the following information:
|
||||
# [mysqld]
|
||||
# basedir=<path-to-mysql-installation-directory>
|
||||
# - Add the above to any other configuration file (for example ~/.my.ini)
|
||||
# and copy my_print_defaults to /usr/bin
|
||||
# - Add the path to the mysql-installation-directory to the basedir variable
|
||||
# below.
|
||||
#
|
||||
# If you want to affect other MySQL variables, you should make your changes
|
||||
# in the /etc/my.cnf, ~/.my.cnf or other MySQL configuration files.
|
||||
|
||||
# If you change base dir, you must also change datadir. These may get
|
||||
# overwritten by settings in the MySQL configuration files.
|
||||
|
||||
basedir=
|
||||
datadir=
|
||||
|
||||
# Default value, in seconds, afterwhich the script should timeout waiting
|
||||
# for server start.
|
||||
# Value here is overriden by value in my.cnf.
|
||||
# 0 means don't wait at all
|
||||
# Negative numbers mean to wait indefinitely
|
||||
service_startup_timeout=900
|
||||
|
||||
# Lock directory for RedHat / SuSE.
|
||||
lockdir='/var/lock/subsys'
|
||||
lock_file_path="$lockdir/mysql"
|
||||
|
||||
# The following variables are only set for letting mysql.server find things.
|
||||
|
||||
# Set some defaults
|
||||
mysqld_pid_file_path=
|
||||
if test -z "$basedir"
|
||||
then
|
||||
basedir=/Users/midoks/Desktop/fwww/server/mysql
|
||||
bindir=/Users/midoks/Desktop/fwww/server/mysql/bin
|
||||
if test -z "$datadir"
|
||||
then
|
||||
datadir=/Users/midoks/Desktop/fwww/server/mysql/data
|
||||
fi
|
||||
sbindir=/Users/midoks/Desktop/fwww/server/mysql/bin
|
||||
libexecdir=/Users/midoks/Desktop/fwww/server/mysql/bin
|
||||
else
|
||||
bindir="$basedir/bin"
|
||||
if test -z "$datadir"
|
||||
then
|
||||
datadir="$basedir/data"
|
||||
fi
|
||||
sbindir="$basedir/sbin"
|
||||
libexecdir="$basedir/libexec"
|
||||
fi
|
||||
|
||||
# datadir_set is used to determine if datadir was set (and so should be
|
||||
# *not* set inside of the --basedir= handler.)
|
||||
datadir_set=
|
||||
|
||||
#
|
||||
# Use LSB init script functions for printing messages, if possible
|
||||
#
|
||||
lsb_functions="/lib/lsb/init-functions"
|
||||
if test -f $lsb_functions ; then
|
||||
. $lsb_functions
|
||||
else
|
||||
log_success_msg()
|
||||
{
|
||||
echo " SUCCESS! $@"
|
||||
}
|
||||
log_failure_msg()
|
||||
{
|
||||
echo " ERROR! $@"
|
||||
}
|
||||
fi
|
||||
|
||||
PATH="/sbin:/usr/sbin:/bin:/usr/bin:$basedir/bin"
|
||||
export PATH
|
||||
|
||||
mode=$1 # start or stop
|
||||
|
||||
[ $# -ge 1 ] && shift
|
||||
|
||||
|
||||
other_args="$*" # uncommon, but needed when called from an RPM upgrade action
|
||||
# Expected: "--skip-networking --skip-grant-tables"
|
||||
# They are not checked here, intentionally, as it is the resposibility
|
||||
# of the "spec" file author to give correct arguments only.
|
||||
|
||||
case `echo "testing\c"`,`echo -n testing` in
|
||||
*c*,-n*) echo_n= echo_c= ;;
|
||||
*c*,*) echo_n=-n echo_c= ;;
|
||||
*) echo_n= echo_c='\c' ;;
|
||||
esac
|
||||
|
||||
parse_server_arguments() {
|
||||
for arg do
|
||||
case "$arg" in
|
||||
--basedir=*) basedir=`echo "$arg" | sed -e 's/^[^=]*=//'`
|
||||
bindir="$basedir/bin"
|
||||
if test -z "$datadir_set"; then
|
||||
datadir="$basedir/data"
|
||||
fi
|
||||
sbindir="$basedir/sbin"
|
||||
libexecdir="$basedir/libexec"
|
||||
;;
|
||||
--datadir=*) datadir=`echo "$arg" | sed -e 's/^[^=]*=//'`
|
||||
datadir_set=1
|
||||
;;
|
||||
--pid-file=*) mysqld_pid_file_path=`echo "$arg" | sed -e 's/^[^=]*=//'` ;;
|
||||
--service-startup-timeout=*) service_startup_timeout=`echo "$arg" | sed -e 's/^[^=]*=//'` ;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
wait_for_pid () {
|
||||
verb="$1" # created | removed
|
||||
pid="$2" # process ID of the program operating on the pid-file
|
||||
pid_file_path="$3" # path to the PID file.
|
||||
|
||||
i=0
|
||||
avoid_race_condition="by checking again"
|
||||
|
||||
while test $i -ne $service_startup_timeout ; do
|
||||
|
||||
case "$verb" in
|
||||
'created')
|
||||
# wait for a PID-file to pop into existence.
|
||||
test -s "$pid_file_path" && i='' && break
|
||||
;;
|
||||
'removed')
|
||||
# wait for this PID-file to disappear
|
||||
test ! -s "$pid_file_path" && i='' && break
|
||||
;;
|
||||
*)
|
||||
echo "wait_for_pid () usage: wait_for_pid created|removed pid pid_file_path"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
# if server isn't running, then pid-file will never be updated
|
||||
if test -n "$pid"; then
|
||||
if kill -0 "$pid" 2>/dev/null; then
|
||||
: # the server still runs
|
||||
else
|
||||
# The server may have exited between the last pid-file check and now.
|
||||
if test -n "$avoid_race_condition"; then
|
||||
avoid_race_condition=""
|
||||
continue # Check again.
|
||||
fi
|
||||
|
||||
# there's nothing that will affect the file.
|
||||
log_failure_msg "The server quit without updating PID file ($pid_file_path)."
|
||||
return 1 # not waiting any more.
|
||||
fi
|
||||
fi
|
||||
|
||||
echo $echo_n ".$echo_c"
|
||||
i=`expr $i + 1`
|
||||
sleep 1
|
||||
|
||||
done
|
||||
|
||||
if test -z "$i" ; then
|
||||
log_success_msg
|
||||
return 0
|
||||
else
|
||||
log_failure_msg
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Get arguments from the my.cnf file,
|
||||
# the only group, which is read from now on is [mysqld]
|
||||
if test -x "$bindir/my_print_defaults"; then
|
||||
print_defaults="$bindir/my_print_defaults"
|
||||
else
|
||||
# Try to find basedir in /etc/my.cnf
|
||||
conf=/etc/my.cnf
|
||||
print_defaults=
|
||||
if test -r $conf
|
||||
then
|
||||
subpat='^[^=]*basedir[^=]*=\(.*\)$'
|
||||
dirs=`sed -e "/$subpat/!d" -e 's//\1/' $conf`
|
||||
for d in $dirs
|
||||
do
|
||||
d=`echo $d | sed -e 's/[ ]//g'`
|
||||
if test -x "$d/bin/my_print_defaults"
|
||||
then
|
||||
print_defaults="$d/bin/my_print_defaults"
|
||||
break
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
# Hope it's in the PATH ... but I doubt it
|
||||
test -z "$print_defaults" && print_defaults="my_print_defaults"
|
||||
fi
|
||||
|
||||
#
|
||||
# Read defaults file from 'basedir'. If there is no defaults file there
|
||||
# check if it's in the old (depricated) place (datadir) and read it from there
|
||||
#
|
||||
|
||||
extra_args=""
|
||||
if test -r "$basedir/my.cnf"
|
||||
then
|
||||
extra_args="-e $basedir/my.cnf"
|
||||
fi
|
||||
|
||||
parse_server_arguments `$print_defaults $extra_args mysqld server mysql_server mysql.server`
|
||||
|
||||
#
|
||||
# Set pid file if not given
|
||||
#
|
||||
if test -z "$mysqld_pid_file_path"
|
||||
then
|
||||
mysqld_pid_file_path=$datadir/`hostname`.pid
|
||||
else
|
||||
case "$mysqld_pid_file_path" in
|
||||
/* ) ;;
|
||||
* ) mysqld_pid_file_path="$datadir/$mysqld_pid_file_path" ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
case "$mode" in
|
||||
'start')
|
||||
# Start daemon
|
||||
|
||||
# Safeguard (relative paths, core dumps..)
|
||||
cd $basedir
|
||||
|
||||
echo $echo_n "Starting MySQL"
|
||||
if test -x $bindir/mysqld_safe
|
||||
then
|
||||
# Give extra arguments to mysqld with the my.cnf file. This script
|
||||
# may be overwritten at next upgrade.
|
||||
$bindir/mysqld_safe --datadir="$datadir" --pid-file="$mysqld_pid_file_path" $other_args >/dev/null &
|
||||
wait_for_pid created "$!" "$mysqld_pid_file_path"; return_value=$?
|
||||
|
||||
# Make lock for RedHat / SuSE
|
||||
if test -w "$lockdir"
|
||||
then
|
||||
touch "$lock_file_path"
|
||||
fi
|
||||
|
||||
exit $return_value
|
||||
else
|
||||
log_failure_msg "Couldn't find MySQL server ($bindir/mysqld_safe)"
|
||||
fi
|
||||
;;
|
||||
|
||||
'stop')
|
||||
# Stop daemon. We use a signal here to avoid having to know the
|
||||
# root password.
|
||||
|
||||
if test -s "$mysqld_pid_file_path"
|
||||
then
|
||||
# signal mysqld_safe that it needs to stop
|
||||
touch "$mysqld_pid_file_path.shutdown"
|
||||
|
||||
mysqld_pid=`cat "$mysqld_pid_file_path"`
|
||||
|
||||
if (kill -0 $mysqld_pid 2>/dev/null)
|
||||
then
|
||||
echo $echo_n "Shutting down MySQL"
|
||||
kill $mysqld_pid
|
||||
# mysqld should remove the pid file when it exits, so wait for it.
|
||||
wait_for_pid removed "$mysqld_pid" "$mysqld_pid_file_path"; return_value=$?
|
||||
else
|
||||
log_failure_msg "MySQL server process #$mysqld_pid is not running!"
|
||||
rm "$mysqld_pid_file_path"
|
||||
fi
|
||||
|
||||
# Delete lock for RedHat / SuSE
|
||||
if test -f "$lock_file_path"
|
||||
then
|
||||
rm -f "$lock_file_path"
|
||||
fi
|
||||
exit $return_value
|
||||
else
|
||||
log_failure_msg "MySQL server PID file could not be found!"
|
||||
fi
|
||||
;;
|
||||
|
||||
'restart')
|
||||
# Stop the service and regardless of whether it was
|
||||
# running or not, start it again.
|
||||
if $0 stop $other_args; then
|
||||
$0 start $other_args
|
||||
else
|
||||
log_failure_msg "Failed to stop running server, so refusing to try to start."
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
|
||||
'reload'|'force-reload')
|
||||
if test -s "$mysqld_pid_file_path" ; then
|
||||
read mysqld_pid < "$mysqld_pid_file_path"
|
||||
kill -HUP $mysqld_pid && log_success_msg "Reloading service MySQL"
|
||||
touch "$mysqld_pid_file_path"
|
||||
else
|
||||
log_failure_msg "MySQL PID file could not be found!"
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
'status')
|
||||
# First, check to see if pid file exists
|
||||
if test -s "$mysqld_pid_file_path" ; then
|
||||
read mysqld_pid < "$mysqld_pid_file_path"
|
||||
if kill -0 $mysqld_pid 2>/dev/null ; then
|
||||
log_success_msg "MySQL running ($mysqld_pid)"
|
||||
exit 0
|
||||
else
|
||||
log_failure_msg "MySQL is not running, but PID file exists"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
# Try to find appropriate mysqld process
|
||||
mysqld_pid=`pgrep -d' ' -f $libexecdir/mysqld`
|
||||
|
||||
# test if multiple pids exist
|
||||
pid_count=`echo $mysqld_pid | wc -w`
|
||||
if test $pid_count -gt 1 ; then
|
||||
log_failure_msg "Multiple MySQL running but PID file could not be found ($mysqld_pid)"
|
||||
exit 5
|
||||
elif test -z $mysqld_pid ; then
|
||||
if test -f "$lock_file_path" ; then
|
||||
log_failure_msg "MySQL is not running, but lock file ($lock_file_path) exists"
|
||||
exit 2
|
||||
fi
|
||||
log_failure_msg "MySQL is not running"
|
||||
exit 3
|
||||
else
|
||||
log_failure_msg "MySQL is running but PID file could not be found"
|
||||
exit 4
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
# usage
|
||||
basename=`basename "$0"`
|
||||
echo "Usage: $basename {start|stop|restart|reload|force-reload|status} [ MySQL server options ]"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
exit 0
|
||||
+624
-3
@@ -36,6 +36,26 @@ function myPost(method,args,callback, title){
|
||||
},'json');
|
||||
}
|
||||
|
||||
function myPostN(method,args,callback, title){
|
||||
|
||||
var _args = null;
|
||||
if (typeof(args) == 'string'){
|
||||
_args = JSON.stringify(str2Obj(args));
|
||||
} else {
|
||||
_args = JSON.stringify(args);
|
||||
}
|
||||
|
||||
var _title = '正在获取...';
|
||||
if (typeof(title) != 'undefined'){
|
||||
_title = title;
|
||||
}
|
||||
$.post('/plugins/run', {name:'mysql', func:method, args:_args}, function(data) {
|
||||
if(typeof(callback) == 'function'){
|
||||
callback(data);
|
||||
}
|
||||
},'json');
|
||||
}
|
||||
|
||||
function myAsyncPost(method,args){
|
||||
var _args = null;
|
||||
if (typeof(args) == 'string'){
|
||||
@@ -822,6 +842,86 @@ function openPhpmyadmin(name,username,password){
|
||||
},200);
|
||||
}
|
||||
|
||||
function delBackup(filename,name){
|
||||
myPost('delete_db_backup',{filename:filename},function(){
|
||||
layer.msg('执行成功!');
|
||||
setTimeout(function(){
|
||||
$('.layui-layer-close2').click();
|
||||
setBackup(name);
|
||||
},2000);
|
||||
});
|
||||
}
|
||||
|
||||
function downloadBackup(file){
|
||||
window.open('/files/download?filename='+encodeURIComponent(file));
|
||||
}
|
||||
|
||||
function importBackup(file,name){
|
||||
myPost('import_db_backup',{file:file,name:name}, function(data){
|
||||
// console.log(data);
|
||||
layer.msg('执行成功!');
|
||||
});
|
||||
}
|
||||
|
||||
function setBackup(db_name,obj){
|
||||
myPost('get_db_backup_list', {name:db_name}, function(data){
|
||||
|
||||
var rdata = $.parseJSON(data.data);
|
||||
var tbody = '';
|
||||
for (var i = 0; i < rdata.data.length; i++) {
|
||||
tbody += '<tr>\
|
||||
<td><span> ' + rdata.data[i]['name'] + '</span></td>\
|
||||
<td><span> ' + rdata.data[i]['size'] + '</span></td>\
|
||||
<td><span> ' + rdata.data[i]['time'] + '</span></td>\
|
||||
<td style="text-align: right;">\
|
||||
<a class="btlink" onclick="importBackup(\'' + rdata.data[i]['name'] + '\',\'' +db_name+ '\')">导入</a> | \
|
||||
<a class="btlink" onclick="downloadBackup(\'' + rdata.data[i]['file'] + '\')">下载</a> | \
|
||||
<a class="btlink" onclick="delBackup(\'' + rdata.data[i]['name'] + '\',\'' +db_name+ '\')">删除</a>\
|
||||
</td>\
|
||||
</tr> ';
|
||||
}
|
||||
|
||||
var s = layer.open({
|
||||
type: 1,
|
||||
title: "数据库备份详情",
|
||||
area: ['600px', '280px'],
|
||||
closeBtn: 2,
|
||||
shadeClose: false,
|
||||
content: '<div class="pd15">\
|
||||
<div class="db_list">\
|
||||
<button id="btn_backup" class="btn btn-success btn-sm" type="button">备份</button>\
|
||||
</div >\
|
||||
<div class="divtable">\
|
||||
<div id="database_fix" style="height:150px;overflow:auto;border:#ddd 1px solid">\
|
||||
<table class="table table-hover "style="border:none">\
|
||||
<thead>\
|
||||
<tr>\
|
||||
<th>文件名称</th>\
|
||||
<th>文件大小</th>\
|
||||
<th>备份时间</th>\
|
||||
<th style="text-align: right;">操作</th>\
|
||||
</tr>\
|
||||
</thead>\
|
||||
<tbody class="gztr">' + tbody + '</tbody>\
|
||||
</table>\
|
||||
</div>\
|
||||
</div>\
|
||||
</div>'
|
||||
});
|
||||
|
||||
$('#btn_backup').click(function(){
|
||||
myPost('set_db_backup',{name:db_name}, function(data){
|
||||
layer.msg('执行成功!');
|
||||
|
||||
setTimeout(function(){
|
||||
layer.close(s);
|
||||
setBackup(db_name,obj);
|
||||
},2000);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function dbList(page, search){
|
||||
var _data = {};
|
||||
@@ -847,10 +947,14 @@ function dbList(page, search){
|
||||
'<span onclick="showHidePass(this)" class="glyphicon glyphicon-eye-open cursor pw-ico" style="margin-left:10px"></span>'+
|
||||
'<span class="ico-copy cursor btcopy" style="margin-left:10px" title="复制密码" onclick="copyPass(\''+rdata.data[i]['password']+'\')"></span>'+
|
||||
'</td>';
|
||||
// list += '<td>备份</td>';
|
||||
|
||||
|
||||
list += '<td><span class="c9 input-edit" onclick="setDbPs(\''+rdata.data[i]['id']+'\',\''+rdata.data[i]['name']+'\',this)" style="display: inline-block;">'+rdata.data[i]['ps']+'</span></td>';
|
||||
list += '<td style="text-align:right">' +
|
||||
'<a href="javascript:;" class="btlink" onclick="openPhpmyadmin(\''+rdata.data[i]['name']+'\',\''+rdata.data[i]['username']+'\',\''+rdata.data[i]['password']+'\')" title="数据库管理">管理</a> | ' +
|
||||
list += '<td style="text-align:right">';
|
||||
|
||||
list += '<a href="javascript:;" class="btlink" class="btlink" onclick="setBackup(\''+rdata.data[i]['name']+'\',this)" title="数据库备份">'+(rdata.data[i]['is_backup']?'备份':'未备份') +'</a> | ';
|
||||
|
||||
list += '<a href="javascript:;" class="btlink" onclick="openPhpmyadmin(\''+rdata.data[i]['name']+'\',\''+rdata.data[i]['username']+'\',\''+rdata.data[i]['password']+'\')" title="数据库管理">管理</a> | ' +
|
||||
'<a href="javascript:;" class="btlink" onclick="repTools(\''+rdata.data[i]['name']+'\')" title="MySQL优化修复工具">工具</a> | ' +
|
||||
'<a href="javascript:;" class="btlink" onclick="setDbAccess(\''+rdata.data[i]['username']+'\')" title="设置数据库权限">权限</a> | ' +
|
||||
'<a href="javascript:;" class="btlink" onclick="setDbPass('+rdata.data[i]['id']+',\''+ rdata.data[i]['username'] +'\',\'' + rdata.data[i]['password'] + '\')">改密</a> | ' +
|
||||
@@ -864,6 +968,7 @@ function dbList(page, search){
|
||||
<button onclick="addDatabase()" title="添加数据库" class="btn btn-success btn-sm" type="button" style="margin-right: 5px;">添加数据库</button>\
|
||||
<button onclick="setRootPwd(0,\''+rdata.info['root_pwd']+'\')" title="设置MySQL管理员密码" class="btn btn-default btn-sm" type="button" style="margin-right: 5px;">root密码</button>\
|
||||
<button onclick="openPhpmyadmin(\'\',\'root\',\''+rdata.info['root_pwd']+'\')" title="打开phpMyadmin" class="btn btn-default btn-sm" type="button" style="margin-right: 5px;">phpMyAdmin</button>\
|
||||
<button onclick="setDbAccess(\'root\')" title="ROOT权限" class="btn btn-default btn-sm" type="button" style="margin-right: 5px;">ROOT权限</button>\
|
||||
<span style="float:right"> \
|
||||
<button batch="true" style="float: right;display: none;margin-left:10px;" onclick="delDbBatch();" title="删除选中项" class="btn btn-default btn-sm">删除选中</button>\
|
||||
</span>\
|
||||
@@ -1099,3 +1204,519 @@ function repTools(db_name, res){
|
||||
tableFixed('database_fix');
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function setDbMaster(name){
|
||||
myPost('set_db_master', {name:name}, function(data){
|
||||
var rdata = $.parseJSON(data.data);
|
||||
layer.msg(rdata.msg, { icon: rdata.status ? 1 : 5 });
|
||||
setTimeout(function(){
|
||||
masterOrSlaveConf();
|
||||
}, 2000);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function setDbSlave(name){
|
||||
myPost('set_db_slave', {name:name}, function(data){
|
||||
var rdata = $.parseJSON(data.data);
|
||||
layer.msg(rdata.msg, { icon: rdata.status ? 1 : 5 });
|
||||
setTimeout(function(){
|
||||
masterOrSlaveConf();
|
||||
}, 2000);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function addMasterRepSlaveUser(){
|
||||
|
||||
|
||||
var index = layer.open({
|
||||
type: 1,
|
||||
skin: 'demo-class',
|
||||
area: '500px',
|
||||
title: '添加同步账户',
|
||||
closeBtn: 1,
|
||||
shift: 5,
|
||||
shadeClose: true,
|
||||
content: "<form class='bt-form pd20 pb70' id='add_master'>\
|
||||
<div class='line'><span class='tname'>用户名</span><div class='info-r'><input name='username' class='bt-input-text mr5' placeholder='用户名' type='text' style='width:330px;' value='"+(randomStrPwd(6))+"'></div></div>\
|
||||
<div class='line'>\
|
||||
<span class='tname'>密码</span>\
|
||||
<div class='info-r'><input class='bt-input-text mr5' type='text' name='password' id='MyPassword' style='width:330px' value='"+(randomStrPwd(16))+"' /><span title='随机密码' class='glyphicon glyphicon-repeat cursor' onclick='repeatPwd(16)'></span></div>\
|
||||
</div>\
|
||||
<input type='hidden' name='ps' value='' />\
|
||||
<div class='bt-form-submit-btn'>\
|
||||
<button id='my_mod_close' type='button' class='btn btn-danger btn-sm btn-title'>关闭</button>\
|
||||
<button type='button' class='btn btn-success btn-sm btn-title' id='submit_add_master' >提交</button>\
|
||||
</div>\
|
||||
</form>",
|
||||
});
|
||||
|
||||
// <div class='line'>\
|
||||
// <span class='tname'>访问权限</span>\
|
||||
// <div class='info-r '>\
|
||||
// <select class='bt-input-text mr5' name='dataAccess' style='width:100px'>\
|
||||
// <option value='127.0.0.1'>本地服务器</option>\
|
||||
// <option value=\"%\">所有人</option>\
|
||||
// <option value='ip'>指定IP</option>\
|
||||
// </select>\
|
||||
// </div>\
|
||||
// </div>\
|
||||
|
||||
$("input[name='name']").keyup(function(){
|
||||
var v = $(this).val();
|
||||
$("input[name='db_user']").val(v);
|
||||
$("input[name='ps']").val(v);
|
||||
});
|
||||
|
||||
$('#my_mod_close').click(function(){
|
||||
$('.layui-layer-close1').click();
|
||||
});
|
||||
$('select[name="dataAccess"]').change(function(){
|
||||
var v = $(this).val();
|
||||
if (v == 'ip'){
|
||||
$(this).after("<input id='dataAccess_subid' class='bt-input-text mr5' type='text' name='address' placeholder='多个IP使用逗号(,)分隔' style='width: 230px; display: inline-block;'>");
|
||||
} else {
|
||||
$('#dataAccess_subid').remove();
|
||||
}
|
||||
});
|
||||
|
||||
$('#submit_add_master').click(function(){
|
||||
|
||||
var data = $("#add_master").serialize();
|
||||
data = decodeURIComponent(data);
|
||||
var dataObj = str2Obj(data);
|
||||
if(!dataObj['address']){
|
||||
dataObj['address'] = dataObj['dataAccess'];
|
||||
}
|
||||
// console.log(dataObj);
|
||||
myPost('add_master_rep_slave_user', dataObj, function(data){
|
||||
var rdata = $.parseJSON(data.data);
|
||||
showMsg(rdata.msg,function(){
|
||||
if (rdata.status){
|
||||
getMasterRepSlaveList();
|
||||
}
|
||||
$('.layui-layer-close1').click();
|
||||
},{icon: rdata.status ? 1 : 2},600);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
function updateMasterRepSlaveUser(username){
|
||||
|
||||
|
||||
var index = layer.open({
|
||||
type: 1,
|
||||
skin: 'demo-class',
|
||||
area: '500px',
|
||||
title: '更新账户',
|
||||
closeBtn: 1,
|
||||
shift: 5,
|
||||
shadeClose: true,
|
||||
content: "<form class='bt-form pd20 pb70' id='update_master'>\
|
||||
<div class='line'><span class='tname'>用户名</span><div class='info-r'><input name='username' readonly='readonly' class='bt-input-text mr5' placeholder='用户名' type='text' style='width:330px;' value='"+username+"'></div></div>\
|
||||
<div class='line'>\
|
||||
<span class='tname'>密码</span>\
|
||||
<div class='info-r'><input class='bt-input-text mr5' type='text' name='password' id='MyPassword' style='width:330px' value='"+(randomStrPwd(16))+"' /><span title='随机密码' class='glyphicon glyphicon-repeat cursor' onclick='repeatPwd(16)'></span></div>\
|
||||
</div>\
|
||||
<input type='hidden' name='ps' value='' />\
|
||||
<div class='bt-form-submit-btn'>\
|
||||
<button type='button' class='btn btn-success btn-sm btn-title' id='submit_update_master' >提交</button>\
|
||||
</div>\
|
||||
</form>",
|
||||
});
|
||||
|
||||
$('#submit_update_master').click(function(){
|
||||
var data = $("#update_master").serialize();
|
||||
data = decodeURIComponent(data);
|
||||
var dataObj = str2Obj(data);
|
||||
// console.log(dataObj);
|
||||
myPost('update_master_rep_slave_user', data, function(data){
|
||||
var rdata = $.parseJSON(data.data);
|
||||
showMsg(rdata.msg,function(){
|
||||
if (rdata.status){
|
||||
getMasterRepSlaveList();
|
||||
}
|
||||
$('.layui-layer-close1').click();
|
||||
},{icon: rdata.status ? 1 : 2},600);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function getMasterRepSlaveUserCmd(username, db=''){
|
||||
myPost('get_master_rep_slave_user_cmd', {username:username,db:db}, function(data){
|
||||
var rdata = $.parseJSON(data.data);
|
||||
|
||||
if (!rdata['status']){
|
||||
layer.msg(rdata['msg']);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
var loadOpen = layer.open({
|
||||
type: 1,
|
||||
title: '同步命令',
|
||||
area: '500px',
|
||||
content:"<form class='bt-form pd20 pb70' id='add_master'>\
|
||||
<div class='line'>"+rdata.data+"</div>\
|
||||
<div class='bt-form-submit-btn'>\
|
||||
<button type='button' class='btn btn-success btn-sm btn-title class-copy-cmd'>复制</button>\
|
||||
</div>\
|
||||
</form>",
|
||||
});
|
||||
|
||||
copyPass(rdata.data);
|
||||
$('.class-copy-cmd').click(function(){
|
||||
copyPass(rdata.data);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function delMasterRepSlaveUser(username){
|
||||
myPost('del_master_rep_slave_user', {username:username}, function(data){
|
||||
var rdata = $.parseJSON(data.data);
|
||||
layer.msg(rdata.msg);
|
||||
|
||||
$('.layui-layer-close1').click();
|
||||
|
||||
setTimeout(function(){
|
||||
getMasterRepSlaveList();
|
||||
},1000);
|
||||
});
|
||||
}
|
||||
|
||||
function getMasterRepSlaveList(){
|
||||
var _data = {};
|
||||
if (typeof(page) =='undefined'){
|
||||
var page = 1;
|
||||
}
|
||||
|
||||
_data['page'] = page;
|
||||
_data['page_size'] = 10;
|
||||
myPost('get_master_rep_slave_list', _data, function(data){
|
||||
// console.log(data);
|
||||
var rdata = [];
|
||||
try {
|
||||
rdata = $.parseJSON(data.data);
|
||||
} catch(e){
|
||||
console.log(e);
|
||||
}
|
||||
var list = '';
|
||||
// console.log(rdata['data']);
|
||||
var user_list = rdata['data'];
|
||||
for (i in user_list) {
|
||||
// console.log(i);
|
||||
var name = user_list[i]['username'];
|
||||
list += '<tr><td>'+name+'</td>\
|
||||
<td>'+user_list[i]['password']+'</td>\
|
||||
<td>\
|
||||
<a class="btlink" onclick="updateMasterRepSlaveUser(\''+name+'\');">修改</a> | \
|
||||
<a class="btlink" onclick="delMasterRepSlaveUser(\''+name+'\');">删除</a> | \
|
||||
<a class="btlink" onclick="getMasterRepSlaveUserCmd(\''+name+'\');">从库同步命令</a>\
|
||||
</td>\
|
||||
</tr>';
|
||||
}
|
||||
|
||||
var page = '<div class="dataTables_paginate_4 dataTables_paginate paging_bootstrap page" style="margin-top:0px;"></div>';
|
||||
page += '<div class="table_toolbar"><span class="sync btn btn-default btn-sm" onclick="addMasterRepSlaveUser()" title="">添加同步账户</span></div>';
|
||||
|
||||
var loadOpen = layer.open({
|
||||
type: 1,
|
||||
title: '同步账户列表',
|
||||
area: '500px',
|
||||
content:"<div class='bt-form pd20 c6'>\
|
||||
<div class='divtable mtb10'>\
|
||||
<div><table class='table table-hover'>\
|
||||
<thead><tr><th>用户民</th><th>密码</th><th>操作</th></tr></thead>\
|
||||
<tbody>" + list + "</tbody>\
|
||||
</table></div>\
|
||||
"+page +"\
|
||||
</div>\
|
||||
</div>"
|
||||
});
|
||||
|
||||
$('.dataTables_paginate_4').html(rdata['page']);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function deleteSlave(){
|
||||
myPost('delete_slave', {}, function(data){
|
||||
var rdata = $.parseJSON(data.data);
|
||||
layer.msg(rdata['msg']);
|
||||
setTimeout(function(){
|
||||
masterOrSlaveConf();
|
||||
}, 3000);
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function getFullSyncStatus(db){
|
||||
|
||||
var btn = '<div class="table_toolbar"><span class="sync btn btn-default btn-sm" id="begin_full_sync" title="">开始</span></div>';
|
||||
var loadOpen = layer.open({
|
||||
type: 1,
|
||||
title: '全量同步['+db+']',
|
||||
area: '500px',
|
||||
content:"<div class='bt-form pd20 c6'>\
|
||||
<div class='divtable mtb10'>\
|
||||
<span id='full_msg'></span>\
|
||||
<div class='progress'>\
|
||||
<div class='progress-bar' role='progressbar' aria-valuenow='0' aria-valuemin='0' aria-valuemax='100' style='min-width: 2em;'>0%</div>\
|
||||
</div>\
|
||||
</div>\
|
||||
"+btn+"\
|
||||
</div>"
|
||||
});
|
||||
|
||||
var timeId = setInterval(function(){
|
||||
fullSync(db,0);
|
||||
}, 1000);
|
||||
|
||||
function fullSync(db,begin){
|
||||
|
||||
myPostN('full_sync', {db:db,begin:begin}, function(data){
|
||||
var rdata = $.parseJSON(data.data);
|
||||
$('#full_msg').text(rdata['msg']);
|
||||
$('.progress-bar').css('width',rdata['progress']+'%');
|
||||
$('.progress-bar').text(rdata['progress']+'%');
|
||||
|
||||
if (rdata['code']==6 ||rdata['code']<0){
|
||||
layer.msg(rdata['msg']);
|
||||
clearInterval(timeId);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
fullSync(db,0);
|
||||
$('#begin_full_sync').click(function(){
|
||||
fullSync(db,1);
|
||||
|
||||
timeId= setTimeout(function(){
|
||||
fullSync(db,0);
|
||||
}, 1000);
|
||||
});
|
||||
|
||||
$('.layui-layer-close1').click(function(){
|
||||
clearInterval(timeId);
|
||||
});
|
||||
}
|
||||
|
||||
function handlerRun(){
|
||||
cmd = 'cd /www/server/mdserver-web && python /www/server/mdserver-web/plugins/mysql/index.py do_full_sync {"db":"all"}';
|
||||
var loadOpen = layer.open({
|
||||
type: 1,
|
||||
title: '手动执行',
|
||||
area: '500px',
|
||||
content:"<form class='bt-form pd20 pb70' id='add_master'>\
|
||||
<div class='line'>"+cmd+"</div>\
|
||||
<div class='bt-form-submit-btn'>\
|
||||
<button type='button' class='btn btn-success btn-sm btn-title class-copy-cmd'>复制</button>\
|
||||
</div>\
|
||||
</form>",
|
||||
});
|
||||
copyPass(cmd);
|
||||
$('.class-copy-cmd').click(function(){
|
||||
copyPass(cmd);
|
||||
});
|
||||
}
|
||||
|
||||
function masterOrSlaveConf(version=''){
|
||||
|
||||
function getMasterDbList(){
|
||||
var _data = {};
|
||||
if (typeof(page) =='undefined'){
|
||||
var page = 1;
|
||||
}
|
||||
|
||||
_data['page'] = page;
|
||||
_data['page_size'] = 10;
|
||||
|
||||
myPost('get_masterdb_list', _data, function(data){
|
||||
var rdata = $.parseJSON(data.data);
|
||||
var list = '';
|
||||
for(i in rdata.data){
|
||||
list += '<tr>';
|
||||
list += '<td>' + rdata.data[i]['name'] +'</td>';
|
||||
list += '<td>' + (rdata.data[i]['master']?'是':'否') +'</td>';
|
||||
list += '<td style="text-align:right">' +
|
||||
'<a href="javascript:;" class="btlink" onclick="setDbMaster(\''+rdata.data[i]['name']+'\')" title="加入或退出">'+(rdata.data[i]['master']?'退出':'加入')+'</a> | ' +
|
||||
'<a href="javascript:;" class="btlink" onclick="getMasterRepSlaveUserCmd(\'\',\''+rdata.data[i]['name']+'\')" title="同步命令">同步命令</a>' +
|
||||
'</td>';
|
||||
list += '</tr>';
|
||||
}
|
||||
|
||||
var con = '<div class="divtable mtb10">\
|
||||
<div class="tablescroll">\
|
||||
<table id="DataBody" class="table table-hover" width="100%" cellspacing="0" cellpadding="0" border="0" style="border: 0 none;">\
|
||||
<thead><tr>\
|
||||
<th>数据库名</th>\
|
||||
<th>同步</th>\
|
||||
<th style="text-align:right;">操作</th></tr></thead>\
|
||||
<tbody>\
|
||||
'+ list +'\
|
||||
</tbody></table>\
|
||||
</div>\
|
||||
<div id="databasePage" class="dataTables_paginate paging_bootstrap page"></div>\
|
||||
<div class="table_toolbar">\
|
||||
<span class="sync btn btn-default btn-sm" onclick="getMasterRepSlaveList()" title="">同步账户列表</span>\
|
||||
</div>\
|
||||
</div>';
|
||||
|
||||
$(".table_master_list").html(con);
|
||||
$('#databasePage').html(rdata.page);
|
||||
});
|
||||
}
|
||||
|
||||
function getAsyncMasterDbList(){
|
||||
var _data = {};
|
||||
if (typeof(page) =='undefined'){
|
||||
var page = 1;
|
||||
}
|
||||
|
||||
_data['page'] = page;
|
||||
_data['page_size'] = 10;
|
||||
|
||||
myPost('get_slave_list', _data, function(data){
|
||||
var rdata = $.parseJSON(data.data);
|
||||
var list = '';
|
||||
for(i in rdata.data){
|
||||
list += '<tr>';
|
||||
list += '<td>' + rdata.data[i]['Master_Host'] +'</td>';
|
||||
list += '<td>' + rdata.data[i]['Master_Port'] +'</td>';
|
||||
list += '<td>' + rdata.data[i]['Master_User'] +'</td>';
|
||||
list += '<td>' + rdata.data[i]['Master_Log_File'] +'</td>';
|
||||
list += '<td>' + rdata.data[i]['Slave_IO_Running'] +'</td>';
|
||||
list += '<td>' + rdata.data[i]['Slave_SQL_Running'] +'</td>';
|
||||
list += '<td style="text-align:right">' +
|
||||
'<a href="javascript:;" class="btlink" onclick="deleteSlave()" title="删除">删除</a>' +
|
||||
'</td>';
|
||||
list += '</tr>';
|
||||
}
|
||||
|
||||
var con = '<div class="divtable mtb10">\
|
||||
<div class="tablescroll">\
|
||||
<table id="DataBody" class="table table-hover" width="100%" cellspacing="0" cellpadding="0" border="0" style="border: 0 none;">\
|
||||
<thead><tr>\
|
||||
<th>主[服务]</th>\
|
||||
<th>端口</th>\
|
||||
<th>用户</th>\
|
||||
<th>日志</th>\
|
||||
<th>IO</th>\
|
||||
<th>SQL</th>\
|
||||
<th style="text-align:right;">操作</th></tr></thead>\
|
||||
<tbody>\
|
||||
'+ list +'\
|
||||
</tbody></table>\
|
||||
</div>\
|
||||
</div>';
|
||||
|
||||
// <div id="databasePage_slave" class="dataTables_paginate paging_bootstrap page"></div>\
|
||||
// <div class="table_toolbar">\
|
||||
// <span class="sync btn btn-default btn-sm" onclick="getMasterRepSlaveList()" title="">添加</span>\
|
||||
// </div>
|
||||
$(".table_slave_status_list").html(con);
|
||||
});
|
||||
}
|
||||
|
||||
function getAsyncDataList(){
|
||||
var _data = {};
|
||||
if (typeof(page) =='undefined'){
|
||||
var page = 1;
|
||||
}
|
||||
|
||||
_data['page'] = page;
|
||||
_data['page_size'] = 10;
|
||||
myPost('get_masterdb_list', _data, function(data){
|
||||
var rdata = $.parseJSON(data.data);
|
||||
var list = '';
|
||||
for(i in rdata.data){
|
||||
list += '<tr>';
|
||||
list += '<td>' + rdata.data[i]['name'] +'</td>';
|
||||
list += '<td style="text-align:right">' +
|
||||
'<a href="javascript:;" class="btlink" onclick="setDbSlave(\''+rdata.data[i]['name']+'\')" title="加入|退出">'+(rdata.data[i]['slave']?'退出':'加入')+'</a> | ' +
|
||||
'<a href="javascript:;" class="btlink" onclick="getFullSyncStatus(\''+rdata.data[i]['name']+'\')" title="修复">修复</a>' +
|
||||
'</td>';
|
||||
list += '</tr>';
|
||||
}
|
||||
|
||||
var con = '<div class="divtable mtb10">\
|
||||
<div class="tablescroll">\
|
||||
<table id="DataBody" class="table table-hover" width="100%" cellspacing="0" cellpadding="0" border="0" style="border: 0 none;">\
|
||||
<thead><tr>\
|
||||
<th>本地库名</th>\
|
||||
<th style="text-align:right;">操作</th></tr></thead>\
|
||||
<tbody>\
|
||||
'+ list +'\
|
||||
</tbody></table>\
|
||||
</div>\
|
||||
<div id="databasePage" class="dataTables_paginate paging_bootstrap page"></div>\
|
||||
<div class="table_toolbar">\
|
||||
<span class="sync btn btn-default btn-sm" onclick="handlerRun()" title="免登录设置后,需要手动执行一下!">手动命令</span>\
|
||||
<span class="sync btn btn-default btn-sm" onclick="getFullSyncStatus(\'ALL\')" title="全量同步">全量同步</span>\
|
||||
</div>\
|
||||
</div>';
|
||||
|
||||
$(".table_slave_list").html(con);
|
||||
$('#databasePage').html(rdata.page);
|
||||
});
|
||||
}
|
||||
|
||||
function getMasterStatus(){
|
||||
myPost('get_master_status', '', function(data){
|
||||
var rdata = $.parseJSON(data.data);
|
||||
var limitCon = '<p class="conf_p">\
|
||||
<span class="f14 c6 mr20">Master[主]配置</span><span class="f14 c6 mr20"></span>\
|
||||
<button class="btn '+(!rdata.status ? 'btn-danger' : 'btn-success')+' btn-xs btn-master va0">'+(!rdata.status ? '未开启' : '已开启') +'</button><hr/>\
|
||||
</p>\
|
||||
<!-- master list -->\
|
||||
<div class="safe bgw table_master_list"></div>\
|
||||
<hr/>\
|
||||
<p class="conf_p">\
|
||||
<span class="f14 c6 mr20">Slave[从]配置</span><span class="f14 c6 mr20"></span>\
|
||||
<button class="btn '+(!rdata.data.slave_status ? 'btn-danger' : 'btn-success')+' btn-xs btn-slave va0">'+(!rdata.data.slave_status ? '未启动' : '已启动') +'</button><hr/>\
|
||||
</p>\
|
||||
<!-- slave status list -->\
|
||||
<div class="safe bgw table_slave_status_list"></div>\
|
||||
<!-- slave list -->\
|
||||
<div class="safe bgw table_slave_list"></div>\
|
||||
';
|
||||
$(".soft-man-con").html(limitCon);
|
||||
|
||||
//设置主服务器配置
|
||||
$(".btn-master").click(function () {
|
||||
myPost('set_master_status', 'close=change', function(data){
|
||||
var rdata = $.parseJSON(data.data);
|
||||
layer.msg(rdata.msg, { icon: rdata.status ? 1 : 5 });
|
||||
setTimeout(function(){
|
||||
getMasterStatus();
|
||||
}, 3000);
|
||||
});
|
||||
});
|
||||
|
||||
$(".btn-slave").click(function () {
|
||||
myPost('set_slave_status', 'close=change', function(data){
|
||||
var rdata = $.parseJSON(data.data);
|
||||
layer.msg(rdata.msg, { icon: rdata.status ? 1 : 5 });
|
||||
setTimeout(function(){
|
||||
getMasterStatus();
|
||||
}, 3000);
|
||||
});
|
||||
});
|
||||
|
||||
if (rdata.status){
|
||||
getMasterDbList();
|
||||
}
|
||||
|
||||
if (rdata.data.slave_status){
|
||||
getAsyncMasterDbList();
|
||||
getAsyncDataList()
|
||||
}
|
||||
});
|
||||
}
|
||||
getMasterStatus();
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ curPath=`pwd`
|
||||
rootPath=$(dirname "$curPath")
|
||||
rootPath=$(dirname "$rootPath")
|
||||
serverPath=$(dirname "$rootPath")
|
||||
|
||||
sysName=`uname`
|
||||
|
||||
install_tmp=${rootPath}/tmp/mw_install.pl
|
||||
mysqlDir=${serverPath}/source/mysql
|
||||
@@ -19,37 +19,40 @@ Install_mysql()
|
||||
mkdir -p ${mysqlDir}
|
||||
echo '正在安装脚本文件...' > $install_tmp
|
||||
|
||||
mkdir -p /var/log/mariadb
|
||||
touch /var/log/mariadb/mariadb.log
|
||||
|
||||
groupadd mysql
|
||||
useradd -g mysql mysql
|
||||
if [ "$sysName" != "Darwin" ];then
|
||||
mkdir -p /var/log/mariadb
|
||||
touch /var/log/mariadb/mariadb.log
|
||||
groupadd mysql
|
||||
useradd -g mysql mysql
|
||||
fi
|
||||
|
||||
if [ ! -f ${mysqlDir}/mysql-5.5.62.tar.gz ];then
|
||||
wget -O ${mysqlDir}/mysql-5.5.62.tar.gz https://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.62.tar.gz
|
||||
fi
|
||||
|
||||
if [ ! -f ${mysqlDir}/mysql-5.5.62 ];then
|
||||
if [ ! -d ${mysqlDir}/mysql-5.5.62 ];then
|
||||
cd ${mysqlDir} && tar -zxvf ${mysqlDir}/mysql-5.5.62.tar.gz
|
||||
fi
|
||||
|
||||
|
||||
cd ${mysqlDir}/mysql-5.5.62 && cmake \
|
||||
-DCMAKE_INSTALL_PREFIX=$serverPath/mysql \
|
||||
-DMYSQL_USER=mysql \
|
||||
-DMYSQL_TCP_PORT=3306 \
|
||||
-DMYSQL_UNIX_ADDR=/var/tmp/mysql.sock \
|
||||
-DWITH_MYISAM_STORAGE_ENGINE=1 \
|
||||
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
|
||||
-DWITH_MEMORY_STORAGE_ENGINE=1 \
|
||||
-DENABLED_LOCAL_INFILE=1 \
|
||||
-DWITH_PARTITION_STORAGE_ENGINE=1 \
|
||||
-DEXTRA_CHARSETS=all \
|
||||
-DDEFAULT_CHARSET=utf8 \
|
||||
-DDEFAULT_COLLATION=utf8_general_ci \
|
||||
&& make && make install && make clean \
|
||||
&& echo '5.5' > $serverPath/mysql/version.pl
|
||||
echo '安装完成' > $install_tmp
|
||||
if [ ! -d $serverPath/mysql ];then
|
||||
cd ${mysqlDir}/mysql-5.5.62 && cmake \
|
||||
-DCMAKE_INSTALL_PREFIX=$serverPath/mysql \
|
||||
-DMYSQL_USER=mysql \
|
||||
-DMYSQL_TCP_PORT=3306 \
|
||||
-DMYSQL_UNIX_ADDR=/var/tmp/mysql.sock \
|
||||
-DWITH_MYISAM_STORAGE_ENGINE=1 \
|
||||
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
|
||||
-DWITH_MEMORY_STORAGE_ENGINE=1 \
|
||||
-DENABLED_LOCAL_INFILE=1 \
|
||||
-DWITH_PARTITION_STORAGE_ENGINE=1 \
|
||||
-DEXTRA_CHARSETS=all \
|
||||
-DDEFAULT_CHARSET=utf8 \
|
||||
-DDEFAULT_COLLATION=utf8_general_ci \
|
||||
&& make && make install && make clean \
|
||||
&& echo '5.5' > $serverPath/mysql/version.pl
|
||||
echo '安装完成' > $install_tmp
|
||||
fi
|
||||
}
|
||||
|
||||
Uninstall_mysql()
|
||||
|
||||
Executable
+73
@@ -0,0 +1,73 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/bin/bash
|
||||
|
||||
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
|
||||
export PATH
|
||||
|
||||
#https://dev.mysql.com/downloads/mysql/5.6.html
|
||||
#https://dev.mysql.com/downloads/file/?id=489600
|
||||
|
||||
curPath=`pwd`
|
||||
rootPath=$(dirname "$curPath")
|
||||
rootPath=$(dirname "$rootPath")
|
||||
serverPath=$(dirname "$rootPath")
|
||||
sysName=`uname`
|
||||
|
||||
|
||||
install_tmp=${rootPath}/tmp/mw_install.pl
|
||||
mysqlDir=${serverPath}/source/mysql
|
||||
|
||||
Install_mysql()
|
||||
{
|
||||
mkdir -p ${mysqlDir}
|
||||
echo '正在安装脚本文件...' > $install_tmp
|
||||
|
||||
if [ "$sysName" != "Darwin" ];then
|
||||
mkdir -p /var/log/mariadb
|
||||
touch /var/log/mariadb/mariadb.log
|
||||
groupadd mysql
|
||||
useradd -g mysql mysql
|
||||
fi
|
||||
|
||||
|
||||
if [ ! -f ${mysqlDir}/mysql-5.6.50.tar.gz ];then
|
||||
wget -O ${mysqlDir}/mysql-5.6.50.tar.gz https://cdn.mysql.com/Downloads/MySQL-5.6/mysql-5.6.50.tar.gz
|
||||
fi
|
||||
|
||||
if [ ! -d ${mysqlDir}/mysql-5.6.50 ];then
|
||||
cd ${mysqlDir} && tar -zxvf ${mysqlDir}/mysql-5.6.50.tar.gz
|
||||
fi
|
||||
|
||||
|
||||
if [ ! -d $serverPath/mysql ];then
|
||||
cd ${mysqlDir}/mysql-5.6.50 && cmake \
|
||||
-DCMAKE_INSTALL_PREFIX=$serverPath/mysql \
|
||||
-DMYSQL_USER=mysql \
|
||||
-DMYSQL_TCP_PORT=3306 \
|
||||
-DMYSQL_UNIX_ADDR=/var/tmp/mysql.sock \
|
||||
-DWITH_MYISAM_STORAGE_ENGINE=1 \
|
||||
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
|
||||
-DWITH_MEMORY_STORAGE_ENGINE=1 \
|
||||
-DENABLED_LOCAL_INFILE=1 \
|
||||
-DWITH_PARTITION_STORAGE_ENGINE=1 \
|
||||
-DEXTRA_CHARSETS=all \
|
||||
-DDEFAULT_CHARSET=utf8 \
|
||||
-DDEFAULT_COLLATION=utf8_general_ci \
|
||||
&& make && make install && make clean
|
||||
echo '5.6' > $serverPath/mysql/version.pl
|
||||
echo '安装完成' > $install_tmp
|
||||
fi
|
||||
}
|
||||
|
||||
Uninstall_mysql()
|
||||
{
|
||||
rm -rf $serverPath/mysql
|
||||
echo '卸载完成' > $install_tmp
|
||||
}
|
||||
|
||||
action=$1
|
||||
if [ "${1}" == 'install' ];then
|
||||
Install_mysql
|
||||
else
|
||||
Uninstall_mysql
|
||||
fi
|
||||
Executable
+73
@@ -0,0 +1,73 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/bin/bash
|
||||
|
||||
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
|
||||
export PATH
|
||||
|
||||
#https://dev.mysql.com/downloads/mysql/5.7.html
|
||||
#https://dev.mysql.com/downloads/file/?id=489855
|
||||
|
||||
curPath=`pwd`
|
||||
rootPath=$(dirname "$curPath")
|
||||
rootPath=$(dirname "$rootPath")
|
||||
serverPath=$(dirname "$rootPath")
|
||||
sysName=`uname`
|
||||
|
||||
|
||||
install_tmp=${rootPath}/tmp/mw_install.pl
|
||||
mysqlDir=${serverPath}/source/mysql
|
||||
|
||||
Install_mysql()
|
||||
{
|
||||
mkdir -p ${mysqlDir}
|
||||
echo '正在安装脚本文件...' > $install_tmp
|
||||
|
||||
if [ "$sysName" != "Darwin" ];then
|
||||
mkdir -p /var/log/mariadb
|
||||
touch /var/log/mariadb/mariadb.log
|
||||
groupadd mysql
|
||||
useradd -g mysql mysql
|
||||
fi
|
||||
|
||||
if [ ! -f ${mysqlDir}/mysql-boost-5.7.32.tar.gz ];then
|
||||
wget -O ${mysqlDir}/mysql-boost-5.7.32.tar.gz https://cdn.mysql.com/Downloads/MySQL-5.7/mysql-boost-5.7.32.tar.gz
|
||||
fi
|
||||
|
||||
if [ ! -d ${mysqlDir}/mysql-5.7.32 ];then
|
||||
cd ${mysqlDir} && tar -zxvf ${mysqlDir}/mysql-boost-5.7.32.tar.gz
|
||||
fi
|
||||
|
||||
if [ ! -d $serverPath/mysql ];then
|
||||
cd ${mysqlDir}/mysql-5.7.32 && cmake \
|
||||
-DCMAKE_INSTALL_PREFIX=$serverPath/mysql \
|
||||
-DMYSQL_USER=mysql \
|
||||
-DMYSQL_TCP_PORT=3306 \
|
||||
-DMYSQL_UNIX_ADDR=/var/tmp/mysql.sock \
|
||||
-DWITH_MYISAM_STORAGE_ENGINE=1 \
|
||||
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
|
||||
-DWITH_MEMORY_STORAGE_ENGINE=1 \
|
||||
-DENABLED_LOCAL_INFILE=1 \
|
||||
-DWITH_PARTITION_STORAGE_ENGINE=1 \
|
||||
-DEXTRA_CHARSETS=all \
|
||||
-DDEFAULT_CHARSET=utf8 \
|
||||
-DDEFAULT_COLLATION=utf8_general_ci \
|
||||
-DDOWNLOAD_BOOST=1 \
|
||||
-DWITH_BOOST=${mysqlDir}/mysql-5.7.28/boost/
|
||||
make && make install && make clean
|
||||
echo '5.7' > $serverPath/mysql/version.pl
|
||||
echo '安装完成' > $install_tmp
|
||||
fi
|
||||
}
|
||||
|
||||
Uninstall_mysql()
|
||||
{
|
||||
rm -rf $serverPath/mysql
|
||||
echo '卸载完成' > $install_tmp
|
||||
}
|
||||
|
||||
action=$1
|
||||
if [ "${1}" == 'install' ];then
|
||||
Install_mysql
|
||||
else
|
||||
Uninstall_mysql
|
||||
fi
|
||||
Executable
+78
@@ -0,0 +1,78 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/bin/bash
|
||||
|
||||
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
|
||||
export PATH
|
||||
|
||||
#https://dev.mysql.com/downloads/mysql/5.7.html
|
||||
#https://dev.mysql.com/downloads/file/?id=489855
|
||||
|
||||
curPath=`pwd`
|
||||
rootPath=$(dirname "$curPath")
|
||||
rootPath=$(dirname "$rootPath")
|
||||
serverPath=$(dirname "$rootPath")
|
||||
sysName=`uname`
|
||||
|
||||
|
||||
install_tmp=${rootPath}/tmp/mw_install.pl
|
||||
mysqlDir=${serverPath}/source/mysql
|
||||
|
||||
Install_mysql()
|
||||
{
|
||||
mkdir -p ${mysqlDir}
|
||||
echo '正在安装脚本文件...' > $install_tmp
|
||||
|
||||
INSTALL_CMD=cmake
|
||||
if [ "$sysName" != "Darwin" ];then
|
||||
mkdir -p /var/log/mariadb
|
||||
touch /var/log/mariadb/mariadb.log
|
||||
groupadd mysql
|
||||
useradd -g mysql mysql
|
||||
|
||||
yum install -y cmake3
|
||||
INSTALL_CMD=cmake3
|
||||
fi
|
||||
|
||||
if [ ! -f ${mysqlDir}/mysql-boost-8.0.22.tar.gz ];then
|
||||
wget -O ${mysqlDir}/mysql-boost-8.0.22.tar.gz https://cdn.mysql.com/archives/mysql-8.0/mysql-boost-8.0.22.tar.gz
|
||||
fi
|
||||
|
||||
if [ ! -d ${mysqlDir}/mysql-8.0.22 ];then
|
||||
cd ${mysqlDir} && tar -zxvf ${mysqlDir}/mysql-boost-8.0.22.tar.gz
|
||||
fi
|
||||
|
||||
if [ ! -d $serverPath/mysql ];then
|
||||
cd ${mysqlDir}/mysql-8.0.22 && ${INSTALL_CMD} \
|
||||
-DCMAKE_INSTALL_PREFIX=$serverPath/mysql \
|
||||
-DMYSQL_USER=mysql \
|
||||
-DMYSQL_TCP_PORT=3306 \
|
||||
-DMYSQL_UNIX_ADDR=/var/tmp/mysql.sock \
|
||||
-DWITH_MYISAM_STORAGE_ENGINE=1 \
|
||||
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
|
||||
-DWITH_MEMORY_STORAGE_ENGINE=1 \
|
||||
-DENABLED_LOCAL_INFILE=1 \
|
||||
-DWITH_PARTITION_STORAGE_ENGINE=1 \
|
||||
-DEXTRA_CHARSETS=all \
|
||||
-DDEFAULT_CHARSET=utf8 \
|
||||
-DDEFAULT_COLLATION=utf8_general_ci \
|
||||
-DDOWNLOAD_BOOST=1 \
|
||||
-DFORCE_INSOURCE_BUILD=1 \
|
||||
-DWITH_BOOST=${mysqlDir}/mysql-8.0.22/boost/
|
||||
make && make install && make clean
|
||||
echo '8.0' > $serverPath/mysql/version.pl
|
||||
echo '安装完成' > $install_tmp
|
||||
fi
|
||||
}
|
||||
|
||||
Uninstall_mysql()
|
||||
{
|
||||
rm -rf $serverPath/mysql
|
||||
echo '卸载完成' > $install_tmp
|
||||
}
|
||||
|
||||
action=$1
|
||||
if [ "${1}" == 'install' ];then
|
||||
Install_mysql
|
||||
else
|
||||
Uninstall_mysql
|
||||
fi
|
||||
+157
-155
@@ -8,11 +8,11 @@ import subprocess
|
||||
import json
|
||||
|
||||
sys.path.append(os.getcwd() + "/class/core")
|
||||
import public
|
||||
import mw
|
||||
|
||||
|
||||
app_debug = False
|
||||
if public.isAppleSystem():
|
||||
if mw.isAppleSystem():
|
||||
app_debug = True
|
||||
|
||||
|
||||
@@ -21,11 +21,11 @@ def getPluginName():
|
||||
|
||||
|
||||
def getPluginDir():
|
||||
return public.getPluginDir() + '/' + getPluginName()
|
||||
return mw.getPluginDir() + '/' + getPluginName()
|
||||
|
||||
|
||||
def getServerDir():
|
||||
return public.getServerDir() + '/' + getPluginName()
|
||||
return mw.getServerDir() + '/' + getPluginName()
|
||||
|
||||
|
||||
def getArgs():
|
||||
@@ -48,12 +48,12 @@ def getArgs():
|
||||
def checkArgs(data, ck=[]):
|
||||
for i in range(len(ck)):
|
||||
if not ck[i] in data:
|
||||
return (False, public.returnJson(False, '参数:(' + ck[i] + ')没有!'))
|
||||
return (True, public.returnJson(True, 'ok'))
|
||||
return (False, mw.returnJson(False, '参数:(' + ck[i] + ')没有!'))
|
||||
return (True, mw.returnJson(True, 'ok'))
|
||||
|
||||
|
||||
def getConf():
|
||||
path = public.getServerDir() + "/openresty/nginx/conf/nginx.conf"
|
||||
path = mw.getServerDir() + "/openresty/nginx/conf/nginx.conf"
|
||||
return path
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ def initDomainInfo():
|
||||
data = []
|
||||
path_domains = getJsonPath('domains')
|
||||
|
||||
_list = public.M('sites').field('id,name,path').where(
|
||||
_list = mw.M('sites').field('id,name,path').where(
|
||||
'status=?', ('1',)).order('id desc').select()
|
||||
|
||||
for i in range(len(_list)):
|
||||
@@ -69,7 +69,7 @@ def initDomainInfo():
|
||||
tmp['name'] = _list[i]['name']
|
||||
tmp['path'] = _list[i]['path']
|
||||
|
||||
_list_domain = public.M('domain').field('name').where(
|
||||
_list_domain = mw.M('domain').field('name').where(
|
||||
'pid=?', (_list[i]['id'],)).order('id desc').select()
|
||||
|
||||
tmp_j = []
|
||||
@@ -78,8 +78,8 @@ def initDomainInfo():
|
||||
|
||||
tmp['domains'] = tmp_j
|
||||
data.append(tmp)
|
||||
cjson = public.getJson(data)
|
||||
public.writeFile(path_domains, cjson)
|
||||
cjson = mw.getJson(data)
|
||||
mw.writeFile(path_domains, cjson)
|
||||
|
||||
|
||||
def initSiteInfo():
|
||||
@@ -88,14 +88,14 @@ def initSiteInfo():
|
||||
path_config = getJsonPath('config')
|
||||
path_site = getJsonPath('site')
|
||||
|
||||
config_contents = public.readFile(path_config)
|
||||
config_contents = mw.readFile(path_config)
|
||||
config_contents = json.loads(config_contents)
|
||||
|
||||
domain_contents = public.readFile(path_domains)
|
||||
domain_contents = mw.readFile(path_domains)
|
||||
domain_contents = json.loads(domain_contents)
|
||||
|
||||
try:
|
||||
site_contents = public.readFile(path_site)
|
||||
site_contents = mw.readFile(path_site)
|
||||
except Exception as e:
|
||||
site_contents = "{}"
|
||||
|
||||
@@ -133,8 +133,8 @@ def initSiteInfo():
|
||||
|
||||
site_contents_new[name] = tmp
|
||||
|
||||
cjson = public.getJson(site_contents_new)
|
||||
public.writeFile(path_site, cjson)
|
||||
cjson = mw.getJson(site_contents_new)
|
||||
mw.writeFile(path_site, cjson)
|
||||
|
||||
|
||||
def initTotalInfo():
|
||||
@@ -142,11 +142,11 @@ def initTotalInfo():
|
||||
path_domains = getJsonPath('domains')
|
||||
path_total = getJsonPath('total')
|
||||
|
||||
domain_contents = public.readFile(path_domains)
|
||||
domain_contents = mw.readFile(path_domains)
|
||||
domain_contents = json.loads(domain_contents)
|
||||
|
||||
try:
|
||||
total_contents = public.readFile(path_total)
|
||||
total_contents = mw.readFile(path_total)
|
||||
except Exception as e:
|
||||
total_contents = "{}"
|
||||
|
||||
@@ -167,8 +167,8 @@ def initTotalInfo():
|
||||
_name[name] = tmp
|
||||
total_contents['sites'] = _name
|
||||
|
||||
cjson = public.getJson(total_contents)
|
||||
public.writeFile(path_total, cjson)
|
||||
cjson = mw.getJson(total_contents)
|
||||
mw.writeFile(path_total, cjson)
|
||||
|
||||
|
||||
def status():
|
||||
@@ -180,7 +180,7 @@ def status():
|
||||
if not os.path.exists(path):
|
||||
return 'stop'
|
||||
|
||||
conf = public.readFile(path)
|
||||
conf = mw.readFile(path)
|
||||
if conf.find("#include luawaf.conf;") != -1:
|
||||
return 'stop'
|
||||
if conf.find("luawaf.conf;") == -1:
|
||||
@@ -189,9 +189,9 @@ def status():
|
||||
|
||||
|
||||
def contentReplace(content):
|
||||
service_path = public.getServerDir()
|
||||
waf_path = public.getServerDir() + "/openresty/nginx/conf/waf"
|
||||
content = content.replace('{$ROOT_PATH}', public.getRootDir())
|
||||
service_path = mw.getServerDir()
|
||||
waf_path = mw.getServerDir() + "/openresty/nginx/conf/waf"
|
||||
content = content.replace('{$ROOT_PATH}', mw.getRootDir())
|
||||
content = content.replace('{$SERVER_PATH}', service_path)
|
||||
content = content.replace('{$WAF_PATH}', waf_path)
|
||||
return content
|
||||
@@ -200,77 +200,77 @@ def contentReplace(content):
|
||||
def initDreplace():
|
||||
|
||||
config = getPluginDir() + '/waf/config.json'
|
||||
content = public.readFile(config)
|
||||
content = mw.readFile(config)
|
||||
content = json.loads(content)
|
||||
content['reqfile_path'] = public.getServerDir(
|
||||
content['reqfile_path'] = mw.getServerDir(
|
||||
) + "/openresty/nginx/conf/waf/html"
|
||||
public.writeFile(config, public.getJson(content))
|
||||
mw.writeFile(config, mw.getJson(content))
|
||||
|
||||
path = public.getServerDir() + "/openresty/nginx/conf"
|
||||
path = mw.getServerDir() + "/openresty/nginx/conf"
|
||||
if not os.path.exists(path + '/waf'):
|
||||
sdir = getPluginDir() + '/waf'
|
||||
cmd = 'cp -rf ' + sdir + ' ' + path
|
||||
public.execShell(cmd)
|
||||
mw.execShell(cmd)
|
||||
|
||||
config = public.getServerDir() + "/openresty/nginx/conf/waf/lua/init.lua"
|
||||
content = public.readFile(config)
|
||||
config = mw.getServerDir() + "/openresty/nginx/conf/waf/lua/init.lua"
|
||||
content = mw.readFile(config)
|
||||
content = contentReplace(content)
|
||||
public.writeFile(config, content)
|
||||
mw.writeFile(config, content)
|
||||
|
||||
waf_conf = public.getServerDir() + "/openresty/nginx/conf/luawaf.conf"
|
||||
waf_conf = mw.getServerDir() + "/openresty/nginx/conf/luawaf.conf"
|
||||
waf_tpl = getPluginDir() + "/conf/luawaf.conf"
|
||||
content = public.readFile(waf_tpl)
|
||||
content = mw.readFile(waf_tpl)
|
||||
content = contentReplace(content)
|
||||
public.writeFile(waf_conf, content)
|
||||
mw.writeFile(waf_conf, content)
|
||||
|
||||
|
||||
def start():
|
||||
initDreplace()
|
||||
|
||||
path = getConf()
|
||||
conf = public.readFile(path)
|
||||
conf = mw.readFile(path)
|
||||
conf = conf.replace('#include luawaf.conf;', "include luawaf.conf;")
|
||||
|
||||
public.writeFile(path, conf)
|
||||
public.restartWeb()
|
||||
mw.writeFile(path, conf)
|
||||
mw.restartWeb()
|
||||
return 'ok'
|
||||
|
||||
|
||||
def stop():
|
||||
path = public.getServerDir() + "/openresty/nginx/conf/waf"
|
||||
path = mw.getServerDir() + "/openresty/nginx/conf/waf"
|
||||
if os.path.exists(path):
|
||||
cmd = 'rm -rf ' + path
|
||||
public.execShell(cmd)
|
||||
mw.execShell(cmd)
|
||||
|
||||
path = getConf()
|
||||
conf = public.readFile(path)
|
||||
conf = mw.readFile(path)
|
||||
conf = conf.replace('include luawaf.conf;', "#include luawaf.conf;")
|
||||
|
||||
public.writeFile(path, conf)
|
||||
public.restartWeb()
|
||||
mw.writeFile(path, conf)
|
||||
mw.restartWeb()
|
||||
return 'ok'
|
||||
|
||||
|
||||
def restart():
|
||||
public.restartWeb()
|
||||
mw.restartWeb()
|
||||
return 'ok'
|
||||
|
||||
|
||||
def reload():
|
||||
stop()
|
||||
public.execShell('rm -rf ' + public.getServerDir() +
|
||||
"/openresty/nginx/logs/error.log")
|
||||
mw.execShell('rm -rf ' + mw.getServerDir() +
|
||||
"/openresty/nginx/logs/error.log")
|
||||
start()
|
||||
return 'ok'
|
||||
|
||||
|
||||
def getJsonPath(name):
|
||||
path = public.getServerDir() + "/openresty/nginx/conf/waf/" + name + ".json"
|
||||
path = mw.getServerDir() + "/openresty/nginx/conf/waf/" + name + ".json"
|
||||
return path
|
||||
|
||||
|
||||
def getRuleJsonPath(name):
|
||||
path = public.getServerDir() + "/openresty/nginx/conf/waf/rule/" + name + ".json"
|
||||
path = mw.getServerDir() + "/openresty/nginx/conf/waf/rule/" + name + ".json"
|
||||
return path
|
||||
|
||||
|
||||
@@ -282,8 +282,8 @@ def getRule():
|
||||
|
||||
rule_name = args['rule_name']
|
||||
fpath = getRuleJsonPath(rule_name)
|
||||
content = public.readFile(fpath)
|
||||
return public.returnJson(True, 'ok', content)
|
||||
content = mw.readFile(fpath)
|
||||
return mw.returnJson(True, 'ok', content)
|
||||
|
||||
|
||||
def addRule():
|
||||
@@ -297,7 +297,7 @@ def addRule():
|
||||
ps = args['ps']
|
||||
|
||||
fpath = getRuleJsonPath(ruleName)
|
||||
content = public.readFile(fpath)
|
||||
content = mw.readFile(fpath)
|
||||
content = json.loads(content)
|
||||
|
||||
tmp_k = []
|
||||
@@ -308,10 +308,11 @@ def addRule():
|
||||
|
||||
content.append(tmp_k)
|
||||
|
||||
cjson = public.getJson(content)
|
||||
public.writeFile(fpath, cjson)
|
||||
cjson = mw.getJson(content)
|
||||
mw.writeFile(fpath, cjson)
|
||||
|
||||
return mw.returnJson(True, '设置成功!', content)
|
||||
|
||||
return public.returnJson(True, '设置成功!', content)
|
||||
|
||||
def removeRule():
|
||||
args = getArgs()
|
||||
@@ -323,16 +324,17 @@ def removeRule():
|
||||
ruleName = args['ruleName']
|
||||
|
||||
fpath = getRuleJsonPath(ruleName)
|
||||
content = public.readFile(fpath)
|
||||
content = mw.readFile(fpath)
|
||||
content = json.loads(content)
|
||||
|
||||
k = content[index]
|
||||
content.remove(k)
|
||||
|
||||
cjson = public.getJson(content)
|
||||
public.writeFile(fpath, cjson)
|
||||
cjson = mw.getJson(content)
|
||||
mw.writeFile(fpath, cjson)
|
||||
|
||||
return mw.returnJson(True, '设置成功!', content)
|
||||
|
||||
return public.returnJson(True, '设置成功!', content)
|
||||
|
||||
def setRuleState():
|
||||
args = getArgs()
|
||||
@@ -344,7 +346,7 @@ def setRuleState():
|
||||
ruleName = args['ruleName']
|
||||
|
||||
fpath = getRuleJsonPath(ruleName)
|
||||
content = public.readFile(fpath)
|
||||
content = mw.readFile(fpath)
|
||||
content = json.loads(content)
|
||||
|
||||
b = content[index][0]
|
||||
@@ -353,11 +355,10 @@ def setRuleState():
|
||||
else:
|
||||
content[index][0] = 1
|
||||
|
||||
cjson = public.getJson(content)
|
||||
public.writeFile(fpath, cjson)
|
||||
|
||||
return public.returnJson(True, '设置成功!', content)
|
||||
cjson = mw.getJson(content)
|
||||
mw.writeFile(fpath, cjson)
|
||||
|
||||
return mw.returnJson(True, '设置成功!', content)
|
||||
|
||||
|
||||
def modifyRule():
|
||||
@@ -372,7 +373,7 @@ def modifyRule():
|
||||
rulePs = args['rulePs']
|
||||
|
||||
fpath = getRuleJsonPath(ruleName)
|
||||
content = public.readFile(fpath)
|
||||
content = mw.readFile(fpath)
|
||||
content = json.loads(content)
|
||||
|
||||
tmp = content[index]
|
||||
@@ -385,10 +386,10 @@ def modifyRule():
|
||||
|
||||
content[index] = tmp_k
|
||||
|
||||
cjson = public.getJson(content)
|
||||
public.writeFile(fpath, cjson)
|
||||
cjson = mw.getJson(content)
|
||||
mw.writeFile(fpath, cjson)
|
||||
|
||||
return public.returnJson(True, '设置成功!', content)
|
||||
return mw.returnJson(True, '设置成功!', content)
|
||||
|
||||
|
||||
def getSiteRule():
|
||||
@@ -401,13 +402,13 @@ def getSiteRule():
|
||||
siteRule = args['ruleName']
|
||||
|
||||
path = getJsonPath('site')
|
||||
content = public.readFile(path)
|
||||
content = mw.readFile(path)
|
||||
content = json.loads(content)
|
||||
|
||||
r = content[siteName][siteRule]
|
||||
|
||||
cjson = public.getJson(r)
|
||||
return public.returnJson(True, 'ok!', cjson)
|
||||
cjson = mw.getJson(r)
|
||||
return mw.returnJson(True, 'ok!', cjson)
|
||||
|
||||
|
||||
def addSiteRule():
|
||||
@@ -421,14 +422,14 @@ def addSiteRule():
|
||||
ruleValue = args['ruleValue']
|
||||
|
||||
path = getJsonPath('site')
|
||||
content = public.readFile(path)
|
||||
content = mw.readFile(path)
|
||||
content = json.loads(content)
|
||||
|
||||
content[siteName][siteRule].append(ruleValue)
|
||||
|
||||
cjson = public.getJson(content)
|
||||
public.writeFile(path, cjson)
|
||||
return public.returnJson(True, '设置成功!')
|
||||
cjson = mw.getJson(content)
|
||||
mw.writeFile(path, cjson)
|
||||
return mw.returnJson(True, '设置成功!')
|
||||
|
||||
|
||||
def addIpWhite():
|
||||
@@ -441,7 +442,7 @@ def addIpWhite():
|
||||
end_ip = args['end_ip']
|
||||
|
||||
path = getRuleJsonPath('ip_white')
|
||||
content = public.readFile(path)
|
||||
content = mw.readFile(path)
|
||||
content = json.loads(content)
|
||||
|
||||
data = []
|
||||
@@ -461,9 +462,9 @@ def addIpWhite():
|
||||
|
||||
content.append(data)
|
||||
|
||||
cjson = public.getJson(content)
|
||||
public.writeFile(path, cjson)
|
||||
return public.returnJson(True, '设置成功!')
|
||||
cjson = mw.getJson(content)
|
||||
mw.writeFile(path, cjson)
|
||||
return mw.returnJson(True, '设置成功!')
|
||||
|
||||
|
||||
def removeIpWhite():
|
||||
@@ -475,15 +476,15 @@ def removeIpWhite():
|
||||
index = args['index']
|
||||
|
||||
path = getRuleJsonPath('ip_white')
|
||||
content = public.readFile(path)
|
||||
content = mw.readFile(path)
|
||||
content = json.loads(content)
|
||||
|
||||
k = content[int(index)]
|
||||
content.remove(k)
|
||||
|
||||
cjson = public.getJson(content)
|
||||
public.writeFile(path, cjson)
|
||||
return public.returnJson(True, '设置成功!')
|
||||
cjson = mw.getJson(content)
|
||||
mw.writeFile(path, cjson)
|
||||
return mw.returnJson(True, '设置成功!')
|
||||
|
||||
|
||||
def addIpBlack():
|
||||
@@ -496,7 +497,7 @@ def addIpBlack():
|
||||
end_ip = args['end_ip']
|
||||
|
||||
path = getRuleJsonPath('ip_black')
|
||||
content = public.readFile(path)
|
||||
content = mw.readFile(path)
|
||||
content = json.loads(content)
|
||||
|
||||
data = []
|
||||
@@ -516,9 +517,9 @@ def addIpBlack():
|
||||
|
||||
content.append(data)
|
||||
|
||||
cjson = public.getJson(content)
|
||||
public.writeFile(path, cjson)
|
||||
return public.returnJson(True, '设置成功!')
|
||||
cjson = mw.getJson(content)
|
||||
mw.writeFile(path, cjson)
|
||||
return mw.returnJson(True, '设置成功!')
|
||||
|
||||
|
||||
def removeIpBlack():
|
||||
@@ -530,15 +531,15 @@ def removeIpBlack():
|
||||
index = args['index']
|
||||
|
||||
path = getRuleJsonPath('ip_black')
|
||||
content = public.readFile(path)
|
||||
content = mw.readFile(path)
|
||||
content = json.loads(content)
|
||||
|
||||
k = content[int(index)]
|
||||
content.remove(k)
|
||||
|
||||
cjson = public.getJson(content)
|
||||
public.writeFile(path, cjson)
|
||||
return public.returnJson(True, '设置成功!')
|
||||
cjson = mw.getJson(content)
|
||||
mw.writeFile(path, cjson)
|
||||
return mw.returnJson(True, '设置成功!')
|
||||
|
||||
|
||||
def setIpv6Black():
|
||||
@@ -550,13 +551,13 @@ def setIpv6Black():
|
||||
addr = args['addr'].replace('_', ':')
|
||||
path = getRuleJsonPath('ipv6_black')
|
||||
|
||||
content = public.readFile(path)
|
||||
content = mw.readFile(path)
|
||||
content = json.loads(content)
|
||||
content.append(addr)
|
||||
|
||||
cjson = public.getJson(content)
|
||||
public.writeFile(path, cjson)
|
||||
return public.returnJson(True, '设置成功!')
|
||||
cjson = mw.getJson(content)
|
||||
mw.writeFile(path, cjson)
|
||||
return mw.returnJson(True, '设置成功!')
|
||||
|
||||
|
||||
def delIpv6Black():
|
||||
@@ -568,14 +569,14 @@ def delIpv6Black():
|
||||
addr = args['addr'].replace('_', ':')
|
||||
path = getRuleJsonPath('ipv6_black')
|
||||
|
||||
content = public.readFile(path)
|
||||
content = mw.readFile(path)
|
||||
content = json.loads(content)
|
||||
|
||||
content.remove(addr)
|
||||
|
||||
cjson = public.getJson(content)
|
||||
public.writeFile(path, cjson)
|
||||
return public.returnJson(True, '设置成功!')
|
||||
cjson = mw.getJson(content)
|
||||
mw.writeFile(path, cjson)
|
||||
return mw.returnJson(True, '设置成功!')
|
||||
|
||||
|
||||
def removeSiteRule():
|
||||
@@ -589,15 +590,15 @@ def removeSiteRule():
|
||||
index = args['index']
|
||||
|
||||
path = getJsonPath('site')
|
||||
content = public.readFile(path)
|
||||
content = mw.readFile(path)
|
||||
content = json.loads(content)
|
||||
|
||||
ruleValue = content[siteName][siteRule][int(index)]
|
||||
content[siteName][siteRule].remove(ruleValue)
|
||||
|
||||
cjson = public.getJson(content)
|
||||
public.writeFile(path, cjson)
|
||||
return public.returnJson(True, '设置成功!')
|
||||
cjson = mw.getJson(content)
|
||||
mw.writeFile(path, cjson)
|
||||
return mw.returnJson(True, '设置成功!')
|
||||
|
||||
|
||||
def setObjStatus():
|
||||
@@ -607,16 +608,16 @@ def setObjStatus():
|
||||
return data[1]
|
||||
|
||||
conf = getJsonPath('config')
|
||||
content = public.readFile(conf)
|
||||
content = mw.readFile(conf)
|
||||
cobj = json.loads(content)
|
||||
|
||||
o = args['obj']
|
||||
status = args['statusCode']
|
||||
cobj[o]['status'] = status
|
||||
|
||||
cjson = public.getJson(cobj)
|
||||
public.writeFile(conf, cjson)
|
||||
return public.returnJson(True, '设置成功!')
|
||||
cjson = mw.getJson(cobj)
|
||||
mw.writeFile(conf, cjson)
|
||||
return mw.returnJson(True, '设置成功!')
|
||||
|
||||
|
||||
def setRetry():
|
||||
@@ -627,34 +628,34 @@ def setRetry():
|
||||
return data[1]
|
||||
|
||||
conf = getJsonPath('config')
|
||||
content = public.readFile(conf)
|
||||
content = mw.readFile(conf)
|
||||
cobj = json.loads(content)
|
||||
|
||||
cobj['retry'] = args
|
||||
|
||||
cjson = public.getJson(cobj)
|
||||
public.writeFile(conf, cjson)
|
||||
cjson = mw.getJson(cobj)
|
||||
mw.writeFile(conf, cjson)
|
||||
|
||||
return public.returnJson(True, '设置成功!', [])
|
||||
return mw.returnJson(True, '设置成功!', [])
|
||||
|
||||
|
||||
def setSiteRetry():
|
||||
return public.returnJson(True, '设置成功-?!', [])
|
||||
return mw.returnJson(True, '设置成功-?!', [])
|
||||
|
||||
|
||||
def setCcConf():
|
||||
args = getArgs()
|
||||
data = checkArgs(args, ['siteName', 'cycle', 'limit', 'endtime','is_open_global','increase'])
|
||||
data = checkArgs(args, ['siteName', 'cycle', 'limit',
|
||||
'endtime', 'is_open_global', 'increase'])
|
||||
if not data[0]:
|
||||
return data[1]
|
||||
|
||||
conf = getJsonPath('config')
|
||||
content = public.readFile(conf)
|
||||
content = mw.readFile(conf)
|
||||
cobj = json.loads(content)
|
||||
|
||||
tmp = cobj['cc']
|
||||
|
||||
|
||||
tmp['cycle'] = int(args['cycle'])
|
||||
tmp['limit'] = int(args['limit'])
|
||||
tmp['endtime'] = int(args['endtime'])
|
||||
@@ -662,12 +663,14 @@ def setCcConf():
|
||||
tmp['increase'] = args['increase']
|
||||
cobj['cc'] = tmp
|
||||
|
||||
cjson = public.getJson(cobj)
|
||||
public.writeFile(conf, cjson)
|
||||
return public.returnJson(True, '设置成功!', [])
|
||||
cjson = mw.getJson(cobj)
|
||||
mw.writeFile(conf, cjson)
|
||||
return mw.returnJson(True, '设置成功!', [])
|
||||
|
||||
|
||||
def setSiteCcConf():
|
||||
return public.returnJson(True, '设置成功-?!', [])
|
||||
return mw.returnJson(True, '设置成功-?!', [])
|
||||
|
||||
|
||||
def saveScanRule():
|
||||
args = getArgs()
|
||||
@@ -676,19 +679,19 @@ def saveScanRule():
|
||||
return data[1]
|
||||
|
||||
path = getRuleJsonPath('scan_black')
|
||||
cjson = public.getJson(args)
|
||||
public.writeFile(path, cjson)
|
||||
return public.returnJson(True, '设置成功!', [])
|
||||
cjson = mw.getJson(args)
|
||||
mw.writeFile(path, cjson)
|
||||
return mw.returnJson(True, '设置成功!', [])
|
||||
|
||||
|
||||
def getSiteConfig():
|
||||
path = getJsonPath('site')
|
||||
content = public.readFile(path)
|
||||
content = mw.readFile(path)
|
||||
|
||||
content = json.loads(content)
|
||||
|
||||
total = getJsonPath('total')
|
||||
total_content = public.readFile(total)
|
||||
total_content = mw.readFile(total)
|
||||
total_content = json.loads(total_content)
|
||||
|
||||
# print total_content
|
||||
@@ -713,8 +716,8 @@ def getSiteConfig():
|
||||
# print tmp
|
||||
content[x]['total'] = tmp
|
||||
|
||||
content = public.getJson(content)
|
||||
return public.returnJson(True, 'ok!', content)
|
||||
content = mw.getJson(content)
|
||||
return mw.returnJson(True, 'ok!', content)
|
||||
|
||||
|
||||
def getSiteConfigByName():
|
||||
@@ -723,7 +726,7 @@ def getSiteConfigByName():
|
||||
if not data[0]:
|
||||
return data[1]
|
||||
path = getJsonPath('site')
|
||||
content = public.readFile(path)
|
||||
content = mw.readFile(path)
|
||||
content = json.loads(content)
|
||||
|
||||
siteName = args['siteName']
|
||||
@@ -731,7 +734,7 @@ def getSiteConfigByName():
|
||||
if siteName in content:
|
||||
retData = content[siteName]
|
||||
|
||||
return public.returnJson(True, 'ok!', retData)
|
||||
return mw.returnJson(True, 'ok!', retData)
|
||||
|
||||
|
||||
def addSiteCdnHeader():
|
||||
@@ -740,7 +743,7 @@ def addSiteCdnHeader():
|
||||
if not data[0]:
|
||||
return data[1]
|
||||
path = getJsonPath('site')
|
||||
content = public.readFile(path)
|
||||
content = mw.readFile(path)
|
||||
content = json.loads(content)
|
||||
|
||||
siteName = args['siteName']
|
||||
@@ -748,9 +751,9 @@ def addSiteCdnHeader():
|
||||
if siteName in content:
|
||||
content[siteName]['cdn_header'].append(args['cdn_header'])
|
||||
|
||||
cjson = public.getJson(content)
|
||||
public.writeFile(path, cjson)
|
||||
return public.returnJson(True, '添加成功!')
|
||||
cjson = mw.getJson(content)
|
||||
mw.writeFile(path, cjson)
|
||||
return mw.returnJson(True, '添加成功!')
|
||||
|
||||
|
||||
def removeSiteCdnHeader():
|
||||
@@ -759,7 +762,7 @@ def removeSiteCdnHeader():
|
||||
if not data[0]:
|
||||
return data[1]
|
||||
path = getJsonPath('site')
|
||||
content = public.readFile(path)
|
||||
content = mw.readFile(path)
|
||||
content = json.loads(content)
|
||||
|
||||
siteName = args['siteName']
|
||||
@@ -767,9 +770,9 @@ def removeSiteCdnHeader():
|
||||
if siteName in content:
|
||||
content[siteName]['cdn_header'].remove(args['cdn_header'])
|
||||
|
||||
cjson = public.getJson(content)
|
||||
public.writeFile(path, cjson)
|
||||
return public.returnJson(True, '删除成功!')
|
||||
cjson = mw.getJson(content)
|
||||
mw.writeFile(path, cjson)
|
||||
return mw.returnJson(True, '删除成功!')
|
||||
|
||||
|
||||
def outputData():
|
||||
@@ -779,8 +782,8 @@ def outputData():
|
||||
return data[1]
|
||||
|
||||
path = getRuleJsonPath(args['s_Name'])
|
||||
content = public.readFile(path)
|
||||
return public.returnJson(True, 'ok', content)
|
||||
content = mw.readFile(path)
|
||||
return mw.returnJson(True, 'ok', content)
|
||||
|
||||
|
||||
def importData():
|
||||
@@ -790,8 +793,8 @@ def importData():
|
||||
return data[1]
|
||||
|
||||
path = getRuleJsonPath(args['s_Name'])
|
||||
public.writeFile(path, args['pdata'])
|
||||
return public.returnJson(True, '设置成功!')
|
||||
mw.writeFile(path, args['pdata'])
|
||||
return mw.returnJson(True, '设置成功!')
|
||||
|
||||
|
||||
def getLogsList():
|
||||
@@ -801,7 +804,7 @@ def getLogsList():
|
||||
return data[1]
|
||||
|
||||
data = []
|
||||
path = public.getLogsDir() + '/waf'
|
||||
path = mw.getLogsDir() + '/waf'
|
||||
files = os.listdir(path)
|
||||
for f in files:
|
||||
if f == '.DS_Store':
|
||||
@@ -811,7 +814,7 @@ def getLogsList():
|
||||
fl = f[1].split('.')
|
||||
data.append(fl[0])
|
||||
|
||||
return public.returnJson(True, 'ok!', data)
|
||||
return mw.returnJson(True, 'ok!', data)
|
||||
|
||||
|
||||
def getSafeLogs():
|
||||
@@ -820,10 +823,10 @@ def getSafeLogs():
|
||||
if not data[0]:
|
||||
return data[1]
|
||||
|
||||
path = public.getLogsDir() + '/waf'
|
||||
path = mw.getLogsDir() + '/waf'
|
||||
file = path + '/' + args['siteName'] + '_' + args['toDate'] + '.log'
|
||||
if not os.path.exists(file):
|
||||
return public.returnJson(False, "文件不存在!")
|
||||
return mw.returnJson(False, "文件不存在!")
|
||||
|
||||
retData = []
|
||||
file = open(file)
|
||||
@@ -835,7 +838,7 @@ def getSafeLogs():
|
||||
|
||||
retData.append(json.loads(line))
|
||||
|
||||
return public.returnJson(True, '设置成功!', retData)
|
||||
return mw.returnJson(True, '设置成功!', retData)
|
||||
|
||||
|
||||
def setObjOpen():
|
||||
@@ -845,7 +848,7 @@ def setObjOpen():
|
||||
return data[1]
|
||||
|
||||
conf = getJsonPath('config')
|
||||
content = public.readFile(conf)
|
||||
content = mw.readFile(conf)
|
||||
cobj = json.loads(content)
|
||||
|
||||
o = args['obj']
|
||||
@@ -854,9 +857,9 @@ def setObjOpen():
|
||||
else:
|
||||
cobj[o]["open"] = True
|
||||
|
||||
cjson = public.getJson(cobj)
|
||||
public.writeFile(conf, cjson)
|
||||
return public.returnJson(True, '设置成功!')
|
||||
cjson = mw.getJson(cobj)
|
||||
mw.writeFile(conf, cjson)
|
||||
return mw.returnJson(True, '设置成功!')
|
||||
|
||||
|
||||
def setSiteObjOpen():
|
||||
@@ -869,7 +872,7 @@ def setSiteObjOpen():
|
||||
obj = args['obj']
|
||||
|
||||
path = getJsonPath('site')
|
||||
content = public.readFile(path)
|
||||
content = mw.readFile(path)
|
||||
content = json.loads(content)
|
||||
|
||||
if type(content[siteName][obj]) == bool:
|
||||
@@ -883,20 +886,19 @@ def setSiteObjOpen():
|
||||
else:
|
||||
content[siteName][obj]['open'] = True
|
||||
|
||||
cjson = public.getJson(content)
|
||||
public.writeFile(path, cjson)
|
||||
return public.returnJson(True, '设置成功!')
|
||||
|
||||
cjson = mw.getJson(content)
|
||||
mw.writeFile(path, cjson)
|
||||
return mw.returnJson(True, '设置成功!')
|
||||
|
||||
|
||||
def getWafSrceen():
|
||||
conf = getJsonPath('total')
|
||||
return public.readFile(conf)
|
||||
return mw.readFile(conf)
|
||||
|
||||
|
||||
def getWafConf():
|
||||
conf = getJsonPath('config')
|
||||
return public.readFile(conf)
|
||||
return mw.readFile(conf)
|
||||
|
||||
|
||||
def getWafSite():
|
||||
|
||||
+44
-37
@@ -7,12 +7,12 @@ import time
|
||||
import subprocess
|
||||
|
||||
sys.path.append(os.getcwd() + "/class/core")
|
||||
import public
|
||||
import mw
|
||||
|
||||
|
||||
app_debug = False
|
||||
|
||||
if public.isAppleSystem():
|
||||
if mw.isAppleSystem():
|
||||
app_debug = True
|
||||
|
||||
|
||||
@@ -21,11 +21,11 @@ def getPluginName():
|
||||
|
||||
|
||||
def getPluginDir():
|
||||
return public.getPluginDir() + '/' + getPluginName()
|
||||
return mw.getPluginDir() + '/' + getPluginName()
|
||||
|
||||
|
||||
def getServerDir():
|
||||
return public.getServerDir() + '/' + getPluginName()
|
||||
return mw.getServerDir() + '/' + getPluginName()
|
||||
|
||||
|
||||
def getInitDFile():
|
||||
@@ -53,11 +53,11 @@ def getArgs():
|
||||
|
||||
def clearTemp():
|
||||
path_bin = getServerDir() + "/nginx"
|
||||
public.execShell('rm -rf ' + path_bin + '/client_body_temp')
|
||||
public.execShell('rm -rf ' + path_bin + '/fastcgi_temp')
|
||||
public.execShell('rm -rf ' + path_bin + '/proxy_temp')
|
||||
public.execShell('rm -rf ' + path_bin + '/scgi_temp')
|
||||
public.execShell('rm -rf ' + path_bin + '/uwsgi_temp')
|
||||
mw.execShell('rm -rf ' + path_bin + '/client_body_temp')
|
||||
mw.execShell('rm -rf ' + path_bin + '/fastcgi_temp')
|
||||
mw.execShell('rm -rf ' + path_bin + '/proxy_temp')
|
||||
mw.execShell('rm -rf ' + path_bin + '/scgi_temp')
|
||||
mw.execShell('rm -rf ' + path_bin + '/uwsgi_temp')
|
||||
|
||||
|
||||
def getConf():
|
||||
@@ -72,13 +72,13 @@ def getConfTpl():
|
||||
|
||||
def getOs():
|
||||
data = {}
|
||||
data['os'] = public.getOs()
|
||||
data['os'] = mw.getOs()
|
||||
ng_exe_bin = getServerDir() + "/nginx/sbin/nginx"
|
||||
if checkAuthEq(ng_exe_bin, 'root'):
|
||||
data['auth'] = True
|
||||
else:
|
||||
data['auth'] = False
|
||||
return public.getJson(data)
|
||||
return mw.getJson(data)
|
||||
|
||||
|
||||
def getInitDTpl():
|
||||
@@ -112,15 +112,15 @@ def checkAuthEq(file, owner='root'):
|
||||
|
||||
def confReplace():
|
||||
service_path = os.path.dirname(os.getcwd())
|
||||
content = public.readFile(getConfTpl())
|
||||
content = mw.readFile(getConfTpl())
|
||||
content = content.replace('{$SERVER_PATH}', service_path)
|
||||
|
||||
user = 'www'
|
||||
user_group = 'www'
|
||||
|
||||
if public.getOs() == 'darwin':
|
||||
if mw.getOs() == 'darwin':
|
||||
# macosx do
|
||||
user = public.execShell(
|
||||
user = mw.execShell(
|
||||
"who | sed -n '2, 1p' |awk '{print $1}'")[0].strip()
|
||||
# user = 'root'
|
||||
user_group = 'staff'
|
||||
@@ -133,9 +133,9 @@ def confReplace():
|
||||
|
||||
nconf = getServerDir() + '/nginx/conf/nginx.conf'
|
||||
|
||||
__content = public.readFile(nconf)
|
||||
__content = mw.readFile(nconf)
|
||||
if __content.find('#user'):
|
||||
public.writeFile(getServerDir() + '/nginx/conf/nginx.conf', content)
|
||||
mw.writeFile(getServerDir() + '/nginx/conf/nginx.conf', content)
|
||||
|
||||
# give nginx root permission
|
||||
ng_exe_bin = getServerDir() + "/nginx/sbin/nginx"
|
||||
@@ -156,18 +156,24 @@ def initDreplace():
|
||||
service_path = os.path.dirname(os.getcwd())
|
||||
|
||||
initD_path = getServerDir() + '/init.d'
|
||||
|
||||
# Openresty is not installed
|
||||
if not os.path.exists(getServerDir()):
|
||||
print "ok"
|
||||
exit(0)
|
||||
|
||||
file_bin = initD_path + '/' + getPluginName()
|
||||
if not os.path.exists(initD_path):
|
||||
os.mkdir(initD_path)
|
||||
file_bin = initD_path + '/' + getPluginName()
|
||||
|
||||
# initd replace
|
||||
content = public.readFile(file_tpl)
|
||||
content = content.replace('{$SERVER_PATH}', service_path)
|
||||
public.writeFile(file_bin, content)
|
||||
public.execShell('chmod +x ' + file_bin)
|
||||
# initd replace
|
||||
content = mw.readFile(file_tpl)
|
||||
content = content.replace('{$SERVER_PATH}', service_path)
|
||||
mw.writeFile(file_bin, content)
|
||||
mw.execShell('chmod +x ' + file_bin)
|
||||
|
||||
# config replace
|
||||
confReplace()
|
||||
# config replace
|
||||
confReplace()
|
||||
|
||||
# make nginx vhost or other
|
||||
makeConf()
|
||||
@@ -176,7 +182,8 @@ def initDreplace():
|
||||
|
||||
|
||||
def status():
|
||||
data = public.execShell("ps -ef|grep nginx |grep -v grep | grep -v python | awk '{print $2}'")
|
||||
data = mw.execShell(
|
||||
"ps -ef|grep nginx |grep -v grep | grep -v python | awk '{print $2}'")
|
||||
if data[0] == '':
|
||||
return 'stop'
|
||||
return 'start'
|
||||
@@ -184,7 +191,7 @@ def status():
|
||||
|
||||
def start():
|
||||
file = initDreplace()
|
||||
data = public.execShell(file + ' start')
|
||||
data = mw.execShell(file + ' start')
|
||||
if data[1] == '':
|
||||
return 'ok'
|
||||
return data[1]
|
||||
@@ -192,7 +199,7 @@ def start():
|
||||
|
||||
def stop():
|
||||
file = initDreplace()
|
||||
data = public.execShell(file + ' stop')
|
||||
data = mw.execShell(file + ' stop')
|
||||
clearTemp()
|
||||
if data[1] == '':
|
||||
return 'ok'
|
||||
@@ -201,7 +208,7 @@ def stop():
|
||||
|
||||
def restart():
|
||||
file = initDreplace()
|
||||
data = public.execShell(file + ' restart')
|
||||
data = mw.execShell(file + ' restart')
|
||||
if data[1] == '':
|
||||
return 'ok'
|
||||
return data[1]
|
||||
@@ -209,7 +216,7 @@ def restart():
|
||||
|
||||
def reload():
|
||||
file = initDreplace()
|
||||
data = public.execShell(file + ' reload')
|
||||
data = mw.execShell(file + ' reload')
|
||||
if data[1] == '':
|
||||
return 'ok'
|
||||
return data[1]
|
||||
@@ -217,7 +224,7 @@ def reload():
|
||||
|
||||
def initdStatus():
|
||||
if not app_debug:
|
||||
if public.isAppleSystem():
|
||||
if mw.isAppleSystem():
|
||||
return "Apple Computer does not support"
|
||||
initd_bin = getInitDFile()
|
||||
if os.path.exists(initd_bin):
|
||||
@@ -228,23 +235,23 @@ def initdStatus():
|
||||
def initdInstall():
|
||||
import shutil
|
||||
if not app_debug:
|
||||
if public.isAppleSystem():
|
||||
if mw.isAppleSystem():
|
||||
return "Apple Computer does not support"
|
||||
|
||||
source_bin = initDreplace()
|
||||
initd_bin = getInitDFile()
|
||||
shutil.copyfile(source_bin, initd_bin)
|
||||
public.execShell('chmod +x ' + initd_bin)
|
||||
public.execShell('chkconfig --add ' + getPluginName())
|
||||
mw.execShell('chmod +x ' + initd_bin)
|
||||
mw.execShell('chkconfig --add ' + getPluginName())
|
||||
return 'ok'
|
||||
|
||||
|
||||
def initdUinstall():
|
||||
if not app_debug:
|
||||
if public.isAppleSystem():
|
||||
if mw.isAppleSystem():
|
||||
return "Apple Computer does not support"
|
||||
|
||||
public.execShell('chkconfig --del ' + getPluginName())
|
||||
mw.execShell('chkconfig --del ' + getPluginName())
|
||||
initd_bin = getInitDFile()
|
||||
os.remove(initd_bin)
|
||||
return 'ok'
|
||||
@@ -253,7 +260,7 @@ def initdUinstall():
|
||||
def runInfo():
|
||||
# 取Openresty负载状态
|
||||
try:
|
||||
result = public.httpGet('http://127.0.0.1/nginx_status')
|
||||
result = mw.httpGet('http://127.0.0.1/nginx_status')
|
||||
tmp = result.split()
|
||||
data = {}
|
||||
data['active'] = tmp[2]
|
||||
@@ -263,7 +270,7 @@ def runInfo():
|
||||
data['Reading'] = tmp[11]
|
||||
data['Writing'] = tmp[13]
|
||||
data['Waiting'] = tmp[15]
|
||||
return public.getJson(data)
|
||||
return mw.getJson(data)
|
||||
except Exception as e:
|
||||
return 'oprenresty not started'
|
||||
|
||||
|
||||
@@ -11,6 +11,6 @@
|
||||
"home":"http://openresty.org",
|
||||
"date":"2017-11-24",
|
||||
"pid": "1",
|
||||
"versions": ["1.11.2", "1.13.6"],
|
||||
"updates": ["1.11.2.5", "1.13.6.2"]
|
||||
"versions": ["1.11.2.5", "1.13.6.2","1.15.8.3","1.19.3.1"],
|
||||
"updates": ["1.11.2.5", "1.13.6.2","1.15.8.3","1.19.3.1"]
|
||||
}
|
||||
@@ -11,22 +11,52 @@ serverPath=$(dirname "$rootPath")
|
||||
action=$1
|
||||
type=$2
|
||||
|
||||
VERSION=$2
|
||||
install_tmp=${rootPath}/tmp/mw_install.pl
|
||||
openrestyDir=${serverPath}/source/openresty
|
||||
|
||||
if id www &> /dev/null ;then
|
||||
echo "www UID is `id -u www`"
|
||||
echo "www Shell is `grep "^www:" /etc/passwd |cut -d':' -f7 `"
|
||||
else
|
||||
groupadd www
|
||||
useradd -g www -s /sbin/nologin www
|
||||
# useradd -g www -s /sbin/nologin www
|
||||
useradd -g www -s /bin/bash www
|
||||
fi
|
||||
|
||||
if [ "${2}" == "" ];then
|
||||
echo '缺少安装脚本...' > $install_tmp
|
||||
exit 0
|
||||
fi
|
||||
Install_openresty()
|
||||
{
|
||||
mkdir -p ${openrestyDir}
|
||||
echo '正在安装脚本文件...' > $install_tmp
|
||||
|
||||
if [ ! -d $curPath/versions/$2 ];then
|
||||
echo '缺少安装脚本2...' > $install_tmp
|
||||
exit 0
|
||||
if [ ! -f ${openrestyDir}/openresty-${VERSION}.tar.gz ];then
|
||||
wget -O ${openrestyDir}/openresty-${VERSION}.tar.gz https://openresty.org/download/openresty-${VERSION}.tar.gz
|
||||
fi
|
||||
|
||||
|
||||
cd ${openrestyDir} && tar -zxvf openresty-${VERSION}.tar.gz
|
||||
|
||||
# --with-openssl=$serverPath/source/lib/openssl-1.0.2q
|
||||
cd ${openrestyDir}/openresty-${VERSION} && ./configure --prefix=$serverPath/openresty \
|
||||
--with-http_v2_module \
|
||||
--with-http_ssl_module \
|
||||
--with-http_slice_module \
|
||||
--with-http_stub_status_module && make && make install && \
|
||||
echo "${VERSION}" > $serverPath/openresty/version.pl
|
||||
|
||||
|
||||
echo '安装完成' > $install_tmp
|
||||
}
|
||||
|
||||
Uninstall_openresty()
|
||||
{
|
||||
rm -rf $serverPath/openresty
|
||||
echo '卸载完成' > $install_tmp
|
||||
}
|
||||
|
||||
action=$1
|
||||
if [ "${1}" == 'install' ];then
|
||||
Install_openresty
|
||||
else
|
||||
Uninstall_openresty
|
||||
fi
|
||||
|
||||
sh -x $curPath/versions/$2/install.sh $1
|
||||
|
||||
@@ -1,47 +0,0 @@
|
||||
#!/bin/bash
|
||||
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
|
||||
export PATH
|
||||
|
||||
curPath=`pwd`
|
||||
rootPath=$(dirname "$curPath")
|
||||
rootPath=$(dirname "$rootPath")
|
||||
serverPath=$(dirname "$rootPath")
|
||||
|
||||
|
||||
install_tmp=${rootPath}/tmp/mw_install.pl
|
||||
openrestyDir=${serverPath}/source/openresty
|
||||
|
||||
Install_openresty()
|
||||
{
|
||||
mkdir -p ${openrestyDir}
|
||||
echo '正在安装脚本文件...' > $install_tmp
|
||||
|
||||
if [ ! -f ${openrestyDir}/openresty-1.11.2.5.tar.gz ];then
|
||||
wget -O ${openrestyDir}/openresty-1.11.2.5.tar.gz https://openresty.org/download/openresty-1.11.2.5.tar.gz
|
||||
fi
|
||||
|
||||
|
||||
cd ${openrestyDir} && tar -zxvf openresty-1.11.2.5.tar.gz
|
||||
|
||||
cd ${openrestyDir}/openresty-1.11.2.5 && ./configure --prefix=$serverPath/openresty \
|
||||
--with-http_v2_module \
|
||||
--with-openssl=$serverPath/source/lib/openssl-1.0.2q \
|
||||
--with-http_stub_status_module && make && make install && \
|
||||
echo '1.11.2' > $serverPath/openresty/version.pl
|
||||
|
||||
|
||||
echo '安装完成' > $install_tmp
|
||||
}
|
||||
|
||||
Uninstall_openresty()
|
||||
{
|
||||
rm -rf $serverPath/openresty
|
||||
echo '卸载完成' > $install_tmp
|
||||
}
|
||||
|
||||
action=$1
|
||||
if [ "${1}" == 'install' ];then
|
||||
Install_openresty
|
||||
else
|
||||
Uninstall_openresty
|
||||
fi
|
||||
@@ -1,45 +0,0 @@
|
||||
#!/bin/bash
|
||||
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
|
||||
export PATH
|
||||
|
||||
curPath=`pwd`
|
||||
rootPath=$(dirname "$curPath")
|
||||
rootPath=$(dirname "$rootPath")
|
||||
serverPath=$(dirname "$rootPath")
|
||||
|
||||
install_tmp=${rootPath}/tmp/mw_install.pl
|
||||
|
||||
openrestyDir=${serverPath}/source/openresty
|
||||
|
||||
Install_openresty()
|
||||
{
|
||||
mkdir -p ${openrestyDir}
|
||||
echo '正在安装脚本文件...' > $install_tmp
|
||||
|
||||
if [ ! -f ${openrestyDir}/openresty-1.13.6.2.tar.gz ];then
|
||||
wget -O ${openrestyDir}/openresty-1.13.6.2.tar.gz https://openresty.org/download/openresty-1.13.6.2.tar.gz
|
||||
fi
|
||||
|
||||
cd ${openrestyDir} && tar -zxvf openresty-1.13.6.2.tar.gz
|
||||
|
||||
cd ${openrestyDir}/openresty-1.13.6.2 && ./configure --prefix=$serverPath/openresty \
|
||||
--with-http_v2_module \
|
||||
--with-openssl=$serverPath/source/lib/openssl-1.0.2q \
|
||||
--with-http_stub_status_module \
|
||||
&& make && make install && \
|
||||
echo '1.13.6' > $serverPath/openresty/version.pl
|
||||
|
||||
echo '安装完成' > $install_tmp
|
||||
}
|
||||
|
||||
Uninstall_openresty()
|
||||
{
|
||||
rm -rf $serverPath/openresty
|
||||
echo '卸载完成' > $install_tmp
|
||||
}
|
||||
action=$1
|
||||
if [ "${1}" == 'install' ];then
|
||||
Install_openresty
|
||||
else
|
||||
Uninstall_openresty
|
||||
fi
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
define('XHProf_Name', 'mdd');
|
||||
|
||||
/**
|
||||
* xhprof 配置,便于调试快速找到问题
|
||||
* author midoks@163.com
|
||||
*/
|
||||
function app_xhprof_start() {
|
||||
$root = '{$ROOT_PATH}';
|
||||
$lib = $root . '/server/xhprof/xhprof_lib/utils/xhprof_lib.php';
|
||||
if (file_exists($lib)) {
|
||||
include_once $lib;
|
||||
include_once $root . '/server/xhprof/xhprof_lib/utils/xhprof_runs.php';
|
||||
xhprof_enable();
|
||||
}
|
||||
}
|
||||
|
||||
function app_xhprof_end() {
|
||||
|
||||
$root = '{$ROOT_PATH}';
|
||||
$lib = $root . '/server/xhprof';
|
||||
if (!file_exists($lib)) {
|
||||
return;
|
||||
}
|
||||
|
||||
//保存xhprof数据
|
||||
$xhprof_data = xhprof_disable();
|
||||
$xhprof_runs = new XHProfRuns_Default();
|
||||
|
||||
$run_id = $xhprof_runs->save_run($xhprof_data, 'xhprof_foo');
|
||||
|
||||
$profiler_url = sprintf('http://{$LOCAL_IP}:5858/index.php?run=%s&source=xhprof_foo', $run_id);
|
||||
echo "<script language='javascript'>window.open('{$profiler_url}')</script>";
|
||||
// echo '<a href="' . $profiler_url . '" target="_blank">Profiler output</a>';
|
||||
|
||||
}
|
||||
|
||||
if (extension_loaded('xhprof')
|
||||
&& isset($_GET[XHProf_Name]) && $_GET[XHProf_Name] == 'ok' &&
|
||||
(!in_array($_SERVER['SCRIPT_NAME'], array('/xhprof_html/callgraph.php',
|
||||
'/xhprof_html/index.php')))) {
|
||||
app_xhprof_start();
|
||||
include_once $_SERVER['SCRIPT_FILENAME'];
|
||||
app_xhprof_end();
|
||||
exit;
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,156 @@
|
||||
<?xml version="1.0" ?>
|
||||
<configuration>
|
||||
|
||||
All relative paths in this config are relative to php's install prefix
|
||||
|
||||
<section name="global_options">
|
||||
|
||||
Pid file
|
||||
<value name="pid_file">/www/server/php/52/logs/php-fpm.pid</value>
|
||||
|
||||
Error log file
|
||||
<value name="error_log">/www/server/php/52/logs/php-fpm.log</value>
|
||||
|
||||
Log level
|
||||
<value name="log_level">notice</value>
|
||||
|
||||
When this amount of php processes exited with SIGSEGV or SIGBUS ...
|
||||
<value name="emergency_restart_threshold">10</value>
|
||||
|
||||
... in a less than this interval of time, a graceful restart will be initiated.
|
||||
Useful to work around accidental curruptions in accelerator's shared memory.
|
||||
<value name="emergency_restart_interval">1m</value>
|
||||
|
||||
Time limit on waiting child's reaction on signals from master
|
||||
<value name="process_control_timeout">5s</value>
|
||||
|
||||
Set to 'no' to debug fpm
|
||||
<value name="daemonize">yes</value>
|
||||
|
||||
</section>
|
||||
|
||||
<workers>
|
||||
|
||||
<section name="pool">
|
||||
|
||||
Name of pool. Used in logs and stats.
|
||||
<value name="name">default</value>
|
||||
|
||||
Address to accept fastcgi requests on.
|
||||
Valid syntax is 'ip.ad.re.ss:port' or just 'port' or '/path/to/unix/socket'
|
||||
<value name="listen_address">/tmp/php-cgi-52.sock</value>
|
||||
|
||||
<value name="listen_options">
|
||||
|
||||
Set listen(2) backlog
|
||||
<value name="backlog">-1</value>
|
||||
|
||||
Set permissions for unix socket, if one used.
|
||||
In Linux read/write permissions must be set in order to allow connections from web server.
|
||||
Many BSD-derrived systems allow connections regardless of permissions.
|
||||
<value name="owner">www</value>
|
||||
<value name="group">www</value>
|
||||
<value name="mode">0666</value>
|
||||
</value>
|
||||
|
||||
Additional php.ini defines, specific to this pool of workers.
|
||||
<value name="php_defines">
|
||||
<!-- <value name="sendmail_path">/usr/sbin/sendmail -t -i</value> -->
|
||||
<!-- <value name="display_errors">0</value> -->
|
||||
</value>
|
||||
|
||||
Unix user of processes
|
||||
<value name="user">www</value>
|
||||
|
||||
Unix group of processes
|
||||
<value name="group">www</value>
|
||||
|
||||
Process manager settings
|
||||
<value name="pm">
|
||||
|
||||
Sets style of controling worker process count.
|
||||
Valid values are 'static' and 'apache-like'
|
||||
<value name="style">static</value>
|
||||
|
||||
Sets the limit on the number of simultaneous requests that will be served.
|
||||
Equivalent to Apache MaxClients directive.
|
||||
Equivalent to PHP_FCGI_CHILDREN environment in original php.fcgi
|
||||
Used with any pm_style.
|
||||
<value name="max_children">5</value>
|
||||
|
||||
Settings group for 'apache-like' pm style
|
||||
<value name="apache_like">
|
||||
|
||||
Sets the number of server processes created on startup.
|
||||
Used only when 'apache-like' pm_style is selected
|
||||
<value name="StartServers">20</value>
|
||||
|
||||
Sets the desired minimum number of idle server processes.
|
||||
Used only when 'apache-like' pm_style is selected
|
||||
<value name="MinSpareServers">5</value>
|
||||
|
||||
Sets the desired maximum number of idle server processes.
|
||||
Used only when 'apache-like' pm_style is selected
|
||||
<value name="MaxSpareServers">35</value>
|
||||
|
||||
</value>
|
||||
|
||||
</value>
|
||||
|
||||
The timeout (in seconds) for serving a single request after which the worker process will be terminated
|
||||
Should be used when 'max_execution_time' ini option does not stop script execution for some reason
|
||||
'0s' means 'off'
|
||||
<value name="request_terminate_timeout">0s</value>
|
||||
|
||||
The timeout (in seconds) for serving of single request after which a php backtrace will be dumped to slow.log file
|
||||
'0s' means 'off'
|
||||
<value name="request_slowlog_timeout">0s</value>
|
||||
|
||||
The log file for slow requests
|
||||
<value name="slowlog">logs/slow.log</value>
|
||||
|
||||
Set open file desc rlimit
|
||||
<value name="rlimit_files">1024</value>
|
||||
|
||||
Set max core size rlimit
|
||||
<value name="rlimit_core">0</value>
|
||||
|
||||
Chroot to this directory at the start, absolute path
|
||||
<value name="chroot"></value>
|
||||
|
||||
Chdir to this directory at the start, absolute path
|
||||
<value name="chdir"></value>
|
||||
|
||||
Redirect workers' stdout and stderr into main error log.
|
||||
If not set, they will be redirected to /dev/null, according to FastCGI specs
|
||||
<value name="catch_workers_output">yes</value>
|
||||
|
||||
How much requests each process should execute before respawn.
|
||||
Useful to work around memory leaks in 3rd party libraries.
|
||||
For endless request processing please specify 0
|
||||
Equivalent to PHP_FCGI_MAX_REQUESTS
|
||||
<value name="max_requests">500</value>
|
||||
|
||||
Comma separated list of ipv4 addresses of FastCGI clients that allowed to connect.
|
||||
Equivalent to FCGI_WEB_SERVER_ADDRS environment in original php.fcgi (5.2.2+)
|
||||
Makes sense only with AF_INET listening socket.
|
||||
<value name="allowed_clients">127.0.0.1</value>
|
||||
|
||||
Pass environment variables like LD_LIBRARY_PATH
|
||||
All $VARIABLEs are taken from current environment
|
||||
<value name="environment">
|
||||
<value name="HOSTNAME">$HOSTNAME</value>
|
||||
<value name="PATH">/usr/local/bin:/usr/bin:/bin</value>
|
||||
<value name="TMP">/tmp</value>
|
||||
<value name="TMPDIR">/tmp</value>
|
||||
<value name="TEMP">/tmp</value>
|
||||
<value name="OSTYPE">$OSTYPE</value>
|
||||
<value name="MACHTYPE">$MACHTYPE</value>
|
||||
<value name="MALLOC_CHECK_">2</value>
|
||||
</value>
|
||||
|
||||
</section>
|
||||
|
||||
</workers>
|
||||
|
||||
</configuration>
|
||||
@@ -1,5 +1,4 @@
|
||||
|
||||
[global]
|
||||
include={$SERVER_PATH}/php/{$PHP_VERSION}/etc/php-fpm.d/*.conf
|
||||
;php_value[auto_prepend_file]={$SERVER_PATH}/md_start.php
|
||||
;php_value[auto_append_file]={$SERVER_PATH}/md_end.php
|
||||
php_value[auto_prepend_file]={$SERVER_PATH}/php/app_start.php
|
||||
@@ -34,10 +34,11 @@ default_mimetype = "text/html"
|
||||
doc_root =
|
||||
user_dir =
|
||||
enable_dl = Off
|
||||
always_populate_raw_post_data=-1
|
||||
|
||||
|
||||
file_uploads = On
|
||||
upload_tmp_dir = "/tmp"
|
||||
upload_tmp_dir = "/tmp/upload"
|
||||
upload_max_filesize = 2M
|
||||
max_file_uploads = 20
|
||||
|
||||
@@ -45,7 +46,7 @@ allow_url_fopen = On
|
||||
allow_url_include = Off
|
||||
default_socket_timeout = 60
|
||||
|
||||
disable_functions = exec,passthru,shell_exec,system,proc_open,popen,parse_ini_file,show_source
|
||||
disable_functions = exec,passthru,shell_exec,system,popen,parse_ini_file,show_source
|
||||
|
||||
[CLI Server]
|
||||
cli_server.color = On
|
||||
|
||||
@@ -33,6 +33,7 @@ default_mimetype = "text/html"
|
||||
doc_root =
|
||||
user_dir =
|
||||
enable_dl = Off
|
||||
always_populate_raw_post_data=-1
|
||||
|
||||
|
||||
file_uploads = On
|
||||
@@ -44,7 +45,7 @@ allow_url_fopen = On
|
||||
allow_url_include = Off
|
||||
default_socket_timeout = 60
|
||||
|
||||
disable_functions = exec,passthru,shell_exec,system,proc_open,popen,parse_ini_file,show_source
|
||||
disable_functions = exec,passthru,shell_exec,system,popen,parse_ini_file,show_source
|
||||
|
||||
[CLI Server]
|
||||
cli_server.color = On
|
||||
|
||||
@@ -0,0 +1,207 @@
|
||||
[PHP]
|
||||
engine = On
|
||||
short_open_tag = On
|
||||
asp_tags = Off
|
||||
precision = 14
|
||||
output_buffering = 4096
|
||||
zlib.output_compression = Off
|
||||
implicit_flush = Off
|
||||
unserialize_callback_func =
|
||||
serialize_precision = 17
|
||||
zend.enable_gc = On
|
||||
expose_php = On
|
||||
max_execution_time = 30
|
||||
max_input_time = 60
|
||||
memory_limit = 128M
|
||||
error_reporting = E_ALL
|
||||
display_errors = On
|
||||
display_startup_errors = On
|
||||
log_errors = On
|
||||
log_errors_max_len = 1024
|
||||
ignore_repeated_errors = Off
|
||||
ignore_repeated_source = Off
|
||||
report_memleaks = On
|
||||
html_errors = On
|
||||
variables_order = "GPCS"
|
||||
request_order = "GP"
|
||||
register_argc_argv = Off
|
||||
auto_globals_jit = On
|
||||
post_max_size = 8M
|
||||
auto_prepend_file =
|
||||
auto_append_file =
|
||||
default_mimetype = "text/html"
|
||||
doc_root =
|
||||
user_dir =
|
||||
enable_dl = Off
|
||||
always_populate_raw_post_data=-1
|
||||
|
||||
|
||||
file_uploads = On
|
||||
upload_tmp_dir = "/tmp/upload"
|
||||
upload_max_filesize = 2M
|
||||
max_file_uploads = 20
|
||||
|
||||
allow_url_fopen = On
|
||||
allow_url_include = Off
|
||||
default_socket_timeout = 60
|
||||
|
||||
disable_functions = exec,passthru,shell_exec,system,popen,parse_ini_file,show_source
|
||||
|
||||
[CLI Server]
|
||||
cli_server.color = On
|
||||
|
||||
[Date]
|
||||
date.timezone = PRC
|
||||
|
||||
[filter]
|
||||
[iconv]
|
||||
iconv.input_encoding = ISO-8859-1
|
||||
iconv.internal_encoding = ISO-8859-1
|
||||
iconv.output_encoding = ISO-8859-1
|
||||
|
||||
[intl]
|
||||
[sqlite]
|
||||
[sqlite3]
|
||||
[Pcre]
|
||||
[Pdo]
|
||||
|
||||
|
||||
[Pdo_mysql]
|
||||
pdo_mysql.cache_size = 2000
|
||||
pdo_mysql.default_socket=
|
||||
|
||||
[Phar]
|
||||
|
||||
[mail function]
|
||||
SMTP = localhost
|
||||
smtp_port = 25
|
||||
mail.add_x_header = On
|
||||
|
||||
|
||||
[SQL]
|
||||
sql.safe_mode = Off
|
||||
|
||||
[ODBC]
|
||||
odbc.allow_persistent = On
|
||||
odbc.check_persistent = On
|
||||
odbc.max_persistent = -1
|
||||
odbc.max_links = -1
|
||||
odbc.defaultlrl = 4096
|
||||
odbc.defaultbinmode = 1
|
||||
|
||||
|
||||
[Interbase]
|
||||
ibase.allow_persistent = 1
|
||||
ibase.max_persistent = -1
|
||||
ibase.max_links = -1
|
||||
ibase.timestampformat = "%Y-%m-%d %H:%M:%S"
|
||||
ibase.dateformat = "%Y-%m-%d"
|
||||
ibase.timeformat = "%H:%M:%S"
|
||||
|
||||
[MySQL]
|
||||
mysql.allow_local_infile = On
|
||||
mysql.allow_persistent = On
|
||||
mysql.cache_size = 2000
|
||||
mysql.max_persistent = -1
|
||||
mysql.max_links = -1
|
||||
mysql.default_port =
|
||||
mysql.default_socket =
|
||||
mysql.default_host =
|
||||
mysql.default_user =
|
||||
mysql.default_password =
|
||||
mysql.connect_timeout = 60
|
||||
mysql.trace_mode = Off
|
||||
|
||||
[MySQLi]
|
||||
mysqli.max_persistent = -1
|
||||
mysqli.allow_persistent = On
|
||||
mysqli.max_links = -1
|
||||
mysqli.cache_size = 2000
|
||||
mysqli.default_port = 3306
|
||||
mysqli.default_socket =
|
||||
mysqli.default_host =
|
||||
mysqli.default_user =
|
||||
mysqli.default_pw =
|
||||
mysqli.reconnect = Off
|
||||
|
||||
[mysqlnd]
|
||||
mysqlnd.collect_statistics = On
|
||||
mysqlnd.collect_memory_statistics = On
|
||||
|
||||
[OCI8]
|
||||
|
||||
|
||||
[PostgreSQL]
|
||||
pgsql.allow_persistent = On
|
||||
pgsql.auto_reset_persistent = Off
|
||||
pgsql.max_persistent = -1
|
||||
pgsql.max_links = -1
|
||||
pgsql.ignore_notice = 0
|
||||
pgsql.log_notice = 0
|
||||
|
||||
[Sybase-CT]
|
||||
sybct.allow_persistent = On
|
||||
sybct.max_persistent = -1
|
||||
sybct.max_links = -1
|
||||
sybct.min_server_severity = 10
|
||||
sybct.min_client_severity = 10
|
||||
|
||||
|
||||
[bcmath]
|
||||
bcmath.scale = 0
|
||||
|
||||
[browscap]
|
||||
|
||||
[Session]
|
||||
session.save_handler = files
|
||||
session.save_path = "/tmp/session"
|
||||
session.use_strict_mode = 0
|
||||
session.use_cookies = 1
|
||||
session.use_only_cookies = 1
|
||||
session.name = PHPSESSID
|
||||
session.auto_start = 0
|
||||
session.cookie_lifetime = 0
|
||||
session.cookie_path = /
|
||||
session.cookie_domain =
|
||||
session.cookie_httponly =
|
||||
session.serialize_handler = php
|
||||
session.gc_probability = 1
|
||||
session.gc_divisor = 1000
|
||||
session.gc_maxlifetime = 1440
|
||||
session.referer_check =
|
||||
session.cache_limiter = nocache
|
||||
session.cache_expire = 180
|
||||
session.use_trans_sid = 0
|
||||
session.hash_function = 0
|
||||
session.hash_bits_per_character = 5
|
||||
url_rewriter.tags = "a=href,area=href,frame=src,input=src,form=fakeentry"
|
||||
|
||||
|
||||
[MSSQL]
|
||||
mssql.allow_persistent = On
|
||||
mssql.max_persistent = -1
|
||||
mssql.max_links = -1
|
||||
mssql.min_error_severity = 10
|
||||
mssql.min_message_severity = 10
|
||||
mssql.compatibility_mode = Off
|
||||
mssql.secure_connection = Off
|
||||
|
||||
[Assertion]
|
||||
[COM]
|
||||
[mbstring]
|
||||
[gd]
|
||||
[exif]
|
||||
[Tidy]
|
||||
|
||||
tidy.clean_output = Off
|
||||
|
||||
[soap]
|
||||
soap.wsdl_cache_enabled=1
|
||||
soap.wsdl_cache_dir="/tmp"
|
||||
soap.wsdl_cache_ttl=86400
|
||||
soap.wsdl_cache_limit = 5
|
||||
|
||||
[sysvshm]
|
||||
|
||||
[ldap]
|
||||
ldap.max_links = -1
|
||||
@@ -15,6 +15,7 @@
|
||||
<p onclick="pluginLogs('php',$('.plugin_version').attr('version'),'fpm_log');">FPM日志</p>
|
||||
<p onclick="pluginLogs('php',$('.plugin_version').attr('version'),'fpm_slow_log');">慢日志</p>
|
||||
<p onclick="getPhpinfo($('.plugin_version').attr('version'));">PHPIFNO</p>
|
||||
<p onclick="pluginConfig('php',$('.plugin_version').attr('version'),'app_start');">预加载脚本</p>
|
||||
</div>
|
||||
<div class="bt-w-con pd15">
|
||||
<div class="soft-man-con"></div>
|
||||
|
||||
+145
-109
@@ -14,10 +14,10 @@ sys.setdefaultencoding('utf8')
|
||||
sys.path.append(os.getcwd() + "/class/core")
|
||||
sys.path.append("/usr/local/lib/python2.7/site-packages")
|
||||
|
||||
import public
|
||||
import mw
|
||||
|
||||
app_debug = False
|
||||
if public.isAppleSystem():
|
||||
if mw.isAppleSystem():
|
||||
app_debug = True
|
||||
|
||||
|
||||
@@ -26,11 +26,11 @@ def getPluginName():
|
||||
|
||||
|
||||
def getPluginDir():
|
||||
return public.getPluginDir() + '/' + getPluginName()
|
||||
return mw.getPluginDir() + '/' + getPluginName()
|
||||
|
||||
|
||||
def getServerDir():
|
||||
return public.getServerDir() + '/' + getPluginName()
|
||||
return mw.getServerDir() + '/' + getPluginName()
|
||||
|
||||
|
||||
def getInitDFile(version):
|
||||
@@ -59,8 +59,8 @@ def getArgs():
|
||||
def checkArgs(data, ck=[]):
|
||||
for i in range(len(ck)):
|
||||
if not ck[i] in data:
|
||||
return (False, public.returnJson(False, '参数:(' + ck[i] + ')没有!'))
|
||||
return (True, public.returnJson(True, 'ok'))
|
||||
return (False, mw.returnJson(False, '参数:(' + ck[i] + ')没有!'))
|
||||
return (True, mw.returnJson(True, 'ok'))
|
||||
|
||||
|
||||
def getConf(version):
|
||||
@@ -71,20 +71,21 @@ def getConf(version):
|
||||
def status(version):
|
||||
cmd = "ps -ef|grep 'php/" + version + \
|
||||
"' |grep -v grep | grep -v python | awk '{print $2}'"
|
||||
data = public.execShell(cmd)
|
||||
data = mw.execShell(cmd)
|
||||
if data[0] == '':
|
||||
return 'stop'
|
||||
return 'start'
|
||||
|
||||
|
||||
def contentReplace(content, version):
|
||||
service_path = public.getServerDir()
|
||||
content = content.replace('{$ROOT_PATH}', public.getRootDir())
|
||||
service_path = mw.getServerDir()
|
||||
content = content.replace('{$ROOT_PATH}', mw.getRootDir())
|
||||
content = content.replace('{$SERVER_PATH}', service_path)
|
||||
content = content.replace('{$PHP_VERSION}', version)
|
||||
content = content.replace('{$LOCAL_IP}', mw.getLocalIp())
|
||||
|
||||
if public.isAppleSystem():
|
||||
# user = public.execShell(
|
||||
if mw.isAppleSystem():
|
||||
# user = mw.execShell(
|
||||
# "who | sed -n '2, 1p' |awk '{print $1}'")[0].strip()
|
||||
content = content.replace('{$PHP_USER}', 'nobody')
|
||||
content = content.replace('{$PHP_GROUP}', 'nobody')
|
||||
@@ -112,47 +113,62 @@ def contentReplace(content, version):
|
||||
|
||||
|
||||
def makeOpenrestyConf():
|
||||
phpversions = ['00', '53', '54', '55', '56', '70', '71', '72', '73', '74']
|
||||
if public.isInstalledWeb():
|
||||
sdir = public.getServerDir()
|
||||
phpversions = ['00', '52', '53', '54', '55', '56',
|
||||
'70', '71', '72', '73', '74', '80']
|
||||
if mw.isInstalledWeb():
|
||||
sdir = mw.getServerDir()
|
||||
d_pathinfo = sdir + '/openresty/nginx/conf/pathinfo.conf'
|
||||
if not os.path.exists(d_pathinfo):
|
||||
s_pathinfo = getPluginDir() + '/conf/pathinfo.conf'
|
||||
shutil.copyfile(s_pathinfo, d_pathinfo)
|
||||
|
||||
info = getPluginDir() + '/info.json'
|
||||
content = public.readFile(info)
|
||||
content = mw.readFile(info)
|
||||
content = json.loads(content)
|
||||
versions = content['versions']
|
||||
tpl = getPluginDir() + '/conf/enable-php.conf'
|
||||
tpl_content = public.readFile(tpl)
|
||||
tpl_content = mw.readFile(tpl)
|
||||
for x in phpversions:
|
||||
dfile = sdir + '/openresty/nginx/conf/enable-php-' + x + '.conf'
|
||||
if not os.path.exists(dfile):
|
||||
if x == '00':
|
||||
public.writeFile(dfile, '')
|
||||
mw.writeFile(dfile, '')
|
||||
else:
|
||||
w_content = contentReplace(tpl_content, x)
|
||||
public.writeFile(dfile, w_content)
|
||||
mw.writeFile(dfile, w_content)
|
||||
|
||||
# php-fpm status
|
||||
for version in phpversions:
|
||||
dfile = sdir + '/openresty/nginx/conf/php_status/phpfpm_status_' + version + '.conf'
|
||||
tpl = getPluginDir() + '/conf/phpfpm_status.conf'
|
||||
if not os.path.exists(dfile):
|
||||
content = public.readFile(tpl)
|
||||
content = mw.readFile(tpl)
|
||||
content = contentReplace(content, version)
|
||||
public.writeFile(dfile, content)
|
||||
public.restartWeb()
|
||||
mw.writeFile(dfile, content)
|
||||
mw.restartWeb()
|
||||
|
||||
|
||||
def phpPrependFile(version):
|
||||
app_start = getServerDir() + '/app_start.php'
|
||||
if not os.path.exists(app_start):
|
||||
tpl = getPluginDir() + '/conf/app_start.php'
|
||||
content = mw.readFile(tpl)
|
||||
content = contentReplace(content, version)
|
||||
mw.writeFile(app_start, content)
|
||||
|
||||
|
||||
def phpFpmReplace(version):
|
||||
desc_php_fpm = getServerDir() + '/' + version + '/etc/php-fpm.conf'
|
||||
if not os.path.exists(desc_php_fpm):
|
||||
tpl_php_fpm = getPluginDir() + '/conf/php-fpm.conf'
|
||||
content = public.readFile(tpl_php_fpm)
|
||||
content = mw.readFile(tpl_php_fpm)
|
||||
content = contentReplace(content, version)
|
||||
public.writeFile(desc_php_fpm, content)
|
||||
mw.writeFile(desc_php_fpm, content)
|
||||
else:
|
||||
if version == '52':
|
||||
tpl_php_fpm = tpl_php_fpm = getPluginDir() + '/conf/php-fpm-52.conf'
|
||||
content = mw.readFile(tpl_php_fpm)
|
||||
mw.writeFile(desc_php_fpm, content)
|
||||
|
||||
|
||||
def phpFpmWwwReplace(version):
|
||||
@@ -164,16 +180,20 @@ def phpFpmWwwReplace(version):
|
||||
service_php_fpmwww = service_php_fpm_dir + '/www.conf'
|
||||
if not os.path.exists(service_php_fpmwww):
|
||||
tpl_php_fpmwww = getPluginDir() + '/conf/www.conf'
|
||||
content = public.readFile(tpl_php_fpmwww)
|
||||
content = mw.readFile(tpl_php_fpmwww)
|
||||
content = contentReplace(content, version)
|
||||
public.writeFile(service_php_fpmwww, content)
|
||||
mw.writeFile(service_php_fpmwww, content)
|
||||
|
||||
|
||||
def makePhpIni(version):
|
||||
d_ini = public.getServerDir() + '/php/' + version + '/etc/php.ini'
|
||||
d_ini = mw.getServerDir() + '/php/' + version + '/etc/php.ini'
|
||||
if not os.path.exists(d_ini):
|
||||
s_ini = getPluginDir() + '/conf/php' + version[0:1] + '.ini'
|
||||
shutil.copyfile(s_ini, d_ini)
|
||||
# shutil.copyfile(s_ini, d_ini)
|
||||
content = mw.readFile(s_ini)
|
||||
if version == '52':
|
||||
content = content + "auto_prepend_file=/www/server/php/app_start.php"
|
||||
mw.writeFile(d_ini, content)
|
||||
|
||||
|
||||
def initReplace(version):
|
||||
@@ -188,26 +208,36 @@ def initReplace(version):
|
||||
if not os.path.exists(file_bin):
|
||||
file_tpl = getPluginDir() + '/init.d/php.tpl'
|
||||
|
||||
content = public.readFile(file_tpl)
|
||||
if version == '52':
|
||||
file_tpl = getPluginDir() + '/init.d/php52.tpl'
|
||||
|
||||
content = mw.readFile(file_tpl)
|
||||
content = contentReplace(content, version)
|
||||
|
||||
public.writeFile(file_bin, content)
|
||||
public.execShell('chmod +x ' + file_bin)
|
||||
mw.writeFile(file_bin, content)
|
||||
mw.execShell('chmod +x ' + file_bin)
|
||||
|
||||
phpPrependFile(version)
|
||||
phpFpmWwwReplace(version)
|
||||
phpFpmReplace(version)
|
||||
|
||||
session_path = '/tmp/session'
|
||||
if not os.path.exists(session_path):
|
||||
os.mkdir(session_path)
|
||||
if not public.isAppleSystem():
|
||||
public.execShell('chown -R www:www ' + session_path)
|
||||
if not mw.isAppleSystem():
|
||||
mw.execShell('chown -R www:www ' + session_path)
|
||||
|
||||
upload_path = '/tmp/upload'
|
||||
if not os.path.exists(upload_path):
|
||||
os.mkdir(upload_path)
|
||||
if not mw.isAppleSystem():
|
||||
mw.execShell('chown -R www:www ' + upload_path)
|
||||
return file_bin
|
||||
|
||||
|
||||
def phpOp(version, method):
|
||||
file = initReplace(version)
|
||||
data = public.execShell(file + ' ' + method)
|
||||
data = mw.execShell(file + ' ' + method)
|
||||
if data[1] == '':
|
||||
return 'ok'
|
||||
return data[1]
|
||||
@@ -231,7 +261,7 @@ def reload(version):
|
||||
|
||||
def initdStatus(version):
|
||||
if not app_debug:
|
||||
if public.isAppleSystem():
|
||||
if mw.isAppleSystem():
|
||||
return "Apple Computer does not support"
|
||||
initd_bin = getInitDFile(version)
|
||||
if os.path.exists(initd_bin):
|
||||
@@ -242,23 +272,23 @@ def initdStatus(version):
|
||||
def initdInstall(version):
|
||||
import shutil
|
||||
if not app_debug:
|
||||
if public.isAppleSystem():
|
||||
if mw.isAppleSystem():
|
||||
return "Apple Computer does not support"
|
||||
|
||||
source_bin = initReplace(version)
|
||||
initd_bin = getInitDFile(version)
|
||||
shutil.copyfile(source_bin, initd_bin)
|
||||
public.execShell('chmod +x ' + initd_bin)
|
||||
public.execShell('chkconfig --add ' + getPluginName() + version)
|
||||
mw.execShell('chmod +x ' + initd_bin)
|
||||
mw.execShell('chkconfig --add ' + getPluginName() + version)
|
||||
return 'ok'
|
||||
|
||||
|
||||
def initdUinstall(version):
|
||||
if not app_debug:
|
||||
if public.isAppleSystem():
|
||||
if mw.isAppleSystem():
|
||||
return "Apple Computer does not support"
|
||||
|
||||
public.execShell('chkconfig --del ' + getPluginName())
|
||||
mw.execShell('chkconfig --del ' + getPluginName())
|
||||
initd_bin = getInitDFile(version)
|
||||
os.remove(initd_bin)
|
||||
return 'ok'
|
||||
@@ -289,7 +319,7 @@ def getPhpConf(version):
|
||||
{'name': 'cgi.fix_pathinfo', 'type': 0, 'ps': '是否开启pathinfo'},
|
||||
{'name': 'date.timezone', 'type': 3, 'ps': '时区'}
|
||||
]
|
||||
phpini = public.readFile(getServerDir() + '/' + version + '/etc/php.ini')
|
||||
phpini = mw.readFile(getServerDir() + '/' + version + '/etc/php.ini')
|
||||
result = []
|
||||
for g in gets:
|
||||
rep = g['name'] + '\s*=\s*([0-9A-Za-z_& ~]+)(\s*;?|\r?\n)'
|
||||
@@ -298,7 +328,7 @@ def getPhpConf(version):
|
||||
continue
|
||||
g['value'] = tmp.groups()[0]
|
||||
result.append(g)
|
||||
return public.getJson(result)
|
||||
return mw.getJson(result)
|
||||
|
||||
|
||||
def submitPhpConf(version):
|
||||
@@ -308,22 +338,22 @@ def submitPhpConf(version):
|
||||
'default_socket_timeout', 'error_reporting']
|
||||
args = getArgs()
|
||||
filename = getServerDir() + '/' + version + '/etc/php.ini'
|
||||
phpini = public.readFile(filename)
|
||||
phpini = mw.readFile(filename)
|
||||
for g in gets:
|
||||
if g in args:
|
||||
rep = g + '\s*=\s*(.+)\r?\n'
|
||||
val = g + ' = ' + args[g] + '\n'
|
||||
phpini = re.sub(rep, val, phpini)
|
||||
public.writeFile(filename, phpini)
|
||||
public.execShell(getServerDir() + '/init.d/php' + version + ' reload')
|
||||
return public.returnJson(True, '设置成功')
|
||||
mw.writeFile(filename, phpini)
|
||||
mw.execShell(getServerDir() + '/init.d/php' + version + ' reload')
|
||||
return mw.returnJson(True, '设置成功')
|
||||
|
||||
|
||||
def getLimitConf(version):
|
||||
fileini = getServerDir() + "/" + version + "/etc/php.ini"
|
||||
phpini = public.readFile(fileini)
|
||||
phpini = mw.readFile(fileini)
|
||||
filefpm = getServerDir() + "/" + version + "/etc/php-fpm.conf"
|
||||
phpfpm = public.readFile(filefpm)
|
||||
phpfpm = mw.readFile(filefpm)
|
||||
|
||||
# print fileini, filefpm
|
||||
data = {}
|
||||
@@ -352,7 +382,7 @@ def getLimitConf(version):
|
||||
except:
|
||||
data['pathinfo'] = False
|
||||
|
||||
return public.getJson(data)
|
||||
return mw.getJson(data)
|
||||
|
||||
|
||||
def setMaxTime(version):
|
||||
@@ -363,22 +393,22 @@ def setMaxTime(version):
|
||||
|
||||
time = args['time']
|
||||
if int(time) < 30 or int(time) > 86400:
|
||||
return public.returnJson(False, '请填写30-86400间的值!')
|
||||
return mw.returnJson(False, '请填写30-86400间的值!')
|
||||
|
||||
filefpm = getServerDir() + "/" + version + "/etc/php-fpm.conf"
|
||||
conf = public.readFile(filefpm)
|
||||
conf = mw.readFile(filefpm)
|
||||
rep = "request_terminate_timeout\s*=\s*([0-9]+)\n"
|
||||
conf = re.sub(rep, "request_terminate_timeout = " + time + "\n", conf)
|
||||
public.writeFile(filefpm, conf)
|
||||
mw.writeFile(filefpm, conf)
|
||||
|
||||
fileini = getServerDir() + "/" + version + "/etc/php.ini"
|
||||
phpini = public.readFile(fileini)
|
||||
phpini = mw.readFile(fileini)
|
||||
rep = "max_execution_time\s*=\s*([0-9]+)\r?\n"
|
||||
phpini = re.sub(rep, "max_execution_time = " + time + "\n", phpini)
|
||||
rep = "max_input_time\s*=\s*([0-9]+)\r?\n"
|
||||
phpini = re.sub(rep, "max_input_time = " + time + "\n", phpini)
|
||||
public.writeFile(fileini, phpini)
|
||||
return public.returnJson(True, '设置成功!')
|
||||
mw.writeFile(fileini, phpini)
|
||||
return mw.returnJson(True, '设置成功!')
|
||||
|
||||
|
||||
def setMaxSize(version):
|
||||
@@ -387,25 +417,25 @@ def setMaxSize(version):
|
||||
return 'missing time args!'
|
||||
max = args['max']
|
||||
if int(max) < 2:
|
||||
return public.returnJson(False, '上传大小限制不能小于2MB!')
|
||||
return mw.returnJson(False, '上传大小限制不能小于2MB!')
|
||||
|
||||
path = getServerDir() + '/' + version + '/etc/php.ini'
|
||||
conf = public.readFile(path)
|
||||
conf = mw.readFile(path)
|
||||
rep = u"\nupload_max_filesize\s*=\s*[0-9]+M"
|
||||
conf = re.sub(rep, u'\nupload_max_filesize = ' + max + 'M', conf)
|
||||
rep = u"\npost_max_size\s*=\s*[0-9]+M"
|
||||
conf = re.sub(rep, u'\npost_max_size = ' + max + 'M', conf)
|
||||
public.writeFile(path, conf)
|
||||
mw.writeFile(path, conf)
|
||||
|
||||
msg = public.getInfo('设置PHP-{1}最大上传大小为[{2}MB]!', (version, max,))
|
||||
public.writeLog('插件管理[PHP]', msg)
|
||||
return public.returnJson(True, '设置成功!')
|
||||
msg = mw.getInfo('设置PHP-{1}最大上传大小为[{2}MB]!', (version, max,))
|
||||
mw.writeLog('插件管理[PHP]', msg)
|
||||
return mw.returnJson(True, '设置成功!')
|
||||
|
||||
|
||||
def getFpmConfig(version):
|
||||
|
||||
filefpm = getServerDir() + '/' + version + '/etc/php-fpm.d/www.conf'
|
||||
conf = public.readFile(filefpm)
|
||||
conf = mw.readFile(filefpm)
|
||||
data = {}
|
||||
rep = "\s*pm.max_children\s*=\s*([0-9]+)\s*"
|
||||
tmp = re.search(rep, conf).groups()
|
||||
@@ -426,7 +456,7 @@ def getFpmConfig(version):
|
||||
rep = "\s*pm\s*=\s*(\w+)\s*"
|
||||
tmp = re.search(rep, conf).groups()
|
||||
data['pm'] = tmp[0]
|
||||
return public.getJson(data)
|
||||
return mw.getJson(data)
|
||||
|
||||
|
||||
def setFpmConfig(version):
|
||||
@@ -442,7 +472,7 @@ def setFpmConfig(version):
|
||||
pm = args['pm']
|
||||
|
||||
file = getServerDir() + '/' + version + '/etc/php-fpm.d/www.conf'
|
||||
conf = public.readFile(file)
|
||||
conf = mw.readFile(file)
|
||||
|
||||
rep = "\s*pm.max_children\s*=\s*([0-9]+)\s*"
|
||||
conf = re.sub(rep, "\npm.max_children = " + max_children, conf)
|
||||
@@ -461,91 +491,91 @@ def setFpmConfig(version):
|
||||
rep = "\s*pm\s*=\s*(\w+)\s*"
|
||||
conf = re.sub(rep, "\npm = " + pm + "\n", conf)
|
||||
|
||||
public.writeFile(file, conf)
|
||||
mw.writeFile(file, conf)
|
||||
reload(version)
|
||||
|
||||
msg = public.getInfo('设置PHP-{1}并发设置,max_children={2},start_servers={3},min_spare_servers={4},max_spare_servers={5}', (version, max_children,
|
||||
start_servers, min_spare_servers, max_spare_servers,))
|
||||
public.writeLog('插件管理[PHP]', msg)
|
||||
return public.returnJson(True, '设置成功!')
|
||||
msg = mw.getInfo('设置PHP-{1}并发设置,max_children={2},start_servers={3},min_spare_servers={4},max_spare_servers={5}', (version, max_children,
|
||||
start_servers, min_spare_servers, max_spare_servers,))
|
||||
mw.writeLog('插件管理[PHP]', msg)
|
||||
return mw.returnJson(True, '设置成功!')
|
||||
|
||||
|
||||
def checkFpmStatusFile(version):
|
||||
if public.isInstalledWeb():
|
||||
sdir = public.getServerDir()
|
||||
if mw.isInstalledWeb():
|
||||
sdir = mw.getServerDir()
|
||||
dfile = sdir + '/openresty/nginx/conf/php_status/phpfpm_status_' + version + '.conf'
|
||||
if not os.path.exists(dfile):
|
||||
tpl = getPluginDir() + '/conf/phpfpm_status.conf'
|
||||
content = public.readFile(tpl)
|
||||
content = mw.readFile(tpl)
|
||||
content = contentReplace(content, version)
|
||||
public.writeFile(dfile, content)
|
||||
public.restartWeb()
|
||||
mw.writeFile(dfile, content)
|
||||
mw.restartWeb()
|
||||
|
||||
|
||||
def getFpmStatus(version):
|
||||
checkFpmStatusFile(version)
|
||||
result = public.httpGet(
|
||||
result = mw.httpGet(
|
||||
'http://127.0.0.1/phpfpm_status_' + version + '?json')
|
||||
tmp = json.loads(result)
|
||||
fTime = time.localtime(int(tmp['start time']))
|
||||
tmp['start time'] = time.strftime('%Y-%m-%d %H:%M:%S', fTime)
|
||||
return public.getJson(tmp)
|
||||
return mw.getJson(tmp)
|
||||
|
||||
|
||||
def getDisableFunc(version):
|
||||
filename = public.getServerDir() + '/php/' + version + '/etc/php.ini'
|
||||
filename = mw.getServerDir() + '/php/' + version + '/etc/php.ini'
|
||||
if not os.path.exists(filename):
|
||||
return public.returnJson(False, '指定PHP版本不存在!')
|
||||
return mw.returnJson(False, '指定PHP版本不存在!')
|
||||
|
||||
phpini = public.readFile(filename)
|
||||
phpini = mw.readFile(filename)
|
||||
data = {}
|
||||
rep = "disable_functions\s*=\s{0,1}(.*)\n"
|
||||
tmp = re.search(rep, phpini).groups()
|
||||
data['disable_functions'] = tmp[0]
|
||||
return public.getJson(data)
|
||||
return mw.getJson(data)
|
||||
|
||||
|
||||
def setDisableFunc(version):
|
||||
filename = public.getServerDir() + '/php/' + version + '/etc/php.ini'
|
||||
filename = mw.getServerDir() + '/php/' + version + '/etc/php.ini'
|
||||
if not os.path.exists(filename):
|
||||
return public.returnJson(False, '指定PHP版本不存在!')
|
||||
return mw.returnJson(False, '指定PHP版本不存在!')
|
||||
|
||||
args = getArgs()
|
||||
disable_functions = args['disable_functions']
|
||||
|
||||
phpini = public.readFile(filename)
|
||||
phpini = mw.readFile(filename)
|
||||
rep = "disable_functions\s*=\s*.*\n"
|
||||
phpini = re.sub(rep, 'disable_functions = ' +
|
||||
disable_functions + "\n", phpini)
|
||||
|
||||
msg = public.getInfo('修改PHP-{1}的禁用函数为[{2}]', (version, disable_functions,))
|
||||
public.writeLog('插件管理[PHP]', msg)
|
||||
public.writeFile(filename, phpini)
|
||||
msg = mw.getInfo('修改PHP-{1}的禁用函数为[{2}]', (version, disable_functions,))
|
||||
mw.writeLog('插件管理[PHP]', msg)
|
||||
mw.writeFile(filename, phpini)
|
||||
reload(version)
|
||||
return public.returnJson(True, '设置成功!')
|
||||
return mw.returnJson(True, '设置成功!')
|
||||
|
||||
|
||||
def checkPhpinfoFile(v):
|
||||
if public.isInstalledWeb():
|
||||
sdir = public.getServerDir()
|
||||
if mw.isInstalledWeb():
|
||||
sdir = mw.getServerDir()
|
||||
dfile = sdir + '/openresty/nginx/conf/php_status/phpinfo_' + v + '.conf'
|
||||
if not os.path.exists(dfile):
|
||||
tpl = getPluginDir() + '/conf/phpinfo.conf'
|
||||
content = public.readFile(tpl)
|
||||
content = mw.readFile(tpl)
|
||||
content = contentReplace(content, v)
|
||||
public.writeFile(dfile, content)
|
||||
public.restartWeb()
|
||||
mw.writeFile(dfile, content)
|
||||
mw.restartWeb()
|
||||
|
||||
|
||||
def getPhpinfo(v):
|
||||
checkPhpinfoFile(v)
|
||||
sPath = public.getRootDir() + '/phpinfo/' + v
|
||||
public.execShell("rm -rf " + public.getRootDir() + '/phpinfo')
|
||||
public.execShell("mkdir -p " + sPath)
|
||||
public.writeFile(sPath + '/phpinfo.php', '<?php phpinfo(); ?>')
|
||||
sPath = mw.getRootDir() + '/phpinfo/' + v
|
||||
mw.execShell("rm -rf " + mw.getRootDir() + '/phpinfo')
|
||||
mw.execShell("mkdir -p " + sPath)
|
||||
mw.writeFile(sPath + '/phpinfo.php', '<?php phpinfo(); ?>')
|
||||
url = 'http://127.0.0.1/' + v + '/phpinfo.php'
|
||||
phpinfo = public.httpGet(url)
|
||||
os.system("rm -rf " + public.getRootDir() + '/phpinfo')
|
||||
phpinfo = mw.httpGet(url)
|
||||
os.system("rm -rf " + mw.getRootDir() + '/phpinfo')
|
||||
return phpinfo
|
||||
|
||||
|
||||
@@ -554,22 +584,22 @@ def get_php_info(args):
|
||||
|
||||
|
||||
def getLibConf(version):
|
||||
fname = public.getServerDir() + '/php/' + version + '/etc/php.ini'
|
||||
fname = mw.getServerDir() + '/php/' + version + '/etc/php.ini'
|
||||
if not os.path.exists(fname):
|
||||
return public.returnJson(False, '指定PHP版本不存在!')
|
||||
return mw.returnJson(False, '指定PHP版本不存在!')
|
||||
|
||||
phpini = public.readFile(fname)
|
||||
phpini = mw.readFile(fname)
|
||||
|
||||
libpath = getPluginDir() + '/versions/phplib.conf'
|
||||
phplib = json.loads(public.readFile(libpath))
|
||||
phplib = json.loads(mw.readFile(libpath))
|
||||
|
||||
libs = []
|
||||
tasks = public.M('tasks').where(
|
||||
tasks = mw.M('tasks').where(
|
||||
"status!=?", ('1',)).field('status,name').select()
|
||||
for lib in phplib:
|
||||
lib['task'] = '1'
|
||||
for task in tasks:
|
||||
tmp = public.getStrBetween('[', ']', task['name'])
|
||||
tmp = mw.getStrBetween('[', ']', task['name'])
|
||||
if not tmp:
|
||||
continue
|
||||
tmp1 = tmp.split('-')
|
||||
@@ -582,7 +612,7 @@ def getLibConf(version):
|
||||
else:
|
||||
lib['status'] = True
|
||||
libs.append(lib)
|
||||
return public.returnJson(True, 'OK!', libs)
|
||||
return mw.returnJson(True, 'OK!', libs)
|
||||
|
||||
|
||||
def installLib(version):
|
||||
@@ -598,8 +628,8 @@ def installLib(version):
|
||||
rettime = time.strftime('%Y-%m-%d %H:%M:%S')
|
||||
insert_info = (None, '安装[' + name + '-' + version + ']',
|
||||
'execshell', '0', rettime, execstr)
|
||||
public.M('tasks').add('id,name,type,status,addtime,execstr', insert_info)
|
||||
return public.returnJson(True, '已将下载任务添加到队列!')
|
||||
mw.M('tasks').add('id,name,type,status,addtime,execstr', insert_info)
|
||||
return mw.returnJson(True, '已将下载任务添加到队列!')
|
||||
|
||||
|
||||
def uninstallLib(version):
|
||||
@@ -612,13 +642,17 @@ def uninstallLib(version):
|
||||
execstr = "cd " + getPluginDir() + '/versions/' + version + " && /bin/bash " + \
|
||||
name + '.sh' + ' uninstall ' + version
|
||||
|
||||
data = public.execShell(execstr)
|
||||
data = mw.execShell(execstr)
|
||||
if data[0] == '' and data[1] == '':
|
||||
return public.returnJson(True, '已经卸载成功!')
|
||||
return mw.returnJson(True, '已经卸载成功!')
|
||||
else:
|
||||
return public.returnJson(False, '卸载信息![通道0]:' + data[0] + "[通道0]:" + data[1])
|
||||
return mw.returnJson(False, '卸载信息![通道0]:' + data[0] + "[通道0]:" + data[1])
|
||||
|
||||
|
||||
def getConfAppStart():
|
||||
pstart = mw.getServerDir() + '/php/app_start.php'
|
||||
return pstart
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
if len(sys.argv) < 3:
|
||||
@@ -650,6 +684,8 @@ if __name__ == "__main__":
|
||||
print fpmSlowLog(version)
|
||||
elif func == 'conf':
|
||||
print getConf(version)
|
||||
elif func == 'app_start':
|
||||
print getConfAppStart()
|
||||
elif func == 'get_php_conf':
|
||||
print getPhpConf(version)
|
||||
elif func == 'submit_php_conf':
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
"name": "php",
|
||||
"title": "PHP",
|
||||
"coexist": true,
|
||||
"versions": ["53","54","55","56","70","71","72","73","74"],
|
||||
"updates": ["5.3.17","5.4.45","5.6.36","7.0.30","7.1.33","7.2.25","7.3.12","7.4.0"],
|
||||
"versions": ["52","53","54","55","56","70","71","72","73","74","80"],
|
||||
"updates": ["5.2.17","5.3.29","5.4.45","5.6.36","7.0.30","7.1.33","7.2.32","7.3.20","7.4.8","8.0.0"],
|
||||
"tip": "soft",
|
||||
"checks": "server/php/VERSION/bin/php",
|
||||
"path": "server/php/VERSION",
|
||||
@@ -14,6 +14,6 @@
|
||||
"author": "Zend",
|
||||
"date": "2017-04-01",
|
||||
"home": "https://www.php.net",
|
||||
"type": "语言解释器",
|
||||
"type": "PHP语言解释器",
|
||||
"pid": "1"
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
#! /bin/sh
|
||||
|
||||
php_fpm_BIN=/www/server/php/52/bin/php-cgi
|
||||
php_fpm_CONF=/www/server/php/52/etc/php-fpm.conf
|
||||
php_fpm_PID=/www/server/php/52/logs/php-fpm.pid
|
||||
|
||||
|
||||
php_opts="--fpm-config $php_fpm_CONF"
|
||||
|
||||
|
||||
wait_for_pid () {
|
||||
try=0
|
||||
|
||||
while test $try -lt 35 ; do
|
||||
|
||||
case "$1" in
|
||||
'created')
|
||||
if [ -f "$2" ] ; then
|
||||
try=''
|
||||
break
|
||||
fi
|
||||
;;
|
||||
|
||||
'removed')
|
||||
if [ ! -f "$2" ] ; then
|
||||
try=''
|
||||
break
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
echo -n .
|
||||
try=`expr $try + 1`
|
||||
sleep 1
|
||||
|
||||
done
|
||||
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
echo -n "Starting php_fpm "
|
||||
|
||||
$php_fpm_BIN --fpm $php_opts
|
||||
|
||||
if [ "$?" != 0 ] ; then
|
||||
echo " failed"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
wait_for_pid created $php_fpm_PID
|
||||
|
||||
if [ -n "$try" ] ; then
|
||||
echo " failed"
|
||||
exit 1
|
||||
else
|
||||
echo " done"
|
||||
fi
|
||||
;;
|
||||
|
||||
stop)
|
||||
echo -n "Shutting down php_fpm "
|
||||
|
||||
if [ ! -r $php_fpm_PID ] ; then
|
||||
echo "warning, no pid file found - php-fpm is not running ?"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
kill -TERM `cat $php_fpm_PID`
|
||||
|
||||
wait_for_pid removed $php_fpm_PID
|
||||
|
||||
if [ -n "$try" ] ; then
|
||||
echo " failed"
|
||||
exit 1
|
||||
else
|
||||
echo " done"
|
||||
fi
|
||||
;;
|
||||
|
||||
quit)
|
||||
echo -n "Gracefully shutting down php_fpm "
|
||||
|
||||
if [ ! -r $php_fpm_PID ] ; then
|
||||
echo "warning, no pid file found - php-fpm is not running ?"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
kill -QUIT `cat $php_fpm_PID`
|
||||
|
||||
wait_for_pid removed $php_fpm_PID
|
||||
|
||||
if [ -n "$try" ] ; then
|
||||
echo " failed"
|
||||
exit 1
|
||||
else
|
||||
echo " done"
|
||||
fi
|
||||
;;
|
||||
|
||||
restart)
|
||||
$0 stop
|
||||
$0 start
|
||||
;;
|
||||
|
||||
reload)
|
||||
|
||||
echo -n "Reload service php-fpm "
|
||||
|
||||
if [ ! -r $php_fpm_PID ] ; then
|
||||
echo "warning, no pid file found - php-fpm is not running ?"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
kill -USR2 `cat $php_fpm_PID`
|
||||
|
||||
echo " done"
|
||||
;;
|
||||
|
||||
logrotate)
|
||||
|
||||
echo -n "Re-opening php-fpm log file "
|
||||
|
||||
if [ ! -r $php_fpm_PID ] ; then
|
||||
echo "warning, no pid file found - php-fpm is not running ?"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
kill -USR1 `cat $php_fpm_PID`
|
||||
|
||||
echo " done"
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "Usage: $0 {start|stop|quit|restart|reload|logrotate}"
|
||||
exit 1
|
||||
;;
|
||||
|
||||
esac
|
||||
Executable
+110
@@ -0,0 +1,110 @@
|
||||
#!/bin/bash
|
||||
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
|
||||
export PATH
|
||||
|
||||
# php 5.2.17 + eaccelerator 0.9.5.3
|
||||
# php 5.3.24 + eaccelerator 0.9.6.1
|
||||
# php 5.4.14 + eaccelerator 1.0 dev
|
||||
|
||||
|
||||
curPath=`pwd`
|
||||
rootPath=$(dirname "$curPath")
|
||||
rootPath=$(dirname "$rootPath")
|
||||
rootPath=$(dirname "$rootPath")
|
||||
rootPath=$(dirname "$rootPath")
|
||||
serverPath=$(dirname "$rootPath")
|
||||
sourcePath=${serverPath}/source/php
|
||||
|
||||
LIBNAME=eaccelerator
|
||||
LIBV=0.9.6
|
||||
sysName=`uname`
|
||||
actionType=$1
|
||||
version=$2
|
||||
extFile=$serverPath/php/${version}/lib/php/extensions/no-debug-non-zts-20060613/${LIBNAME}.so
|
||||
|
||||
if [ "$sysName" == "Darwin" ];then
|
||||
BAK='_bak'
|
||||
else
|
||||
BAK=''
|
||||
fi
|
||||
|
||||
Install_lib()
|
||||
{
|
||||
isInstall=`cat $serverPath/php/$version/etc/php.ini|grep "${LIBNAME}.so"`
|
||||
if [ "${isInstall}" != "" ];then
|
||||
echo "php-$version 已安装${LIBNAME},请选择其它版本!"
|
||||
return
|
||||
fi
|
||||
|
||||
|
||||
if [ ! -f "$extFile" ];then
|
||||
|
||||
php_lib=$sourcePath/php_lib
|
||||
mkdir -p $php_lib
|
||||
|
||||
if [ ! -d $php_lib/${LIBNAME}-${LIBV} ];then
|
||||
wget -O $php_lib/${LIBNAME}-${LIBV}.tar.gz https://github.com/eaccelerator/eaccelerator/archive/${LIBV}.tar.gz
|
||||
# wget -O $php_lib/${LIBNAME}-${LIBV}.tar.bz2 http://dl.wdlinux.cn:5180/soft/eaccelerator-0.9.6.1.tar.bz2
|
||||
cd $php_lib && tar -zxvf ${LIBNAME}-${LIBV}.tar.gz
|
||||
fi
|
||||
cd $php_lib/${LIBNAME}-${LIBV}
|
||||
|
||||
$serverPath/php/$version/bin/phpize
|
||||
./configure --with-php-config=$serverPath/php/$version/bin/php-config \
|
||||
--enable-eaccelerator=shared
|
||||
make && make install && make clean
|
||||
|
||||
fi
|
||||
|
||||
if [ ! -f "$extFile" ];then
|
||||
echo "ERROR!"
|
||||
return
|
||||
fi
|
||||
|
||||
EA_DIR=/tmp/eaccelerator
|
||||
mkdir -p $EA_DIR
|
||||
chmod 777 -R $EA_DIR
|
||||
echo "" >> $serverPath/php/$version/etc/php.ini
|
||||
echo "[${LIBNAME}]" >> $serverPath/php/$version/etc/php.ini
|
||||
echo "extension=${LIBNAME}.so" >> $serverPath/php/$version/etc/php.ini
|
||||
echo "${LIBNAME}.enable=1" >> $serverPath/php/$version/etc/php.ini
|
||||
echo "${LIBNAME}.optimizer=1" >> $serverPath/php/$version/etc/php.ini
|
||||
echo "${LIBNAME}.shm_size=64" >> $serverPath/php/$version/etc/php.ini
|
||||
echo "${LIBNAME}.cache_dir=${EA_DIR}" >> $serverPath/php/$version/etc/php.ini
|
||||
echo "${LIBNAME}.allowed_admin_path=/www/wwwroot/you_project_dir" >> $serverPath/php/$version/etc/php.ini
|
||||
|
||||
|
||||
$serverPath/php/init.d/php$version reload
|
||||
echo '==========================================================='
|
||||
echo 'successful!'
|
||||
}
|
||||
|
||||
|
||||
Uninstall_lib()
|
||||
{
|
||||
if [ ! -f "$serverPath/php/$version/bin/php-config" ];then
|
||||
echo "php$version 未安装,请选择其它版本!"
|
||||
return
|
||||
fi
|
||||
|
||||
if [ ! -f "$extFile" ];then
|
||||
echo "php$version 未安装${LIBNAME},请选择其它版本!"
|
||||
echo "php-$vphp not install ${LIBNAME}, Plese select other version!"
|
||||
return
|
||||
fi
|
||||
|
||||
sed -i $BAK "/${LIBNAME}.so/d" $serverPath/php/$version/etc/php.ini
|
||||
sed -i $BAK "/${LIBNAME}/d" $serverPath/php/$version/etc/php.ini
|
||||
|
||||
rm -f $extFile
|
||||
$serverPath/php/init.d/php$version reload
|
||||
echo '==============================================='
|
||||
echo 'successful!'
|
||||
}
|
||||
|
||||
|
||||
if [ "$actionType" == 'install' ];then
|
||||
Install_lib
|
||||
elif [ "$actionType" == 'uninstall' ];then
|
||||
Uninstall_lib
|
||||
fi
|
||||
Executable
+143
@@ -0,0 +1,143 @@
|
||||
#!/bin/bash
|
||||
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
|
||||
export PATH
|
||||
|
||||
curPath=`pwd`
|
||||
rootPath=$(dirname "$curPath")
|
||||
rootPath=$(dirname "$rootPath")
|
||||
serverPath=$(dirname "$rootPath")
|
||||
sourcePath=${serverPath}/source
|
||||
sysName=`uname`
|
||||
install_tmp=${rootPath}/tmp/mw_install.pl
|
||||
|
||||
|
||||
version=5.2.17
|
||||
PHP_VER=52
|
||||
Install_php()
|
||||
{
|
||||
#------------------------ install start ------------------------------------#
|
||||
echo "安装php-${version} ..." > $install_tmp
|
||||
mkdir -p $sourcePath/php
|
||||
mkdir -p $serverPath/php
|
||||
|
||||
if [ ! -d $sourcePath/php/php${PHP_VER} ];then
|
||||
if [ ! -f $sourcePath/php/php-${version}.tar.gz ];then
|
||||
wget --no-check-certificate -O $sourcePath/php/php-${version}.tar.gz https://museum.php.net/php5/php-${version}.tar.gz
|
||||
fi
|
||||
|
||||
if [ ! -f $sourcePath/php/php-5.2.17-fpm-0.5.14.diff.gz ]; then
|
||||
wget -O $sourcePath/php/php-5.2.17-fpm-0.5.14.diff.gz http://php-fpm.org/downloads/php-5.2.17-fpm-0.5.14.diff.gz
|
||||
fi
|
||||
|
||||
|
||||
if [ ! -f $sourcePath/php/php-5.2.17-max-input-vars.patch ]; then
|
||||
wget -O $sourcePath/php/php-5.2.17-max-input-vars.patch https://raw.github.com/laruence/laruence.github.com/master/php-5.2-max-input-vars/php-5.2.17-max-input-vars.patch
|
||||
fi
|
||||
|
||||
if [ ! -f $sourcePath/php/php-5.x.x.patch ]; then
|
||||
wget -O $sourcePath/php/php-5.x.x.patch https://mail.gnome.org/archives/xml/2012-August/txtbgxGXAvz4N.txt
|
||||
fi
|
||||
|
||||
|
||||
cd $sourcePath/php && tar -zxvf $sourcePath/php/php-${version}.tar.gz
|
||||
mv $sourcePath/php/php-${version} $sourcePath/php/php${PHP_VER}
|
||||
|
||||
|
||||
cd $sourcePath/php
|
||||
gzip -cd php-5.2.17-fpm-0.5.14.diff.gz | patch -d php${PHP_VER} -p1
|
||||
cd $sourcePath/php/php${PHP_VER}
|
||||
patch -p1 < ../php-5.2.17-max-input-vars.patch
|
||||
patch -p0 -b < ../php-5.x.x.patch
|
||||
sed -i "s/\!png_check_sig (sig, 8)/png_sig_cmp (sig, 0, 8)/" ext/gd/libgd/gd_png.c
|
||||
fi
|
||||
|
||||
|
||||
if [ -f $serverPath/php/${PHP_VER}/bin/php.dSYM ];then
|
||||
mv $serverPath/php/${PHP_VER}/bin/php.dSYM $serverPath/php/${PHP_VER}/bin/php
|
||||
fi
|
||||
|
||||
if [ -f $serverPath/php/${PHP_VER}/sbin/php-fpm.dSYM ];then
|
||||
mv $serverPath/php/${PHP_VER}/sbin/php-fpm.dSYM $serverPath/php/${PHP_VER}/sbin/php-fpm
|
||||
fi
|
||||
|
||||
|
||||
if [ -f $serverPath/php/${PHP_VER}/bin/php ];then
|
||||
return
|
||||
fi
|
||||
|
||||
OPTIONS=''
|
||||
if [ $sysName == 'Darwin' ]; then
|
||||
OPTIONS='--without-iconv'
|
||||
OPTIONS="${OPTIONS} --with-freetype-dir=${serverPath}/lib/freetype"
|
||||
OPTIONS="${OPTIONS} --with-curl=${serverPath}/lib/curl"
|
||||
else
|
||||
OPTIONS="--with-iconv=${serverPath}/lib/libiconv"
|
||||
OPTIONS="${OPTIONS} --with-freetype-dir=${serverPath}/lib/freetype"
|
||||
OPTIONS="${OPTIONS} --with-gd --enable-gd-native-ttf"
|
||||
OPTIONS="${OPTIONS} --with-curl"
|
||||
fi
|
||||
|
||||
|
||||
if [ ! -d $serverPath/php/${PHP_VER} ];then
|
||||
ln -s /usr/lib64/libjpeg.so /usr/lib/libjpeg.so
|
||||
ln -s /usr/lib64/libpng.so /usr/lib/
|
||||
cp -frp /usr/lib64/libldap* /usr/lib/
|
||||
export MYSQL_LIB_DIR=/usr/lib64/mysql
|
||||
|
||||
cd $sourcePath/php/php${PHP_VER} && ./configure \
|
||||
--prefix=$serverPath/php/${PHP_VER} \
|
||||
--exec-prefix=$serverPath/php/${PHP_VER} \
|
||||
--with-config-file-path=$serverPath/php/${PHP_VER}/etc \
|
||||
--with-zlib-dir=$serverPath/lib/zlib \
|
||||
--enable-xml \
|
||||
--enable-mysqlnd \
|
||||
--enable-shared \
|
||||
--with-mysql=mysqlnd \
|
||||
--enable-embedded-mysqli=shared \
|
||||
--enable-sysvmsg \
|
||||
--enable-sysvsem \
|
||||
--enable-sysvshm \
|
||||
--disable-fileinfo \
|
||||
$OPTIONS \
|
||||
--enable-fastcgi \
|
||||
--enable-fpm
|
||||
make ZEND_EXTRA_LIBS='-liconv' && make install && make clean
|
||||
fi
|
||||
|
||||
if [ "$?" != "0" ];then
|
||||
echo "install fail!!"
|
||||
rm -rf $sourcePath/php/php${PHP_VER}
|
||||
exit 2
|
||||
fi
|
||||
|
||||
|
||||
if [ -f $serverPath/php/${PHP_VER}/bin/php.dSYM ];then
|
||||
mv $serverPath/php/${PHP_VER}/bin/php.dSYM $serverPath/php/${PHP_VER}/bin/php
|
||||
fi
|
||||
|
||||
if [ -f $serverPath/php/${PHP_VER}/sbin/php-fpm.dSYM ];then
|
||||
mv $serverPath/php/${PHP_VER}/sbin/php-fpm.dSYM $serverPath/php/${PHP_VER}/sbin/php-fpm
|
||||
fi
|
||||
|
||||
if [ ! -d $serverPath/php/${PHP_VER}/lib/php/extensions/no-debug-non-zts-20060613 ]; then
|
||||
mkdir -p $serverPath/php/${PHP_VER}/lib/php/extensions/no-debug-non-zts-20060613
|
||||
fi
|
||||
|
||||
#------------------------ install end ------------------------------------#
|
||||
}
|
||||
|
||||
|
||||
|
||||
Uninstall_php()
|
||||
{
|
||||
$serverPath/php/init.d/php${PHP_VER} stop
|
||||
rm -rf $serverPath/php/${PHP_VER}
|
||||
echo "uninstall php-${version} ..." > $install_tmp
|
||||
}
|
||||
|
||||
action=${1}
|
||||
if [ "${1}" == 'install' ];then
|
||||
Install_php
|
||||
else
|
||||
Uninstall_php
|
||||
fi
|
||||
Executable
+93
@@ -0,0 +1,93 @@
|
||||
#!/bin/bash
|
||||
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
|
||||
export PATH
|
||||
|
||||
curPath=`pwd`
|
||||
|
||||
rootPath=$(dirname "$curPath")
|
||||
rootPath=$(dirname "$rootPath")
|
||||
rootPath=$(dirname "$rootPath")
|
||||
rootPath=$(dirname "$rootPath")
|
||||
serverPath=$(dirname "$rootPath")
|
||||
sourcePath=${serverPath}/source/php
|
||||
|
||||
LIBNAME=intl
|
||||
LIBV=3.0.0
|
||||
sysName=`uname`
|
||||
actionType=$1
|
||||
version=$2
|
||||
extFile=$serverPath/php/${version}/lib/php/extensions/no-debug-non-zts-20060613/${LIBNAME}.so
|
||||
|
||||
if [ "$sysName" == "Darwin" ];then
|
||||
BAK='_bak'
|
||||
else
|
||||
BAK=''
|
||||
fi
|
||||
|
||||
Install_lib()
|
||||
{
|
||||
isInstall=`cat $serverPath/php/$version/etc/php.ini|grep "${LIBNAME}.so"`
|
||||
if [ "${isInstall}" != "" ];then
|
||||
echo "php-$version 已安装${LIBNAME},请选择其它版本!"
|
||||
return
|
||||
fi
|
||||
|
||||
|
||||
if [ ! -f "$extFile" ];then
|
||||
|
||||
php_lib=$sourcePath/php_lib
|
||||
mkdir -p $php_lib
|
||||
|
||||
wget -O $php_lib/${LIBNAME}-${LIBV}.tgz http://pecl.php.net/get/${LIBNAME}-${LIBV}.tgz
|
||||
|
||||
cd $php_lib && tar xvf ${LIBNAME}-${LIBV}.tgz
|
||||
cd ${LIBNAME}-${LIBV}
|
||||
$serverPath/php/$version/bin/phpize
|
||||
./configure --with-php-config=$serverPath/php/$version/bin/php-config
|
||||
make && make install && make clean
|
||||
|
||||
fi
|
||||
|
||||
if [ ! -f "$extFile" ];then
|
||||
echo "ERROR!"
|
||||
return
|
||||
fi
|
||||
|
||||
echo "" >> $serverPath/php/$version/etc/php.ini
|
||||
echo "[${LIBNAME}]" >> $serverPath/php/$version/etc/php.ini
|
||||
echo "extension=${LIBNAME}.so" >> $serverPath/php/$version/etc/php.ini
|
||||
|
||||
$serverPath/php/init.d/php$version reload
|
||||
echo '==========================================================='
|
||||
echo 'successful!'
|
||||
}
|
||||
|
||||
|
||||
Uninstall_lib()
|
||||
{
|
||||
if [ ! -f "$serverPath/php/$version/bin/php-config" ];then
|
||||
echo "php$version 未安装,请选择其它版本!"
|
||||
return
|
||||
fi
|
||||
|
||||
if [ ! -f "$extFile" ];then
|
||||
echo "php$version 未安装${LIBNAME},请选择其它版本!"
|
||||
echo "php-$vphp not install ${LIBNAME}, Plese select other version!"
|
||||
return
|
||||
fi
|
||||
|
||||
sed -i $BAK "/${LIBNAME}.so/d" $serverPath/php/$version/etc/php.ini
|
||||
sed -i $BAK "/${LIBNAME}/d" $serverPath/php/$version/etc/php.ini
|
||||
|
||||
rm -f $extFile
|
||||
$serverPath/php/init.d/php$version reload
|
||||
echo '==============================================='
|
||||
echo 'successful!'
|
||||
}
|
||||
|
||||
|
||||
if [ "$actionType" == 'install' ];then
|
||||
Install_lib
|
||||
elif [ "$actionType" == 'uninstall' ];then
|
||||
Uninstall_lib
|
||||
fi
|
||||
Executable
+91
@@ -0,0 +1,91 @@
|
||||
#!/bin/bash
|
||||
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
|
||||
export PATH
|
||||
|
||||
curPath=`pwd`
|
||||
|
||||
rootPath=$(dirname "$curPath")
|
||||
rootPath=$(dirname "$rootPath")
|
||||
rootPath=$(dirname "$rootPath")
|
||||
rootPath=$(dirname "$rootPath")
|
||||
serverPath=$(dirname "$rootPath")
|
||||
sourcePath=${serverPath}/source/php
|
||||
|
||||
LIBNAME=memcache
|
||||
LIBV=2.2.7
|
||||
sysName=`uname`
|
||||
actionType=$1
|
||||
version=$2
|
||||
extFile=$serverPath/php/${version}/lib/php/extensions/no-debug-non-zts-20060613/${LIBNAME}.so
|
||||
|
||||
if [ "$sysName" == "Darwin" ];then
|
||||
BAK='_bak'
|
||||
else
|
||||
BAK=''
|
||||
fi
|
||||
|
||||
Install_lib()
|
||||
{
|
||||
isInstall=`cat $serverPath/php/$version/etc/php.ini|grep "${LIBNAME}.so"`
|
||||
if [ "${isInstall}" != "" ];then
|
||||
echo "php-$version 已安装${LIBNAME},请选择其它版本!"
|
||||
return
|
||||
fi
|
||||
|
||||
if [ ! -f "$extFile" ];then
|
||||
php_lib=$sourcePath/php_lib
|
||||
mkdir -p $php_lib
|
||||
|
||||
wget -O $php_lib/${LIBNAME}-${LIBV}.tgz http://pecl.php.net/get/${LIBNAME}-${LIBV}.tgz
|
||||
|
||||
cd $php_lib && tar xvf ${LIBNAME}-${LIBV}.tgz
|
||||
cd ${LIBNAME}-${LIBV}
|
||||
$serverPath/php/$version/bin/phpize
|
||||
./configure --with-php-config=$serverPath/php/$version/bin/php-config --enable-memcache --with-zlib-dir
|
||||
make && make install && make clean
|
||||
|
||||
fi
|
||||
|
||||
if [ ! -f "$extFile" ];then
|
||||
echo "ERROR!"
|
||||
return
|
||||
fi
|
||||
echo "" >> $serverPath/php/$version/etc/php.ini
|
||||
echo "[${LIBNAME}]" >> $serverPath/php/$version/etc/php.ini
|
||||
echo "extension=${LIBNAME}.so" >> $serverPath/php/$version/etc/php.ini
|
||||
|
||||
|
||||
$serverPath/php/init.d/php$version reload
|
||||
echo '==========================================================='
|
||||
echo 'successful!'
|
||||
}
|
||||
|
||||
|
||||
Uninstall_lib()
|
||||
{
|
||||
if [ ! -f "$serverPath/php/$version/bin/php-config" ];then
|
||||
echo "php-$version 未安装,请选择其它版本!"
|
||||
return
|
||||
fi
|
||||
|
||||
if [ ! -f "$extFile" ];then
|
||||
echo "php-$version 未安装${LIBNAME},请选择其它版本!"
|
||||
echo "php-$version not install memcache, Plese select other version!"
|
||||
return
|
||||
fi
|
||||
|
||||
sed -i $BAK "/${LIBNAME}.so/d" $serverPath/php/$version/etc/php.ini
|
||||
sed -i $BAK "/${LIBNAME}/d" $serverPath/php/$version/etc/php.ini
|
||||
|
||||
rm -f $extFile
|
||||
$serverPath/php/init.d/php$version reload
|
||||
echo '==============================================='
|
||||
echo 'successful!'
|
||||
}
|
||||
|
||||
|
||||
if [ "$actionType" == 'install' ];then
|
||||
Install_lib
|
||||
elif [ "$actionType" == 'uninstall' ];then
|
||||
Uninstall_lib
|
||||
fi
|
||||
Executable
+98
@@ -0,0 +1,98 @@
|
||||
#!/bin/bash
|
||||
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
|
||||
export PATH
|
||||
|
||||
curPath=`pwd`
|
||||
|
||||
rootPath=$(dirname "$curPath")
|
||||
rootPath=$(dirname "$rootPath")
|
||||
rootPath=$(dirname "$rootPath")
|
||||
rootPath=$(dirname "$rootPath")
|
||||
serverPath=$(dirname "$rootPath")
|
||||
sourcePath=${serverPath}/source/php
|
||||
|
||||
LIBNAME=redis
|
||||
LIBV=2.2.7
|
||||
sysName=`uname`
|
||||
actionType=$1
|
||||
version=$2
|
||||
|
||||
extDir=$serverPath/php/${version}/lib/php/extensions/no-debug-non-zts-20060613/
|
||||
|
||||
if [ "$sysName" == "Darwin" ];then
|
||||
BAK='_bak'
|
||||
else
|
||||
BAK=''
|
||||
fi
|
||||
|
||||
Install_lib()
|
||||
{
|
||||
isInstall=`cat $serverPath/php/$version/etc/php.ini|grep "${LIBNAME}.so"`
|
||||
if [ "${isInstall}" != "" ];then
|
||||
echo "php-$version 已安装${LIBNAME},请选择其它版本!"
|
||||
return
|
||||
fi
|
||||
|
||||
extFile=$extDir${LIBNAME}.so
|
||||
if [ ! -f "$extFile" ];then
|
||||
|
||||
php_lib=$sourcePath/php_lib
|
||||
mkdir -p $php_lib
|
||||
|
||||
if [ ! -f $php_lib/${LIBNAME}-${LIBV}.tgz ];then
|
||||
wget -O $php_lib/${LIBNAME}-${LIBV}.tgz http://pecl.php.net/get/${LIBNAME}-${LIBV}.tgz
|
||||
cd $php_lib && tar xvf ${LIBNAME}-${LIBV}.tgz
|
||||
fi
|
||||
cd $php_lib/${LIBNAME}-${LIBV}
|
||||
|
||||
$serverPath/php/$version/bin/phpize
|
||||
./configure --with-php-config=$serverPath/php/$version/bin/php-config
|
||||
make && make install && make clean
|
||||
|
||||
fi
|
||||
sleep 1
|
||||
if [ ! -f "$extFile" ];then
|
||||
echo "ERROR!"
|
||||
return
|
||||
fi
|
||||
|
||||
echo "" >> $serverPath/php/$version/etc/php.ini
|
||||
echo "[${LIBNAME}]" >> $serverPath/php/$version/etc/php.ini
|
||||
echo "extension=${LIBNAME}.so" >> $serverPath/php/$version/etc/php.ini
|
||||
|
||||
$serverPath/php/init.d/php$version reload
|
||||
echo '==========================================================='
|
||||
echo 'successful!'
|
||||
}
|
||||
|
||||
|
||||
Uninstall_lib()
|
||||
{
|
||||
if [ ! -f "$serverPath/php/$version/bin/php-config" ];then
|
||||
echo "php$version 未安装,请选择其它版本!"
|
||||
return
|
||||
fi
|
||||
|
||||
extFile=$extDir${LIBNAME}.so
|
||||
if [ ! -f "$extFile" ];then
|
||||
echo "php$version 未安装${LIBNAME},请选择其它版本!"
|
||||
echo "php-$vphp not install memcache, Plese select other version!"
|
||||
return
|
||||
fi
|
||||
|
||||
sed -i $BAK "/${LIBNAME}.so/d" $serverPath/php/$version/etc/php.ini
|
||||
sed -i $BAK "/${LIBNAME}/d" $serverPath/php/$version/etc/php.ini
|
||||
|
||||
rm -f $extFile
|
||||
$serverPath/php/init.d/php$version reload
|
||||
echo '==============================================='
|
||||
echo 'successful!'
|
||||
}
|
||||
|
||||
|
||||
|
||||
if [ "$actionType" == 'install' ];then
|
||||
Install_lib
|
||||
elif [ "$actionType" == 'uninstall' ];then
|
||||
Uninstall_lib
|
||||
fi
|
||||
Executable
+101
@@ -0,0 +1,101 @@
|
||||
#!/bin/bash
|
||||
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
|
||||
export PATH
|
||||
|
||||
curPath=`pwd`
|
||||
|
||||
rootPath=$(dirname "$curPath")
|
||||
rootPath=$(dirname "$rootPath")
|
||||
rootPath=$(dirname "$rootPath")
|
||||
rootPath=$(dirname "$rootPath")
|
||||
serverPath=$(dirname "$rootPath")
|
||||
sourcePath=${serverPath}/source/php
|
||||
|
||||
LIBNAME=xhprof
|
||||
LIBV=0.9.4
|
||||
sysName=`uname`
|
||||
actionType=$1
|
||||
version=$2
|
||||
extFile=$serverPath/php/${version}/lib/php/extensions/no-debug-non-zts-20060613/${LIBNAME}.so
|
||||
|
||||
if [ "$sysName" == "Darwin" ];then
|
||||
BAK='_bak'
|
||||
else
|
||||
BAK=''
|
||||
fi
|
||||
|
||||
Install_lib()
|
||||
{
|
||||
isInstall=`cat $serverPath/php/$version/etc/php.ini|grep "${LIBNAME}.so"`
|
||||
if [ "${isInstall}" != "" ];then
|
||||
echo "php-$version 已安装${LIBNAME},请选择其它版本!"
|
||||
return
|
||||
fi
|
||||
|
||||
if [ ! -f "$extFile" ];then
|
||||
php_lib=$sourcePath/php_lib
|
||||
mkdir -p $php_lib
|
||||
if [ ! -d $php_lib/${LIBNAME}-${LIBV} ];then
|
||||
wget -O $php_lib/${LIBNAME}-${LIBV}.tgz http://pecl.php.net/get/${LIBNAME}-${LIBV}.tgz
|
||||
cd $php_lib && tar xvf ${LIBNAME}-${LIBV}.tgz
|
||||
fi
|
||||
cd $php_lib/${LIBNAME}-${LIBV}/extension
|
||||
|
||||
$serverPath/php/$version/bin/phpize
|
||||
./configure --enable-xhprof \
|
||||
--with-php-config=$serverPath/php/$version/bin/php-config
|
||||
make && make install && make clean
|
||||
|
||||
fi
|
||||
|
||||
if [ ! -f "$extFile" ];then
|
||||
echo "ERROR!"
|
||||
return
|
||||
fi
|
||||
|
||||
if [ ! -f /tmp/xhprof ];then
|
||||
mkdir -p /tmp/xhprof
|
||||
chown -R www:www /tmp/xhprof
|
||||
fi
|
||||
|
||||
echo "" >> $serverPath/php/$version/etc/php.ini
|
||||
echo "[${LIBNAME}]" >> $serverPath/php/$version/etc/php.ini
|
||||
echo "extension=${LIBNAME}.so" >> $serverPath/php/$version/etc/php.ini
|
||||
echo "${LIBNAME}.output_dir=/tmp/xhprof" >> $serverPath/php/$version/etc/php.ini
|
||||
|
||||
|
||||
$serverPath/php/init.d/php$version reload
|
||||
echo '==========================================================='
|
||||
echo 'successful!'
|
||||
}
|
||||
|
||||
|
||||
Uninstall_lib()
|
||||
{
|
||||
if [ ! -f "$serverPath/php/$version/bin/php-config" ];then
|
||||
echo "php-$version 未安装,请选择其它版本!"
|
||||
return
|
||||
fi
|
||||
|
||||
if [ ! -f "$extFile" ];then
|
||||
echo "php-$version 未安装${LIBNAME},请选择其它版本!"
|
||||
echo "php-$version not install ${LIBNAME}, Plese select other version!"
|
||||
return
|
||||
fi
|
||||
|
||||
sed -i $BAK "/${LIBNAME}.so/d" $serverPath/php/$version/etc/php.ini
|
||||
sed -i $BAK "/${LIBNAME}/d" $serverPath/php/$version/etc/php.ini
|
||||
|
||||
rm -f $extFile
|
||||
|
||||
$serverPath/php/init.d/php$version reload
|
||||
echo '==============================================='
|
||||
echo 'successful!'
|
||||
}
|
||||
|
||||
|
||||
if [ "$actionType" == 'install' ];then
|
||||
Install_lib
|
||||
elif [ "$actionType" == 'uninstall' ];then
|
||||
Uninstall_lib
|
||||
fi
|
||||
Executable
+101
@@ -0,0 +1,101 @@
|
||||
#!/bin/bash
|
||||
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
|
||||
export PATH
|
||||
|
||||
curPath=`pwd`
|
||||
|
||||
rootPath=$(dirname "$curPath")
|
||||
rootPath=$(dirname "$rootPath")
|
||||
rootPath=$(dirname "$rootPath")
|
||||
rootPath=$(dirname "$rootPath")
|
||||
serverPath=$(dirname "$rootPath")
|
||||
sourcePath=${serverPath}/source/php
|
||||
|
||||
LIBNAME=ZendGuardLoader
|
||||
|
||||
sysName=`uname`
|
||||
actionType=$1
|
||||
version=$2
|
||||
extFile=$serverPath/php/${version}/lib/php/extensions/no-debug-non-zts-20060613/ZendOptimizer.so
|
||||
|
||||
if [ "$sysName" == "Darwin" ];then
|
||||
BAK='_bak'
|
||||
else
|
||||
BAK=''
|
||||
fi
|
||||
|
||||
Install_lib()
|
||||
{
|
||||
|
||||
|
||||
isInstall=`cat $serverPath/php/$version/etc/php.ini|grep "ZendOptimizer.so"`
|
||||
if [ "${isInstall}" != "" ];then
|
||||
echo "php-$version 已安装${LIBNAME},请选择其它版本!"
|
||||
return
|
||||
fi
|
||||
|
||||
if [ ! -f "$extFile" ];then
|
||||
|
||||
php_lib=$sourcePath/php_lib
|
||||
mkdir -p $php_lib
|
||||
|
||||
if [ $sysName == 'Darwin' ]; then
|
||||
wget -O $php_lib/zend-loader-php5.3.tar.gz http://downloads.zend.com/guard/5.5.0/ZendGuardLoader-php-5.3-darwin-i386.tar.gz
|
||||
else
|
||||
wget -O $php_lib/ZendOptimizer-3.3.3-linux-glibc23-x86_64.tar.gz http://downloads.zend.com/optimizer/3.3.3/ZendOptimizer-3.3.3-linux-glibc23-x86_64.tar.gz
|
||||
fi
|
||||
|
||||
cd $php_lib && tar zxvf ZendOptimizer-3.3.3-linux-glibc23-x86_64.tar.gz
|
||||
cd $php_lib/ZendOptimizer-3.3.3-linux-glibc23-x86_64
|
||||
cp $php_lib/ZendOptimizer-3.3.3-linux-glibc23-x86_64/data/5_2_x_comp/ZendOptimizer.so $serverPath/php/$version/lib/php/extensions/no-debug-non-zts-20060613/
|
||||
|
||||
fi
|
||||
|
||||
if [ ! -f "$extFile" ];then
|
||||
echo "ERROR!"
|
||||
return
|
||||
fi
|
||||
|
||||
echo "" >> $serverPath/php/$version/etc/php.ini
|
||||
echo "[Zend ZendGuard Loader]" >> $serverPath/php/$version/etc/php.ini
|
||||
echo "zend_extension=$serverPath/php/$version/lib/php/extensions/no-debug-non-zts-20060613/ZendOptimizer.so" >> $serverPath/php/$version/etc/php.ini
|
||||
echo "zend_loader.enable=1" >> $serverPath/php/$version/etc/php.ini
|
||||
echo "zend_loader.disable_licensing=0" >> $serverPath/php/$version/etc/php.ini
|
||||
echo "zend_loader.obfuscation_level_support=3" >> $serverPath/php/$version/etc/php.ini
|
||||
echo "zend_loader.license_path=" >> $serverPath/php/$version/etc/php.ini
|
||||
|
||||
$serverPath/php/init.d/php$version reload
|
||||
echo '==========================================================='
|
||||
echo 'successful!'
|
||||
}
|
||||
|
||||
|
||||
Uninstall_lib()
|
||||
{
|
||||
if [ ! -f "$serverPath/php/$version/bin/php-config" ];then
|
||||
echo "php$version 未安装,请选择其它版本!"
|
||||
return
|
||||
fi
|
||||
|
||||
if [ ! -f "$extFile" ];then
|
||||
echo "php-$version 未安装${LIBNAME},请选择其它版本!"
|
||||
return
|
||||
fi
|
||||
|
||||
sed -i $BAK "/ZendOptimizer.so/d" $serverPath/php/$version/etc/php.ini
|
||||
sed -i $BAK "/zend_loader/d" $serverPath/php/$version/etc/php.ini
|
||||
sed -i $BAK "/\[Zend ZendGuard Loader\]/d" $serverPath/php/$version/etc/php.ini
|
||||
|
||||
rm -f $extFile
|
||||
$serverPath/php/init.d/php$version reload
|
||||
echo '==============================================='
|
||||
echo 'successful!'
|
||||
}
|
||||
|
||||
|
||||
|
||||
if [ "$actionType" == 'install' ];then
|
||||
Install_lib
|
||||
elif [ "$actionType" == 'uninstall' ];then
|
||||
Uninstall_lib
|
||||
fi
|
||||
@@ -18,6 +18,12 @@ actionType=$1
|
||||
version=$2
|
||||
extFile=$serverPath/php/${version}/lib/php/extensions/no-debug-non-zts-20090626/${LIBNAME}.so
|
||||
|
||||
if [ "$sysName" == "Darwin" ];then
|
||||
BAK='_bak'
|
||||
else
|
||||
BAK=''
|
||||
fi
|
||||
|
||||
Install_lib()
|
||||
{
|
||||
isInstall=`cat $serverPath/php/$version/etc/php.ini|grep "${LIBNAME}.so"`
|
||||
@@ -31,15 +37,15 @@ Install_lib()
|
||||
_LIBNAME=$(echo $LIBNAME | tr '[a-z]' '[A-Z]')
|
||||
php_lib=$sourcePath/php_lib
|
||||
mkdir -p $php_lib
|
||||
if [ ! -f $php_lib/${LIBNAME}-${LIBV}.tgz ];then
|
||||
if [ ! -d $php_lib/${_LIBNAME}-${LIBV} ];then
|
||||
wget -O $php_lib/${LIBNAME}-${LIBV}.tgz http://pecl.php.net/get/${_LIBNAME}-${LIBV}.tgz
|
||||
cd $php_lib
|
||||
tar xvf ${LIBNAME}-${LIBV}.tgz
|
||||
fi
|
||||
cd $php_lib/${LIBNAME}-${LIBV}
|
||||
cd $php_lib/${_LIBNAME}-${LIBV}
|
||||
|
||||
$serverPath/php/$version/bin/phpize
|
||||
./configure --with-php-config=$serverPath/php/$version/bin/php-config
|
||||
./configure --with-php-config=$serverPath/php/$version/bin/php-config && \
|
||||
make && make install && make clean
|
||||
|
||||
fi
|
||||
@@ -73,8 +79,8 @@ Uninstall_lib()
|
||||
return
|
||||
fi
|
||||
|
||||
sed -i '_bak' "/${LIBNAME}.so/d" $serverPath/php/$version/etc/php.ini
|
||||
sed -i '_bak' "/${LIBNAME}/d" $serverPath/php/$version/etc/php.ini
|
||||
sed -i $BAK "/${LIBNAME}.so/d" $serverPath/php/$version/etc/php.ini
|
||||
sed -i $BAK "/${LIBNAME}/d" $serverPath/php/$version/etc/php.ini
|
||||
|
||||
rm -f $extFile
|
||||
$serverPath/php/init.d/php$version reload
|
||||
|
||||
@@ -22,6 +22,12 @@ actionType=$1
|
||||
version=$2
|
||||
extFile=$serverPath/php/${version}/lib/php/extensions/no-debug-non-zts-20090626/${LIBNAME}.so
|
||||
|
||||
if [ "$sysName" == "Darwin" ];then
|
||||
BAK='_bak'
|
||||
else
|
||||
BAK=''
|
||||
fi
|
||||
|
||||
Install_lib()
|
||||
{
|
||||
isInstall=`cat $serverPath/php/$version/etc/php.ini|grep "${LIBNAME}.so"`
|
||||
@@ -37,9 +43,9 @@ Install_lib()
|
||||
mkdir -p $php_lib
|
||||
|
||||
if [ ! -d $php_lib/${LIBNAME}-${LIBV} ];then
|
||||
wget -O $php_lib/${LIBNAME}-${LIBV}.tgz https://github.com/eaccelerator/eaccelerator/archive/${LIBV}.tar.gz
|
||||
wget -O $php_lib/${LIBNAME}-${LIBV}.tar.gz https://github.com/eaccelerator/eaccelerator/archive/${LIBV}.tar.gz
|
||||
# wget -O $php_lib/${LIBNAME}-${LIBV}.tar.bz2 http://dl.wdlinux.cn:5180/soft/eaccelerator-0.9.6.1.tar.bz2
|
||||
cd $php_lib && tar zxvf ${LIBNAME}-${LIBV}.tar.gz
|
||||
cd $php_lib && tar -zxvf ${LIBNAME}-${LIBV}.tar.gz
|
||||
fi
|
||||
cd $php_lib/${LIBNAME}-${LIBV}
|
||||
|
||||
@@ -78,8 +84,8 @@ Uninstall_lib()
|
||||
return
|
||||
fi
|
||||
|
||||
sed -i '_bak' "/${LIBNAME}.so/d" $serverPath/php/$version/etc/php.ini
|
||||
sed -i '_bak' "/${LIBNAME}/d" $serverPath/php/$version/etc/php.ini
|
||||
sed -i $BAK "/${LIBNAME}.so/d" $serverPath/php/$version/etc/php.ini
|
||||
sed -i $BAK "/${LIBNAME}/d" $serverPath/php/$version/etc/php.ini
|
||||
|
||||
rm -f $extFile
|
||||
$serverPath/php/init.d/php$version reload
|
||||
|
||||
@@ -21,7 +21,10 @@ mkdir -p $sourcePath/php
|
||||
mkdir -p $serverPath/php
|
||||
|
||||
if [ ! -d $sourcePath/php/php${PHP_VER} ];then
|
||||
wget --no-check-certificate -O $sourcePath/php/php-${version}.tar.xz http://au1.php.net/distributions/php-${version}.tar.xz
|
||||
if [ ! -f $sourcePath/php/php-${version}.tar.xz ];then
|
||||
wget --no-check-certificate -O $sourcePath/php/php-${version}.tar.xz http://au1.php.net/distributions/php-${version}.tar.xz
|
||||
fi
|
||||
|
||||
cd $sourcePath/php && tar -Jxf $sourcePath/php/php-${version}.tar.xz
|
||||
mv $sourcePath/php/php-${version} $sourcePath/php/php${PHP_VER}
|
||||
fi
|
||||
@@ -59,6 +62,10 @@ if [ ! -d $serverPath/php/53 ];then
|
||||
--exec-prefix=$serverPath/php/53 \
|
||||
--with-config-file-path=$serverPath/php/53/etc \
|
||||
--with-zlib-dir=$serverPath/lib/zlib \
|
||||
--enable-mysqlnd \
|
||||
--with-mysql=mysqlnd \
|
||||
--with-pdo-mysql=mysqlnd \
|
||||
--with-mysqli=mysqlnd \
|
||||
--enable-zip \
|
||||
--enable-exif \
|
||||
--enable-hash \
|
||||
@@ -94,6 +101,11 @@ if [ -f $serverPath/php/53/sbin/php-fpm.dSYM ];then
|
||||
mv $serverPath/php/53/sbin/php-fpm.dSYM $serverPath/php/53/sbin/php-fpm
|
||||
fi
|
||||
|
||||
|
||||
if [ ! -d $serverPath/php/53/lib/php/extensions/no-debug-non-zts-20090626 ]; then
|
||||
mkdir -p $serverPath/php/53/lib/php/extensions/no-debug-non-zts-20090626
|
||||
fi
|
||||
|
||||
#------------------------ install end ------------------------------------#
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,12 @@ actionType=$1
|
||||
version=$2
|
||||
extFile=$serverPath/php/${version}/lib/php/extensions/no-debug-non-zts-20090626/${LIBNAME}.so
|
||||
|
||||
if [ "$sysName" == "Darwin" ];then
|
||||
BAK='_bak'
|
||||
else
|
||||
BAK=''
|
||||
fi
|
||||
|
||||
Install_lib()
|
||||
{
|
||||
isInstall=`cat $serverPath/php/$version/etc/php.ini|grep "${LIBNAME}.so"`
|
||||
@@ -70,8 +76,8 @@ Uninstall_lib()
|
||||
return
|
||||
fi
|
||||
|
||||
sed -i '_bak' "/${LIBNAME}.so/d" $serverPath/php/$version/etc/php.ini
|
||||
sed -i '_bak' "/${LIBNAME}/d" $serverPath/php/$version/etc/php.ini
|
||||
sed -i $BAK "/${LIBNAME}.so/d" $serverPath/php/$version/etc/php.ini
|
||||
sed -i $BAK "/${LIBNAME}/d" $serverPath/php/$version/etc/php.ini
|
||||
|
||||
rm -f $extFile
|
||||
$serverPath/php/init.d/php$version reload
|
||||
|
||||
@@ -18,6 +18,12 @@ actionType=$1
|
||||
version=$2
|
||||
extFile=$serverPath/php/${version}/lib/php/extensions/no-debug-non-zts-20090626/${LIBNAME}.so
|
||||
|
||||
if [ "$sysName" == "Darwin" ];then
|
||||
BAK='_bak'
|
||||
else
|
||||
BAK=''
|
||||
fi
|
||||
|
||||
Install_lib()
|
||||
{
|
||||
isInstall=`cat $serverPath/php/$version/etc/php.ini|grep "${LIBNAME}.so"`
|
||||
@@ -68,8 +74,8 @@ Uninstall_lib()
|
||||
return
|
||||
fi
|
||||
|
||||
sed -i '_bak' '/${LIBNAME}.so/d' $serverPath/php/$version/etc/php.ini
|
||||
sed -i '_bak' '/${LIBNAME}/d' $serverPath/php/$version/etc/php.ini
|
||||
sed -i $BAK "/${LIBNAME}.so/d" $serverPath/php/$version/etc/php.ini
|
||||
sed -i $BAK "/${LIBNAME}/d" $serverPath/php/$version/etc/php.ini
|
||||
|
||||
rm -f $extFile
|
||||
$serverPath/php/init.d/php$version reload
|
||||
|
||||
@@ -18,6 +18,12 @@ actionType=$1
|
||||
version=$2
|
||||
extFile=$serverPath/php/${version}/lib/php/extensions/no-debug-non-zts-20090626/${LIBNAME}.so
|
||||
|
||||
if [ "$sysName" == "Darwin" ];then
|
||||
BAK='_bak'
|
||||
else
|
||||
BAK=''
|
||||
fi
|
||||
|
||||
Install_lib()
|
||||
{
|
||||
isInstall=`cat $serverPath/php/$version/etc/php.ini|grep "${LIBNAME}.so"`
|
||||
@@ -32,15 +38,15 @@ Install_lib()
|
||||
php_lib=$sourcePath/php_lib
|
||||
mkdir -p $php_lib
|
||||
|
||||
wget -O $php_lib/${LIBNAME}-${LIBV}.tgz http://pecl.php.net/get/${LIBNAME}-${LIBV}.tgz
|
||||
if [ ! -f $php_lib/${LIBNAME}-${LIBV} ] ;then
|
||||
wget -O $php_lib/${LIBNAME}-${LIBV}.tgz http://pecl.php.net/get/${LIBNAME}-${LIBV}.tgz
|
||||
cd $php_lib && tar xvf ${LIBNAME}-${LIBV}.tgz
|
||||
fi
|
||||
cd $php_lib/${LIBNAME}-${LIBV}
|
||||
|
||||
cd $php_lib && tar xvf ${LIBNAME}-${LIBV}.tgz
|
||||
cd ${LIBNAME}-${LIBV}
|
||||
$serverPath/php/$version/bin/phpize
|
||||
./configure --with-php-config=$serverPath/php/$version/bin/php-config \
|
||||
--enable-memcache --with-zlib-dir=$serverPath/lib/zlib \
|
||||
--with-libmemcached-dir=$serverPath/lib/libmemcached
|
||||
make && make install && make clean
|
||||
--enable-memcached && make clean && make && make install && make clean
|
||||
|
||||
fi
|
||||
|
||||
@@ -72,8 +78,8 @@ Uninstall_lib()
|
||||
return
|
||||
fi
|
||||
|
||||
sed -i '_bak' '/${LIBNAME}.so/d' $serverPath/php/$version/etc/php.ini
|
||||
sed -i '_bak' '/${LIBNAME}/d' $serverPath/php/$version/etc/php.ini
|
||||
sed -i $BAK "/${LIBNAME}.so/d" $serverPath/php/$version/etc/php.ini
|
||||
sed -i $BAK "/${LIBNAME}/d" $serverPath/php/$version/etc/php.ini
|
||||
|
||||
rm -f $extFile
|
||||
$serverPath/php/init.d/php$version reload
|
||||
|
||||
@@ -18,6 +18,12 @@ actionType=$1
|
||||
version=$2
|
||||
extFile=$serverPath/php/${version}/lib/php/extensions/no-debug-non-zts-20090626/${LIBNAME}.so
|
||||
|
||||
if [ "$sysName" == "Darwin" ];then
|
||||
BAK='_bak'
|
||||
else
|
||||
BAK=''
|
||||
fi
|
||||
|
||||
Install_lib()
|
||||
{
|
||||
isInstall=`cat $serverPath/php/$version/etc/php.ini|grep "${LIBNAME}.so"`
|
||||
@@ -79,8 +85,8 @@ Uninstall_lib()
|
||||
return
|
||||
fi
|
||||
|
||||
sed -i '_bak' "/${LIBNAME}.so/d" $serverPath/php/$version/etc/php.ini
|
||||
sed -i '_bak' "/${LIBNAME}/d" $serverPath/php/$version/etc/php.ini
|
||||
sed -i $BAK "/${LIBNAME}.so/d" $serverPath/php/$version/etc/php.ini
|
||||
sed -i $BAK "/${LIBNAME}/d" $serverPath/php/$version/etc/php.ini
|
||||
|
||||
rm -f $extFile
|
||||
$serverPath/php/init.d/php$version reload
|
||||
|
||||
@@ -18,6 +18,12 @@ actionType=$1
|
||||
version=$2
|
||||
extFile=$serverPath/php/${version}/lib/php/extensions/no-debug-non-zts-20090626/${LIBNAME}.so
|
||||
|
||||
if [ "$sysName" == "Darwin" ];then
|
||||
BAK='_bak'
|
||||
else
|
||||
BAK=''
|
||||
fi
|
||||
|
||||
Install_lib()
|
||||
{
|
||||
isInstall=`cat $serverPath/php/$version/etc/php.ini|grep "${LIBNAME}.so"`
|
||||
@@ -28,7 +34,7 @@ Install_lib()
|
||||
|
||||
if [ ! -f "$extFile" ];then
|
||||
|
||||
php_lib=$sourcePath/php_${version}_lib
|
||||
php_lib=$sourcePath/php_lib
|
||||
mkdir -p $php_lib
|
||||
|
||||
if [ ! -d $php_lib/zendopcache-7.0.5 ];then
|
||||
@@ -77,17 +83,14 @@ Uninstall_lib()
|
||||
return
|
||||
fi
|
||||
|
||||
sed -i '_bak' "/${LIBNAME}.so/d" $serverPath/php/$version/etc/php.ini
|
||||
sed -i '_bak' "/${LIBNAME}/d" $serverPath/php/$version/etc/php.ini
|
||||
|
||||
if [ ! -f "$extFile" ];then
|
||||
echo "php-$version 未安装${LIBNAME},请选择其它版本!"
|
||||
echo "php-$version not install ${LIBNAME}, Plese select other version!"
|
||||
return
|
||||
fi
|
||||
|
||||
sed -i '_bak' "/${LIBNAME}.so/d" $serverPath/php/$version/etc/php.ini
|
||||
sed -i '_bak' "/${LIBNAME}/d" $serverPath/php/$version/etc/php.ini
|
||||
sed -i $BAK "/${LIBNAME}.so/d" $serverPath/php/$version/etc/php.ini
|
||||
sed -i $BAK "/${LIBNAME}/d" $serverPath/php/$version/etc/php.ini
|
||||
|
||||
rm -f $extFile
|
||||
|
||||
|
||||
@@ -19,6 +19,12 @@ version=$2
|
||||
|
||||
extDir=$serverPath/php/${version}/lib/php/extensions/no-debug-non-zts-20090626/
|
||||
|
||||
if [ "$sysName" == "Darwin" ];then
|
||||
BAK='_bak'
|
||||
else
|
||||
BAK=''
|
||||
fi
|
||||
|
||||
Install_lib()
|
||||
{
|
||||
isInstall=`cat $serverPath/php/$version/etc/php.ini|grep "${LIBNAME}.so"`
|
||||
@@ -74,8 +80,8 @@ Uninstall_lib()
|
||||
return
|
||||
fi
|
||||
|
||||
sed -i '_bak' "/${LIBNAME}.so/d" $serverPath/php/$version/etc/php.ini
|
||||
sed -i '_bak' "/${LIBNAME}/d" $serverPath/php/$version/etc/php.ini
|
||||
sed -i $BAK "/${LIBNAME}.so/d" $serverPath/php/$version/etc/php.ini
|
||||
sed -i $BAK "/${LIBNAME}/d" $serverPath/php/$version/etc/php.ini
|
||||
|
||||
rm -f $extFile
|
||||
$serverPath/php/init.d/php$version reload
|
||||
|
||||
@@ -20,6 +20,12 @@ version=$2
|
||||
|
||||
extDir=$serverPath/php/${version}/lib/php/extensions/no-debug-non-zts-20090626/
|
||||
|
||||
if [ "$sysName" == "Darwin" ];then
|
||||
BAK='_bak'
|
||||
else
|
||||
BAK=''
|
||||
fi
|
||||
|
||||
Install_lib()
|
||||
{
|
||||
isInstall=`cat $serverPath/php/$version/etc/php.ini|grep "${_LIBNAME}.so"`
|
||||
@@ -28,7 +34,7 @@ Install_lib()
|
||||
return
|
||||
fi
|
||||
|
||||
extFile=$extDir${LIBNAME}.so
|
||||
extFile=$extDir${_LIBNAME}.so
|
||||
if [ ! -f "$extFile" ];then
|
||||
|
||||
OPTIONS=''
|
||||
@@ -74,15 +80,15 @@ Uninstall_lib()
|
||||
return
|
||||
fi
|
||||
|
||||
extFile=$extDir${LIBNAME}.so
|
||||
extFile=$extDir${_LIBNAME}.so
|
||||
if [ ! -f "$extFile" ];then
|
||||
echo "php-$version 未安装${LIBNAME},请选择其它版本!"
|
||||
echo "php-$version not install ${LIBNAME}, Plese select other version!"
|
||||
return
|
||||
fi
|
||||
_LIBNAME=$(echo $LIBNAME | tr '[A-Z]' '[a-z]')
|
||||
sed -i '_bak' "/${_LIBNAME}.so/d" $serverPath/php/$version/etc/php.ini
|
||||
sed -i '_bak' "/${_LIBNAME}/d" $serverPath/php/$version/etc/php.ini
|
||||
sed -i $BAK "/${_LIBNAME}.so/d" $serverPath/php/$version/etc/php.ini
|
||||
sed -i $BAK "/${_LIBNAME}/d" $serverPath/php/$version/etc/php.ini
|
||||
|
||||
rm -f $extFile
|
||||
$serverPath/php/init.d/php$version reload
|
||||
|
||||
@@ -19,6 +19,12 @@ version=$2
|
||||
|
||||
extDir=$serverPath/php/${version}/lib/php/extensions/no-debug-non-zts-20090626/
|
||||
|
||||
if [ "$sysName" == "Darwin" ];then
|
||||
BAK='_bak'
|
||||
else
|
||||
BAK=''
|
||||
fi
|
||||
|
||||
Install_lib()
|
||||
{
|
||||
isInstall=`cat $serverPath/php/$version/etc/php.ini|grep "${LIBNAME}.so"`
|
||||
@@ -79,8 +85,8 @@ Uninstall_lib()
|
||||
return
|
||||
fi
|
||||
|
||||
sed -i '_bak' "/${LIBNAME}.so/d" $serverPath/php/$version/etc/php.ini
|
||||
sed -i '_bak' "/${LIBNAME}/d" $serverPath/php/$version/etc/php.ini
|
||||
sed -i $BAK "/${LIBNAME}.so/d" $serverPath/php/$version/etc/php.ini
|
||||
sed -i $BAK "/${LIBNAME}/d" $serverPath/php/$version/etc/php.ini
|
||||
|
||||
rm -f $extFile
|
||||
$serverPath/php/init.d/php$version reload
|
||||
|
||||
@@ -22,6 +22,13 @@ if [ "$version" = '70' ] || [ "$version" = '71' ] || [ "$version" = '72' ];then
|
||||
fi
|
||||
extFile=$serverPath/php/${version}/lib/php/extensions/no-debug-non-zts-20090626/${LIBNAME}.so
|
||||
|
||||
sysName=`uname`
|
||||
if [ "$sysName" == "Darwin" ];then
|
||||
BAK='_bak'
|
||||
else
|
||||
BAK=''
|
||||
fi
|
||||
|
||||
|
||||
Install_lib()
|
||||
{
|
||||
@@ -90,8 +97,8 @@ Uninstall_lib()
|
||||
fi
|
||||
|
||||
echo $serverPath/php/$version/etc/php.ini
|
||||
sed -i '_bak' "/${LIBNAME}.so/d" $serverPath/php/$version/etc/php.ini
|
||||
sed -i '_bak' "/${LIBNAME}/d" $serverPath/php/$version/etc/php.ini
|
||||
sed -i $BAK "/${LIBNAME}.so/d" $serverPath/php/$version/etc/php.ini
|
||||
sed -i $BAK "/${LIBNAME}/d" $serverPath/php/$version/etc/php.ini
|
||||
|
||||
rm -f $extFile
|
||||
$serverPath/php/init.d/php$version reload
|
||||
|
||||
@@ -18,6 +18,13 @@ actionType=$1
|
||||
version=$2
|
||||
extFile=$serverPath/php/${version}/lib/php/extensions/no-debug-non-zts-20090626/${LIBNAME}.so
|
||||
|
||||
|
||||
if [ "$sysName" == "Darwin" ];then
|
||||
BAK='_bak'
|
||||
else
|
||||
BAK=''
|
||||
fi
|
||||
|
||||
Install_lib()
|
||||
{
|
||||
isInstall=`cat $serverPath/php/$version/etc/php.ini|grep "${LIBNAME}.so"`
|
||||
@@ -72,8 +79,8 @@ Uninstall_lib()
|
||||
return
|
||||
fi
|
||||
|
||||
sed -i '_bak' '/${LIBNAME}.so/d' $serverPath/php/$version/etc/php.ini
|
||||
sed -i '_bak' '/${LIBNAME}/d' $serverPath/php/$version/etc/php.ini
|
||||
sed -i $BAK "/${LIBNAME}.so/d" $serverPath/php/$version/etc/php.ini
|
||||
sed -i $BAK "/${LIBNAME}/d" $serverPath/php/$version/etc/php.ini
|
||||
|
||||
rm -f $extFile
|
||||
$serverPath/php/init.d/php$version reload
|
||||
|
||||
@@ -18,6 +18,12 @@ actionType=$1
|
||||
version=$2
|
||||
extFile=$serverPath/php/${version}/lib/php/extensions/no-debug-non-zts-20090626/${LIBNAME}.so
|
||||
|
||||
if [ "$sysName" == "Darwin" ];then
|
||||
BAK='_bak'
|
||||
else
|
||||
BAK=''
|
||||
fi
|
||||
|
||||
Install_lib()
|
||||
{
|
||||
isInstall=`cat $serverPath/php/$version/etc/php.ini|grep "${LIBNAME}.so"`
|
||||
@@ -47,10 +53,16 @@ Install_lib()
|
||||
return
|
||||
fi
|
||||
|
||||
if [ ! -f /tmp/xhprof ];then
|
||||
mkdir -p /tmp/xhprof
|
||||
chown -R www:www /tmp/xhprof
|
||||
fi
|
||||
|
||||
echo "" >> $serverPath/php/$version/etc/php.ini
|
||||
echo "[${LIBNAME}]" >> $serverPath/php/$version/etc/php.ini
|
||||
echo "extension=${LIBNAME}.so" >> $serverPath/php/$version/etc/php.ini
|
||||
echo "${LIBNAME}.output_dir=/tmp/xhprof" >> $serverPath/php/$version/etc/php.ini
|
||||
|
||||
|
||||
$serverPath/php/init.d/php$version reload
|
||||
echo '==========================================================='
|
||||
@@ -71,10 +83,11 @@ Uninstall_lib()
|
||||
return
|
||||
fi
|
||||
|
||||
sed -i '_bak' "/${LIBNAME}.so/d" $serverPath/php/$version/etc/php.ini
|
||||
sed -i '_bak' "/${LIBNAME}/d" $serverPath/php/$version/etc/php.ini
|
||||
sed -i $BAK "/${LIBNAME}.so/d" $serverPath/php/$version/etc/php.ini
|
||||
sed -i $BAK "/${LIBNAME}/d" $serverPath/php/$version/etc/php.ini
|
||||
|
||||
rm -f $extFile
|
||||
|
||||
$serverPath/php/init.d/php$version reload
|
||||
echo '==============================================='
|
||||
echo 'successful!'
|
||||
|
||||
@@ -23,6 +23,12 @@ if [ "$version" = '70' ] || [ "$version" = '71' ] || [ "$version" = '72' ] || [
|
||||
LIBV='3.0.7';
|
||||
fi
|
||||
|
||||
if [ "$sysName" == "Darwin" ];then
|
||||
BAK='_bak'
|
||||
else
|
||||
BAK=''
|
||||
fi
|
||||
|
||||
Install_lib()
|
||||
{
|
||||
|
||||
@@ -79,9 +85,9 @@ Uninstall_lib()
|
||||
fi
|
||||
|
||||
echo $serverPath/php/$version/etc/php.ini
|
||||
sed -i '_bak' "/yaf.so/d" $serverPath/php/$version/etc/php.ini
|
||||
sed -i '_bak' "/yaf.use_namespace/d" $serverPath/php/$version/etc/php.ini
|
||||
sed -i '_bak' "/\[yaf\]/d" $serverPath/php/$version/etc/php.ini
|
||||
sed -i $BAK "/yaf.so/d" $serverPath/php/$version/etc/php.ini
|
||||
sed -i $BAK "/yaf.use_namespace/d" $serverPath/php/$version/etc/php.ini
|
||||
sed -i $BAK "/\[yaf\]/d" $serverPath/php/$version/etc/php.ini
|
||||
|
||||
rm -f $extFile
|
||||
$serverPath/php/init.d/php$version reload
|
||||
|
||||
@@ -23,6 +23,12 @@ if [ "$version" = '70' ] || [ "$version" = '71' ] || [ "$version" = '72' ] || [
|
||||
LIBV='2.0.5'
|
||||
fi
|
||||
|
||||
if [ "$sysName" == "Darwin" ];then
|
||||
BAK='_bak'
|
||||
else
|
||||
BAK=''
|
||||
fi
|
||||
|
||||
Install_lib()
|
||||
{
|
||||
|
||||
@@ -81,9 +87,9 @@ Uninstall_lib()
|
||||
fi
|
||||
|
||||
echo $serverPath/php/$version/etc/php.ini
|
||||
sed -i '_bak' "/${LIBNAME}.so/d" $serverPath/php/$version/etc/php.ini
|
||||
sed -i '_bak' "/${LIBNAME}.use_namespace/d" $serverPath/php/$version/etc/php.ini
|
||||
sed -i '_bak' "/\[${LIBNAME}\]/d" $serverPath/php/$version/etc/php.ini
|
||||
sed -i $BAK "/${LIBNAME}.so/d" $serverPath/php/$version/etc/php.ini
|
||||
sed -i $BAK "/${LIBNAME}.use_namespace/d" $serverPath/php/$version/etc/php.ini
|
||||
sed -i $BAK "/\[${LIBNAME}\]/d" $serverPath/php/$version/etc/php.ini
|
||||
|
||||
rm -f $extFile
|
||||
$serverPath/php/init.d/php$version reload
|
||||
|
||||
@@ -18,6 +18,12 @@ actionType=$1
|
||||
version=$2
|
||||
extFile=$serverPath/php/${version}/lib/php/extensions/no-debug-non-zts-20090626/${LIBNAME}.so
|
||||
|
||||
if [ "$sysName" == "Darwin" ];then
|
||||
BAK='_bak'
|
||||
else
|
||||
BAK=''
|
||||
fi
|
||||
|
||||
Install_lib()
|
||||
{
|
||||
|
||||
@@ -52,7 +58,7 @@ Install_lib()
|
||||
|
||||
echo "" >> $serverPath/php/$version/etc/php.ini
|
||||
echo "[Zend ZendGuard Loader]" >> $serverPath/php/$version/etc/php.ini
|
||||
echo "zend_extension=ZendGuardLoader.so" >> $serverPath/php/$version/etc/php.ini
|
||||
echo "zend_extension=$serverPath/php/$version/lib/php/extensions/no-debug-non-zts-20090626/ZendGuardLoader.so" >> $serverPath/php/$version/etc/php.ini
|
||||
echo "zend_loader.enable=1" >> $serverPath/php/$version/etc/php.ini
|
||||
echo "zend_loader.disable_licensing=0" >> $serverPath/php/$version/etc/php.ini
|
||||
echo "zend_loader.obfuscation_level_support=3" >> $serverPath/php/$version/etc/php.ini
|
||||
@@ -76,9 +82,9 @@ Uninstall_lib()
|
||||
return
|
||||
fi
|
||||
|
||||
sed -i '_bak' "/ZendGuardLoader.so/d" $serverPath/php/$version/etc/php.ini
|
||||
sed -i '_bak' "/zend_loader/d" $serverPath/php/$version/etc/php.ini
|
||||
sed -i '_bak' "/\[Zend ZendGuard Loader\]/d" $serverPath/php/$version/etc/php.ini
|
||||
sed -i $BAK "/ZendGuardLoader.so/d" $serverPath/php/$version/etc/php.ini
|
||||
sed -i $BAK "/zend_loader/d" $serverPath/php/$version/etc/php.ini
|
||||
sed -i $BAK "/\[Zend ZendGuard Loader\]/d" $serverPath/php/$version/etc/php.ini
|
||||
|
||||
rm -f $extFile
|
||||
$serverPath/php/init.d/php$version reload
|
||||
|
||||
@@ -12,12 +12,19 @@ serverPath=$(dirname "$rootPath")
|
||||
sourcePath=${serverPath}/source/php
|
||||
|
||||
LIBNAME=apc
|
||||
_LIBNAME=$(echo $LIBNAME | tr '[a-z]' '[A-Z]')
|
||||
LIBV=3.1.9
|
||||
sysName=`uname`
|
||||
actionType=$1
|
||||
version=$2
|
||||
extFile=$serverPath/php/${version}/lib/php/extensions/no-debug-non-zts-20100525/${LIBNAME}.so
|
||||
|
||||
if [ "$sysName" == "Darwin" ];then
|
||||
BAK='_bak'
|
||||
else
|
||||
BAK=''
|
||||
fi
|
||||
|
||||
Install_lib()
|
||||
{
|
||||
isInstall=`cat $serverPath/php/$version/etc/php.ini|grep "${LIBNAME}.so"`
|
||||
@@ -30,12 +37,11 @@ Install_lib()
|
||||
|
||||
php_lib=$sourcePath/php_lib
|
||||
mkdir -p $php_lib
|
||||
if [ ! -d $php_lib/${LIBNAME}-${LIBV}];then
|
||||
_LIBNAME=$(echo $LIBNAME | tr '[a-z]' '[A-Z]')
|
||||
if [ ! -d $php_lib/${_LIBNAME}-${LIBV} ];then
|
||||
wget -O $php_lib/${LIBNAME}-${LIBV}.tgz http://pecl.php.net/get/${_LIBNAME}-${LIBV}.tgz
|
||||
cd $php_lib && tar xvf ${LIBNAME}-${LIBV}.tgz
|
||||
fi
|
||||
cd $php_lib/${LIBNAME}-${LIBV}
|
||||
cd $php_lib/${_LIBNAME}-${LIBV}
|
||||
|
||||
$serverPath/php/$version/bin/phpize
|
||||
./configure --with-php-config=$serverPath/php/$version/bin/php-config
|
||||
@@ -71,8 +77,8 @@ Uninstall_lib()
|
||||
return
|
||||
fi
|
||||
|
||||
sed -i '_bak' "/${LIBNAME}.so/d" $serverPath/php/$version/etc/php.ini
|
||||
sed -i '_bak' "/${LIBNAME}/d" $serverPath/php/$version/etc/php.ini
|
||||
sed -i $BAK "/${LIBNAME}.so/d" $serverPath/php/$version/etc/php.ini
|
||||
sed -i $BAK "/${LIBNAME}/d" $serverPath/php/$version/etc/php.ini
|
||||
|
||||
rm -f $extFile
|
||||
$serverPath/php/init.d/php$version reload
|
||||
|
||||
@@ -18,6 +18,12 @@ actionType=$1
|
||||
version=$2
|
||||
extFile=$serverPath/php/${version}/lib/php/extensions/no-debug-non-zts-20100525/${LIBNAME}.so
|
||||
|
||||
if [ "$sysName" == "Darwin" ];then
|
||||
BAK='_bak'
|
||||
else
|
||||
BAK=''
|
||||
fi
|
||||
|
||||
Install_lib()
|
||||
{
|
||||
isInstall=`cat $serverPath/php/$version/etc/php.ini|grep "${LIBNAME}.so"`
|
||||
@@ -38,9 +44,7 @@ Install_lib()
|
||||
cd ${LIBNAME}-${LIBV}
|
||||
$serverPath/php/$version/bin/phpize
|
||||
./configure --with-php-config=$serverPath/php/$version/bin/php-config \
|
||||
--enable-memcache --with-zlib-dir=$serverPath/lib/zlib \
|
||||
--with-libmemcached-dir=$serverPath/lib/libmemcached
|
||||
make && make install && make clean
|
||||
&& make && make install && make clean
|
||||
|
||||
fi
|
||||
|
||||
@@ -72,8 +76,8 @@ Uninstall_lib()
|
||||
return
|
||||
fi
|
||||
|
||||
sed -i '_bak' '/${LIBNAME}.so/d' $serverPath/php/$version/etc/php.ini
|
||||
sed -i '_bak' '/${LIBNAME}/d' $serverPath/php/$version/etc/php.ini
|
||||
sed -i $BAK "/${LIBNAME}.so/d" $serverPath/php/$version/etc/php.ini
|
||||
sed -i $BAK "/${LIBNAME}/d" $serverPath/php/$version/etc/php.ini
|
||||
|
||||
rm -f $extFile
|
||||
$serverPath/php/init.d/php$version reload
|
||||
|
||||
@@ -21,7 +21,10 @@ mkdir -p $sourcePath/php
|
||||
mkdir -p $serverPath/php
|
||||
|
||||
if [ ! -d $sourcePath/php/php${PHP_VER} ];then
|
||||
wget --no-check-certificate -O $sourcePath/php/php-${version}.tar.gz http://au1.php.net/distributions/php-${version}.tar.gz
|
||||
if [ ! -f $sourcePath/php/php-${version}.tar.gz ];then
|
||||
wget --no-check-certificate -O $sourcePath/php/php-${version}.tar.gz http://au1.php.net/distributions/php-${version}.tar.gz
|
||||
fi
|
||||
|
||||
cd $sourcePath/php && tar -zxvf $sourcePath/php/php-${version}.tar.gz
|
||||
mv $sourcePath/php/php-${version} $sourcePath/php/php${PHP_VER}
|
||||
fi
|
||||
@@ -38,13 +41,16 @@ else
|
||||
OPTIONS="${OPTIONS} --with-curl"
|
||||
fi
|
||||
|
||||
if [ ! -d $serverPath/php/54 ];then
|
||||
if [ ! -d $serverPath/php/${PHP_VER} ];then
|
||||
cd $sourcePath/php/php${PHP_VER} && ./configure \
|
||||
--prefix=$serverPath/php/54 \
|
||||
--exec-prefix=$serverPath/php/54 \
|
||||
--with-config-file-path=$serverPath/php/54/etc \
|
||||
--prefix=$serverPath/php/${PHP_VER} \
|
||||
--exec-prefix=$serverPath/php/${PHP_VER} \
|
||||
--with-config-file-path=$serverPath/php/${PHP_VER}/etc \
|
||||
--with-zlib-dir=$serverPath/lib/zlib \
|
||||
--enable-mysqlnd \
|
||||
--with-mysql=mysqlnd \
|
||||
--with-pdo-mysql=mysqlnd \
|
||||
--with-mysqli=mysqlnd \
|
||||
--enable-zip \
|
||||
--enable-mbstring \
|
||||
--enable-sockets \
|
||||
|
||||
@@ -18,6 +18,12 @@ actionType=$1
|
||||
version=$2
|
||||
extFile=$serverPath/php/${version}/lib/php/extensions/no-debug-non-zts-20100525/${LIBNAME}.so
|
||||
|
||||
if [ "$sysName" == "Darwin" ];then
|
||||
BAK='_bak'
|
||||
else
|
||||
BAK=''
|
||||
fi
|
||||
|
||||
Install_lib()
|
||||
{
|
||||
isInstall=`cat $serverPath/php/$version/etc/php.ini|grep "${LIBNAME}.so"`
|
||||
@@ -72,8 +78,8 @@ Uninstall_lib()
|
||||
return
|
||||
fi
|
||||
|
||||
sed -i '_bak' '/${LIBNAME}.so/d' $serverPath/php/$version/etc/php.ini
|
||||
sed -i '_bak' '/${LIBNAME}/d' $serverPath/php/$version/etc/php.ini
|
||||
sed -i $BAK "/${LIBNAME}.so/d" $serverPath/php/$version/etc/php.ini
|
||||
sed -i $BAK "/${LIBNAME}/d" $serverPath/php/$version/etc/php.ini
|
||||
|
||||
rm -f $extFile
|
||||
$serverPath/php/init.d/php$version reload
|
||||
|
||||
@@ -18,6 +18,12 @@ actionType=$1
|
||||
version=$2
|
||||
extFile=$serverPath/php/${version}/lib/php/extensions/no-debug-non-zts-20100525/${LIBNAME}.so
|
||||
|
||||
if [ "$sysName" == "Darwin" ];then
|
||||
BAK='_bak'
|
||||
else
|
||||
BAK=''
|
||||
fi
|
||||
|
||||
Install_lib()
|
||||
{
|
||||
isInstall=`cat $serverPath/php/$version/etc/php.ini|grep "${LIBNAME}.so"`
|
||||
@@ -40,10 +46,7 @@ Install_lib()
|
||||
|
||||
$serverPath/php/$version/bin/phpize
|
||||
./configure --with-php-config=$serverPath/php/$version/bin/php-config \
|
||||
--enable-memcache \
|
||||
--with-zlib-dir=$serverPath/lib/zlib \
|
||||
--with-libmemcached-dir=$serverPath/lib/libmemcached
|
||||
make && make install && make clean
|
||||
--enable-memcached && make clean && make && make install && make clean
|
||||
|
||||
fi
|
||||
|
||||
@@ -75,8 +78,8 @@ Uninstall_lib()
|
||||
return
|
||||
fi
|
||||
|
||||
sed -i '_bak' '/${LIBNAME}.so/d' $serverPath/php/$version/etc/php.ini
|
||||
sed -i '_bak' '/${LIBNAME}/d' $serverPath/php/$version/etc/php.ini
|
||||
sed -i $BAK "/${LIBNAME}.so/d" $serverPath/php/$version/etc/php.ini
|
||||
sed -i $BAK "/${LIBNAME}/d" $serverPath/php/$version/etc/php.ini
|
||||
|
||||
rm -f $extFile
|
||||
$serverPath/php/init.d/php$version reload
|
||||
|
||||
@@ -18,6 +18,12 @@ actionType=$1
|
||||
version=$2
|
||||
extFile=$serverPath/php/${version}/lib/php/extensions/no-debug-non-zts-20100525/${LIBNAME}.so
|
||||
|
||||
if [ "$sysName" == "Darwin" ];then
|
||||
BAK='_bak'
|
||||
else
|
||||
BAK=''
|
||||
fi
|
||||
|
||||
Install_lib()
|
||||
{
|
||||
isInstall=`cat $serverPath/php/$version/etc/php.ini|grep "${LIBNAME}.so"`
|
||||
@@ -78,8 +84,8 @@ Uninstall_lib()
|
||||
return
|
||||
fi
|
||||
|
||||
sed -i '_bak' "/${LIBNAME}.so/d" $serverPath/php/$version/etc/php.ini
|
||||
sed -i '_bak' "/${LIBNAME}/d" $serverPath/php/$version/etc/php.ini
|
||||
sed -i $BAK "/${LIBNAME}.so/d" $serverPath/php/$version/etc/php.ini
|
||||
sed -i $BAK "/${LIBNAME}/d" $serverPath/php/$version/etc/php.ini
|
||||
|
||||
rm -f $extFile
|
||||
$serverPath/php/init.d/php$version reload
|
||||
|
||||
@@ -18,6 +18,12 @@ actionType=$1
|
||||
version=$2
|
||||
extFile=$serverPath/php/${version}/lib/php/extensions/no-debug-non-zts-20100525/${LIBNAME}.so
|
||||
|
||||
if [ "$sysName" == "Darwin" ];then
|
||||
BAK='_bak'
|
||||
else
|
||||
BAK=''
|
||||
fi
|
||||
|
||||
Install_lib()
|
||||
{
|
||||
isInstall=`cat $serverPath/php/$version/etc/php.ini|grep "${LIBNAME}.so"`
|
||||
@@ -75,9 +81,6 @@ Uninstall_lib()
|
||||
echo "php-$version 未安装,请选择其它版本!"
|
||||
return
|
||||
fi
|
||||
|
||||
sed -i '_bak' "/${LIBNAME}.so/d" $serverPath/php/$version/etc/php.ini
|
||||
sed -i '_bak' "/${LIBNAME}/d" $serverPath/php/$version/etc/php.ini
|
||||
|
||||
if [ ! -f "$extFile" ];then
|
||||
echo "php-$version 未安装${LIBNAME},请选择其它版本!"
|
||||
@@ -85,8 +88,8 @@ Uninstall_lib()
|
||||
return
|
||||
fi
|
||||
|
||||
sed -i '_bak' "/${LIBNAME}.so/d" $serverPath/php/$version/etc/php.ini
|
||||
sed -i '_bak' "/${LIBNAME}/d" $serverPath/php/$version/etc/php.ini
|
||||
sed -i $BAK "/${LIBNAME}.so/d" $serverPath/php/$version/etc/php.ini
|
||||
sed -i $BAK "/${LIBNAME}/d" $serverPath/php/$version/etc/php.ini
|
||||
|
||||
rm -f $extFile
|
||||
|
||||
|
||||
@@ -19,6 +19,12 @@ version=$2
|
||||
|
||||
extDir=$serverPath/php/${version}/lib/php/extensions/no-debug-non-zts-20100525/
|
||||
|
||||
if [ "$sysName" == "Darwin" ];then
|
||||
BAK='_bak'
|
||||
else
|
||||
BAK=''
|
||||
fi
|
||||
|
||||
Install_lib()
|
||||
{
|
||||
isInstall=`cat $serverPath/php/$version/etc/php.ini|grep "${LIBNAME}.so"`
|
||||
@@ -73,8 +79,8 @@ Uninstall_lib()
|
||||
return
|
||||
fi
|
||||
|
||||
sed -i '_bak' "/${LIBNAME}.so/d" $serverPath/php/$version/etc/php.ini
|
||||
sed -i '_bak' "/${LIBNAME}/d" $serverPath/php/$version/etc/php.ini
|
||||
sed -i $BAK "/${LIBNAME}.so/d" $serverPath/php/$version/etc/php.ini
|
||||
sed -i $BAK "/${LIBNAME}/d" $serverPath/php/$version/etc/php.ini
|
||||
|
||||
rm -f $extFile
|
||||
$serverPath/php/init.d/php$version reload
|
||||
|
||||
@@ -20,6 +20,13 @@ version=$2
|
||||
|
||||
extDir=$serverPath/php/${version}/lib/php/extensions/no-debug-non-zts-20100525/
|
||||
|
||||
sysName=`uname`
|
||||
if [ "$sysName" == "Darwin" ];then
|
||||
BAK='_bak'
|
||||
else
|
||||
BAK=''
|
||||
fi
|
||||
|
||||
Install_lib()
|
||||
{
|
||||
isInstall=`cat $serverPath/php/$version/etc/php.ini|grep "${_LIBNAME}.so"`
|
||||
@@ -28,7 +35,7 @@ Install_lib()
|
||||
return
|
||||
fi
|
||||
|
||||
extFile=$extDir${LIBNAME}.so
|
||||
extFile=$extDir${_LIBNAME}.so
|
||||
if [ ! -f "$extFile" ];then
|
||||
|
||||
php_lib=$sourcePath/php_lib
|
||||
@@ -74,15 +81,15 @@ Uninstall_lib()
|
||||
return
|
||||
fi
|
||||
|
||||
extFile=$extDir${LIBNAME}.so
|
||||
extFile=$extDir${_LIBNAME}.so
|
||||
if [ ! -f "$extFile" ];then
|
||||
echo "php-$version 未安装${LIBNAME},请选择其它版本!"
|
||||
echo "php-$version not install ${LIBNAME}, Plese select other version!"
|
||||
return
|
||||
fi
|
||||
_LIBNAME=$(echo $LIBNAME | tr '[A-Z]' '[a-z]')
|
||||
sed -i '_bak' "/${_LIBNAME}.so/d" $serverPath/php/$version/etc/php.ini
|
||||
sed -i '_bak' "/${_LIBNAME}/d" $serverPath/php/$version/etc/php.ini
|
||||
sed -i $BAK "/${_LIBNAME}.so/d" $serverPath/php/$version/etc/php.ini
|
||||
sed -i $BAK "/${_LIBNAME}/d" $serverPath/php/$version/etc/php.ini
|
||||
|
||||
rm -f $extFile
|
||||
$serverPath/php/init.d/php$version reload
|
||||
|
||||
@@ -19,6 +19,12 @@ version=$2
|
||||
|
||||
extDir=$serverPath/php/${version}/lib/php/extensions/no-debug-non-zts-20100525/
|
||||
|
||||
if [ "$sysName" == "Darwin" ];then
|
||||
BAK='_bak'
|
||||
else
|
||||
BAK=''
|
||||
fi
|
||||
|
||||
Install_lib()
|
||||
{
|
||||
isInstall=`cat $serverPath/php/$version/etc/php.ini|grep "${LIBNAME}.so"`
|
||||
@@ -79,8 +85,8 @@ Uninstall_lib()
|
||||
return
|
||||
fi
|
||||
|
||||
sed -i '_bak' "/${LIBNAME}.so/d" $serverPath/php/$version/etc/php.ini
|
||||
sed -i '_bak' "/${LIBNAME}/d" $serverPath/php/$version/etc/php.ini
|
||||
sed -i $BAK "/${LIBNAME}.so/d" $serverPath/php/$version/etc/php.ini
|
||||
sed -i $BAK "/${LIBNAME}/d" $serverPath/php/$version/etc/php.ini
|
||||
|
||||
rm -f $extFile
|
||||
$serverPath/php/init.d/php$version reload
|
||||
|
||||
@@ -21,6 +21,11 @@ if [ "$version" = '70' ] || [ "$version" = '71' ] || [ "$version" = '72' ];then
|
||||
fi
|
||||
extFile=$serverPath/php/${version}/lib/php/extensions/no-debug-non-zts-20100525/${LIBNAME}.so
|
||||
|
||||
if [ "$sysName" == "Darwin" ];then
|
||||
BAK='_bak'
|
||||
else
|
||||
BAK=''
|
||||
fi
|
||||
|
||||
Install_lib()
|
||||
{
|
||||
@@ -88,8 +93,8 @@ Uninstall_lib()
|
||||
fi
|
||||
|
||||
echo $serverPath/php/$version/etc/php.ini
|
||||
sed -i '_bak' "/${LIBNAME}.so/d" $serverPath/php/$version/etc/php.ini
|
||||
sed -i '_bak' "/${LIBNAME}/d" $serverPath/php/$version/etc/php.ini
|
||||
sed -i $BAK "/${LIBNAME}.so/d" $serverPath/php/$version/etc/php.ini
|
||||
sed -i $BAK "/${LIBNAME}/d" $serverPath/php/$version/etc/php.ini
|
||||
|
||||
rm -f $extFile
|
||||
$serverPath/php/init.d/php$version reload
|
||||
|
||||
@@ -18,6 +18,12 @@ actionType=$1
|
||||
version=$2
|
||||
extFile=$serverPath/php/${version}/lib/php/extensions/no-debug-non-zts-20100525/${LIBNAME}.so
|
||||
|
||||
if [ "$sysName" == "Darwin" ];then
|
||||
BAK='_bak'
|
||||
else
|
||||
BAK=''
|
||||
fi
|
||||
|
||||
Install_lib()
|
||||
{
|
||||
isInstall=`cat $serverPath/php/$version/etc/php.ini|grep "${LIBNAME}.so"`
|
||||
@@ -38,9 +44,7 @@ Install_lib()
|
||||
cd ${LIBNAME}-${LIBV}
|
||||
$serverPath/php/$version/bin/phpize
|
||||
./configure --with-php-config=$serverPath/php/$version/bin/php-config \
|
||||
--enable-memcache --with-zlib-dir=$serverPath/lib/zlib \
|
||||
--with-libmemcached-dir=$serverPath/lib/libmemcached
|
||||
make && make install && make clean
|
||||
&& make && make install && make clean
|
||||
|
||||
fi
|
||||
|
||||
@@ -72,8 +76,8 @@ Uninstall_lib()
|
||||
return
|
||||
fi
|
||||
|
||||
sed -i '_bak' '/${LIBNAME}.so/d' $serverPath/php/$version/etc/php.ini
|
||||
sed -i '_bak' '/${LIBNAME}/d' $serverPath/php/$version/etc/php.ini
|
||||
sed -i $BAK "/${LIBNAME}.so/d" $serverPath/php/$version/etc/php.ini
|
||||
sed -i $BAK "/${LIBNAME}/d" $serverPath/php/$version/etc/php.ini
|
||||
|
||||
rm -f $extFile
|
||||
$serverPath/php/init.d/php$version reload
|
||||
|
||||
@@ -18,6 +18,12 @@ actionType=$1
|
||||
version=$2
|
||||
extFile=$serverPath/php/${version}/lib/php/extensions/no-debug-non-zts-20100525/${LIBNAME}.so
|
||||
|
||||
if [ "$sysName" == "Darwin" ];then
|
||||
BAK='_bak'
|
||||
else
|
||||
BAK=''
|
||||
fi
|
||||
|
||||
Install_lib()
|
||||
{
|
||||
isInstall=`cat $serverPath/php/$version/etc/php.ini|grep "${LIBNAME}.so"`
|
||||
@@ -45,10 +51,16 @@ Install_lib()
|
||||
return
|
||||
fi
|
||||
|
||||
if [ ! -f /tmp/xhprof ];then
|
||||
mkdir -p /tmp/xhprof
|
||||
chown -R www:www /tmp/xhprof
|
||||
fi
|
||||
|
||||
|
||||
echo "" >> $serverPath/php/$version/etc/php.ini
|
||||
echo "[${LIBNAME}]" >> $serverPath/php/$version/etc/php.ini
|
||||
echo "extension=${LIBNAME}.so" >> $serverPath/php/$version/etc/php.ini
|
||||
echo "${LIBNAME}.output_dir=/tmp/xhprof" >> $serverPath/php/$version/etc/php.ini
|
||||
|
||||
$serverPath/php/init.d/php$version reload
|
||||
echo '==========================================================='
|
||||
@@ -73,6 +85,7 @@ Uninstall_lib()
|
||||
sed -i '_bak' "/${LIBNAME}/d" $serverPath/php/$version/etc/php.ini
|
||||
|
||||
rm -f $extFile
|
||||
|
||||
$serverPath/php/init.d/php$version reload
|
||||
echo '==============================================='
|
||||
echo 'successful!'
|
||||
|
||||
@@ -23,6 +23,13 @@ if [ "$version" = '70' ] || [ "$version" = '71' ] || [ "$version" = '72' ] || [
|
||||
LIBV='3.0.7'
|
||||
fi
|
||||
|
||||
sysName=`uname`
|
||||
if [ "$sysName" == "Darwin" ];then
|
||||
BAK='_bak'
|
||||
else
|
||||
BAK=''
|
||||
fi
|
||||
|
||||
Install_lib()
|
||||
{
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user