mirror of
https://github.com/midoks/mdserver-web.git
synced 2026-10-10 07:09:25 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3a7882e7fa | ||
|
|
bec2a9a12c | ||
|
|
8f02363782 | ||
|
|
939c847f3e | ||
|
|
a623039db7 | ||
|
|
b7f49a1839 | ||
|
|
f1f60870f6 | ||
|
|
3b04739fd4 | ||
|
|
fdf1e0b0be | ||
|
|
d3385f526f | ||
|
|
20f9095b93 | ||
|
|
757cf483a2 | ||
|
|
1712cfd024 | ||
|
|
2b524cbe75 | ||
|
|
607d384000 | ||
|
|
14cdc7b82e | ||
|
|
c3219bcba2 | ||
|
|
a12c4dd78e | ||
|
|
39c6f19592 | ||
|
|
f18c05a097 | ||
|
|
80f296ea19 | ||
|
|
b3e9283a58 | ||
|
|
2e140a3ae1 | ||
|
|
4d733c8886 | ||
|
|
62a7320baf | ||
|
|
3dc7c2f5c1 | ||
|
|
fe62bbee06 | ||
|
|
f7c0cd82a0 | ||
|
|
13a2014558 | ||
|
|
5981f94376 | ||
|
|
005e0f1513 | ||
|
|
63a0f0fbdc | ||
|
|
edc0be11a1 | ||
|
|
908b6e67c6 | ||
|
|
dfe46332db | ||
|
|
fcdf2e18b2 | ||
|
|
3c8f9bcf96 | ||
|
|
ebadd6d80d | ||
|
|
6062699074 | ||
|
|
df9d57ba70 | ||
|
|
ffca953539 | ||
|
|
bd4946124f | ||
|
|
8e18c63cee | ||
|
|
d201ca2574 | ||
|
|
b644f91090 | ||
|
|
931f51cf59 | ||
|
|
0909a11fd9 | ||
|
|
2ba2833699 | ||
|
|
20389263fb | ||
|
|
86141ccf3a | ||
|
|
b2fdf84ca0 | ||
|
|
8fbc456e1a | ||
|
|
4e43382496 | ||
|
|
0326d4f112 | ||
|
|
a87c13c5e0 | ||
|
|
5f3720c855 | ||
|
|
f548e020c4 | ||
|
|
7f21781c0b | ||
|
|
680b0f09f2 | ||
|
|
482943a63c | ||
|
|
2871aee18e | ||
|
|
ff46d9b36e | ||
|
|
fd5fcba543 | ||
|
|
fe04e02e88 | ||
|
|
93554332a7 | ||
|
|
b541c7e1b7 | ||
|
|
1dec1a286a | ||
|
|
b17510104d | ||
|
|
c2c8ea0ce6 | ||
|
|
acbdb013ae | ||
|
|
b025f21765 | ||
|
|
1afc8a69e5 | ||
|
|
743fc9e8d3 | ||
|
|
8d692d2b3b | ||
|
|
a0b362e691 | ||
|
|
98e1c2ae8f | ||
|
|
c0e5915285 | ||
|
|
667a0fd0fd | ||
|
|
8ed5f283b0 | ||
|
|
643c370d30 | ||
|
|
4601303065 | ||
|
|
14940d6734 | ||
|
|
fdc2b0f5c4 | ||
|
|
cf0b233f63 | ||
|
|
b3a7ef2206 | ||
|
|
9a3ca3e833 | ||
|
|
9afff8df3f | ||
|
|
ccd0b06223 | ||
|
|
7b495fe9bf | ||
|
|
2c3fb75e8f | ||
|
|
53b606602f | ||
|
|
ecef0cf994 | ||
|
|
3691d41b23 | ||
|
|
1f66457a3e | ||
|
|
8e05beccfd | ||
|
|
35424eae1f | ||
|
|
ed6df6d527 | ||
|
|
4366c4afde | ||
|
|
4bb059f62f | ||
|
|
aa8f618d9c | ||
|
|
dfd753e4c1 | ||
|
|
e38daf3c89 | ||
|
|
535838fc5e | ||
|
|
797853bd61 | ||
|
|
0de3aff045 | ||
|
|
0b7b48ab23 | ||
|
|
5ff0a0bfbc | ||
|
|
9131f44d67 | ||
|
|
6b86bb9d2b | ||
|
|
dc06d6beda | ||
|
|
2c8ea2498e | ||
|
|
6b01173b61 | ||
|
|
883c554850 | ||
|
|
d267da351c | ||
|
|
13a39f4d6a | ||
|
|
cff1d5ee89 | ||
|
|
bf5274c313 | ||
|
|
5623e3efac | ||
|
|
b93bb6c64c | ||
|
|
c9962f169e | ||
|
|
080f343ee2 | ||
|
|
5aeaf13f16 | ||
|
|
528094cfa7 | ||
|
|
ed3e3336b2 | ||
|
|
a75a49c2ae | ||
|
|
1204e72f41 | ||
|
|
13ca5544a5 | ||
|
|
e53fe26d52 | ||
|
|
13772399f6 | ||
|
|
98f11e2662 | ||
|
|
f0b0302f75 | ||
|
|
5b9b466cb9 | ||
|
|
5588a11ea5 | ||
|
|
da05a4ef19 | ||
|
|
34cf899529 | ||
|
|
0d7d67b012 | ||
|
|
5b778bfc0d | ||
|
|
6ce414cecf | ||
|
|
c8160b63e7 | ||
|
|
68d957fd6e | ||
|
|
f09c438500 | ||
|
|
9bc9944a3e | ||
|
|
9e4c2b13d5 | ||
|
|
cd7143047f | ||
|
|
d608ac4d94 | ||
|
|
9fedf9d10d | ||
|
|
9936191da2 | ||
|
|
538eba3acf | ||
|
|
e39ee9a6f7 | ||
|
|
e1820ad5b3 | ||
|
|
22133f1a6c | ||
|
|
0041cbdff3 | ||
|
|
889da3c769 | ||
|
|
d086eb9c61 | ||
|
|
832fa9cd1a | ||
|
|
8c19fb9629 | ||
|
|
a2e4dd6753 | ||
|
|
22ba7dda55 | ||
|
|
2ffa36eecb | ||
|
|
fe5843b35d | ||
|
|
e95acbe947 | ||
|
|
aed8319dd3 | ||
|
|
babe1b885e | ||
|
|
0612f52402 | ||
|
|
db67cea737 | ||
|
|
52cf675843 | ||
|
|
3421bf6ab5 | ||
|
|
2f39bd600b | ||
|
|
acd5ec69e8 | ||
|
|
09878728af | ||
|
|
af82e9f129 | ||
|
|
c74630e738 | ||
|
|
e4e0697b4b | ||
|
|
11b5ac658b | ||
|
|
1306731164 | ||
|
|
bb6c933aee | ||
|
|
d6a93ef1e6 | ||
|
|
6610da402a | ||
|
|
3ace9cf51e | ||
|
|
49c7ec6073 | ||
|
|
8cf526667e | ||
|
|
6c42876411 | ||
|
|
79471e3806 | ||
|
|
cad06425fc | ||
|
|
6f1e11e474 | ||
|
|
59d13e50ce | ||
|
|
5da0746240 | ||
|
|
192ea8b029 | ||
|
|
bfc20b3e42 | ||
|
|
56bee5c752 | ||
|
|
312df5de1f | ||
|
|
4d3640286c | ||
|
|
20930806b6 | ||
|
|
71360b61da | ||
|
|
411645c9e2 | ||
|
|
3de4e1bfff | ||
|
|
34285f6051 | ||
|
|
84f0cda89b | ||
|
|
04012085ce | ||
|
|
9ad00f3ce7 | ||
|
|
609a4ed351 | ||
|
|
5ca74fd312 | ||
|
|
3b1bb06c68 | ||
|
|
b6b7de42d6 | ||
|
|
3aa3b532ac | ||
|
|
290c740ab1 | ||
|
|
23fd4ca1de | ||
|
|
c128a799b2 | ||
|
|
401c103b76 | ||
|
|
6fb88eb428 | ||
|
|
956f20d295 | ||
|
|
03f8578a37 | ||
|
|
265e17beac | ||
|
|
f3d83ad8a5 | ||
|
|
39b376a7cb | ||
|
|
07858794ef | ||
|
|
391473fc14 | ||
|
|
0993adcc5f | ||
|
|
90b1d88111 | ||
|
|
87098cff95 | ||
|
|
e6e64b2a4c | ||
|
|
81436ea81b | ||
|
|
cf7d29190d | ||
|
|
4ff62ec6ad | ||
|
|
dac3ccce8d | ||
|
|
10bd7aa70f | ||
|
|
dec0afc3d3 | ||
|
|
2331853b3b | ||
|
|
b9e063e423 | ||
|
|
52294948b2 | ||
|
|
87bec2b988 | ||
|
|
9ab91ecc93 | ||
|
|
18312a3596 | ||
|
|
8fb35440c8 | ||
|
|
a874934379 | ||
|
|
2c4e4aea3f | ||
|
|
6b115261be | ||
|
|
059ce6228b | ||
|
|
cfa396b4bb | ||
|
|
11e4b377ed | ||
|
|
31fe2aab92 | ||
|
|
19042a9088 | ||
|
|
2eb4543c3b | ||
|
|
e33ccbfc7d | ||
|
|
ed8c9eed0a | ||
|
|
7163a7bbcf | ||
|
|
3f1c23ec8b | ||
|
|
3a6cb0ae2a | ||
|
|
936492d410 | ||
|
|
39d265aae7 | ||
|
|
5a33098dd3 | ||
|
|
c9927c3fb9 | ||
|
|
da90386816 | ||
|
|
6be4c5977b | ||
|
|
bbf93bfd9e | ||
|
|
a2570af5f7 | ||
|
|
77120cf31b | ||
|
|
395f449b93 | ||
|
|
8be5f4aa7b | ||
|
|
3ccebf4f47 | ||
|
|
15d48accad | ||
|
|
d0045d831c | ||
|
|
a7cac3d671 | ||
|
|
7bc7fdecae | ||
|
|
480663e2ad | ||
|
|
2290efd060 | ||
|
|
dece5a0532 | ||
|
|
b0a44d24d4 | ||
|
|
d092d9f5f2 | ||
|
|
944b3e779c | ||
|
|
55dc2715e9 | ||
|
|
84bf3abd5d | ||
|
|
00c9157f9b | ||
|
|
faa95b0d88 | ||
|
|
52d0b3c940 | ||
|
|
0141028d41 | ||
|
|
9e6bf08a72 | ||
|
|
49ff9750cb | ||
|
|
75b2b4dbc2 | ||
|
|
667c60dda0 | ||
|
|
aa6818f953 | ||
|
|
6f884fe60a | ||
|
|
a56d53c672 | ||
|
|
00b1788172 | ||
|
|
cee268fcbc | ||
|
|
40dd929823 | ||
|
|
b59949e181 | ||
|
|
9c5975253a | ||
|
|
62003b987a | ||
|
|
df0a454c3a | ||
|
|
02048c3265 | ||
|
|
65649d171d | ||
|
|
a136da6ec2 | ||
|
|
3b25ca7e60 | ||
|
|
c5cf8f8afb | ||
|
|
89f7d464ab | ||
|
|
4cac6d1921 | ||
|
|
dca5c82d2f | ||
|
|
08988130b5 | ||
|
|
8849001384 | ||
|
|
ae0a6b5079 | ||
|
|
d6c6ae5561 | ||
|
|
a6dc15f22d | ||
|
|
360b962bd2 | ||
|
|
37d37e0f1d | ||
|
|
ddc6da9172 | ||
|
|
ceba7ab673 | ||
|
|
384704b8e5 | ||
|
|
232d0c2f74 | ||
|
|
ef8e6f07f5 | ||
|
|
435e565559 | ||
|
|
ec9d7e337d | ||
|
|
b5c7a2a778 | ||
|
|
72d9c9b761 | ||
|
|
30812e1fba | ||
|
|
c95cb07e8d | ||
|
|
f3f2ea8ef0 | ||
|
|
9e5a5192cb | ||
|
|
271b3d448c | ||
|
|
b7424e7195 | ||
|
|
b607527e1f | ||
|
|
3c42a4e450 | ||
|
|
b11fd9508a | ||
|
|
dc0504cf24 | ||
|
|
1d8b82395f | ||
|
|
39ac55760e | ||
|
|
ef6071956d | ||
|
|
bbbe1c84ce | ||
|
|
064252daad | ||
|
|
3cb63c6265 | ||
|
|
b541abad42 | ||
|
|
547027be0d | ||
|
|
d786b2524a | ||
|
|
abac345628 | ||
|
|
d4290cbdd2 | ||
|
|
cfd2d99e24 | ||
|
|
28437ccfb0 | ||
|
|
43bf755609 | ||
|
|
de225fc8b9 | ||
|
|
44f891f7a3 | ||
|
|
64d1387b03 | ||
|
|
51ccbefb04 | ||
|
|
29e3017e51 | ||
|
|
197e2d80c6 | ||
|
|
b8f04043bc | ||
|
|
2ed70b4b96 | ||
|
|
d056c37be5 | ||
|
|
e75abae4b9 | ||
|
|
3e695770d7 | ||
|
|
7301edbc5a | ||
|
|
704b256408 | ||
|
|
e129051a06 | ||
|
|
d38e9f7ad0 | ||
|
|
c696742866 | ||
|
|
046389df99 | ||
|
|
3e244ed227 | ||
|
|
5016aedb0f | ||
|
|
c1cd45a5f3 | ||
|
|
79c9865a5d | ||
|
|
4082f29424 | ||
|
|
d777a29d8c | ||
|
|
04e43e051e | ||
|
|
dffe9a77e7 | ||
|
|
1b1462586e | ||
|
|
f11d2db761 | ||
|
|
842c16540a | ||
|
|
614cc1032f | ||
|
|
ad46b2050e | ||
|
|
8109989927 | ||
|
|
9d9b39dfe2 | ||
|
|
422514c40a | ||
|
|
632568643b | ||
|
|
a5f29a2a6a | ||
|
|
b02705aa5a | ||
|
|
1f9ab560e3 | ||
|
|
b3970326cd | ||
|
|
f6d008e0b6 | ||
|
|
6f9a49ad7a | ||
|
|
fc3c7d334a | ||
|
|
1030d1b923 | ||
|
|
94d4a90bcc | ||
|
|
da4b872666 | ||
|
|
cf15b19f4b | ||
|
|
aa9cdaada4 | ||
|
|
659c9fe16b | ||
|
|
2b8c6d6e43 | ||
|
|
263f83088f | ||
|
|
374c938ac0 | ||
|
|
6aa73b0cae | ||
|
|
7f731ae06f | ||
|
|
f87aff704c | ||
|
|
be9fa87133 | ||
|
|
de6fc19dee | ||
|
|
3987c6d3dc | ||
|
|
96875052cd | ||
|
|
583de57f96 | ||
|
|
41b7245f03 | ||
|
|
ee3684706f | ||
|
|
07936dfb81 | ||
|
|
5c46202be0 | ||
|
|
7123a15457 | ||
|
|
4aeb45b1d5 | ||
|
|
006a62be22 | ||
|
|
1e91d11125 | ||
|
|
99fb4aa723 | ||
|
|
5c5bbb2da2 | ||
|
|
8b05045901 | ||
|
|
1b73439525 | ||
|
|
ec51ad016a | ||
|
|
a42fae66ac | ||
|
|
b4c635c2e5 | ||
|
|
9802bc5915 | ||
|
|
196fbbdd7d | ||
|
|
fa278abd50 | ||
|
|
f9b2dbcb5e | ||
|
|
a8808be9ae | ||
|
|
4122de13e3 | ||
|
|
4acae8e5f5 | ||
|
|
1abb611c3e | ||
|
|
726f9fa0d2 | ||
|
|
cfb64caadc | ||
|
|
f501dd5150 | ||
|
|
d1fe006e39 | ||
|
|
d4db5dbfac | ||
|
|
efa512a3f6 | ||
|
|
b53436343d | ||
|
|
bb1a634f3c | ||
|
|
acda55cc55 | ||
|
|
0ff0728517 | ||
|
|
c575f55354 | ||
|
|
d58339dbcb | ||
|
|
f6a18fa25f | ||
|
|
3016eff372 | ||
|
|
ca518591f3 | ||
|
|
d2c74f2243 | ||
|
|
71dbf8e359 | ||
|
|
cb2ad0ca82 | ||
|
|
a157db7879 | ||
|
|
fb949f4ee6 | ||
|
|
b91ae3fde2 | ||
|
|
b508e8003b | ||
|
|
0632a4b535 | ||
|
|
397e0b89a5 | ||
|
|
2427bf81cd | ||
|
|
4179bbf580 | ||
|
|
b93c3bb88e | ||
|
|
a52c854afd | ||
|
|
d7e5cf1f45 | ||
|
|
cfb444deac | ||
|
|
78615451ac | ||
|
|
0134643c83 | ||
|
|
70ddd1c86f | ||
|
|
808dc743ef | ||
|
|
e30693f9f2 | ||
|
|
5c97fbe011 | ||
|
|
6419a18525 | ||
|
|
4a804e9243 | ||
|
|
d44526004f | ||
|
|
c1f402b278 | ||
|
|
45a3eec1b5 | ||
|
|
d6f41ceb6a | ||
|
|
a1bc0f6faf | ||
|
|
8420961cf7 | ||
|
|
421594c01d | ||
|
|
ca13e8ad77 | ||
|
|
f161f24253 | ||
|
|
e5ab03951f | ||
|
|
5b45bab36d | ||
|
|
0594d3f9ce | ||
|
|
ad541216c5 | ||
|
|
1adc0c1405 | ||
|
|
b22185b374 | ||
|
|
02f3107e93 | ||
|
|
52fece867d | ||
|
|
2e3578dcf1 | ||
|
|
73b09a7886 | ||
|
|
f33c7e5a5e | ||
|
|
3e90db2c8d | ||
|
|
d599363609 | ||
|
|
ec3167f239 | ||
|
|
2b1099b6e9 | ||
|
|
e55a0760e3 | ||
|
|
5c1353a38f | ||
|
|
f95684b316 | ||
|
|
6fc729ccf9 | ||
|
|
45d0c4fc4a | ||
|
|
6759b9055c | ||
|
|
de694b2465 | ||
|
|
c7b3daca36 | ||
|
|
452769233f | ||
|
|
8d196a3aa1 | ||
|
|
01baf509ad | ||
|
|
d59ee2c843 | ||
|
|
8919d5734e | ||
|
|
bb91b30d6d | ||
|
|
103ab2e099 | ||
|
|
0d33d0db79 | ||
|
|
6d9f4cfa08 | ||
|
|
c88c95ba21 | ||
|
|
a705f6a8e4 | ||
|
|
3f40ed0a01 | ||
|
|
39653896bf | ||
|
|
31d665d962 | ||
|
|
811fa4a40d | ||
|
|
320f58424d | ||
|
|
376f0f0a4e | ||
|
|
0efb700cee | ||
|
|
ff3fcae366 | ||
|
|
22d94ce67c | ||
|
|
042fd7ac6d | ||
|
|
1a48f52dad | ||
|
|
fc5970c65d | ||
|
|
e758698ee2 | ||
|
|
ea03bb056a | ||
|
|
088346fd5e | ||
|
|
cbcb686363 |
+7
-4
@@ -151,18 +151,18 @@ data/system.db-journal
|
||||
data/hook_*.json
|
||||
data/letsencrypt.json
|
||||
data/basic_auth.json
|
||||
data/notify.json
|
||||
data/api.json
|
||||
data/bind_domain.pl
|
||||
data/unauthorized_status.pl
|
||||
|
||||
plugins/vip_*
|
||||
plugins/own_*
|
||||
plugins/my_*
|
||||
plugins/l2tp
|
||||
plugins/openlitespeed
|
||||
plugins/system_safe
|
||||
plugins/tamper_proof
|
||||
plugins/tamper_proof_*
|
||||
plugins/op_load_balance
|
||||
plugins/cryptocurrency_trade
|
||||
plugins/gdrive
|
||||
plugins/mtproxy
|
||||
plugins/zimg
|
||||
@@ -175,4 +175,7 @@ plugins/file_search
|
||||
debug.out
|
||||
|
||||
|
||||
data/unauthorized_status.pl
|
||||
|
||||
|
||||
mdioks.session-journal
|
||||
*.session
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
基本上可以使用,后续会继续优化!欢迎提供意见!
|
||||
|
||||
- 吹水组 - https://t.me/mdserver_web
|
||||
- 交流论坛 - https://bbs.midoks.me
|
||||
|
||||
```
|
||||
如果出现问题,最好私给我面板信息。不要让我猜。如果不提供,不要提出问题,自行解决。 — 座右铭
|
||||
@@ -73,7 +74,7 @@ phpMyAdmin[4.4.15]支持MySQL[5.5-5.7]
|
||||
phpMyAdmin[5.2.0]支持MySQL[8.0]
|
||||
|
||||
PHP[53-72]支持phpMyAdmin[4.4.15]
|
||||
PHP[72-81]支持phpMyAdmin[5.2.0]
|
||||
PHP[72-82]支持phpMyAdmin[5.2.0]
|
||||
```
|
||||
|
||||
# 特别赞助
|
||||
@@ -98,35 +99,29 @@ docker run -itd --name mw-server --privileged=true -p 7200:7200 -p 80:80 -p 443:
|
||||
```
|
||||
|
||||
|
||||
### 版本更新 0.12.3
|
||||
### 版本更新 0.14.5
|
||||
|
||||
* 优先使用firewalld防火墙。
|
||||
* PHP[APT]加入curl扩展。
|
||||
* 配置添加【未认证响应状态】功能。
|
||||
* 存在ipv6时,启动时强制开启。
|
||||
* OP防火墙-性能优化。
|
||||
* 网站统计优化。
|
||||
* 优化backup_ftp插件。
|
||||
* 各种细节优化。
|
||||
* 软件管理-搜索功能。
|
||||
* 文件-右键功能优化。
|
||||
|
||||
### JSDelivr安装地址
|
||||
|
||||
- 初始安装
|
||||
|
||||
```
|
||||
curl -fsSL https://cdn.jsdelivr.net/gh/midoks/mdserver-web@latest/scripts/install.sh | bash
|
||||
curl --insecure -fsSL https://cdn.jsdelivr.net/gh/midoks/mdserver-web@latest/scripts/install.sh | bash
|
||||
```
|
||||
|
||||
- 直接更新
|
||||
|
||||
```
|
||||
curl -fsSL https://cdn.jsdelivr.net/gh/midoks/mdserver-web@latest/scripts/update.sh | bash
|
||||
curl --insecure -fsSL https://cdn.jsdelivr.net/gh/midoks/mdserver-web@latest/scripts/update.sh | bash
|
||||
```
|
||||
|
||||
- 卸载脚本
|
||||
|
||||
```
|
||||
wget -O uninstall.sh https://cdn.jsdelivr.net/gh/midoks/mdserver-web@latest/scripts/uninstall.sh && bash uninstall.sh
|
||||
wget --no-check-certificate -O uninstall.sh https://cdn.jsdelivr.net/gh/midoks/mdserver-web@latest/scripts/uninstall.sh && bash uninstall.sh
|
||||
```
|
||||
|
||||
### 备用地址
|
||||
@@ -134,20 +129,20 @@ wget -O uninstall.sh https://cdn.jsdelivr.net/gh/midoks/mdserver-web@latest/scri
|
||||
- 初始安装
|
||||
|
||||
```
|
||||
curl -fsSL https://raw.githubusercontent.com/midoks/mdserver-web/master/scripts/install.sh | bash
|
||||
|
||||
curl --insecure -fsSL https://raw.githubusercontent.com/midoks/mdserver-web/master/scripts/install.sh | bash
|
||||
curl --insecure -fsSL https://code.midoks.me/midoks/mdserver-web/raw/branch/master/scripts/install.sh | bash
|
||||
```
|
||||
|
||||
- 直接更新
|
||||
|
||||
```
|
||||
curl -fsSL https://raw.githubusercontent.com/midoks/mdserver-web/master/scripts/update.sh | bash
|
||||
curl --insecure -fsSL https://raw.githubusercontent.com/midoks/mdserver-web/master/scripts/update.sh | bash
|
||||
```
|
||||
|
||||
- 卸载脚本
|
||||
|
||||
```
|
||||
wget -O uninstall.sh https://raw.githubusercontent.com/midoks/mdserver-web/master/scripts/uninstall.sh && bash uninstall.sh
|
||||
wget --no-check-certificate -O uninstall.sh https://raw.githubusercontent.com/midoks/mdserver-web/master/scripts/uninstall.sh && bash uninstall.sh
|
||||
```
|
||||
|
||||
|
||||
@@ -156,22 +151,22 @@ wget -O uninstall.sh https://raw.githubusercontent.com/midoks/mdserver-web/maste
|
||||
- 需已经安装mdserver-web
|
||||
|
||||
```
|
||||
curl -fsSL https://raw.githubusercontent.com/midoks/mdserver-web/dev/scripts/quick/app.sh | bash
|
||||
curl --insecure -fsSL https://raw.githubusercontent.com/midoks/mdserver-web/dev/scripts/quick/app.sh | bash
|
||||
```
|
||||
|
||||
|
||||
### DEV使用
|
||||
|
||||
```
|
||||
curl -fsSL https://raw.githubusercontent.com/midoks/mdserver-web/dev/scripts/install_dev.sh | bash
|
||||
curl -fsSL https://raw.githubusercontent.com/midoks/mdserver-web/dev/scripts/update_dev.sh | bash
|
||||
curl --insecure -fsSL https://raw.githubusercontent.com/midoks/mdserver-web/dev/scripts/install_dev.sh | bash
|
||||
curl --insecure -fsSL https://raw.githubusercontent.com/midoks/mdserver-web/dev/scripts/update_dev.sh | bash
|
||||
|
||||
wget -O uninstall.sh https://raw.githubusercontent.com/midoks/mdserver-web/dev/scripts/uninstall.sh && bash uninstall.sh
|
||||
wget --no-check-certificate -O uninstall.sh https://raw.githubusercontent.com/midoks/mdserver-web/dev/scripts/uninstall.sh && bash uninstall.sh
|
||||
|
||||
curl -fsSL https://raw.githubusercontent.com/midoks/mdserver-web/dev/scripts/quick/debug.sh | bash
|
||||
curl --insecure -fsSL https://raw.githubusercontent.com/midoks/mdserver-web/dev/scripts/quick/debug.sh | bash
|
||||
|
||||
curl -fsSL https://gitee.com/midoks/mdserver-web/raw/dev/scripts/install_dev.sh | bash
|
||||
curl -fsSL https://gitee.com/midoks/mdserver-web/raw/dev/scripts/update_dev.sh | bash
|
||||
curl --insecure -fsSL https://code.midoks.me/midoks/mdserver-web/raw/branch/dev/scripts/install_dev.sh | bash
|
||||
curl --insecure -fsSL https://code.midoks.me/midoks/mdserver-web/raw/branch/dev/scripts/update_dev.sh | bash
|
||||
```
|
||||
|
||||
### 捐赠地址 USDT(TRC20)
|
||||
|
||||
@@ -371,8 +371,7 @@ fi
|
||||
response = urllib.request.urlopen(req, timeout=timeout)
|
||||
return response
|
||||
except Exception as ex:
|
||||
|
||||
self.getError()
|
||||
# self.getError()
|
||||
raise Exception("requestsPost: {}".format(self.getError(str(ex))))
|
||||
|
||||
def getRequestJson(self, response):
|
||||
@@ -1007,7 +1006,7 @@ fi
|
||||
try:
|
||||
result = {}
|
||||
x509 = OpenSSL.crypto.load_certificate(
|
||||
OpenSSL.crypto.FILETYPE_PEM, public.readFile(pem_file))
|
||||
OpenSSL.crypto.FILETYPE_PEM, mw.readFile(pem_file))
|
||||
# 取产品名称
|
||||
issuer = x509.get_issuer()
|
||||
result['issuer'] = ''
|
||||
@@ -1281,16 +1280,16 @@ fullchain.pem 粘贴到证书输入框
|
||||
# 获取当前正在使用此证书的网站目录
|
||||
def getSslUsedSite(self, save_path):
|
||||
pkey_file = '{}/privkey.pem'.format(save_path)
|
||||
pkey = public.readFile(pkey_file)
|
||||
pkey = mw.readFile(pkey_file)
|
||||
if not pkey:
|
||||
return False
|
||||
cert_paths = 'vhost/cert'
|
||||
import panelSite
|
||||
args = public.dict_obj()
|
||||
args = mw.dict_obj()
|
||||
args.siteName = ''
|
||||
for c_name in os.listdir(cert_paths):
|
||||
skey_file = '{}/{}/privkey.pem'.format(cert_paths, c_name)
|
||||
skey = public.readFile(skey_file)
|
||||
skey = mw.readFile(skey_file)
|
||||
if not skey:
|
||||
continue
|
||||
if skey == pkey:
|
||||
@@ -1298,7 +1297,7 @@ fullchain.pem 粘贴到证书输入框
|
||||
run_path = panelSite.panelSite().GetRunPath(args)
|
||||
if not run_path:
|
||||
continue
|
||||
sitePath = public.M('sites').where(
|
||||
sitePath = mw.M('sites').where(
|
||||
'name=?', c_name).getField('path')
|
||||
if not sitePath:
|
||||
continue
|
||||
@@ -1316,7 +1315,7 @@ fullchain.pem 粘贴到证书输入框
|
||||
self.__config['orders'] = {}
|
||||
import panelSite
|
||||
siteObj = panelSite.panelSite()
|
||||
args = public.dict_obj()
|
||||
args = mw.dict_obj()
|
||||
for siteName in os.listdir(cert_path):
|
||||
try:
|
||||
cert_file = '{}/{}/fullchain.pem'.format(cert_path, siteName)
|
||||
@@ -1522,7 +1521,7 @@ fullchain.pem 粘贴到证书输入框
|
||||
self.__config['orders'][i]['auth_to'] = auth_to
|
||||
|
||||
# 是否到了允许重试的时间
|
||||
if 'next_retry_time' in self._config['orders'][i]:
|
||||
if 'next_retry_time' in self.__config['orders'][i]:
|
||||
timeout = self.__config['orders'][i][
|
||||
'next_retry_time'] - int(time.time())
|
||||
if timeout > 0:
|
||||
|
||||
@@ -916,7 +916,7 @@ class cert_request:
|
||||
try:
|
||||
result = {}
|
||||
x509 = OpenSSL.crypto.load_certificate(
|
||||
OpenSSL.crypto.FILETYPE_PEM, public.readFile(pem_file))
|
||||
OpenSSL.crypto.FILETYPE_PEM, mw.readFile(pem_file))
|
||||
# 取产品名称
|
||||
issuer = x509.get_issuer()
|
||||
result['issuer'] = ''
|
||||
@@ -1186,16 +1186,16 @@ fullchain.pem 粘贴到证书输入框
|
||||
# 获取当前正在使用此证书的网站目录
|
||||
def getSslUsedSite(self, save_path):
|
||||
pkey_file = '{}/privkey.pem'.format(save_path)
|
||||
pkey = public.readFile(pkey_file)
|
||||
pkey = mw.readFile(pkey_file)
|
||||
if not pkey:
|
||||
return False
|
||||
cert_paths = 'vhost/cert'
|
||||
import panelSite
|
||||
args = public.dict_obj()
|
||||
args = mw.dict_obj()
|
||||
args.siteName = ''
|
||||
for c_name in os.listdir(cert_paths):
|
||||
skey_file = '{}/{}/privkey.pem'.format(cert_paths, c_name)
|
||||
skey = public.readFile(skey_file)
|
||||
skey = mw.readFile(skey_file)
|
||||
if not skey:
|
||||
continue
|
||||
if skey == pkey:
|
||||
@@ -1203,7 +1203,7 @@ fullchain.pem 粘贴到证书输入框
|
||||
run_path = panelSite.panelSite().GetRunPath(args)
|
||||
if not run_path:
|
||||
continue
|
||||
sitePath = public.M('sites').where(
|
||||
sitePath = mw.M('sites').where(
|
||||
'name=?', c_name).getField('path')
|
||||
if not sitePath:
|
||||
continue
|
||||
@@ -1221,7 +1221,7 @@ fullchain.pem 粘贴到证书输入框
|
||||
self.__config['orders'] = {}
|
||||
import panelSite
|
||||
siteObj = panelSite.panelSite()
|
||||
args = public.dict_obj()
|
||||
args = mw.dict_obj()
|
||||
for siteName in os.listdir(cert_path):
|
||||
try:
|
||||
cert_file = '{}/{}/fullchain.pem'.format(cert_path, siteName)
|
||||
|
||||
+192
-12
@@ -27,7 +27,7 @@ from flask import request
|
||||
|
||||
class config_api:
|
||||
|
||||
__version = '0.12.3'
|
||||
__version = '0.14.5'
|
||||
__api_addr = 'data/api.json'
|
||||
|
||||
def __init__(self):
|
||||
@@ -348,7 +348,23 @@ class config_api:
|
||||
keyPath = 'ssl/private.pem'
|
||||
certPath = 'ssl/cert.pem'
|
||||
if not os.path.exists(certPath):
|
||||
mw.createSSL()
|
||||
# 不再自动生成证书
|
||||
# mw.createSSL()
|
||||
cert['privateKey'] = ''
|
||||
cert['is_https'] = ''
|
||||
cert['certPem'] = ''
|
||||
cert['rep'] = os.path.exists('ssl/input.pl')
|
||||
cert['info'] = {'endtime': 0, 'subject': '无',
|
||||
'notAfter': '无', 'notBefore': '无', 'issuer': '无'}
|
||||
return cert
|
||||
|
||||
panel_ssl = mw.getServerDir() + "/web_conf/nginx/vhost/panel.conf"
|
||||
if not os.path.exists(panel_ssl):
|
||||
cert['is_https'] = ''
|
||||
else:
|
||||
ssl_data = mw.readFile(panel_ssl)
|
||||
if ssl_data.find('$server_port !~ 443') != -1:
|
||||
cert['is_https'] = 'checked'
|
||||
|
||||
cert['privateKey'] = mw.readFile(keyPath)
|
||||
cert['certPem'] = mw.readFile(certPath)
|
||||
@@ -380,13 +396,86 @@ class config_api:
|
||||
mw.writeFile('ssl/input.pl', 'True')
|
||||
return mw.returnJson(True, '证书已保存!')
|
||||
|
||||
# 设置面板SSL证书设置
|
||||
def setPanelHttpToHttpsApi(self):
|
||||
|
||||
bind_domain = 'data/bind_domain.pl'
|
||||
if not os.path.exists(bind_domain):
|
||||
return mw.returnJson(False, '先要绑定域名!')
|
||||
|
||||
keyPath = 'ssl/private.pem'
|
||||
if not os.path.exists(keyPath):
|
||||
return mw.returnJson(False, '未申请SSL证书!')
|
||||
|
||||
is_https = request.form.get('https', '').strip()
|
||||
|
||||
panel_ssl = mw.getServerDir() + "/web_conf/nginx/vhost/panel.conf"
|
||||
if not os.path.exists(panel_ssl):
|
||||
return mw.returnJson(False, '未开启面板SSL!')
|
||||
|
||||
if is_https == 'false':
|
||||
conf = mw.readFile(panel_ssl)
|
||||
if conf:
|
||||
if conf.find('ssl_certificate') == -1:
|
||||
return mw.returnJson(False, '当前未开启SSL')
|
||||
to = "#error_page 404/404.html;\n\
|
||||
#HTTP_TO_HTTPS_START\n\
|
||||
if ($server_port !~ 443){\n\
|
||||
rewrite ^(/.*)$ https://$host$1 permanent;\n\
|
||||
}\n\
|
||||
#HTTP_TO_HTTPS_END"
|
||||
conf = conf.replace('#error_page 404/404.html;', to)
|
||||
mw.writeFile(panel_ssl, conf)
|
||||
else:
|
||||
conf = mw.readFile(panel_ssl)
|
||||
if conf:
|
||||
rep = "\n\s*#HTTP_TO_HTTPS_START(.|\n){1,300}#HTTP_TO_HTTPS_END"
|
||||
conf = re.sub(rep, '', conf)
|
||||
rep = "\s+if.+server_port.+\n.+\n\s+\s*}"
|
||||
conf = re.sub(rep, '', conf)
|
||||
mw.writeFile(panel_ssl, conf)
|
||||
|
||||
mw.restartWeb()
|
||||
|
||||
action = '开启'
|
||||
if is_https == 'true':
|
||||
action = '关闭'
|
||||
return mw.returnJson(True, action + 'HTTPS跳转成功!')
|
||||
|
||||
# 删除面板证书
|
||||
def delPanelSslApi(self):
|
||||
bind_domain = 'data/bind_domain.pl'
|
||||
if not os.path.exists(bind_domain):
|
||||
return mw.returnJson(False, '未绑定域名!')
|
||||
|
||||
siteName = mw.readFile(bind_domain).strip()
|
||||
|
||||
src_letpath = mw.getServerDir() + '/web_conf/letsencrypt/' + siteName
|
||||
|
||||
dst_letpath = mw.getRunDir() + '/ssl'
|
||||
dst_csrpath = dst_letpath + '/cert.pem'
|
||||
dst_keypath = dst_letpath + '/private.pem'
|
||||
|
||||
if os.path.exists(src_letpath) or os.path.exists(dst_csrpath):
|
||||
if os.path.exists(src_letpath):
|
||||
mw.execShell('rm -rf ' + src_letpath)
|
||||
if os.path.exists(dst_csrpath):
|
||||
mw.execShell('rm -rf ' + dst_csrpath)
|
||||
if os.path.exists(dst_keypath):
|
||||
mw.execShell('rm -rf ' + dst_keypath)
|
||||
# mw.restartWeb()
|
||||
return mw.returnJson(True, '已经删除SSL!')
|
||||
|
||||
# mw.restartWeb()
|
||||
return mw.returnJson(False, '已经不存在SSL!')
|
||||
|
||||
# 申请面板let证书
|
||||
def applyPanelLetSslApi(self):
|
||||
|
||||
# check domain is bind?
|
||||
bind_domain = 'data/bind_domain.pl'
|
||||
if not os.path.exists(bind_domain):
|
||||
return mw.returnJson(False, '未绑定域名!')
|
||||
return mw.returnJson(False, '先要绑定域名!')
|
||||
|
||||
siteName = mw.readFile(bind_domain).strip()
|
||||
auth_to = mw.getRunDir() + "/tmp"
|
||||
@@ -404,6 +493,8 @@ class config_api:
|
||||
dst_csrpath = dst_letpath + '/cert.pem'
|
||||
dst_keypath = dst_letpath + '/private.pem'
|
||||
|
||||
is_already_apply = False
|
||||
|
||||
if not os.path.exists(src_letpath):
|
||||
import cert_api
|
||||
data = cert_api.cert_api().applyCertApi(to_args)
|
||||
@@ -415,6 +506,8 @@ class config_api:
|
||||
msg = msg + '<p><span>响应状态:</span>' + str(emsg['status']) + '</p><p><span>错误类型:</span>' + emsg[
|
||||
'type'] + '</p><p><span>错误代码:</span>' + emsg['detail'] + '</p>'
|
||||
return mw.returnJson(data['status'], msg, data['msg'])
|
||||
else:
|
||||
is_already_apply = True
|
||||
|
||||
mw.buildSoftLink(src_csrpath, dst_csrpath, True)
|
||||
mw.buildSoftLink(src_keypath, dst_keypath, True)
|
||||
@@ -426,6 +519,9 @@ class config_api:
|
||||
if os.path.exists(tmp_well_know):
|
||||
mw.execShell('rm -rf ' + tmp_well_know)
|
||||
|
||||
if is_already_apply:
|
||||
return mw.returnJson(True, '重复申请!', data)
|
||||
|
||||
return mw.returnJson(True, '申请成功!', data)
|
||||
|
||||
def setPanelDomainApi(self):
|
||||
@@ -509,8 +605,6 @@ class config_api:
|
||||
return mw.returnJson(True, 'SSL已关闭,请使用http协议访问面板!')
|
||||
else:
|
||||
try:
|
||||
if not os.path.exists('ssl/input.ssl'):
|
||||
mw.createSSL()
|
||||
mw.writeFile(sslConf, 'True')
|
||||
|
||||
keyPath = mw.getRunDir() + '/ssl/private.pem'
|
||||
@@ -661,6 +755,67 @@ class config_api:
|
||||
mw.writeLog('面板设置', '将未授权响应状态码设置为:{}'.format(status_code))
|
||||
return mw.returnJson(True, '设置成功!')
|
||||
|
||||
def getNotifyApi(self):
|
||||
# 获取
|
||||
data = mw.getNotifyData(True)
|
||||
return mw.returnData(True, 'ok', data)
|
||||
|
||||
def setNotifyApi(self):
|
||||
tag = request.form.get('tag', '').strip()
|
||||
data = request.form.get('data', '').strip()
|
||||
|
||||
cfg = mw.getNotifyData(False)
|
||||
|
||||
crypt_data = mw.enDoubleCrypt(tag, data)
|
||||
if tag in cfg:
|
||||
cfg[tag]['cfg'] = crypt_data
|
||||
else:
|
||||
t = {'cfg': crypt_data}
|
||||
cfg[tag] = t
|
||||
|
||||
mw.writeNotify(cfg)
|
||||
return mw.returnData(True, '设置成功')
|
||||
|
||||
def setNotifyTestApi(self):
|
||||
# 异步通知验证
|
||||
tag = request.form.get('tag', '').strip()
|
||||
tag_data = request.form.get('data', '').strip()
|
||||
|
||||
if tag == 'tgbot':
|
||||
t = json.loads(tag_data)
|
||||
test_bool = mw.tgbotNotifyTest(t['app_token'], t['chat_id'])
|
||||
if test_bool:
|
||||
return mw.returnData(True, '验证成功')
|
||||
return mw.returnData(False, '验证失败')
|
||||
|
||||
if tag == 'email':
|
||||
t = json.loads(tag_data)
|
||||
test_bool = mw.emailNotifyTest(t)
|
||||
if test_bool:
|
||||
return mw.returnData(True, '验证成功')
|
||||
return mw.returnData(False, '验证失败')
|
||||
|
||||
return mw.returnData(False, '暂时未支持该验证')
|
||||
|
||||
def setNotifyEnableApi(self):
|
||||
# 异步通知验证
|
||||
tag = request.form.get('tag', '').strip()
|
||||
tag_enable = request.form.get('enable', '').strip()
|
||||
|
||||
data = mw.getNotifyData(False)
|
||||
op_enable = True
|
||||
op_action = '开启'
|
||||
if tag_enable != 'true':
|
||||
op_enable = False
|
||||
op_action = '关闭'
|
||||
|
||||
if tag in data:
|
||||
data[tag]['enable'] = op_enable
|
||||
|
||||
mw.writeNotify(data)
|
||||
|
||||
return mw.returnData(True, op_action + '成功')
|
||||
|
||||
def getPanelTokenApi(self):
|
||||
api_file = self.__api_addr
|
||||
tmp = mw.readFile(api_file)
|
||||
@@ -693,10 +848,6 @@ class config_api:
|
||||
def setPanelTokenApi(self):
|
||||
op_type = request.form.get('op_type', '').strip()
|
||||
|
||||
api_file = self.__api_addr
|
||||
tmp = mw.readFile(api_file)
|
||||
data = json.loads(tmp)
|
||||
|
||||
if op_type == '1':
|
||||
token = mw.getRandomString(32)
|
||||
data['token'] = mw.md5(token)
|
||||
@@ -706,7 +857,14 @@ class config_api:
|
||||
mw.writeFile(api_file, json.dumps(data))
|
||||
return mw.returnJson(True, 'ok', token)
|
||||
|
||||
elif op_type == '2':
|
||||
api_file = self.__api_addr
|
||||
if not os.path.exists(api_file):
|
||||
return mw.returnJson(False, "先在API接口配置")
|
||||
else:
|
||||
tmp = mw.readFile(api_file)
|
||||
data = json.loads(tmp)
|
||||
|
||||
if op_type == '2':
|
||||
data['open'] = not data['open']
|
||||
stats = {True: '开启', False: '关闭'}
|
||||
if not 'token_crypt' in data:
|
||||
@@ -721,6 +879,7 @@ class config_api:
|
||||
return mw.returnJson(not not data['open'], token)
|
||||
|
||||
elif op_type == '3':
|
||||
|
||||
limit_addr = request.form.get('limit_addr', '').strip()
|
||||
data['limit_addr'] = limit_addr.split('\n')
|
||||
mw.writeLog('API配置', '变更IP限制为[%s]' % limit_addr)
|
||||
@@ -820,7 +979,9 @@ class config_api:
|
||||
data['username'] = mw.M('users').where(
|
||||
"id=?", (1,)).getField('username')
|
||||
|
||||
# databases hook 获取
|
||||
data['hook_tag'] = request.args.get('tag', '')
|
||||
|
||||
# databases hook
|
||||
database_hook_file = 'data/hook_database.json'
|
||||
if os.path.exists(database_hook_file):
|
||||
df = mw.readFile(database_hook_file)
|
||||
@@ -829,7 +990,7 @@ class config_api:
|
||||
else:
|
||||
data['hook_database'] = []
|
||||
|
||||
# menu hook 获取
|
||||
# menu hook
|
||||
menu_hook_file = 'data/hook_menu.json'
|
||||
if os.path.exists(menu_hook_file):
|
||||
df = mw.readFile(menu_hook_file)
|
||||
@@ -838,4 +999,23 @@ class config_api:
|
||||
else:
|
||||
data['hook_menu'] = []
|
||||
|
||||
# global_static hook
|
||||
global_static_hook_file = 'data/hook_global_static.json'
|
||||
if os.path.exists(global_static_hook_file):
|
||||
df = mw.readFile(global_static_hook_file)
|
||||
df = json.loads(df)
|
||||
data['hook_global_static'] = df
|
||||
else:
|
||||
data['hook_global_static'] = []
|
||||
|
||||
# notiy config
|
||||
notify_data = mw.getNotifyData(True)
|
||||
notify_tag_list = ['tgbot', 'email']
|
||||
for tag in notify_tag_list:
|
||||
new_tag = 'notify_' + tag + '_enable'
|
||||
data[new_tag] = ''
|
||||
if tag in notify_data and 'enable' in notify_data[tag]:
|
||||
if notify_data[tag]['enable']:
|
||||
data[new_tag] = 'checked'
|
||||
|
||||
return data
|
||||
|
||||
+1
-1
@@ -348,7 +348,7 @@ class Sql():
|
||||
except Exception as ex:
|
||||
return "error: " + str(ex)
|
||||
|
||||
def query(self, sql, param):
|
||||
def query(self, sql, param=()):
|
||||
# 执行SQL语句返回数据集
|
||||
self.__getConn()
|
||||
try:
|
||||
|
||||
+111
-2
@@ -247,8 +247,8 @@ class files_api:
|
||||
os.remove(task_log)
|
||||
return mw.returnJson(True, '任务已删除!')
|
||||
|
||||
# 上传文件
|
||||
def uploadFileApi(self):
|
||||
# 上传文件
|
||||
from werkzeug.utils import secure_filename
|
||||
from flask import request
|
||||
|
||||
@@ -263,6 +263,8 @@ class files_api:
|
||||
if os.path.exists(filename):
|
||||
s_path = filename
|
||||
p_stat = os.stat(s_path)
|
||||
|
||||
# print(filename)
|
||||
f.save(filename)
|
||||
os.chown(filename, p_stat.st_uid, p_stat.st_gid)
|
||||
os.chmod(filename, p_stat.st_mode)
|
||||
@@ -271,6 +273,86 @@ class files_api:
|
||||
mw.writeLog('文件管理', msg)
|
||||
return mw.returnMsg(True, '上传成功!')
|
||||
|
||||
# 设置文件和目录权限
|
||||
def setMode(self, path):
|
||||
s_path = os.path.dirname(path)
|
||||
p_stat = os.stat(s_path)
|
||||
os.chown(path, p_stat.st_uid, p_stat.st_gid)
|
||||
os.chmod(path, p_stat.st_mode)
|
||||
|
||||
def uploadSegmentApi(self):
|
||||
# 分段上传
|
||||
path = request.form.get('path', '')
|
||||
name = request.form.get('name', '')
|
||||
size = request.form.get('size')
|
||||
start = request.form.get('start')
|
||||
dir_mode = request.form.get('dir_mode', '')
|
||||
file_mode = request.form.get('file_mode', '')
|
||||
|
||||
if not mw.fileNameCheck(name):
|
||||
return mw.returnJson(False, '文件名中不能包含特殊字符!')
|
||||
|
||||
if path == '/':
|
||||
return mw.returnJson(False, '不能直接上传文件到系统根目录!')
|
||||
|
||||
if name.find('./') != -1 or path.find('./') != -1:
|
||||
return mw.returnJson(False, '错误的参数')
|
||||
|
||||
if not os.path.exists(path):
|
||||
os.makedirs(path, 493)
|
||||
if not dir_mode != '' or not file_mode != '':
|
||||
mw.setMode(path)
|
||||
|
||||
save_path = os.path.join(
|
||||
path, name + '.' + str(int(size)) + '.upload.tmp')
|
||||
d_size = 0
|
||||
if os.path.exists(save_path):
|
||||
d_size = os.path.getsize(save_path)
|
||||
|
||||
if d_size != int(start):
|
||||
return str(d_size)
|
||||
|
||||
f = open(save_path, 'ab')
|
||||
b64_data = request.form.get('b64_data', '0')
|
||||
if b64_data == '1':
|
||||
import base64
|
||||
b64_data = base64.b64decode(args.b64_data)
|
||||
f.write(b64_data)
|
||||
else:
|
||||
upload_files = request.files.getlist("blob")
|
||||
for tmp_f in upload_files:
|
||||
f.write(tmp_f.read())
|
||||
|
||||
f.close()
|
||||
f_size = os.path.getsize(save_path)
|
||||
if f_size != int(size):
|
||||
return str(f_size)
|
||||
|
||||
new_name = os.path.join(path, name)
|
||||
if os.path.exists(new_name):
|
||||
if new_name.find('.user.ini') != -1:
|
||||
mw.execShell("chattr -i " + new_name)
|
||||
try:
|
||||
os.remove(new_name)
|
||||
except:
|
||||
mw.execShell("rm -f %s" % new_name)
|
||||
|
||||
os.renames(save_path, new_name)
|
||||
|
||||
if dir_mode != '' and dir_mode != '':
|
||||
mode_tmp1 = dir_mode.split(',')
|
||||
mw.setMode(path, mode_tmp1[0])
|
||||
mw.setOwn(path, mode_tmp1[1])
|
||||
mode_tmp2 = file_mode.split(',')
|
||||
mw.setMode(new_name, mode_tmp2[0])
|
||||
mw.setOwn(new_name, mode_tmp2[1])
|
||||
else:
|
||||
self.setMode(new_name)
|
||||
|
||||
msg = mw.getInfo('上传文件[{1}] 到 [{2}]成功!', (new_name, path))
|
||||
mw.writeLog('文件管理', msg)
|
||||
return mw.returnMsg(True, '上传成功!')
|
||||
|
||||
def getRecycleBinApi(self):
|
||||
rPath = self.rPath
|
||||
if not os.path.exists(rPath):
|
||||
@@ -626,7 +708,7 @@ class files_api:
|
||||
return not path in nDirs
|
||||
|
||||
def getDirSize(self, path):
|
||||
if mw.getOs() == 'darwin':
|
||||
if mw.isAppleSystem():
|
||||
tmp = mw.execShell('du -sh ' + path)
|
||||
else:
|
||||
tmp = mw.execShell('du -sbh ' + path)
|
||||
@@ -905,6 +987,33 @@ class files_api:
|
||||
|
||||
return mw.getJson(data)
|
||||
|
||||
def execShellApi(self):
|
||||
# 执行SHELL命令
|
||||
shell = request.form.get('shell', '').strip()
|
||||
path = request.form.get('path', '').strip()
|
||||
disabled = ['vi', 'vim', 'top', 'passwd', 'su']
|
||||
tmp = shell.split(' ')
|
||||
if tmp[0] in disabled:
|
||||
return mw.returnJson(False, '禁止执行[{}]'.format(tmp[0]))
|
||||
shellStr = '''#!/bin/bash
|
||||
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
|
||||
export PATH
|
||||
cd %s
|
||||
%s
|
||||
''' % (path, shell)
|
||||
mw.writeFile('/tmp/panelShell.sh', shellStr)
|
||||
mw.execShell(
|
||||
'nohup bash /tmp/panelShell.sh > /tmp/panelShell.pl 2>&1 &')
|
||||
return mw.returnJson(True, 'ok')
|
||||
|
||||
def getExecShellMsgApi(self):
|
||||
# 取SHELL执行结果
|
||||
fileName = '/tmp/panelShell.pl'
|
||||
if not os.path.exists(fileName):
|
||||
return ''
|
||||
status = not mw.processExists('bash', None, '/tmp/panelShell.sh')
|
||||
return mw.returnJson(status, mw.getNumLines(fileName, 200))
|
||||
|
||||
def __get_stats(self, filename, path=None):
|
||||
filename = filename.replace('//', '/')
|
||||
try:
|
||||
|
||||
+12
-11
@@ -36,10 +36,10 @@ class firewall_api:
|
||||
iptables_file = mw.systemdCfgDir() + '/iptables.service'
|
||||
if os.path.exists('/usr/sbin/firewalld'):
|
||||
self.__isFirewalld = True
|
||||
elif os.path.exists(iptables_file):
|
||||
self.__isIptables = True
|
||||
elif os.path.exists('/usr/sbin/ufw'):
|
||||
self.__isUfw = True
|
||||
elif os.path.exists(iptables_file):
|
||||
self.__isIptables = True
|
||||
elif mw.isAppleSystem():
|
||||
self.__isMac = True
|
||||
|
||||
@@ -123,12 +123,12 @@ class firewall_api:
|
||||
address = port
|
||||
if self.__isUfw:
|
||||
mw.execShell('ufw delete deny from ' + address + ' to any')
|
||||
elif self.__isIptables:
|
||||
cmd = 'iptables -D INPUT -s ' + address + ' -j DROP'
|
||||
mw.execShell(cmd)
|
||||
elif self.__isFirewalld:
|
||||
mw.execShell(
|
||||
'firewall-cmd --permanent --remove-rich-rule=\'rule family=ipv4 source address="' + address + '" drop\'')
|
||||
elif self.__isIptables:
|
||||
cmd = 'iptables -D INPUT -s ' + address + ' -j DROP'
|
||||
mw.execShell(cmd)
|
||||
else:
|
||||
pass
|
||||
|
||||
@@ -149,14 +149,15 @@ class firewall_api:
|
||||
return mw.returnJson(False, '失败,不能删除当前面板端口!')
|
||||
if self.__isUfw:
|
||||
mw.execShell('ufw delete allow ' + port + '/tcp')
|
||||
elif self.__isIptables:
|
||||
mw.execShell(
|
||||
'iptables -D INPUT -p tcp -m state --state NEW -m tcp --dport ' + port + ' -j ACCEPT')
|
||||
elif self.__isFirewalld:
|
||||
port = port.replace(':', '-')
|
||||
mw.execShell(
|
||||
'firewall-cmd --permanent --zone=public --remove-port=' + port + '/tcp')
|
||||
mw.execShell(
|
||||
'firewall-cmd --permanent --zone=public --remove-port=' + port + '/udp')
|
||||
elif self.__isIptables:
|
||||
mw.execShell(
|
||||
'iptables -D INPUT -p tcp -m state --state NEW -m tcp --dport ' + port + ' -j ACCEPT')
|
||||
else:
|
||||
pass
|
||||
msg = mw.getInfo('删除防火墙放行端口[{1}]成功!', (port,))
|
||||
@@ -438,13 +439,13 @@ class firewall_api:
|
||||
def addAcceptPort(self, port):
|
||||
if self.__isUfw:
|
||||
mw.execShell('ufw allow ' + port + '/tcp')
|
||||
elif self.__isIptables:
|
||||
cmd = 'iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport ' + port + ' -j ACCEPT'
|
||||
mw.execShell(cmd)
|
||||
elif self.__isFirewalld:
|
||||
port = port.replace(':', '-')
|
||||
cmd = 'firewall-cmd --permanent --zone=public --add-port=' + port + '/tcp'
|
||||
mw.execShell(cmd)
|
||||
elif self.__isIptables:
|
||||
cmd = 'iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport ' + port + ' -j ACCEPT'
|
||||
mw.execShell(cmd)
|
||||
else:
|
||||
pass
|
||||
return True
|
||||
|
||||
+403
-10
@@ -22,10 +22,14 @@ import hashlib
|
||||
import shlex
|
||||
import datetime
|
||||
import subprocess
|
||||
import glob
|
||||
import base64
|
||||
import re
|
||||
import db
|
||||
|
||||
from random import Random
|
||||
|
||||
import db
|
||||
|
||||
|
||||
def execShell(cmdstring, cwd=None, timeout=None, shell=True):
|
||||
|
||||
@@ -80,6 +84,10 @@ def getPanelDataDir():
|
||||
return getRunDir() + '/data'
|
||||
|
||||
|
||||
def getPanelTmp():
|
||||
return getRunDir() + '/tmp'
|
||||
|
||||
|
||||
def getServerDir():
|
||||
return getRootDir() + '/server'
|
||||
|
||||
@@ -123,6 +131,23 @@ def getAcmeDir():
|
||||
return acme
|
||||
|
||||
|
||||
def getAcmeDomainDir(domain):
|
||||
acme_dir = getAcmeDir()
|
||||
acme_domain = acme_dir + '/' + domain
|
||||
acme_domain_ecc = acme_domain + '_ecc'
|
||||
if os.path.exists(acme_domain_ecc):
|
||||
acme_domain = acme_domain_ecc
|
||||
return acme_domain
|
||||
|
||||
|
||||
def fileNameCheck(filename):
|
||||
f_strs = [';', '&', '<', '>']
|
||||
for fs in f_strs:
|
||||
if filename.find(fs) != -1:
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
def triggerTask():
|
||||
isTask = getRunDir() + '/tmp/panelTask.pl'
|
||||
writeFile(isTask, 'True')
|
||||
@@ -519,6 +544,14 @@ def getDate():
|
||||
return time.strftime('%Y-%m-%d %X', time.localtime())
|
||||
|
||||
|
||||
def getDateFromNow(tf_format="%Y-%m-%d %H:%M:%S", time_zone="Asia/Shanghai"):
|
||||
# 取格式时间
|
||||
import time
|
||||
os.environ['TZ'] = time_zone
|
||||
time.tzset()
|
||||
return time.strftime(tf_format, time.localtime())
|
||||
|
||||
|
||||
def getDataFromInt(val):
|
||||
time_format = '%Y-%m-%d %H:%M:%S'
|
||||
time_str = time.localtime(val)
|
||||
@@ -534,10 +567,39 @@ def writeLog(stype, msg, args=()):
|
||||
uid = session['uid']
|
||||
except Exception as e:
|
||||
pass
|
||||
# print(getTracebackInfo())
|
||||
# writeFileLog(getTracebackInfo())
|
||||
return writeDbLog(stype, msg, args, uid)
|
||||
|
||||
|
||||
def writeFileLog(msg, path=None, limit_size=50 * 1024 * 1024, save_limit=3):
|
||||
log_file = getServerDir() + '/mdserver-web/logs/debug.log'
|
||||
if path != None:
|
||||
log_file = path
|
||||
|
||||
if os.path.exists(log_file):
|
||||
size = os.path.getsize(log_file)
|
||||
if size > limit_size:
|
||||
log_file_rename = log_file + "_" + \
|
||||
time.strftime("%Y-%m-%d_%H%M%S") + '.log'
|
||||
os.rename(log_file, log_file_rename)
|
||||
logs = sorted(glob.glob(log_file + "_*"))
|
||||
count = len(logs)
|
||||
save_limit = count - save_limit
|
||||
for i in range(count):
|
||||
if i > save_limit:
|
||||
break
|
||||
os.remove(logs[i])
|
||||
# print('|---多余日志[' + logs[i] + ']已删除!')
|
||||
|
||||
f = open(log_file, 'ab+')
|
||||
msg += "\n"
|
||||
if __name__ == '__main__':
|
||||
print(msg)
|
||||
f.write(msg.encode('utf-8'))
|
||||
f.close()
|
||||
return True
|
||||
|
||||
|
||||
def writeDbLog(stype, msg, args=(), uid=1):
|
||||
try:
|
||||
import time
|
||||
@@ -656,7 +718,7 @@ def enCrypt(key, strings):
|
||||
result = f.encrypt(strings)
|
||||
return result.decode('utf-8')
|
||||
except:
|
||||
print(getTracebackInfo())
|
||||
writeFileLog(getTracebackInfo())
|
||||
return strings
|
||||
|
||||
|
||||
@@ -675,7 +737,7 @@ def deCrypt(key, strings):
|
||||
result = f.decrypt(strings).decode('utf-8')
|
||||
return result
|
||||
except:
|
||||
print(getTracebackInfo())
|
||||
writeFileLog(getTracebackInfo())
|
||||
return strings
|
||||
|
||||
|
||||
@@ -694,7 +756,7 @@ def enDoubleCrypt(key, strings):
|
||||
result = f.encrypt(strings)
|
||||
return result.decode('utf-8')
|
||||
except:
|
||||
print(getTracebackInfo())
|
||||
writeFileLog(getTracebackInfo())
|
||||
return strings
|
||||
|
||||
|
||||
@@ -712,10 +774,137 @@ def deDoubleCrypt(key, strings):
|
||||
result = f.decrypt(strings).decode('utf-8')
|
||||
return result
|
||||
except:
|
||||
print(getTracebackInfo())
|
||||
writeFileLog(getTracebackInfo())
|
||||
return strings
|
||||
|
||||
|
||||
def aesEncrypt(data, key='ABCDEFGHIJKLMNOP', vi='0102030405060708'):
|
||||
# aes加密
|
||||
# @param data 被加密的数据
|
||||
# @param key 加解密密匙 16位
|
||||
# @param vi 16位
|
||||
|
||||
from cryptography.hazmat.primitives import padding
|
||||
from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
|
||||
from cryptography.hazmat.backends import default_backend
|
||||
|
||||
if not isinstance(data, bytes):
|
||||
data = data.encode()
|
||||
|
||||
# AES_CBC_KEY = os.urandom(32)
|
||||
# AES_CBC_IV = os.urandom(16)
|
||||
|
||||
AES_CBC_KEY = key.encode()
|
||||
AES_CBC_IV = vi.encode()
|
||||
|
||||
# print("AES_CBC_KEY:", AES_CBC_KEY)
|
||||
# print("AES_CBC_IV:", AES_CBC_IV)
|
||||
|
||||
padder = padding.PKCS7(algorithms.AES.block_size).padder()
|
||||
padded_data = padder.update(data) + padder.finalize()
|
||||
|
||||
cipher = Cipher(algorithms.AES(AES_CBC_KEY),
|
||||
modes.CBC(AES_CBC_IV),
|
||||
backend=default_backend())
|
||||
encryptor = cipher.encryptor()
|
||||
|
||||
edata = encryptor.update(padded_data)
|
||||
|
||||
# print(edata)
|
||||
# print(str(edata))
|
||||
# print(edata.decode())
|
||||
return edata
|
||||
|
||||
|
||||
def aesDecrypt(data, key='ABCDEFGHIJKLMNOP', vi='0102030405060708'):
|
||||
# aes加密
|
||||
# @param data 被解密的数据
|
||||
# @param key 加解密密匙 16位
|
||||
# @param vi 16位
|
||||
|
||||
from cryptography.hazmat.primitives import padding
|
||||
from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
|
||||
from cryptography.hazmat.backends import default_backend
|
||||
|
||||
from cryptography.hazmat.primitives import padding
|
||||
from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
|
||||
from cryptography.hazmat.backends import default_backend
|
||||
|
||||
if not isinstance(data, bytes):
|
||||
data = data.encode()
|
||||
|
||||
AES_CBC_KEY = key.encode()
|
||||
AES_CBC_IV = vi.encode()
|
||||
|
||||
cipher = Cipher(algorithms.AES(AES_CBC_KEY),
|
||||
modes.CBC(AES_CBC_IV),
|
||||
backend=default_backend())
|
||||
decryptor = cipher.decryptor()
|
||||
|
||||
ddata = decryptor.update(data)
|
||||
|
||||
unpadder = padding.PKCS7(algorithms.AES.block_size).unpadder()
|
||||
data = unpadder.update(ddata)
|
||||
|
||||
try:
|
||||
uppadded_data = data + unpadder.finalize()
|
||||
except ValueError:
|
||||
raise Exception('无效的加密信息!')
|
||||
|
||||
return uppadded_data
|
||||
|
||||
|
||||
def aesEncrypt_Crypto(data, key, vi):
|
||||
# 该方法保留,暂时不使用
|
||||
# aes加密
|
||||
# @param data 被加密的数据
|
||||
# @param key 加解密密匙 16位
|
||||
# @param vi 16位
|
||||
|
||||
from Crypto.Cipher import AES
|
||||
cryptor = AES.new(key.encode('utf8'), AES.MODE_CBC, vi.encode('utf8'))
|
||||
# 判断是否含有中文
|
||||
zhmodel = re.compile(u'[\u4e00-\u9fff]')
|
||||
match = zhmodel.search(data)
|
||||
if match == None:
|
||||
# 无中文时
|
||||
add = 16 - len(data) % 16
|
||||
pad = lambda s: s + add * chr(add)
|
||||
data = pad(data)
|
||||
enctext = cryptor.encrypt(data.encode('utf8'))
|
||||
else:
|
||||
# 含有中文时
|
||||
data = data.encode()
|
||||
add = 16 - len(data) % 16
|
||||
data = data + add * (chr(add)).encode()
|
||||
enctext = cryptor.encrypt(data)
|
||||
encodestrs = base64.b64encode(enctext).decode('utf8')
|
||||
return encodestrs
|
||||
|
||||
|
||||
def aesDecrypt_Crypto(data, key, vi):
|
||||
# 该方法保留,暂时不使用
|
||||
# aes加密
|
||||
# @param data 被加密的数据
|
||||
# @param key 加解密密匙 16位
|
||||
# @param vi 16位
|
||||
|
||||
from crypto.Cipher import AES
|
||||
data = data.encode('utf8')
|
||||
encodebytes = base64.urlsafe_b64decode(data)
|
||||
cipher = AES.new(key.encode('utf8'), AES.MODE_CBC, vi.encode('utf8'))
|
||||
text_decrypted = cipher.decrypt(encodebytes)
|
||||
# 判断是否含有中文
|
||||
zhmodel = re.compile(u'[\u4e00-\u9fff]')
|
||||
match = zhmodel.search(text_decrypted)
|
||||
if match == False:
|
||||
# 无中文时补位
|
||||
unpad = lambda s: s[0:-s[-1]]
|
||||
text_decrypted = unpad(text_decrypted)
|
||||
text_decrypted = text_decrypted.decode('utf8').rstrip() # 去掉补位的右侧空格
|
||||
return text_decrypted
|
||||
|
||||
|
||||
def buildSoftLink(src, dst, force=False):
|
||||
'''
|
||||
建立软连接
|
||||
@@ -988,7 +1177,7 @@ def getLocalIp():
|
||||
try:
|
||||
ipaddress = readFile(filename)
|
||||
if not ipaddress or ipaddress == '127.0.0.1':
|
||||
cmd = "curl -4 -sS --connect-timeout 5 -m 60 https://v6r.ipip.net/?format=text"
|
||||
cmd = "curl --insecure -4 -sS --connect-timeout 5 -m 60 https://v6r.ipip.net/?format=text"
|
||||
ip = execShell(cmd)
|
||||
result = ip[0].strip()
|
||||
if result == '':
|
||||
@@ -997,7 +1186,7 @@ def getLocalIp():
|
||||
return result
|
||||
return ipaddress
|
||||
except Exception as e:
|
||||
cmd = "curl -6 -sS --connect-timeout 5 -m 60 https://v6r.ipip.net/?format=text"
|
||||
cmd = "curl --insecure -6 -sS --connect-timeout 5 -m 60 https://v6r.ipip.net/?format=text"
|
||||
ip = execShell(cmd)
|
||||
result = ip[0].strip()
|
||||
if result == '':
|
||||
@@ -1122,6 +1311,15 @@ def setOwn(filename, user, group=None):
|
||||
return True
|
||||
|
||||
|
||||
def setMode(filename, mode):
|
||||
# 设置文件权限
|
||||
if not os.path.exists(filename):
|
||||
return False
|
||||
mode = int(str(mode), 8)
|
||||
os.chmod(filename, mode)
|
||||
return True
|
||||
|
||||
|
||||
def checkPort(port):
|
||||
# 检查端口是否合法
|
||||
ports = ['21', '443', '888']
|
||||
@@ -1207,7 +1405,7 @@ def makeConf():
|
||||
file = getRunDir() + '/data/json/config.json'
|
||||
if not os.path.exists(file):
|
||||
c = {}
|
||||
c['title'] = '大圣面板'
|
||||
c['title'] = '金蝉面板'
|
||||
c['home'] = 'http://github/midoks/mdserver-web'
|
||||
c['recycle_bin'] = True
|
||||
c['template'] = 'default'
|
||||
@@ -1507,7 +1705,7 @@ def getCertName(certPath):
|
||||
result['notAfter'], "%Y-%m-%d")) - time.time()) / 86400)
|
||||
return result
|
||||
except Exception as e:
|
||||
# print(getTracebackInfo())
|
||||
writeFileLog(getTracebackInfo())
|
||||
return None
|
||||
|
||||
|
||||
@@ -1605,6 +1803,176 @@ def getMyORMDb():
|
||||
o = ormDb.ORM()
|
||||
return o
|
||||
|
||||
##################### notify start #########################################
|
||||
|
||||
|
||||
def initNotifyConfig():
|
||||
p = getNotifyPath()
|
||||
if not os.path.exists(p):
|
||||
writeFile(p, '{}')
|
||||
return True
|
||||
|
||||
|
||||
def getNotifyPath():
|
||||
path = 'data/notify.json'
|
||||
return path
|
||||
|
||||
|
||||
def getNotifyData(is_parse=False):
|
||||
initNotifyConfig()
|
||||
notify_file = getNotifyPath()
|
||||
notify_data = readFile(notify_file)
|
||||
|
||||
data = json.loads(notify_data)
|
||||
|
||||
if is_parse:
|
||||
tag_list = ['tgbot', 'email']
|
||||
for t in tag_list:
|
||||
if t in data and 'cfg' in data[t]:
|
||||
data[t]['data'] = json.loads(deDoubleCrypt(t, data[t]['cfg']))
|
||||
return data
|
||||
|
||||
|
||||
def writeNotify(data):
|
||||
p = getNotifyPath()
|
||||
return writeFile(p, json.dumps(data))
|
||||
|
||||
|
||||
def tgbotNotifyChatID():
|
||||
data = getNotifyData(True)
|
||||
if 'tgbot' in data and 'enable' in data['tgbot']:
|
||||
if data['tgbot']['enable']:
|
||||
t = data['tgbot']['data']
|
||||
return t['chat_id']
|
||||
return ''
|
||||
|
||||
|
||||
def tgbotNotifyObject():
|
||||
data = getNotifyData(True)
|
||||
if 'tgbot' in data and 'enable' in data['tgbot']:
|
||||
if data['tgbot']['enable']:
|
||||
t = data['tgbot']['data']
|
||||
import telebot
|
||||
bot = telebot.TeleBot(app_token)
|
||||
return True, bot
|
||||
return False, None
|
||||
|
||||
|
||||
def tgbotNotifyMessage(app_token, chat_id, msg):
|
||||
import telebot
|
||||
bot = telebot.TeleBot(app_token)
|
||||
try:
|
||||
data = bot.send_message(chat_id, msg)
|
||||
return True
|
||||
except Exception as e:
|
||||
writeFileLog(str(e))
|
||||
return False
|
||||
|
||||
|
||||
def tgbotNotifyHttpPost(app_token, chat_id, msg):
|
||||
try:
|
||||
url = 'https://api.telegram.org/bot' + app_token + '/sendMessage'
|
||||
post_data = {
|
||||
'chat_id': chat_id,
|
||||
'text': msg,
|
||||
}
|
||||
rdata = httpPost(url, post_data)
|
||||
return True
|
||||
except Exception as e:
|
||||
writeFileLog(str(e))
|
||||
return False
|
||||
|
||||
|
||||
def tgbotNotifyTest(app_token, chat_id):
|
||||
msg = 'MW-通知验证测试OK'
|
||||
return tgbotNotifyHttpPost(app_token, chat_id, msg)
|
||||
|
||||
|
||||
def emailNotifyMessage(data):
|
||||
'''
|
||||
邮件通知
|
||||
'''
|
||||
sys.path.append(os.getcwd() + "/class/plugin")
|
||||
import memail
|
||||
try:
|
||||
if data['smtp_ssl'] == 'ssl':
|
||||
memail.sendSSL(data['smtp_host'], data['smtp_port'],
|
||||
data['username'], data['password'],
|
||||
data['to_mail_addr'], data['subject'], data['content'])
|
||||
else:
|
||||
memail.send(data['smtp_host'], data['smtp_port'],
|
||||
data['username'], data['password'],
|
||||
data['to_mail_addr'], data['subject'], data['content'])
|
||||
return True
|
||||
except Exception as e:
|
||||
print(getTracebackInfo())
|
||||
return False
|
||||
|
||||
|
||||
def emailNotifyTest(data):
|
||||
# print(data)
|
||||
data['subject'] = 'MW通知测试'
|
||||
data['content'] = data['mail_test']
|
||||
return emailNotifyMessage(data)
|
||||
|
||||
|
||||
def notifyMessageTry(msg, stype='common', trigger_time=300, is_write_log=True):
|
||||
|
||||
lock_file = getPanelTmp() + '/notify_lock.json'
|
||||
if not os.path.exists(lock_file):
|
||||
writeFile(lock_file, '{}')
|
||||
|
||||
lock_data = json.loads(readFile(lock_file))
|
||||
if stype in lock_data:
|
||||
diff_time = time.time() - lock_data[stype]['do_time']
|
||||
if diff_time >= trigger_time:
|
||||
lock_data[stype]['do_time'] = time.time()
|
||||
else:
|
||||
return False
|
||||
else:
|
||||
lock_data[stype] = {'do_time': time.time()}
|
||||
|
||||
writeFile(lock_file, json.dumps(lock_data))
|
||||
|
||||
if is_write_log:
|
||||
writeLog("通知管理[" + stype + "]", msg)
|
||||
|
||||
data = getNotifyData(True)
|
||||
# tag_list = ['tgbot', 'email']
|
||||
# tagbot
|
||||
do_notify = False
|
||||
if 'tgbot' in data and 'enable' in data['tgbot']:
|
||||
if data['tgbot']['enable']:
|
||||
t = data['tgbot']['data']
|
||||
i = sys.version_info
|
||||
|
||||
# telebot 在python小于3.7无法使用
|
||||
if i[0] < 3 or i[1] < 7:
|
||||
do_notify = tgbotNotifyHttpPost(
|
||||
t['app_token'], t['chat_id'], msg)
|
||||
else:
|
||||
do_notify = tgbotNotifyMessage(
|
||||
t['app_token'], t['chat_id'], msg)
|
||||
|
||||
if 'email' in data and 'enable' in data['email']:
|
||||
if data['email']['enable']:
|
||||
t = data['email']['data']
|
||||
t['subject'] = 'MW通知'
|
||||
t['content'] = msg
|
||||
do_notify = emailNotifyMessage(t)
|
||||
return do_notify
|
||||
|
||||
|
||||
def notifyMessage(msg, stype='common', trigger_time=300, is_write_log=True):
|
||||
try:
|
||||
return notifyMessageTry(msg, stype, trigger_time, is_write_log)
|
||||
except Exception as e:
|
||||
writeFileLog(getTracebackInfo())
|
||||
return False
|
||||
|
||||
|
||||
##################### notify end #########################################
|
||||
|
||||
|
||||
##################### ssh start #########################################
|
||||
def getSshDir():
|
||||
@@ -1614,6 +1982,31 @@ def getSshDir():
|
||||
return '/root/.ssh'
|
||||
|
||||
|
||||
def processExists(pname, exe=None, cmdline=None):
|
||||
# 进程是否存在
|
||||
try:
|
||||
import psutil
|
||||
pids = psutil.pids()
|
||||
for pid in pids:
|
||||
try:
|
||||
p = psutil.Process(pid)
|
||||
if p.name() == pname:
|
||||
if not exe and not cmdline:
|
||||
return True
|
||||
else:
|
||||
if exe:
|
||||
if p.exe() == exe:
|
||||
return True
|
||||
if cmdline:
|
||||
if cmdline in p.cmdline():
|
||||
return True
|
||||
except:
|
||||
pass
|
||||
return False
|
||||
except:
|
||||
return True
|
||||
|
||||
|
||||
def createRsa():
|
||||
# ssh-keygen -t rsa -P "" -C "midoks@163.com"
|
||||
ssh_dir = getSshDir()
|
||||
|
||||
+32
-13
@@ -71,8 +71,9 @@ class plugins_api:
|
||||
if not mw.isNumber(sType):
|
||||
sType = 0
|
||||
|
||||
# print sPage
|
||||
data = self.getPluginList(sType, int(sPage))
|
||||
# print(sPage, sType)
|
||||
search = request.args.get('search', '').lower()
|
||||
data = self.getPluginList(sType, search, int(sPage))
|
||||
return mw.getJson(data)
|
||||
|
||||
def menuGetAbsPath(self, tag, path):
|
||||
@@ -91,7 +92,7 @@ class plugins_api:
|
||||
t = mw.readFile(menu_file)
|
||||
tlist = json.loads(t)
|
||||
for menu_data in tlist:
|
||||
if 'path' in menu_data:
|
||||
if tag == menu_data['name'] and 'path' in menu_data:
|
||||
tpath = self.menuGetAbsPath(tag, menu_data['path'])
|
||||
content = mw.readFile(tpath)
|
||||
data['plugin_content'] = content
|
||||
@@ -256,13 +257,14 @@ class plugins_api:
|
||||
data = json.loads(t)
|
||||
|
||||
for idx in range(len(data)):
|
||||
if data[idx]['title'] == info['title'] and data[idx]['name'] == info['name']:
|
||||
if data[idx]['name'] == info['name']:
|
||||
data.remove(data[idx])
|
||||
break
|
||||
mw.writeFile(hookPath, json.dumps(data))
|
||||
|
||||
def hookInstall(self, info):
|
||||
valid_hook = ['backup', 'database']
|
||||
valid_list_hook = ['menu']
|
||||
valid_list_hook = ['menu', 'global_static', 'site_cb']
|
||||
if 'hook' in info:
|
||||
hooks = info['hook']
|
||||
for h in hooks:
|
||||
@@ -280,7 +282,7 @@ class plugins_api:
|
||||
|
||||
def hookUninstall(self, info):
|
||||
valid_hook = ['backup', 'database']
|
||||
valid_list_hook = ['menu']
|
||||
valid_list_hook = ['menu', 'global_static', 'site_cb']
|
||||
if 'hook' in info:
|
||||
hooks = info['hook']
|
||||
for h in hooks:
|
||||
@@ -780,7 +782,18 @@ class plugins_api:
|
||||
print(e)
|
||||
return plugins_info
|
||||
|
||||
def getAllListPage(self, sType='0', page=1, pageSize=10):
|
||||
def searchKey(self, info, kw):
|
||||
try:
|
||||
if info['title'].lower().find(kw) > -1:
|
||||
return True
|
||||
if info['ps'].lower().find(kw) > -1:
|
||||
return True
|
||||
if info['name'].lower().find(kw) > -1:
|
||||
return True
|
||||
except Exception as e:
|
||||
return False
|
||||
|
||||
def getAllListPage(self, sType='0', kw='', page=1, pageSize=10):
|
||||
plugins_info = []
|
||||
for dirinfo in os.listdir(self.__plugin_dir):
|
||||
if dirinfo[0:1] == '.':
|
||||
@@ -791,11 +804,14 @@ class plugins_api:
|
||||
if os.path.exists(json_file):
|
||||
try:
|
||||
data = json.loads(mw.readFile(json_file))
|
||||
# 判断是否搜索
|
||||
if kw != '' and not self.searchKey(data, kw):
|
||||
continue
|
||||
tmp_data = self.makeList(data, sType)
|
||||
for index in range(len(tmp_data)):
|
||||
plugins_info.append(tmp_data[index])
|
||||
except Exception as e:
|
||||
print(e)
|
||||
print(mw.getTracebackInfo())
|
||||
|
||||
start = (page - 1) * pageSize
|
||||
end = start + pageSize
|
||||
@@ -925,14 +941,14 @@ class plugins_api:
|
||||
|
||||
return plugins_info
|
||||
|
||||
def getPluginList(self, sType, sPage=1, sPageSize=10):
|
||||
# print sType, sPage, sPageSize
|
||||
def getPluginList(self, sType, kw='', sPage=1, sPageSize=10):
|
||||
# print(sType, kw, sPage, sPageSize)
|
||||
|
||||
ret = {}
|
||||
ret['type'] = json.loads(mw.readFile(self.__type))
|
||||
# plugins_info = self.getAllListThread(sType)
|
||||
# plugins_info = self.getAllListProcess(sType)
|
||||
data = self.getAllListPage(sType, sPage, sPageSize)
|
||||
data = self.getAllListPage(sType, kw, sPage, sPageSize)
|
||||
ret['data'] = data[0]
|
||||
|
||||
args = {}
|
||||
@@ -1014,8 +1030,11 @@ class plugins_api:
|
||||
|
||||
# shell 调用
|
||||
def run(self, name, func, version='', args='', script='index'):
|
||||
path = self.__plugin_dir + \
|
||||
'/' + name + '/' + script + '.py'
|
||||
|
||||
path = self.__plugin_dir + '/' + name + '/' + script + '.py'
|
||||
if not os.path.exists(path):
|
||||
path = self.__plugin_dir + '/' + name + '/' + name + '.py'
|
||||
|
||||
py = 'python3 ' + path
|
||||
|
||||
if args == '':
|
||||
|
||||
+42
-10
@@ -72,6 +72,30 @@ class site_api:
|
||||
mw.execShell("mkdir -p " + self.sslLetsDir +
|
||||
" && chmod -R 755 " + self.sslLetsDir)
|
||||
|
||||
def runHook(self, hook_name, func_name):
|
||||
# 站点操作Hook
|
||||
hook_file = 'data/hook_site_cb.json'
|
||||
hook_cfg = []
|
||||
if os.path.exists(hook_file):
|
||||
t = mw.readFile(hook_file)
|
||||
hook_cfg = json.loads(t)
|
||||
|
||||
hook_num = len(hook_cfg)
|
||||
if hook_num == 0:
|
||||
return
|
||||
|
||||
import plugins_api
|
||||
pa = plugins_api.plugins_api()
|
||||
|
||||
for x in range(hook_num):
|
||||
hook_data = hook_cfg[x]
|
||||
if func_name in hook_data:
|
||||
app_name = hook_data["name"]
|
||||
run_func = hook_data[func_name]['func']
|
||||
# print(app_name, run_func)
|
||||
pa.run(app_name, run_func)
|
||||
return True
|
||||
|
||||
##### ----- start ----- ###
|
||||
def listApi(self):
|
||||
limit = request.form.get('limit', '10')
|
||||
@@ -550,7 +574,7 @@ class site_api:
|
||||
return mw.returnJson(False, '使用中,先关闭再删除')
|
||||
mw.execShell('rm -rf ' + ssl_lets_dir)
|
||||
elif ssl_type == 'acme':
|
||||
ssl_acme_dir = mw.getAcmeDir() + '/' + site_name
|
||||
ssl_acme_dir = mw.getAcmeDomainDir(site_name)
|
||||
csr_acme_path = ssl_acme_dir + '/fullchain.cer' # 生成证书路径
|
||||
if mw.md5(mw.readFile(csr_acme_path)) == mw.md5(mw.readFile(csr_path)):
|
||||
return mw.returnJson(False, '使用中,先关闭再删除')
|
||||
@@ -587,9 +611,9 @@ class site_api:
|
||||
csr_path = self.sslLetsDir + '/' + site_name + '/fullchain.pem' # 生成证书路径
|
||||
key_path = self.sslLetsDir + '/' + site_name + '/privkey.pem' # 密钥文件路径
|
||||
elif ssl_type == 'acme':
|
||||
csr_path = mw.getAcmeDir() + '/' + site_name + '/fullchain.cer' # 生成证书路径
|
||||
key_path = mw.getAcmeDir() + '/' + site_name + '/' + \
|
||||
site_name + '.key' # 密钥文件路径
|
||||
acme_dir = mw.getAcmeDomainDir(site_name)
|
||||
csr_path = acme_dir + '/fullchain.cer' # 生成证书路径
|
||||
key_path = acme_dir + '/' + site_name + '.key' # 密钥文件路径
|
||||
|
||||
key = mw.readFile(key_path)
|
||||
csr = mw.readFile(csr_path)
|
||||
@@ -989,16 +1013,17 @@ class site_api:
|
||||
# print(cmd)
|
||||
result = mw.execShell(cmd)
|
||||
|
||||
src_path = acme_dir + '/' + domains[0]
|
||||
src_path = mw.getAcmeDomainDir(domains[0])
|
||||
src_cert = src_path + '/fullchain.cer'
|
||||
src_key = src_path + '/' + domains[0] + '.key'
|
||||
src_cert.replace("\*", "*")
|
||||
|
||||
msg = '签发失败,您尝试申请证书的失败次数已达上限!<p>1、检查域名是否绑定到对应站点</p>\
|
||||
<p>2、检查域名是否正确解析到本服务器,或解析还未完全生效</p>\
|
||||
<p>3、如果您的站点设置了反向代理,或使用了CDN,请先将其关闭</p>\
|
||||
<p>4、如果您的站点设置了301重定向,请先将其关闭</p>\
|
||||
<p>5、如果以上检查都确认没有问题,请尝试更换DNS服务商</p>'
|
||||
if not os.path.exists(src_cert.replace("\*", "*")):
|
||||
if not os.path.exists(src_cert):
|
||||
data = {}
|
||||
data['err'] = result
|
||||
data['out'] = result[0]
|
||||
@@ -1271,6 +1296,7 @@ class site_api:
|
||||
mw.M('domain').add('pid,name,port,addtime',
|
||||
(pid, domain_name, domain_port, mw.getDate()))
|
||||
|
||||
self.runHook('site_cb', 'add')
|
||||
return mw.returnJson(True, '域名添加成功!')
|
||||
|
||||
def addDirBindApi(self):
|
||||
@@ -1400,7 +1426,7 @@ class site_api:
|
||||
data['filename'] = filename
|
||||
return mw.getJson(data)
|
||||
|
||||
# 修改物理路径
|
||||
# 修改物理路径
|
||||
def setPathApi(self):
|
||||
mid = request.form.get('id', '')
|
||||
path = request.form.get('path', '')
|
||||
@@ -2529,16 +2555,18 @@ location ^~ {from} {\n\
|
||||
self.createRootDir(self.sitePath)
|
||||
self.nginxAddConf()
|
||||
|
||||
mw.M('domain').add('pid,name,port,addtime',
|
||||
(pid, self.siteName, self.sitePort, mw.getDate()))
|
||||
|
||||
# 添加更多域名
|
||||
for domain in siteMenu['domainlist']:
|
||||
self.addDomain(domain, self.siteName, pid)
|
||||
|
||||
mw.M('domain').add('pid,name,port,addtime',
|
||||
(pid, self.siteName, self.sitePort, mw.getDate()))
|
||||
|
||||
data = {}
|
||||
data['siteStatus'] = False
|
||||
mw.restartWeb()
|
||||
|
||||
self.runHook('site_cb', 'add')
|
||||
return mw.returnJson(True, '添加成功')
|
||||
|
||||
def deleteWSLogs(self, webname):
|
||||
@@ -2588,6 +2616,8 @@ location ^~ {from} {\n\
|
||||
mw.execShell('rm -rf ' + ssl_acme_dir)
|
||||
|
||||
mw.M('sites').where("id=?", (sid,)).delete()
|
||||
mw.M('domain').where("pid=?", (sid,)).delete()
|
||||
mw.M('domain').where("name=?", (webname,)).delete()
|
||||
|
||||
# binding domain delete
|
||||
binding_list = mw.M('binding').field(
|
||||
@@ -2605,6 +2635,8 @@ location ^~ {from} {\n\
|
||||
|
||||
mw.M('binding').where("pid=?", (sid,)).delete()
|
||||
mw.restartWeb()
|
||||
|
||||
self.runHook('site_cb', 'delete')
|
||||
return mw.returnJson(True, '站点删除成功!')
|
||||
|
||||
def setEndDate(self, sid, edate):
|
||||
|
||||
@@ -166,6 +166,33 @@ class system_api:
|
||||
except:
|
||||
return False
|
||||
|
||||
def getEnvInfoApi(self, get=None):
|
||||
serverInfo = {}
|
||||
serverInfo['status'] = True
|
||||
sdir = mw.getServerDir()
|
||||
|
||||
serverInfo['webserver'] = '未安装'
|
||||
if os.path.exists(sdir + '/openresty/nginx/sbin/nginx'):
|
||||
serverInfo['webserver'] = 'OpenResty'
|
||||
serverInfo['php'] = []
|
||||
phpversions = ['52', '53', '54', '55', '56', '70', '71',
|
||||
'72', '73', '74', '80', '81', '82', '83', '84']
|
||||
phpPath = sdir + '/php/'
|
||||
for pv in phpversions:
|
||||
if not os.path.exists(phpPath + pv + '/bin/php'):
|
||||
continue
|
||||
serverInfo['php'].append(pv)
|
||||
serverInfo['mysql'] = False
|
||||
if os.path.exists(sdir + '/mysql/bin/mysql'):
|
||||
serverInfo['mysql'] = True
|
||||
import psutil
|
||||
try:
|
||||
diskInfo = psutil.disk_usage('/www')
|
||||
except:
|
||||
diskInfo = psutil.disk_usage('/')
|
||||
serverInfo['disk'] = diskInfo[2]
|
||||
return mw.returnJson(True, 'ok', serverInfo)
|
||||
|
||||
def getPanelInfo(self, get=None):
|
||||
# 取面板配置
|
||||
address = mw.GetLocalIp()
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
# coding:utf-8
|
||||
|
||||
# ---------------------------------------------------------------------------------
|
||||
# MW-Linux面板
|
||||
# ---------------------------------------------------------------------------------
|
||||
# copyright (c) 2018-∞(https://github.com/midoks/mdserver-web) All rights reserved.
|
||||
# ---------------------------------------------------------------------------------
|
||||
# Author: midoks <midoks@163.com>
|
||||
# ---------------------------------------------------------------------------------
|
||||
|
||||
# ---------------------------------------------------------------------------------
|
||||
# VIP用户管理
|
||||
# ---------------------------------------------------------------------------------
|
||||
|
||||
import mw
|
||||
|
||||
from flask import request
|
||||
import requests
|
||||
|
||||
|
||||
class vip_api:
|
||||
|
||||
api_url = 'https://wo.midoks.me/api/wp-json/vip'
|
||||
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
def loginApi(self):
|
||||
username = request.form.get('username', '')
|
||||
password = request.form.get('password', '')
|
||||
password = mw.aesEncrypt(password)
|
||||
|
||||
headers = {
|
||||
"Content-Type": "application/x-www-form-urlencoded",
|
||||
}
|
||||
|
||||
print("name:", str(username))
|
||||
print("pwd:", str(password))
|
||||
args = {
|
||||
'name': username,
|
||||
'pass': password
|
||||
}
|
||||
data = requests.post(self.api_url + '/v1/login',
|
||||
data=args, headers=headers)
|
||||
|
||||
print(data.text)
|
||||
|
||||
return mw.returnJson(False, "测试中!")
|
||||
@@ -0,0 +1,43 @@
|
||||
# coding: utf-8
|
||||
|
||||
import smtplib
|
||||
|
||||
from email import encoders
|
||||
from email.header import Header
|
||||
from email.mime.text import MIMEText
|
||||
from email.utils import parseaddr, formataddr
|
||||
|
||||
|
||||
def _format_addr(s):
|
||||
name, addr = parseaddr(s)
|
||||
return formataddr((Header(name, 'utf-8').encode(), addr))
|
||||
|
||||
|
||||
def send(smtp_host, smtp_port, username, password, to_mail, subject, content):
|
||||
|
||||
smtp = smtplib.SMTP()
|
||||
smtp.connect(smtp_host, port=smtp_port)
|
||||
smtp.login(user=username, password=password)
|
||||
|
||||
msg = MIMEText(content, 'plain', 'utf-8')
|
||||
msg['From'] = _format_addr(username)
|
||||
msg['To'] = _format_addr(to_mail)
|
||||
msg['Subject'] = Header(subject, 'utf-8').encode()
|
||||
|
||||
smtp.sendmail(from_addr=username, to_addrs=to_mail, msg=msg.as_string())
|
||||
return True
|
||||
|
||||
|
||||
def sendSSL(smtp_host, smtp_port, username, password, to_mail, subject, content):
|
||||
|
||||
smtp = smtplib.SMTP_SSL(smtp_host, port=smtp_port)
|
||||
smtp.login(user=username, password=password)
|
||||
|
||||
msg = MIMEText(content, 'plain', 'utf-8')
|
||||
msg['From'] = _format_addr(username)
|
||||
msg['To'] = _format_addr(to_mail)
|
||||
msg['Subject'] = Header(subject, 'utf-8').encode()
|
||||
|
||||
smtp.sendmail(from_addr=username, to_addrs=to_mail, msg=msg.as_string())
|
||||
smtp.quit()
|
||||
return True
|
||||
@@ -65,6 +65,9 @@ class ORM:
|
||||
def setCharset(self, charset):
|
||||
self.__DB_CHARSET = charset
|
||||
|
||||
def setHost(self, host):
|
||||
self.__DB_HOST = host
|
||||
|
||||
def setPort(self, port):
|
||||
self.__DB_PORT = port
|
||||
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
存放VIP关键数据
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 1.5 KiB |
Executable
+20
@@ -0,0 +1,20 @@
|
||||
<div class="bt-form">
|
||||
<div class='plugin_version'></div>
|
||||
<div class="bt-w-main">
|
||||
<div class="bt-w-menu">
|
||||
<p class="bgw" onclick="pluginService('docker');">服务</p>
|
||||
<p onclick="pluginInitD('docker');">自启动</p>
|
||||
<p onclick="dockerList();">容器列表</p>
|
||||
</div>
|
||||
<div class="bt-w-con pd15">
|
||||
<div class="soft-man-con"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
resetPluginWinWidth(700);
|
||||
resetPluginWinHeight(400);
|
||||
$.getScript( "/plugins/file?name=docker&f=js/docker.js", function(){
|
||||
pluginService('docker', $('.plugin_version').attr('version'));
|
||||
});
|
||||
</script>
|
||||
Executable
+169
@@ -0,0 +1,169 @@
|
||||
# coding:utf-8
|
||||
|
||||
import sys
|
||||
import io
|
||||
import os
|
||||
import time
|
||||
import re
|
||||
|
||||
sys.path.append(os.getcwd() + "/class/core")
|
||||
import mw
|
||||
|
||||
app_debug = False
|
||||
if mw.isAppleSystem():
|
||||
app_debug = True
|
||||
|
||||
|
||||
def getPluginName():
|
||||
return 'docker'
|
||||
|
||||
|
||||
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 getConf():
|
||||
path = getServerDir() + "/redis.conf"
|
||||
return path
|
||||
|
||||
|
||||
def getConfTpl():
|
||||
path = getPluginDir() + "/config/redis.conf"
|
||||
return path
|
||||
|
||||
|
||||
def getInitDTpl():
|
||||
path = getPluginDir() + "/init.d/" + getPluginName() + ".tpl"
|
||||
return path
|
||||
|
||||
|
||||
def getArgs():
|
||||
args = sys.argv[3:]
|
||||
tmp = {}
|
||||
args_len = len(args)
|
||||
|
||||
if args_len == 1:
|
||||
t = args[0].strip('{').strip('}')
|
||||
if t.strip() == '':
|
||||
tmp = []
|
||||
else:
|
||||
t = t.split(':')
|
||||
tmp[t[0]] = t[1]
|
||||
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 status():
|
||||
data = mw.execShell(
|
||||
"ps -ef|grep dockerd |grep -v grep | grep -v python | grep -v mdserver-web | awk '{print $2}'")
|
||||
|
||||
if data[0] == '':
|
||||
return 'stop'
|
||||
return 'start'
|
||||
|
||||
|
||||
def initDreplace():
|
||||
return ''
|
||||
|
||||
|
||||
def dockerOp(method):
|
||||
file = initDreplace()
|
||||
|
||||
if not mw.isAppleSystem():
|
||||
data = mw.execShell('systemctl ' + method + ' docker')
|
||||
if data[1] == '':
|
||||
return 'ok'
|
||||
return data[1]
|
||||
return 'fail'
|
||||
|
||||
|
||||
def start():
|
||||
return dockerOp('start')
|
||||
|
||||
|
||||
def stop():
|
||||
return dockerOp('stop')
|
||||
|
||||
|
||||
def restart():
|
||||
status = dockerOp('restart')
|
||||
|
||||
log_file = runLog()
|
||||
mw.execShell("echo '' > " + log_file)
|
||||
return status
|
||||
|
||||
|
||||
def reload():
|
||||
return dockerOp('reload')
|
||||
|
||||
|
||||
def initdStatus():
|
||||
if mw.isAppleSystem():
|
||||
return "Apple Computer does not support"
|
||||
|
||||
shell_cmd = 'systemctl status ' + \
|
||||
getPluginName() + ' | grep loaded | grep "enabled;"'
|
||||
data = mw.execShell(shell_cmd)
|
||||
if data[0] == '':
|
||||
return 'fail'
|
||||
return 'ok'
|
||||
|
||||
|
||||
def initdInstall():
|
||||
if mw.isAppleSystem():
|
||||
return "Apple Computer does not support"
|
||||
|
||||
mw.execShell('systemctl enable ' + getPluginName())
|
||||
return 'ok'
|
||||
|
||||
|
||||
def initdUinstall():
|
||||
if mw.isAppleSystem():
|
||||
return "Apple Computer does not support"
|
||||
|
||||
mw.execShell('systemctl disable ' + getPluginName())
|
||||
return 'ok'
|
||||
|
||||
|
||||
def runLog():
|
||||
return getServerDir() + '/data/redis.log'
|
||||
|
||||
|
||||
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 == 'conf':
|
||||
print(getConf())
|
||||
elif func == 'run_log':
|
||||
print(runLog())
|
||||
else:
|
||||
print('error')
|
||||
Executable
+18
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"sort": 7,
|
||||
"ps": "Docker 是一个开源的应用容器引擎(开发测试中)",
|
||||
"name": "docker",
|
||||
"title": "Docker",
|
||||
"shell": "install.sh",
|
||||
"versions":["1.0"],
|
||||
"updates":["1.0"],
|
||||
"tip": "soft",
|
||||
"checks": "server/docker",
|
||||
"path": "server/docker",
|
||||
"display": 1,
|
||||
"author": "Zend",
|
||||
"date": "2017-04-01",
|
||||
"home": "https://docker.io",
|
||||
"type": 0,
|
||||
"pid": "2"
|
||||
}
|
||||
Executable
+77
@@ -0,0 +1,77 @@
|
||||
#!/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")
|
||||
|
||||
# cd /www/server/mdserver-web/plugins/docker && /bin/bash install.sh uninstall 1.0
|
||||
# cd /www/server/mdserver-web/plugins/docker && /bin/bash install.sh install 1.0
|
||||
|
||||
install_tmp=${rootPath}/tmp/mw_install.pl
|
||||
VERSION=$2
|
||||
|
||||
Install_Docker()
|
||||
{
|
||||
which docker
|
||||
if [ "$?" == "0" ];then
|
||||
echo '安装已经完成docker' > $install_tmp
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo '正在安装脚本文件...' > $install_tmp
|
||||
mkdir -p $serverPath/source
|
||||
|
||||
if [ ! -d $serverPath/docker ];then
|
||||
curl -fsSL https://get.docker.com | bash
|
||||
mkdir -p $serverPath/docker
|
||||
fi
|
||||
|
||||
if [ -d $serverPath/docker ];then
|
||||
echo "${VERSION}" > $serverPath/docker/version.pl
|
||||
echo '安装完成' > $install_tmp
|
||||
|
||||
cd ${rootPath} && python3 ${rootPath}/plugins/docker/index.py start
|
||||
cd ${rootPath} && python3 ${rootPath}/plugins/docker/index.py initd_install
|
||||
fi
|
||||
}
|
||||
|
||||
Uninstall_Docker()
|
||||
{
|
||||
CMD=yum
|
||||
which apt
|
||||
if [ "$?" == "0" ];then
|
||||
CMD=apt
|
||||
fi
|
||||
|
||||
if [ -f /usr/lib/systemd/system/docker.service ];then
|
||||
systemctl stop docker
|
||||
systemctl disable docker
|
||||
rm -rf /usr/lib/systemd/system/docker.service
|
||||
systemctl daemon-reload
|
||||
fi
|
||||
|
||||
$CMD remove -y docker docker-ce-cli containerd.io
|
||||
# docker-client \
|
||||
# docker-client-latest \
|
||||
# docker-common \
|
||||
# docker-latest \
|
||||
# docker-latest-logrotate \
|
||||
# docker-logrotate \
|
||||
# docker-selinux \
|
||||
# docker-engine-selinux \
|
||||
# docker-engine \
|
||||
# docker-ce
|
||||
|
||||
rm -rf $serverPath/docker
|
||||
echo "Uninstall_Docker" > $install_tmp
|
||||
}
|
||||
|
||||
action=$1
|
||||
if [ "${1}" == 'install' ];then
|
||||
Install_Docker
|
||||
else
|
||||
Uninstall_Docker
|
||||
fi
|
||||
Executable
+60
@@ -0,0 +1,60 @@
|
||||
function dPost(method, version, args,callback){
|
||||
var loadT = layer.msg('正在获取...', { icon: 16, time: 0, shade: 0.3 });
|
||||
|
||||
var req_data = {};
|
||||
req_data['name'] = 'docker';
|
||||
req_data['func'] = method;
|
||||
req_data['version'] = version;
|
||||
|
||||
if (typeof(args) == 'string'){
|
||||
req_data['args'] = JSON.stringify(toArrayObject(args));
|
||||
} else {
|
||||
req_data['args'] = JSON.stringify(args);
|
||||
}
|
||||
|
||||
$.post('/plugins/run', req_data, function(data) {
|
||||
layer.close(loadT);
|
||||
if (!data.status){
|
||||
//错误展示10S
|
||||
layer.msg(data.msg,{icon:0,time:2000,shade: [10, '#000']});
|
||||
return;
|
||||
}
|
||||
|
||||
if(typeof(callback) == 'function'){
|
||||
callback(data);
|
||||
}
|
||||
},'json');
|
||||
}
|
||||
|
||||
function dPostCallbak(method, version, args,callback){
|
||||
var loadT = layer.msg('正在获取...', { icon: 16, time: 0, shade: 0.3 });
|
||||
|
||||
var req_data = {};
|
||||
req_data['name'] = 'docker';
|
||||
req_data['func'] = method;
|
||||
args['version'] = version;
|
||||
|
||||
if (typeof(args) == 'string'){
|
||||
req_data['args'] = JSON.stringify(toArrayObject(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 dockerList(){
|
||||
$(".soft-man-con").html('');
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,11 @@ if [ ! -d $WEB_PATH ];then
|
||||
mkdir -p $WEB_PATH
|
||||
rsync -vauP --delete --exclude=".*" $GIT_PROJECT_DIR/ $WEB_PATH
|
||||
else
|
||||
rsync -vauP --exclude=".*" $GIT_PROJECT_DIR/ $WEB_PATH
|
||||
if [ -f $GIT_PROJECT_DIR/exclude.list ];then
|
||||
rsync -vauP --delete --exclude-from="$GIT_PROJECT_DIR/exclude.list" $GIT_PROJECT_DIR/ $WEB_PATH
|
||||
else
|
||||
rsync -vauP --exclude=".*" $GIT_PROJECT_DIR/ $WEB_PATH
|
||||
fi
|
||||
fi
|
||||
|
||||
sysName=`uname`
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
{
|
||||
"ps": "Gitea 是一个开源社区驱动的轻量级代码托管解决方案。",
|
||||
"ps": "Gitea是一个开源社区驱动的轻量级代码托管解决方案。",
|
||||
"name": "gitea",
|
||||
"title": "Gitea",
|
||||
"versions": ["1.17.2"],
|
||||
"versions": ["1.17.2","1.18.5"],
|
||||
"tip": "soft",
|
||||
"install_pre_inspection":false,
|
||||
"uninstall_pre_inspection":true,
|
||||
|
||||
@@ -14,7 +14,7 @@ if [ -f ${rootPath}/bin/activate ];then
|
||||
fi
|
||||
|
||||
|
||||
URL_DOWNLOAD=https://dl.gitea.io/
|
||||
URL_DOWNLOAD=https://dl.gitea.com
|
||||
|
||||
|
||||
bash ${rootPath}/scripts/getos.sh
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
"uninstall_pre_inspection":true,
|
||||
"checks": "server/mariadb",
|
||||
"path": "server/mariadb",
|
||||
"versions":["10.6","10.7","10.8","10.9"],
|
||||
"versions":["10.6","10.7","10.8","10.9","10.11","11.0"],
|
||||
"shell":"install.sh",
|
||||
"checks":"server/mariadb",
|
||||
"path":"server/mariadb",
|
||||
|
||||
@@ -1185,7 +1185,7 @@ function myLogs(){
|
||||
<span class="f14 c6 mr20">二进制日志 </span><span class="f14 c6 mr20">' + toSize(rdata.msg) + '</span>\
|
||||
'+line_status+'\
|
||||
<p class="f14 c6 mtb10" style="border-top:#ddd 1px solid; padding:10px 0">错误日志<button class="btn btn-default btn-clear btn-xs" style="float:right;" >清理日志</button></p>\
|
||||
<textarea readonly style="margin: 0px;width: 100%;height: 440px;background-color: #333;color:#fff; padding:0 5px" id="error_log"></textarea>\
|
||||
<textarea readonly style="margin: 0px;width: 100%;height: 438px;background-color: #333;color:#fff; padding:0 5px" id="error_log"></textarea>\
|
||||
</p>';
|
||||
$(".soft-man-con").html(limitCon);
|
||||
|
||||
|
||||
Executable
+119
@@ -0,0 +1,119 @@
|
||||
#!/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.5.html#downloads
|
||||
#https://dev.mysql.com/downloads/file/?id=480541
|
||||
|
||||
curPath=`pwd`
|
||||
rootPath=$(dirname "$curPath")
|
||||
rootPath=$(dirname "$rootPath")
|
||||
serverPath=$(dirname "$rootPath")
|
||||
sysName=`uname`
|
||||
|
||||
install_tmp=${rootPath}/tmp/mw_install.pl
|
||||
mariadbDir=${serverPath}/source/mariadb
|
||||
|
||||
MY_VER=10.11.2
|
||||
|
||||
Install_app()
|
||||
{
|
||||
mkdir -p ${mariadbDir}
|
||||
echo '正在安装脚本文件...' > $install_tmp
|
||||
|
||||
if id mysql &> /dev/null ;then
|
||||
echo "mysql uid is `id -u www`"
|
||||
echo "mysql shell is `grep "^www:" /etc/passwd |cut -d':' -f7 `"
|
||||
else
|
||||
groupadd mysql
|
||||
useradd -g mysql mysql
|
||||
fi
|
||||
|
||||
if [ "$sysName" != "Darwin" ];then
|
||||
mkdir -p /var/log/mariadb
|
||||
touch /var/log/mariadb/mariadb.log
|
||||
fi
|
||||
|
||||
# ----- cpu start ------
|
||||
if [ -z "${cpuCore}" ]; then
|
||||
cpuCore="1"
|
||||
fi
|
||||
|
||||
if [ -f /proc/cpuinfo ];then
|
||||
cpuCore=`cat /proc/cpuinfo | grep "processor" | wc -l`
|
||||
fi
|
||||
|
||||
MEM_INFO=$(free -m|grep Mem|awk '{printf("%.f",($2)/1024)}')
|
||||
if [ "${cpuCore}" != "1" ] && [ "${MEM_INFO}" != "0" ];then
|
||||
if [ "${cpuCore}" -gt "${MEM_INFO}" ];then
|
||||
cpuCore="${MEM_INFO}"
|
||||
fi
|
||||
else
|
||||
cpuCore="1"
|
||||
fi
|
||||
|
||||
if [ "$cpuCore" -gt "2" ];then
|
||||
cpuCore=`echo "$cpuCore" | awk '{printf("%.f",($1)*0.8)}'`
|
||||
else
|
||||
cpuCore="1"
|
||||
fi
|
||||
# ----- cpu end ------
|
||||
|
||||
# if [ ! -f ${mariadbDir}/mariadb-${MY_VER}.tar.gz ];then
|
||||
# wget --no-check-certificate -O ${mariadbDir}/mariadb-${MY_VER}.tar.gz --tries=3 https://mirrors.aliyun.com/mariadb/mariadb-${MY_VER}/source/mariadb-${MY_VER}.tar.gz
|
||||
# fi
|
||||
|
||||
# https://downloads.mariadb.org/interstitial/mariadb-10.9.1/source/mariadb-10.9.1.tar.gz
|
||||
if [ ! -f ${mariadbDir}/mariadb-${MY_VER}.tar.gz ];then
|
||||
wget --no-check-certificate -O ${mariadbDir}/mariadb-${MY_VER}.tar.gz --tries=3 https://archive.mariadb.org/mariadb-${MY_VER}/source/mariadb-${MY_VER}.tar.gz
|
||||
fi
|
||||
|
||||
if [ ! -d ${mariadbDir}/mariadb-${MY_VER} ];then
|
||||
cd ${mariadbDir} && tar -zxvf ${mariadbDir}/mariadb-${MY_VER}.tar.gz
|
||||
fi
|
||||
|
||||
|
||||
if [ ! -d $serverPath/mariadb ];then
|
||||
cd ${mariadbDir}/mariadb-${MY_VER} && cmake \
|
||||
-DCMAKE_INSTALL_PREFIX=$serverPath/mariadb \
|
||||
-DMYSQL_DATADIR=$serverPath/mariadb/data/ \
|
||||
-DMYSQL_USER=mysql \
|
||||
-DMYSQL_UNIX_ADDR=$serverPath/mariadb/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=utf8mb4 \
|
||||
-DDEFAULT_COLLATION=utf8mb4_general_ci \
|
||||
-DCMAKE_C_COMPILER=/usr/bin/gcc \
|
||||
-DCMAKE_CXX_COMPILER=/usr/bin/g++
|
||||
make -j${cpuCore} && make install && make clean
|
||||
|
||||
if [ -d $serverPath/mariadb ];then
|
||||
echo '10.11' > $serverPath/mariadb/version.pl
|
||||
echo '安装完成' > $install_tmp
|
||||
else
|
||||
echo '安装失败' > $install_tmp
|
||||
echo 'install fail'>&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
rm -rf ${mariadbDir}/mariadb-${MY_VER}
|
||||
rm -rf ${mariadbDir}/mariadb-${MY_VER}.tar.gz
|
||||
}
|
||||
|
||||
Uninstall_app()
|
||||
{
|
||||
rm -rf $serverPath/mariadb
|
||||
echo '卸载完成' > $install_tmp
|
||||
}
|
||||
|
||||
action=$1
|
||||
if [ "${1}" == 'install' ];then
|
||||
Install_app
|
||||
else
|
||||
Uninstall_app
|
||||
fi
|
||||
@@ -13,7 +13,7 @@ sysName=`uname`
|
||||
install_tmp=${rootPath}/tmp/mw_install.pl
|
||||
mariadbDir=${serverPath}/source/mariadb
|
||||
|
||||
MY_VER=10.6.9
|
||||
MY_VER=10.6.12
|
||||
|
||||
Install_app()
|
||||
{
|
||||
|
||||
@@ -14,7 +14,7 @@ sysName=`uname`
|
||||
install_tmp=${rootPath}/tmp/mw_install.pl
|
||||
mariadbDir=${serverPath}/source/mariadb
|
||||
|
||||
MY_VER=10.7.4
|
||||
MY_VER=10.7.8
|
||||
|
||||
Install_app()
|
||||
{
|
||||
|
||||
@@ -14,7 +14,7 @@ sysName=`uname`
|
||||
install_tmp=${rootPath}/tmp/mw_install.pl
|
||||
mariadbDir=${serverPath}/source/mariadb
|
||||
|
||||
MY_VER=10.8.5
|
||||
MY_VER=10.8.7
|
||||
|
||||
Install_app()
|
||||
{
|
||||
|
||||
@@ -14,7 +14,7 @@ sysName=`uname`
|
||||
install_tmp=${rootPath}/tmp/mw_install.pl
|
||||
mariadbDir=${serverPath}/source/mariadb
|
||||
|
||||
MY_VER=10.9.2
|
||||
MY_VER=10.9.5
|
||||
|
||||
Install_app()
|
||||
{
|
||||
|
||||
Executable
+119
@@ -0,0 +1,119 @@
|
||||
#!/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.5.html#downloads
|
||||
#https://dev.mysql.com/downloads/file/?id=480541
|
||||
|
||||
curPath=`pwd`
|
||||
rootPath=$(dirname "$curPath")
|
||||
rootPath=$(dirname "$rootPath")
|
||||
serverPath=$(dirname "$rootPath")
|
||||
sysName=`uname`
|
||||
|
||||
install_tmp=${rootPath}/tmp/mw_install.pl
|
||||
mariadbDir=${serverPath}/source/mariadb
|
||||
|
||||
MY_VER=11.0.1
|
||||
|
||||
Install_app()
|
||||
{
|
||||
mkdir -p ${mariadbDir}
|
||||
echo '正在安装脚本文件...' > $install_tmp
|
||||
|
||||
if id mysql &> /dev/null ;then
|
||||
echo "mysql uid is `id -u www`"
|
||||
echo "mysql shell is `grep "^www:" /etc/passwd |cut -d':' -f7 `"
|
||||
else
|
||||
groupadd mysql
|
||||
useradd -g mysql mysql
|
||||
fi
|
||||
|
||||
if [ "$sysName" != "Darwin" ];then
|
||||
mkdir -p /var/log/mariadb
|
||||
touch /var/log/mariadb/mariadb.log
|
||||
fi
|
||||
|
||||
# ----- cpu start ------
|
||||
if [ -z "${cpuCore}" ]; then
|
||||
cpuCore="1"
|
||||
fi
|
||||
|
||||
if [ -f /proc/cpuinfo ];then
|
||||
cpuCore=`cat /proc/cpuinfo | grep "processor" | wc -l`
|
||||
fi
|
||||
|
||||
MEM_INFO=$(free -m|grep Mem|awk '{printf("%.f",($2)/1024)}')
|
||||
if [ "${cpuCore}" != "1" ] && [ "${MEM_INFO}" != "0" ];then
|
||||
if [ "${cpuCore}" -gt "${MEM_INFO}" ];then
|
||||
cpuCore="${MEM_INFO}"
|
||||
fi
|
||||
else
|
||||
cpuCore="1"
|
||||
fi
|
||||
|
||||
if [ "$cpuCore" -gt "2" ];then
|
||||
cpuCore=`echo "$cpuCore" | awk '{printf("%.f",($1)*0.8)}'`
|
||||
else
|
||||
cpuCore="1"
|
||||
fi
|
||||
# ----- cpu end ------
|
||||
|
||||
# if [ ! -f ${mariadbDir}/mariadb-${MY_VER}.tar.gz ];then
|
||||
# wget --no-check-certificate -O ${mariadbDir}/mariadb-${MY_VER}.tar.gz --tries=3 https://mirrors.aliyun.com/mariadb/mariadb-${MY_VER}/source/mariadb-${MY_VER}.tar.gz
|
||||
# fi
|
||||
|
||||
# https://downloads.mariadb.org/interstitial/mariadb-10.9.1/source/mariadb-10.9.1.tar.gz
|
||||
if [ ! -f ${mariadbDir}/mariadb-${MY_VER}.tar.gz ];then
|
||||
wget --no-check-certificate -O ${mariadbDir}/mariadb-${MY_VER}.tar.gz --tries=3 https://archive.mariadb.org/mariadb-${MY_VER}/source/mariadb-${MY_VER}.tar.gz
|
||||
fi
|
||||
|
||||
if [ ! -d ${mariadbDir}/mariadb-${MY_VER} ];then
|
||||
cd ${mariadbDir} && tar -zxvf ${mariadbDir}/mariadb-${MY_VER}.tar.gz
|
||||
fi
|
||||
|
||||
|
||||
if [ ! -d $serverPath/mariadb ];then
|
||||
cd ${mariadbDir}/mariadb-${MY_VER} && cmake \
|
||||
-DCMAKE_INSTALL_PREFIX=$serverPath/mariadb \
|
||||
-DMYSQL_DATADIR=$serverPath/mariadb/data/ \
|
||||
-DMYSQL_USER=mysql \
|
||||
-DMYSQL_UNIX_ADDR=$serverPath/mariadb/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=utf8mb4 \
|
||||
-DDEFAULT_COLLATION=utf8mb4_general_ci \
|
||||
-DCMAKE_C_COMPILER=/usr/bin/gcc \
|
||||
-DCMAKE_CXX_COMPILER=/usr/bin/g++
|
||||
make -j${cpuCore} && make install && make clean
|
||||
|
||||
if [ -d $serverPath/mariadb ];then
|
||||
echo '10.11' > $serverPath/mariadb/version.pl
|
||||
echo '安装完成' > $install_tmp
|
||||
else
|
||||
echo '安装失败' > $install_tmp
|
||||
echo 'install fail'>&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
rm -rf ${mariadbDir}/mariadb-${MY_VER}
|
||||
rm -rf ${mariadbDir}/mariadb-${MY_VER}.tar.gz
|
||||
}
|
||||
|
||||
Uninstall_app()
|
||||
{
|
||||
rm -rf $serverPath/mariadb
|
||||
echo '卸载完成' > $install_tmp
|
||||
}
|
||||
|
||||
action=$1
|
||||
if [ "${1}" == 'install' ];then
|
||||
Install_app
|
||||
else
|
||||
Uninstall_app
|
||||
fi
|
||||
@@ -228,11 +228,11 @@ label.checkbox_label span {
|
||||
</div>
|
||||
<div class="mtb20">
|
||||
<span class="panel_setp_span">接收数据的面板地址</span>
|
||||
<input type="text" class="bt-input-text" name="psync_url" value="" placeholder="接收数据面板地址,如: http://127.0.0.1:8888">
|
||||
<input type="text" class="bt-input-text" name="sync_url" value="" placeholder="接收数据面板地址,如: http://127.0.0.1:8888">
|
||||
</div>
|
||||
<div class="mtb20">
|
||||
<span class="panel_setp_span">接收数据的面板API</span>
|
||||
<input type="text" class="bt-input-text" name="psync_token" value="" placeholder="接收数据面板API密钥" />
|
||||
<input type="text" class="bt-input-text" name="sync_token" value="" placeholder="接收数据面板API密钥" />
|
||||
<a href="#" target="_blank" class="btlink ml5">获取API秘钥</a>
|
||||
</div>
|
||||
<div class="mtb20">
|
||||
@@ -243,8 +243,7 @@ label.checkbox_label span {
|
||||
<button class="btn btn-success infoNext">下一步</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="pa15 psync_path" style="margin:0 50px">
|
||||
</div>
|
||||
<div class="pa15 psync_path" style="margin:0 50px;"></div>
|
||||
<div class="pa15 psync_data" style="text-align: left;">
|
||||
<div class="checkbox_conten">
|
||||
<div class="checkbox_data">
|
||||
@@ -253,7 +252,7 @@ label.checkbox_label span {
|
||||
<input type="checkbox" id="sites_All" checked>
|
||||
<span>网站</span>
|
||||
</label>
|
||||
<ul></ul>
|
||||
<ul id="sites_li"></ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="checkbox_data">
|
||||
@@ -262,7 +261,7 @@ label.checkbox_label span {
|
||||
<input type="checkbox" id="db_All" checked>
|
||||
<span>数据库</span>
|
||||
</label>
|
||||
<ul></ul>
|
||||
<ul id="db_li"></ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -286,6 +285,7 @@ label.checkbox_label span {
|
||||
|
||||
<script type="text/javascript">
|
||||
resetPluginWinWidth(700);
|
||||
resetPluginWinWidth(700);
|
||||
$.getScript( "/plugins/file?name=migration_api&f=js/app.js", function(){
|
||||
initStep();
|
||||
});
|
||||
|
||||
+1001
-13
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"sort": 7,
|
||||
"ps": "[<span style='color:red;'>潜龙勿用</span>]一键迁移,仅网站数据和MySQL数据",
|
||||
"ps": "[<span style='color:red;'>潜龙勿用</span>]一键迁移,仅网站数据和MySQL数据(仅支持源码安装软件)",
|
||||
"name": "migration_api",
|
||||
"title": "一键迁移API",
|
||||
"shell": "install.sh",
|
||||
|
||||
+246
-22
@@ -1,4 +1,24 @@
|
||||
function maPost(method,args,callback){
|
||||
|
||||
function maPostNoMsg(method,args,callback){
|
||||
var _args = null;
|
||||
if (typeof(args) == 'string'){
|
||||
_args = JSON.stringify(toArrayObject(args));
|
||||
} else {
|
||||
_args = JSON.stringify(args);
|
||||
}
|
||||
$.post('/plugins/run', {name:'migration_api', func:method, args:_args}, function(data) {
|
||||
if (!data.status){
|
||||
layer.msg(data.msg,{icon:0,time:2000,shade: [0.3, '#000']});
|
||||
return;
|
||||
}
|
||||
|
||||
if(typeof(callback) == 'function'){
|
||||
callback(data);
|
||||
}
|
||||
},'json');
|
||||
}
|
||||
|
||||
function maPost(method,args,callback, msg = '正在获取...'){
|
||||
var _args = null;
|
||||
if (typeof(args) == 'string'){
|
||||
_args = JSON.stringify(toArrayObject(args));
|
||||
@@ -6,7 +26,7 @@ function maPost(method,args,callback){
|
||||
_args = JSON.stringify(args);
|
||||
}
|
||||
|
||||
var loadT = layer.msg('正在获取...', { icon: 16, time: 0, shade: 0.3 });
|
||||
var loadT = layer.msg(msg, { icon: 16, time: 0, shade: 0.3 });
|
||||
$.post('/plugins/run', {name:'migration_api', func:method, args:_args}, function(data) {
|
||||
layer.close(loadT);
|
||||
if (!data.status){
|
||||
@@ -30,6 +50,7 @@ function maAsyncPost(method,args){
|
||||
return syncPost('/plugins/run', {name:'migration_api', func:method, args:_args});
|
||||
}
|
||||
|
||||
|
||||
function maPostCallbak(method, args, callback){
|
||||
var loadT = layer.msg('正在获取...', { icon: 16, time: 0, shade: 0.3 });
|
||||
|
||||
@@ -58,43 +79,246 @@ function maPostCallbak(method, args, callback){
|
||||
}
|
||||
|
||||
|
||||
function initStep1(){
|
||||
maPost('step_one',{}, function(rdata){
|
||||
console.log(rdata);
|
||||
function selectProgress(val){
|
||||
$('.step_head li').removeClass('active');
|
||||
$('.step_head li').each(function(){
|
||||
var v = $(this).find('span').text();
|
||||
if (val == v){
|
||||
$(this).addClass('active');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function initStep1(){
|
||||
var url = $('input[name="sync_url"]').val();
|
||||
var token = $('input[name="sync_token"]').val();
|
||||
maPost('step_one',{url:url,token:token}, function(rdata){
|
||||
var rdata = $.parseJSON(rdata.data);
|
||||
showMsg(rdata.msg,function(){
|
||||
if (rdata.status){
|
||||
initStep2();
|
||||
}
|
||||
},{ icon: rdata.status ? 1 : 2 });
|
||||
},'API校验中...');
|
||||
}
|
||||
|
||||
function initStep2(){
|
||||
maPost('step_one',{}, function(rdata){
|
||||
console.log(rdata);
|
||||
});
|
||||
maPost('step_two',{}, function(rdata){
|
||||
var rdata = $.parseJSON(rdata.data);
|
||||
showMsg(rdata.msg,function(){
|
||||
if (rdata.status){
|
||||
selectProgress(2);
|
||||
$('.psync_info').hide();
|
||||
|
||||
var info = rdata.data;
|
||||
|
||||
var body = '<div class="divtable">\
|
||||
<table class="table table-hover">\
|
||||
<thead>\
|
||||
<tr><th style="border-right:1px solid #ddd">服务</th><th>当前服务器</th><th>远程服务器</th></tr>\
|
||||
</thead>\
|
||||
<tbody>\
|
||||
<tr>\
|
||||
<td style="border-right:1px solid #ddd">网站服务</td>\
|
||||
<td>'+info['local']['webserver']+'</td>\
|
||||
<td>'+info['remote']['webserver']+'</td>\
|
||||
</tr>\
|
||||
<tr>\
|
||||
<td style="border-right:1px solid #ddd">安装MySQL</td>\
|
||||
<td>'+(info['local']['mysql']?'是':'否')+'</td>\
|
||||
<td>'+(info['remote']['mysql']?'是':'否')+'</td>\
|
||||
</tr>\
|
||||
<tr>\
|
||||
<td style="border-right:1px solid #ddd">安装PHP</td>\
|
||||
<td>'+(info['local']['php'].join('/'))+'</td>\
|
||||
<td>'+(info['remote']['php'].join('/')) +'</td>\
|
||||
</tr>\
|
||||
<tr>\
|
||||
<td style="border-right:1px solid #ddd">可用磁盘</td>\
|
||||
<td>'+info['local']['disk']+'</td>\
|
||||
<td>'+info['remote']['disk'][0]['size'][0]+'</td>\
|
||||
</tr>\
|
||||
</tbody>\
|
||||
</table>\
|
||||
</div>';
|
||||
body += '<div class="line mtb20" style="text-align: left;">\
|
||||
<button class="btn btn-default btn-sm mr20 pathTestting">重新检测</button>\
|
||||
<button class="btn btn-default btn-sm mr20 pathBcak">上一步</button>\
|
||||
<button class="btn btn-success btn-sm psync-next pathNext">下一步</button>\
|
||||
</div>';
|
||||
|
||||
$('.psync_path').html(body);
|
||||
$('.psync_path').show();
|
||||
}
|
||||
},{ icon: rdata.status ? 1 : 2 });
|
||||
},'检测环境中...');
|
||||
}
|
||||
|
||||
function initStep3(){
|
||||
maPost('step_one',{}, function(rdata){
|
||||
console.log(rdata);
|
||||
maPost('step_three',{}, function(rdata){
|
||||
var rdata = $.parseJSON(rdata.data);
|
||||
showMsg(rdata.msg,function(){
|
||||
if (rdata.status){
|
||||
selectProgress(3);
|
||||
var pdata = rdata.data;
|
||||
var site_li = '';
|
||||
for (var i = 0; i < pdata.sites.length; i++) {
|
||||
site_li+='<li>\
|
||||
<label>\
|
||||
<input type="checkbox" data-id="'+i+'" id="sites_'+pdata.sites[i]['name']+'" value="'+pdata.sites[i]['name']+'" name="sites" checked="">\
|
||||
<span title="'+pdata.sites[i]['name']+'">'+pdata.sites[i]['name']+'</span>\
|
||||
</label>\
|
||||
</li>';
|
||||
}
|
||||
|
||||
$('#sites_li').html(site_li);
|
||||
|
||||
|
||||
var db_li = '';
|
||||
for (var i = 0; i < pdata.databases.length; i++) {
|
||||
db_li+='<li>\
|
||||
<label>\
|
||||
<input type="checkbox" data-id="'+i+'" id="sites_'+pdata.databases[i]['name']+'" value="'+pdata.databases[i]['name']+'" name="databases" checked="">\
|
||||
<span title="'+pdata.databases[i]['name']+'">'+pdata.databases[i]['name']+'</span>\
|
||||
</label>\
|
||||
</li>';
|
||||
}
|
||||
$('#db_li').html(db_li);
|
||||
|
||||
$('.psync_path').hide();
|
||||
$('.psync_data').show();
|
||||
}
|
||||
},{ icon: rdata.status ? 1 : 2 });
|
||||
});
|
||||
}
|
||||
|
||||
function renderMigrationProgress(){
|
||||
maPostNoMsg('get_speed',{}, function(rdata){
|
||||
var rdata = $.parseJSON(rdata.data);
|
||||
// console.log('speed:',rdata.data);
|
||||
if (rdata.status){
|
||||
if (rdata['data']['action'] == 'True'){
|
||||
var end = '<div class="line">\
|
||||
<div class="success text-center" style="padding: 10px 0 15px;">\
|
||||
<p>数据迁移完成,请务必检查数据完整性!</p>\
|
||||
<p style="font-size: 14px;margin-top:2px;color: #939292;">传输大小: '+toSize(rdata['data']['total_size'])+',耗时: '+rdata['data']['total_time']+',平均速度: '+toSize(rdata['data']['speed'])+'/s</p>\
|
||||
<p class="mtb15">\
|
||||
<button class="btn btn-success btn-sm mr5 okBtn">确定完成</button>\
|
||||
<a class="btn btn-default btn-sm" style="margin-left: 10px;" target="_blank" href="/files/download?filename='+rdata['data']['log_file']+'">迁移日志</a>\
|
||||
</p>\
|
||||
</div>\
|
||||
</div>';
|
||||
$('.psync_migrate').html(end);
|
||||
} else{
|
||||
$('.psync_migrate .action').text(rdata['data']['action']);
|
||||
$('.psync_migrate .done').text(rdata['data']['done']);
|
||||
$('.psync_migrate pre').text(rdata['data']['log']);
|
||||
|
||||
var p = (rdata['data']['all_speed']/rdata['data']['all_total'])*100;
|
||||
if (p>100){
|
||||
p = 100;
|
||||
}
|
||||
$('.psync_migrate .progress_info_bar').width(p+'%');
|
||||
$('.psync_migrate .progress_info').text(p+'%');
|
||||
|
||||
renderMigrationProgress();
|
||||
}
|
||||
} else{
|
||||
layer.msg(rdata.msg,{icon:1});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function initStep4(){
|
||||
maPost('step_one',{}, function(rdata){
|
||||
console.log(rdata);
|
||||
var site_checked = '';
|
||||
$('input[name="sites"]:checked').each(function(){
|
||||
site_checked += $(this).val()+',';
|
||||
});
|
||||
|
||||
var databases_checked = '';
|
||||
$('input[name="databases"]:checked').each(function(){
|
||||
databases_checked+=$(this).val()+',';
|
||||
});
|
||||
|
||||
maPost('step_four',{sites:site_checked,databases:databases_checked}, function(rdata){
|
||||
var rdata = $.parseJSON(rdata.data);
|
||||
selectProgress(4);
|
||||
|
||||
var progress = '<div style="margin: 0 40px;">\
|
||||
<div class="line">\
|
||||
<div style="text-align:left"><span class="action">--</span>\
|
||||
<span style="margin-left: 20px;" class="done">当前: --</span><img src="/static/img/ing.gif"><a style="position: absolute;right: 40px;" class="btlink psync_close" onclick="migrate.close();">[取消]</a></div>\
|
||||
<div class="bt-progress" style="border-radius:0;height:20px;line-height:19px">\
|
||||
<div class="bt-progress-bar progress_info_bar" style="border-radius: 0px; height: 20px; width: 0%;">\
|
||||
<span class="bt-progress-text progress_info"></span></div>\
|
||||
</div>\
|
||||
</div>\
|
||||
</div>\
|
||||
<pre style="height: 222px;text-align: left;margin:5px 38px 0;font-size: 12px;line-height: 20px;padding: 10px;background-color: #333;color: #fff;"></pre>\
|
||||
</div>';
|
||||
|
||||
|
||||
$('.psync_data').hide();
|
||||
$('.psync_migrate').html(progress);
|
||||
$('.psync_migrate').show();
|
||||
|
||||
renderMigrationProgress();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function initStep(){
|
||||
console.log($('.infoNext'));
|
||||
maPost('get_conf',{}, function(rdata){
|
||||
var rdata = $.parseJSON(rdata.data);
|
||||
$('input[name="sync_url"]').val(rdata.data['url']);
|
||||
$('input[name="sync_token"]').val(rdata.data['token']);
|
||||
});
|
||||
|
||||
$('.infoNext').click(function(){
|
||||
var step = $('.step_head .active span').text();
|
||||
// console.log(step);
|
||||
// initStep1();
|
||||
switch(step){
|
||||
case '1':initStep1();break;
|
||||
case '2':initStep2();break;
|
||||
case '3':initStep3();break;
|
||||
case '4':initStep4();break;
|
||||
}
|
||||
initStep1();
|
||||
});
|
||||
|
||||
// 重新检测按钮
|
||||
$('.psync_path').on('click', '.pathTestting', function () {
|
||||
initStep2();
|
||||
});
|
||||
|
||||
$('.psync_path').on('click', '.pathBcak', function(){
|
||||
$('.psync_path').hide();
|
||||
$('.psync_info').show();
|
||||
selectProgress(1);
|
||||
});
|
||||
|
||||
$('.psync_path').on('click', '.pathNext', function(){
|
||||
initStep3();
|
||||
});
|
||||
|
||||
|
||||
$('.psync_data').on('click', '.dataBack', function(){
|
||||
$('.psync_data').hide();
|
||||
$('.psync_path').show();
|
||||
selectProgress(2);
|
||||
});
|
||||
|
||||
|
||||
$('.psync_data').on('click', '.dataMigrate', function(){
|
||||
initStep4();
|
||||
});
|
||||
|
||||
$('#sites_All').on('click',function(){
|
||||
var ch = $(this).prop('checked');
|
||||
$('#sites_li input').prop('checked',ch);
|
||||
});
|
||||
|
||||
$('#db_All').on('click',function(){
|
||||
var ch = $(this).prop('checked');
|
||||
$('#db_li input').prop('checked',ch);
|
||||
});
|
||||
|
||||
$('.psync_migrate').on('click', '.okBtn', function(){
|
||||
$('.psync_migrate').hide();
|
||||
$('.psync_info').show();
|
||||
selectProgress(1);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -65,6 +65,7 @@ binlog-ignore-db = performance_schema
|
||||
#slave
|
||||
log-slave-updates
|
||||
#replicate-do-db
|
||||
slave_skip_errors=1062
|
||||
replicate-ignore-db = information_schema
|
||||
replicate-ignore-db = performance_schema
|
||||
replicate-ignore-db = mysql
|
||||
|
||||
@@ -62,6 +62,7 @@ binlog-ignore-db = performance_schema
|
||||
#slave
|
||||
log_replica_updates
|
||||
#replicate-do-db
|
||||
slave_skip_errors=1062
|
||||
replicate-ignore-db = information_schema
|
||||
replicate-ignore-db = performance_schema
|
||||
replicate-ignore-db = mysql
|
||||
|
||||
@@ -2474,7 +2474,8 @@ def doFullSyncUser(version=''):
|
||||
|
||||
if not os.path.exists(bak_file):
|
||||
dump_sql_data = getServerDir() + "/bin/mysqldump " + dmp_option + " --force --opt --default-character-set=utf8 --single-transaction -h" + ip + " -P" + \
|
||||
port + " -u" + user + " -p" + apass + " " + sync_db + " > " + bak_file
|
||||
port + " -u" + user + " -p" + apass + \
|
||||
" --ssl-mode=DISABLED " + sync_db + " > " + bak_file
|
||||
mw.execShell(dump_sql_data)
|
||||
|
||||
writeDbSyncStatus({'code': 2, 'msg': '本地导入数据...', 'progress': 40})
|
||||
|
||||
@@ -1208,7 +1208,7 @@ function myLogs(){
|
||||
<span class="f14 c6 mr20">二进制日志 </span><span class="f14 c6 mr20">' + toSize(rdata.msg) + '</span>\
|
||||
'+line_status+'\
|
||||
<p class="f14 c6 mtb10" style="border-top:#ddd 1px solid; padding:10px 0">错误日志<button class="btn btn-default btn-clear btn-xs" style="float:right;" >清理日志</button></p>\
|
||||
<textarea readonly style="margin: 0px;width: 100%;height: 440px;background-color: #333;color:#fff; padding:0 5px" id="error_log"></textarea>\
|
||||
<textarea readonly style="margin: 0px;width: 100%;height: 438px;background-color: #333;color:#fff; padding:0 5px" id="error_log"></textarea>\
|
||||
</p>';
|
||||
$(".soft-man-con").html(limitCon);
|
||||
|
||||
|
||||
@@ -66,6 +66,7 @@ binlog-ignore-db = performance_schema
|
||||
#slave
|
||||
log-slave-updates
|
||||
#replicate-do-db
|
||||
slave_skip_errors=1062
|
||||
replicate-ignore-db = information_schema
|
||||
replicate-ignore-db = performance_schema
|
||||
replicate-ignore-db = mysql
|
||||
|
||||
@@ -62,6 +62,7 @@ binlog-ignore-db = performance_schema
|
||||
#slave
|
||||
log_replica_updates
|
||||
#replicate-do-db
|
||||
slave_skip_errors=1062
|
||||
replicate-ignore-db = information_schema
|
||||
replicate-ignore-db = performance_schema
|
||||
replicate-ignore-db = mysql
|
||||
|
||||
@@ -2434,7 +2434,8 @@ def doFullSyncUser(version=''):
|
||||
|
||||
if not os.path.exists(bak_file):
|
||||
dump_sql_data = getServerDir() + "/bin/mysqldump " + dmp_option + " --force --opt --default-character-set=utf8 --single-transaction -h" + ip + " -P" + \
|
||||
port + " -u" + user + " -p" + apass + " " + sync_db + " > " + bak_file
|
||||
port + " -u" + user + " -p" + apass + \
|
||||
" --ssl-mode=DISABLED " + sync_db + " > " + bak_file
|
||||
mw.execShell(dump_sql_data)
|
||||
|
||||
writeDbSyncStatus({'code': 2, 'msg': '本地导入数据...', 'progress': 40})
|
||||
|
||||
@@ -1208,7 +1208,7 @@ function myLogs(){
|
||||
<span class="f14 c6 mr20">二进制日志 </span><span class="f14 c6 mr20">' + toSize(rdata.msg) + '</span>\
|
||||
'+line_status+'\
|
||||
<p class="f14 c6 mtb10" style="border-top:#ddd 1px solid; padding:10px 0">错误日志<button class="btn btn-default btn-clear btn-xs" style="float:right;" >清理日志</button></p>\
|
||||
<textarea readonly style="margin: 0px;width: 100%;height: 440px;background-color: #333;color:#fff; padding:0 5px" id="error_log"></textarea>\
|
||||
<textarea readonly style="margin: 0px;width: 100%;height: 438px;background-color: #333;color:#fff; padding:0 5px" id="error_log"></textarea>\
|
||||
</p>';
|
||||
$(".soft-man-con").html(limitCon);
|
||||
|
||||
|
||||
@@ -70,6 +70,7 @@ log-slave-updates = 1
|
||||
# Prevent replication from starting automatically with MySQL
|
||||
#skip-slave-start = 1
|
||||
#replicate-do-db
|
||||
slave_skip_errors=1062
|
||||
replicate-ignore-db = information_schema
|
||||
replicate-ignore-db = performance_schema
|
||||
replicate-ignore-db = mysql
|
||||
|
||||
@@ -72,6 +72,7 @@ log-slave-updates = 1
|
||||
# Prevent replication from starting automatically with MySQL
|
||||
#skip-slave-start = 1
|
||||
#replicate-do-db
|
||||
slave_skip_errors=1062
|
||||
replicate-ignore-db = information_schema
|
||||
replicate-ignore-db = performance_schema
|
||||
replicate-ignore-db = mysql
|
||||
|
||||
@@ -17,6 +17,7 @@ datadir = {$SERVER_APP_PATH}/data
|
||||
log-error = {$SERVER_APP_PATH}/data/error.log
|
||||
server-id = {$SERVER_ID}
|
||||
|
||||
explicit_defaults_for_timestamp=true
|
||||
default_storage_engine = InnoDB
|
||||
|
||||
|
||||
@@ -73,6 +74,7 @@ binlog-ignore-db = performance_schema
|
||||
# Prevent replication from starting automatically with MySQL
|
||||
#skip-slave-start = 1
|
||||
#replicate-do-db
|
||||
slave_skip_errors=1062
|
||||
replicate-ignore-db = information_schema
|
||||
replicate-ignore-db = performance_schema
|
||||
replicate-ignore-db = mysql
|
||||
@@ -94,7 +96,7 @@ innodb_file_per_table = 1
|
||||
innodb_large_prefix = 1
|
||||
|
||||
secure-file-priv={$SERVER_APP_PATH}/tmp
|
||||
|
||||
#secure-file-priv=disabled
|
||||
[mysqldump]
|
||||
quick
|
||||
|
||||
|
||||
@@ -71,6 +71,7 @@ log_replica_updates = 1
|
||||
# Prevent replication from starting automatically with MySQL
|
||||
#skip_replica_start = 1
|
||||
#replicate-do-db
|
||||
replica_skip_errors=1062
|
||||
replicate-ignore-db = information_schema
|
||||
replicate-ignore-db = performance_schema
|
||||
replicate-ignore-db = mysql
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
<p onclick="masterOrSlaveConf($('.plugin_version').attr('version'))">主从配置</p>
|
||||
</div>
|
||||
<div class="bt-w-con pd15">
|
||||
<div class="soft-man-con" style="height: 530px; overflow: auto;"></div>
|
||||
<div class="soft-man-con"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
+69
-14
@@ -48,19 +48,20 @@ def getInitDFile():
|
||||
|
||||
def getArgs():
|
||||
args = sys.argv[2:]
|
||||
|
||||
tmp = {}
|
||||
args_len = len(args)
|
||||
|
||||
if args_len == 1:
|
||||
t = args[0].strip('{').strip('}')
|
||||
t = t.split(':')
|
||||
if t.strip() == '':
|
||||
tmp = []
|
||||
else:
|
||||
t = t.split(':', 1)
|
||||
tmp[t[0]] = t[1]
|
||||
tmp[t[0]] = t[1]
|
||||
elif args_len > 1:
|
||||
for i in range(len(args)):
|
||||
t = args[i].split(':')
|
||||
t = args[i].split(':', 1)
|
||||
tmp[t[0]] = t[1]
|
||||
|
||||
return tmp
|
||||
|
||||
|
||||
@@ -382,7 +383,7 @@ def initMysql57Data():
|
||||
myconf = serverdir + "/etc/my.cnf"
|
||||
user = pGetDbUser()
|
||||
cmd = 'cd ' + serverdir + ' && ./bin/mysqld --defaults-file=' + myconf + \
|
||||
' --initialize-insecure --explicit_defaults_for_timestamp'
|
||||
' --initialize-insecure --explicit_defaults_for_timestamp --user=mysql'
|
||||
data = mw.execShell(cmd)
|
||||
# print(data)
|
||||
return False
|
||||
@@ -842,12 +843,29 @@ def setDbBackup():
|
||||
return data[1]
|
||||
|
||||
scDir = mw.getRunDir() + '/scripts/backup.py'
|
||||
|
||||
cmd = 'python3 ' + scDir + ' database ' + args['name'] + ' 3'
|
||||
os.system(cmd)
|
||||
return mw.returnJson(True, 'ok')
|
||||
|
||||
|
||||
# 数据库密码处理
|
||||
def myPass(act, root):
|
||||
conf_file = getConf()
|
||||
mw.execShell("sed -i '/user=root/d' {}".format(conf_file))
|
||||
mw.execShell("sed -i '/password=/d' {}".format(conf_file))
|
||||
if act:
|
||||
mycnf = mw.readFile(conf_file)
|
||||
src_dump = "[mysqldump]\n"
|
||||
sub_dump = src_dump + "user=root\npassword=\"{}\"\n".format(root)
|
||||
if not mycnf:
|
||||
return False
|
||||
mycnf = mycnf.replace(src_dump, sub_dump)
|
||||
if len(mycnf) > 100:
|
||||
mw.writeFile(conf_file, mycnf)
|
||||
return True
|
||||
return True
|
||||
|
||||
|
||||
def importDbExternal():
|
||||
args = getArgs()
|
||||
data = checkArgs(args, ['file', 'name'])
|
||||
@@ -902,11 +920,16 @@ def importDbExternal():
|
||||
pwd = pSqliteDb('config').where('id=?', (1,)).getField('mysql_root')
|
||||
sock = getSocketFile()
|
||||
|
||||
os.environ["MYSQL_PWD"] = pwd
|
||||
mysql_cmd = getServerDir() + '/bin/mysql -S ' + sock + ' -uroot -p' + \
|
||||
pwd + ' ' + name + ' < ' + import_sql
|
||||
my_cnf = getConf()
|
||||
|
||||
myPass(True, pwd)
|
||||
mysql_cmd = getServerDir() + '/bin/mysql --defaults-file=' + my_cnf + \
|
||||
' -uroot -p\"' + pwd + '\" -f ' + name + ' < ' + import_sql
|
||||
|
||||
# print(mysql_cmd)
|
||||
rdata = mw.execShell(mysql_cmd)
|
||||
myPass(False, pwd)
|
||||
# print(rdata)
|
||||
if ext != 'sql':
|
||||
os.remove(import_sql)
|
||||
|
||||
@@ -2371,6 +2394,25 @@ def initSlaveStatus(version=''):
|
||||
return initSlaveStatusSyncUser(version)
|
||||
|
||||
|
||||
def makeSyncUsercmd(u, version=''):
|
||||
mode = recognizeDbMode()
|
||||
sql = ''
|
||||
|
||||
ip = u['ip']
|
||||
port = u['port']
|
||||
username = u['user']
|
||||
password = u['pass']
|
||||
if mode == "gtid":
|
||||
sql = "CHANGE MASTER TO MASTER_HOST='" + ip + "', MASTER_PORT=" + port + ", MASTER_USER='" + \
|
||||
username + "', MASTER_PASSWORD='" + \
|
||||
password + "', MASTER_AUTO_POSITION=1"
|
||||
if version == '8.0':
|
||||
sql = "CHANGE REPLICATION SOURCE TO SOURCE_HOST='" + ip + "', SOURCE_PORT=" + port + ", SOURCE_USER='" + \
|
||||
username + "', SOURCE_PASSWORD='" + \
|
||||
password + "', MASTER_AUTO_POSITION=1"
|
||||
return sql
|
||||
|
||||
|
||||
def initSlaveStatusSyncUser(version=''):
|
||||
conn = pSqliteDb('slave_sync_user')
|
||||
data = conn.field('ip,port,user,pass,mode,cmd').find()
|
||||
@@ -2393,8 +2435,19 @@ def initSlaveStatusSyncUser(version=''):
|
||||
if local_mode != mode_name:
|
||||
return mw.returnJson(False, '同步模式不一致!')
|
||||
|
||||
t = db.query(u['cmd'])
|
||||
# print(t)
|
||||
if u['cmd'] == '' and local_mode == 'gtid':
|
||||
sql = makeSyncUsercmd(u, version)
|
||||
# print(sql)
|
||||
t = db.query(sql)
|
||||
else:
|
||||
if u['cmd'] == '':
|
||||
return mw.returnJson(False, '经典模式下,必须手写同步命令!')
|
||||
# print(u['cmd'])
|
||||
t = db.query(u['cmd'])
|
||||
isError = isSqlError(t)
|
||||
if isError:
|
||||
return isError
|
||||
|
||||
db.query("start slave user='{}' password='{}';".format(
|
||||
u['user'], u['pass']))
|
||||
return mw.returnJson(True, '初始化成功!')
|
||||
@@ -2612,8 +2665,10 @@ def doFullSyncUser(version=''):
|
||||
writeDbSyncStatus({'code': 1, 'msg': '远程导出数据...', 'progress': 20})
|
||||
|
||||
if not os.path.exists(bak_file):
|
||||
dump_sql_data = getServerDir() + "/bin/mysqldump " + dmp_option + " --force --opt --default-character-set=utf8 --single-transaction -h" + ip + " -P" + \
|
||||
port + " -u" + user + " -p" + apass + " " + sync_db + " > " + bak_file
|
||||
dump_sql_data = getServerDir() + "/bin/mysqldump " + dmp_option + " --force --opt --default-character-set=utf8 --single-transaction -h" + ip + " -P" + \
|
||||
port + " -u" + user + " -p\"" + apass + \
|
||||
"\" --ssl-mode=DISABLED " + sync_db + " > " + bak_file
|
||||
# print(dump_sql_data)
|
||||
mw.execShell(dump_sql_data)
|
||||
|
||||
writeDbSyncStatus({'code': 2, 'msg': '本地导入数据...', 'progress': 40})
|
||||
|
||||
@@ -1208,7 +1208,7 @@ function myLogs(){
|
||||
<span class="f14 c6 mr20">二进制日志 </span><span class="f14 c6 mr20">' + toSize(rdata.msg) + '</span>\
|
||||
'+line_status+'\
|
||||
<p class="f14 c6 mtb10" style="border-top:#ddd 1px solid; padding:10px 0">错误日志<button class="btn btn-default btn-clear btn-xs" style="float:right;" >清理日志</button></p>\
|
||||
<textarea readonly style="margin: 0px;width: 100%;height: 440px;background-color: #333;color:#fff; padding:0 5px" id="error_log"></textarea>\
|
||||
<textarea readonly style="margin: 0px;width: 100%;height: 438px;background-color: #333;color:#fff; padding:0 5px" id="error_log"></textarea>\
|
||||
</p>';
|
||||
$(".soft-man-con").html(limitCon);
|
||||
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
## 指定共享内存
|
||||
lua_shared_dict healthcheck 10m;
|
||||
@@ -0,0 +1,64 @@
|
||||
location / {
|
||||
proxy_pass http://{$UPSTREAM_NAME};
|
||||
|
||||
client_max_body_size 10m;
|
||||
client_body_buffer_size 128k;
|
||||
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header Host $proxy_host;
|
||||
proxy_connect_timeout 90;
|
||||
proxy_send_timeout 90;
|
||||
proxy_read_timeout 90;
|
||||
proxy_buffer_size 4k;
|
||||
proxy_buffers 4 32k;
|
||||
proxy_busy_buffers_size 64k;
|
||||
proxy_temp_file_write_size 64k;
|
||||
}
|
||||
|
||||
|
||||
#location /upstream_status {
|
||||
# allow 127.0.0.1;
|
||||
# deny all;
|
||||
# access_log off;
|
||||
# default_type text/plain;
|
||||
# content_by_lua_block {
|
||||
# local hc = require "resty.upstream.healthcheck"
|
||||
# ngx.say("OpenResty Worker PID: ", ngx.worker.pid())
|
||||
# ngx.print(hc.status_page())
|
||||
# }
|
||||
#}
|
||||
|
||||
location /upstream_status_{$UPSTREAM_NAME} {
|
||||
allow 127.0.0.1;
|
||||
deny all;
|
||||
access_log off;
|
||||
default_type text/plain;
|
||||
content_by_lua_block {
|
||||
local json = require "cjson"
|
||||
local ok, upstream = pcall(require, "ngx.upstream")
|
||||
if not ok then
|
||||
ngx.print("[]")
|
||||
return
|
||||
end
|
||||
|
||||
local get_primary_peers = upstream.get_primary_peers
|
||||
local get_backup_peers = upstream.get_backup_peers
|
||||
local upstream_name = "{$UPSTREAM_NAME}"
|
||||
|
||||
peers, err = get_primary_peers(upstream_name)
|
||||
if not peers then
|
||||
ngx.print("[]")
|
||||
return
|
||||
end
|
||||
|
||||
peers_backup, err = get_backup_peers(upstream_name)
|
||||
if peers_backup then
|
||||
for k, v in pairs(peers_backup) do
|
||||
table.insert(peers,v)
|
||||
end
|
||||
end
|
||||
|
||||
ngx.print(json.encode(peers))
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
upstream {$UPSTREAM_NAME}
|
||||
{
|
||||
{$NODE_ALGO}
|
||||
{$NODE_SERVER_LIST}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 853 B |
Executable
+21
@@ -0,0 +1,21 @@
|
||||
<div class="bt-form">
|
||||
<div class="bt-w-main">
|
||||
<div class="bt-w-menu">
|
||||
<p class="bgw" onclick="pluginService('op_load_balance');">服务</p>
|
||||
<p onclick="loadBalanceList();">负载均衡</p>
|
||||
</div>
|
||||
<div class="bt-w-con pd15">
|
||||
<div class="soft-man-con"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<script type="text/javascript" src="/plugins/file?name=op_load_balance&f=js/app.js"></script>
|
||||
<script type="text/javascript">
|
||||
resetPluginWinWidth(800);
|
||||
resetPluginWinHeight(300);
|
||||
$.getScript( "/plugins/file?name=op_load_balance&f=js/app.js", function(){
|
||||
pluginService('op_load_balance');
|
||||
});
|
||||
</script>
|
||||
Executable
+474
@@ -0,0 +1,474 @@
|
||||
# coding:utf-8
|
||||
|
||||
import sys
|
||||
import io
|
||||
import os
|
||||
import time
|
||||
import subprocess
|
||||
import json
|
||||
import re
|
||||
|
||||
sys.path.append(os.getcwd() + "/class/core")
|
||||
import mw
|
||||
|
||||
|
||||
app_debug = False
|
||||
if mw.isAppleSystem():
|
||||
app_debug = True
|
||||
|
||||
|
||||
def getPluginName():
|
||||
return 'op_load_balance'
|
||||
|
||||
|
||||
def getPluginDir():
|
||||
return mw.getPluginDir() + '/' + getPluginName()
|
||||
|
||||
|
||||
def getServerDir():
|
||||
return mw.getServerDir() + '/' + getPluginName()
|
||||
|
||||
|
||||
def getArgs():
|
||||
args = sys.argv[2:]
|
||||
tmp = {}
|
||||
args_len = len(args)
|
||||
|
||||
if args_len == 1:
|
||||
t = args[0].strip('{').strip('}')
|
||||
if t.strip() == '':
|
||||
tmp = []
|
||||
else:
|
||||
t = t.split(':')
|
||||
tmp[t[0]] = t[1]
|
||||
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 getConf():
|
||||
path = getServerDir() + "/cfg.json"
|
||||
|
||||
if not os.path.exists(path):
|
||||
mw.writeFile(path, '[]')
|
||||
|
||||
c = mw.readFile(path)
|
||||
return json.loads(c)
|
||||
|
||||
|
||||
def writeConf(data):
|
||||
path = getServerDir() + "/cfg.json"
|
||||
mw.writeFile(path, json.dumps(data))
|
||||
|
||||
|
||||
def contentReplace(content):
|
||||
service_path = mw.getServerDir()
|
||||
content = content.replace('{$ROOT_PATH}', mw.getRootDir())
|
||||
content = content.replace('{$SERVER_PATH}', service_path)
|
||||
content = content.replace('{$APP_PATH}', app_path)
|
||||
return content
|
||||
|
||||
|
||||
def restartWeb():
|
||||
mw.opWeb('stop')
|
||||
mw.opWeb('start')
|
||||
|
||||
|
||||
def loadBalanceConf():
|
||||
path = mw.getServerDir() + '/web_conf/nginx/vhost/load_balance.conf'
|
||||
return path
|
||||
|
||||
|
||||
def initDreplace():
|
||||
|
||||
dst_conf_tpl = getPluginDir() + '/conf/load_balance.conf'
|
||||
dst_conf = loadBalanceConf()
|
||||
|
||||
if not os.path.exists(dst_conf):
|
||||
con = mw.readFile(dst_conf_tpl)
|
||||
mw.writeFile(dst_conf, con)
|
||||
|
||||
|
||||
def status():
|
||||
if not mw.getWebStatus():
|
||||
return 'stop'
|
||||
|
||||
dst_conf = loadBalanceConf()
|
||||
if not os.path.exists(dst_conf):
|
||||
return 'stop'
|
||||
|
||||
return 'start'
|
||||
|
||||
|
||||
def start():
|
||||
initDreplace()
|
||||
restartWeb()
|
||||
return 'ok'
|
||||
|
||||
|
||||
def stop():
|
||||
dst_conf = loadBalanceConf()
|
||||
os.remove(dst_conf)
|
||||
|
||||
deleteLoadBalanceAllCfg()
|
||||
restartWeb()
|
||||
return 'ok'
|
||||
|
||||
|
||||
def restart():
|
||||
restartWeb()
|
||||
return 'ok'
|
||||
|
||||
|
||||
def reload():
|
||||
restartWeb()
|
||||
return 'ok'
|
||||
|
||||
|
||||
def installPreInspection():
|
||||
check_op = mw.getServerDir() + "/openresty"
|
||||
if not os.path.exists(check_op):
|
||||
return "请先安装OpenResty"
|
||||
return 'ok'
|
||||
|
||||
|
||||
def deleteLoadBalanceAllCfg():
|
||||
cfg = getConf()
|
||||
upstream_dir = mw.getServerDir() + '/web_conf/nginx/upstream'
|
||||
lua_dir = mw.getServerDir() + '/web_conf/nginx/lua/init_worker_by_lua_file'
|
||||
rewrite_dir = mw.getServerDir() + '/web_conf/nginx/rewrite'
|
||||
vhost_dir = mw.getServerDir() + '/web_conf/nginx/vhost'
|
||||
|
||||
for conf in cfg:
|
||||
upstream_file = upstream_dir + '/' + conf['upstream_name'] + '.conf'
|
||||
if os.path.exists(upstream_file):
|
||||
os.remove(upstream_file)
|
||||
|
||||
lua_file = lua_dir + '/' + conf['upstream_name'] + '.lua'
|
||||
if os.path.exists(lua_file):
|
||||
os.remove(lua_file)
|
||||
|
||||
rewrite_file = rewrite_dir + '/' + conf['domain'] + '.conf'
|
||||
mw.writeFile(rewrite_file, '')
|
||||
|
||||
path = vhost_dir + '/' + conf['domain'] + '.conf'
|
||||
|
||||
content = mw.readFile(path)
|
||||
content = re.sub('include ' + upstream_file + ';' + "\n", '', content)
|
||||
mw.writeFile(path, content)
|
||||
|
||||
mw.opLuaInitWorkerFile()
|
||||
|
||||
|
||||
def makeConfServerList(data):
|
||||
slist = ''
|
||||
for x in data:
|
||||
slist += 'server '
|
||||
slist += x['ip'] + ':' + x['port']
|
||||
|
||||
if x['state'] == '0':
|
||||
slist += ' down;\n\t'
|
||||
continue
|
||||
|
||||
if x['state'] == '2':
|
||||
slist += ' backup;\n\t'
|
||||
continue
|
||||
|
||||
slist += ' weight=' + x['weight']
|
||||
slist += ' max_fails=' + x['max_fails']
|
||||
slist += ' fail_timeout=' + x['fail_timeout'] + "s;\n\t"
|
||||
return slist
|
||||
|
||||
|
||||
def makeLoadBalanceAllCfg(row):
|
||||
# 生成所有配置
|
||||
cfg = getConf()
|
||||
|
||||
upstream_dir = mw.getServerDir() + '/web_conf/nginx/upstream'
|
||||
rewrite_dir = mw.getServerDir() + '/web_conf/nginx/rewrite'
|
||||
vhost_dir = mw.getServerDir() + '/web_conf/nginx/vhost'
|
||||
upstream_tpl = getPluginDir() + '/conf/upstream.tpl.conf'
|
||||
rewrite_tpl = getPluginDir() + '/conf/rewrite.tpl.conf'
|
||||
|
||||
if not os.path.exists(upstream_dir):
|
||||
os.makedirs(upstream_dir)
|
||||
|
||||
conf = cfg[row]
|
||||
|
||||
# replace vhost start
|
||||
vhost_file = vhost_dir + '/' + conf['domain'] + '.conf'
|
||||
vcontent = mw.readFile(vhost_file)
|
||||
|
||||
vhost_find_str = 'upstream/' + conf['upstream_name'] + '.conf'
|
||||
vhead = 'include ' + mw.getServerDir() + '/web_conf/nginx/' + \
|
||||
vhost_find_str + ';'
|
||||
|
||||
vpos = vcontent.find(vhost_find_str)
|
||||
if vpos < 0:
|
||||
vcontent = vhead + "\n" + vcontent
|
||||
mw.writeFile(vhost_file, vcontent)
|
||||
# replace vhost end
|
||||
|
||||
# make upstream start
|
||||
upstream_file = upstream_dir + '/' + conf['upstream_name'] + '.conf'
|
||||
content = ''
|
||||
if len(conf['node_list']) > 0:
|
||||
content = mw.readFile(upstream_tpl)
|
||||
slist = makeConfServerList(conf['node_list'])
|
||||
content = content.replace('{$NODE_SERVER_LIST}', slist)
|
||||
content = content.replace('{$UPSTREAM_NAME}', conf['upstream_name'])
|
||||
if conf['node_algo'] != 'polling':
|
||||
content = content.replace('{$NODE_ALGO}', conf['node_algo'] + ';')
|
||||
else:
|
||||
content = content.replace('{$NODE_ALGO}', '')
|
||||
mw.writeFile(upstream_file, content)
|
||||
# make upstream end
|
||||
|
||||
# make rewrite start
|
||||
rewrite_file = rewrite_dir + '/' + conf['domain'] + '.conf'
|
||||
rcontent = ''
|
||||
if len(conf['node_list']) > 0:
|
||||
rcontent = mw.readFile(rewrite_tpl)
|
||||
rcontent = rcontent.replace('{$UPSTREAM_NAME}', conf['upstream_name'])
|
||||
mw.writeFile(rewrite_file, rcontent)
|
||||
# make rewrite end
|
||||
|
||||
# health check start
|
||||
lua_dir = mw.getServerDir() + '/web_conf/nginx/lua/init_worker_by_lua_file'
|
||||
lua_init_worker_file = lua_dir + '/' + conf['upstream_name'] + '.lua'
|
||||
if conf['node_health_check'] == 'ok':
|
||||
lua_dir_tpl = getPluginDir() + '/lua/health_check.lua.tpl'
|
||||
content = mw.readFile(lua_dir_tpl)
|
||||
content = content.replace('{$UPSTREAM_NAME}', conf['upstream_name'])
|
||||
content = content.replace('{$DOMAIN}', conf['domain'])
|
||||
mw.writeFile(lua_init_worker_file, content)
|
||||
else:
|
||||
if os.path.exists(lua_init_worker_file):
|
||||
os.remove(lua_init_worker_file)
|
||||
|
||||
mw.opLuaInitWorkerFile()
|
||||
# health check end
|
||||
return True
|
||||
|
||||
|
||||
def add_load_balance(args):
|
||||
|
||||
data = checkArgs(
|
||||
args, ['domain', 'upstream_name', 'node_algo', 'node_list', 'node_health_check'])
|
||||
if not data[0]:
|
||||
return data[1]
|
||||
|
||||
domain_json = args['domain']
|
||||
|
||||
tmp = json.loads(domain_json)
|
||||
domain = tmp['domain']
|
||||
|
||||
cfg = getConf()
|
||||
cfg_len = len(cfg)
|
||||
tmp = {}
|
||||
tmp['domain'] = domain
|
||||
tmp['data'] = args['domain']
|
||||
tmp['upstream_name'] = args['upstream_name']
|
||||
tmp['node_algo'] = args['node_algo']
|
||||
tmp['node_list'] = args['node_list']
|
||||
tmp['node_health_check'] = args['node_health_check']
|
||||
cfg.append(tmp)
|
||||
writeConf(cfg)
|
||||
|
||||
import site_api
|
||||
sobj = site_api.site_api()
|
||||
domain_path = mw.getWwwDir() + '/' + domain
|
||||
|
||||
ps = '负载均衡[' + domain + ']'
|
||||
data = sobj.add(domain_json, '80', ps, domain_path, '00')
|
||||
|
||||
makeLoadBalanceAllCfg(cfg_len)
|
||||
mw.restartWeb()
|
||||
return mw.returnJson(True, '添加成功', data)
|
||||
|
||||
|
||||
def edit_load_balance(args):
|
||||
data = checkArgs(
|
||||
args, ['row', 'node_algo', 'node_list', 'node_health_check'])
|
||||
if not data[0]:
|
||||
return data[1]
|
||||
|
||||
row = int(args['row'])
|
||||
|
||||
cfg = getConf()
|
||||
tmp = cfg[row]
|
||||
tmp['node_algo'] = args['node_algo']
|
||||
tmp['node_list'] = args['node_list']
|
||||
tmp['node_health_check'] = args['node_health_check']
|
||||
cfg[row] = tmp
|
||||
writeConf(cfg)
|
||||
|
||||
makeLoadBalanceAllCfg(row)
|
||||
mw.restartWeb()
|
||||
return mw.returnJson(True, '修改成功', data)
|
||||
|
||||
|
||||
def loadBalanceList():
|
||||
cfg = getConf()
|
||||
return mw.returnJson(True, 'ok', cfg)
|
||||
|
||||
|
||||
def loadBalanceDelete():
|
||||
args = getArgs()
|
||||
data = checkArgs(args, ['row'])
|
||||
if not data[0]:
|
||||
return data[1]
|
||||
|
||||
row = int(args['row'])
|
||||
|
||||
cfg = getConf()
|
||||
data = cfg[row]
|
||||
|
||||
import site_api
|
||||
sobj = site_api.site_api()
|
||||
|
||||
sid = mw.M('sites').where('name=?', (data['domain'],)).getField('id')
|
||||
|
||||
if type(sid) == list:
|
||||
del(cfg[row])
|
||||
writeConf(cfg)
|
||||
return mw.returnJson(False, '已经删除了!')
|
||||
|
||||
status = sobj.delete(sid, data['domain'], 1)
|
||||
status_data = json.loads(status)
|
||||
|
||||
if status_data['status']:
|
||||
del(cfg[row])
|
||||
writeConf(cfg)
|
||||
|
||||
upstream_dir = mw.getServerDir() + '/web_conf/nginx/upstream'
|
||||
rewrite_dir = mw.getServerDir() + '/web_conf/nginx/rewrite'
|
||||
|
||||
upstream_file = upstream_dir + '/' + data['upstream_name'] + '.conf'
|
||||
if os.path.exists(upstream_file):
|
||||
os.remove(upstream_file)
|
||||
|
||||
rewrite_file = rewrite_dir + '/' + data['domain'] + '.conf'
|
||||
if os.path.exists(rewrite_file):
|
||||
mw.writeFile(rewrite_file, '')
|
||||
|
||||
return mw.returnJson(status_data['status'], status_data['msg'])
|
||||
|
||||
|
||||
def http_get(url):
|
||||
ret = re.search(r'https://', url)
|
||||
if ret:
|
||||
try:
|
||||
from gevent import monkey
|
||||
monkey.patch_ssl()
|
||||
import requests
|
||||
ret = requests.get(url=str(url), verify=False, timeout=10)
|
||||
status = [200, 301, 302, 404, 403]
|
||||
if ret.status_code in status:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
except:
|
||||
return False
|
||||
else:
|
||||
try:
|
||||
if sys.version_info[0] == 2:
|
||||
import urllib2
|
||||
rec = urllib2.urlopen(url, timeout=3)
|
||||
else:
|
||||
import urllib.request
|
||||
rec = urllib.request.urlopen(url, timeout=3)
|
||||
status = [200, 301, 302, 404, 403]
|
||||
if rec.getcode() in status:
|
||||
return True
|
||||
return False
|
||||
except:
|
||||
return False
|
||||
|
||||
|
||||
def checkUrl():
|
||||
args = getArgs()
|
||||
data = checkArgs(args, ['ip', 'port', 'path'])
|
||||
if not data[0]:
|
||||
return data[1]
|
||||
|
||||
ip = args['ip']
|
||||
port = args['port']
|
||||
path = args['path']
|
||||
|
||||
if port == '443':
|
||||
url = 'https://' + str(ip) + ':' + str(port) + str(path.strip())
|
||||
else:
|
||||
url = 'http://' + str(ip) + ':' + str(port) + str(path.strip())
|
||||
ret = http_get(url)
|
||||
if not ret:
|
||||
return mw.returnJson(False, '访问节点[%s]失败' % url)
|
||||
return mw.returnJson(True, '访问节点[%s]成功' % url)
|
||||
|
||||
|
||||
def getHealthStatus():
|
||||
args = getArgs()
|
||||
data = checkArgs(args, ['row'])
|
||||
if not data[0]:
|
||||
return data[1]
|
||||
|
||||
row = int(args['row'])
|
||||
|
||||
cfg = getConf()
|
||||
data = cfg[row]
|
||||
|
||||
url = 'http://' + data['domain'] + \
|
||||
'/upstream_status_' + data['upstream_name']
|
||||
|
||||
url_data = mw.httpGet(url)
|
||||
return mw.returnJson(True, 'ok', json.loads(url_data))
|
||||
|
||||
|
||||
def getLogs():
|
||||
args = getArgs()
|
||||
data = checkArgs(args, ['domain'])
|
||||
if not data[0]:
|
||||
return data[1]
|
||||
|
||||
domain = args['domain']
|
||||
logs = mw.getLogsDir() + '/' + domain + '.log'
|
||||
return logs
|
||||
|
||||
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 == 'install_pre_inspection':
|
||||
print(installPreInspection())
|
||||
elif func == 'add_load_balance':
|
||||
print(addLoadBalance())
|
||||
elif func == 'load_balance_list':
|
||||
print(loadBalanceList())
|
||||
elif func == 'load_balance_delete':
|
||||
print(loadBalanceDelete())
|
||||
elif func == 'check_url':
|
||||
print(checkUrl())
|
||||
elif func == 'get_logs':
|
||||
print(getLogs())
|
||||
elif func == 'get_health_status':
|
||||
print(getHealthStatus())
|
||||
else:
|
||||
print('error')
|
||||
Executable
+16
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"title":"OP负载均衡",
|
||||
"tip":"soft",
|
||||
"name":"op_load_balance",
|
||||
"type":"其他插件",
|
||||
"install_pre_inspection":true,
|
||||
"ps":"基于OpenResty的负载均衡",
|
||||
"shell":"install.sh",
|
||||
"checks":"server/op_load_balance",
|
||||
"path":"server/op_load_balance",
|
||||
"author":"midoks",
|
||||
"home":"https://github.com/midoks",
|
||||
"date":"2023-02-02",
|
||||
"pid": "1",
|
||||
"versions": ["1.0"]
|
||||
}
|
||||
Executable
+45
@@ -0,0 +1,45 @@
|
||||
#!/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
|
||||
|
||||
action=$1
|
||||
version=$2
|
||||
sys_os=`uname`
|
||||
|
||||
if [ -f ${rootPath}/bin/activate ];then
|
||||
source ${rootPath}/bin/activate
|
||||
fi
|
||||
|
||||
if [ "$sys_os" == "Darwin" ];then
|
||||
BAK='_bak'
|
||||
else
|
||||
BAK=''
|
||||
fi
|
||||
|
||||
Install_App(){
|
||||
echo '正在安装脚本文件...' > $install_tmp
|
||||
mkdir -p $serverPath/op_load_balance
|
||||
echo "${version}" > $serverPath/op_load_balance/version.pl
|
||||
cd ${rootPath} && python3 ${rootPath}/plugins/op_load_balance/index.py start
|
||||
echo 'install ok' > $install_tmp
|
||||
}
|
||||
|
||||
Uninstall_App(){
|
||||
cd ${rootPath} && python3 ${rootPath}/plugins/op_load_balance/index.py stop
|
||||
rm -rf $serverPath/op_load_balance
|
||||
}
|
||||
|
||||
|
||||
action=$1
|
||||
if [ "${1}" == 'install' ];then
|
||||
Install_App
|
||||
else
|
||||
Uninstall_App
|
||||
fi
|
||||
@@ -0,0 +1,606 @@
|
||||
function ooPost(method,args,callback){
|
||||
var _args = null;
|
||||
if (typeof(args) == 'string'){
|
||||
_args = JSON.stringify(toArrayObject(args));
|
||||
} else {
|
||||
_args = JSON.stringify(args);
|
||||
}
|
||||
|
||||
var loadT = layer.msg('正在获取...', { icon: 16, time: 0, shade: 0.3 });
|
||||
$.post('/plugins/run', {name:'op_load_balance', 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 ooAsyncPost(method,args){
|
||||
var _args = null;
|
||||
if (typeof(args) == 'string'){
|
||||
_args = JSON.stringify(toArrayObject(args));
|
||||
} else {
|
||||
_args = JSON.stringify(args);
|
||||
}
|
||||
return syncPost('/plugins/run', {name:'op_load_balance', func:method, args:_args});
|
||||
}
|
||||
|
||||
function ooPostCallbak(method, args, callback){
|
||||
var loadT = layer.msg('正在获取...', { icon: 16, time: 0, shade: 0.3 });
|
||||
|
||||
var req_data = {};
|
||||
req_data['name'] = 'op_load_balance';
|
||||
req_data['func'] = method;
|
||||
args['version'] = '1.0';
|
||||
|
||||
if (typeof(args) == 'string'){
|
||||
req_data['args'] = JSON.stringify(toArrayObject(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 addNode(){
|
||||
layer.open({
|
||||
type: 1,
|
||||
area: ['450px','580px'],
|
||||
title: '添加节点',
|
||||
closeBtn: 1,
|
||||
shift: 5,
|
||||
shadeClose: true,
|
||||
btn:['提交','关闭'],
|
||||
content: "<form class='bt-form pd20'>\
|
||||
<div class='line'>\
|
||||
<span class='tname'>IP地址</span>\
|
||||
<div class='info-r'>\
|
||||
<input name='ip' class='bt-input-text mr5' placeholder='负载名称,可以是英文字母和下划线,不能使用中文' type='text' style='width:250px' value='127.0.0.1'>\
|
||||
</div>\
|
||||
</div>\
|
||||
<div class='line'>\
|
||||
<span class='tname'>端口</span>\
|
||||
<div class='info-r'>\
|
||||
<input name='port' class='bt-input-text mr5' type='text' style='width:250px' value='80'>\
|
||||
</div>\
|
||||
</div>\
|
||||
<div class='line'>\
|
||||
<span class='tname'>验证文件路径</span>\
|
||||
<div class='info-r'>\
|
||||
<input name='path' class='bt-input-text mr5' type='text' style='width:250px' value='/'>\
|
||||
</div>\
|
||||
</div>\
|
||||
<div class='line'>\
|
||||
<span class='tname'>节点状态</span>\
|
||||
<div class='info-r'>\
|
||||
<select name='state'>\
|
||||
<option value='1'>参与者</option>\
|
||||
<option value='2'>备份</option>\
|
||||
<option value='0'>停用</option>\
|
||||
</select>\
|
||||
</div>\
|
||||
</div>\
|
||||
<div class='line'>\
|
||||
<span class='tname'>权重</span>\
|
||||
<div class='info-r'>\
|
||||
<input name='weight' class='bt-input-text mr5' type='text' style='width:250px' value='1'>\
|
||||
</div>\
|
||||
</div>\
|
||||
<div class='line'>\
|
||||
<span class='tname'>阈值</span>\
|
||||
<div class='info-r'>\
|
||||
<input name='max_fails' class='bt-input-text mr5' type='text' style='width:250px' value='2'>次\
|
||||
</div>\
|
||||
</div>\
|
||||
<div class='line'>\
|
||||
<span class='tname'>恢复时间</span>\
|
||||
<div class='info-r'>\
|
||||
<input name='fail_timeout' class='bt-input-text mr5' type='text' style='width:250px' value='10'>秒\
|
||||
</div>\
|
||||
</div>\
|
||||
<ul style='margin-left:10px' class='help-info-text c7'>\
|
||||
<li>备份状态: 指当其它节点都无法使用时才会使用此节点</li>\
|
||||
<li>参与状态: 正常参与负载均衡,请至少添加1个普通节点</li>\
|
||||
<li>验证文件路径: 用于检查文件路径地址是否可用</li>\
|
||||
<li>IP地址: 仅支持IP地址,否则无法正常参与负载均衡</li>\
|
||||
<li>阈值: 在恢复时间的时间段内,如果OpenResty与节点通信尝试失败的次数达到此值,OpenResty就认为服务器不可用</li>\
|
||||
</ul>\
|
||||
</form>",
|
||||
success:function(){
|
||||
},
|
||||
yes:function(index) {
|
||||
|
||||
var ip = $('input[name="ip"]').val();
|
||||
var port = $('input[name="port"]').val();
|
||||
var path = $('input[name="path"]').val();
|
||||
var state = $('select[name="state"]').val();
|
||||
var weight = $('input[name="weight"]').val();
|
||||
var max_fails = $('input[name="max_fails"]').val();
|
||||
var fail_timeout = $('input[name="fail_timeout"]').val();
|
||||
|
||||
ooPost('check_url', {ip:ip,port:port,path:path},function(rdata){
|
||||
var rdata = $.parseJSON(rdata.data);
|
||||
showMsg(rdata.msg, function(){
|
||||
if (rdata.status){
|
||||
layer.close(index);
|
||||
$('#nodecon .nulltr').hide();
|
||||
|
||||
var tbody = '<tr>';
|
||||
tbody +='<td>'+ip+'</td>';
|
||||
tbody +='<td>'+port+'</td>';
|
||||
tbody +='<td>'+path+'</td>';
|
||||
|
||||
tbody +="<td><select name='state'>";
|
||||
var state_option_list = {
|
||||
'1':'参与者',
|
||||
'2':'备份',
|
||||
'0':'停用',
|
||||
}
|
||||
for (i in state_option_list) {
|
||||
if (i == state){
|
||||
tbody +="<option value='"+i+"' selected>"+state_option_list[i]+"</option>";
|
||||
} else{
|
||||
tbody +="<option value='"+i+"'>"+state_option_list[i]+"</option>";
|
||||
}
|
||||
}
|
||||
tbody +="</select></td>";
|
||||
|
||||
tbody +='<td><input type="number" name="weight" value="'+weight+'" style="width:50px"></td>';
|
||||
tbody +='<td><input type="number" name="max_fails" value="'+max_fails+'" style="width:50px"></td>';
|
||||
tbody +='<td><input type="number" name="fail_timeout" value="'+fail_timeout+'" style="width:50px"></td>';
|
||||
tbody +='<td class="text-right" width="50"><a class="btlink minus delete">删除</a></td>';
|
||||
tbody += '</tr>';
|
||||
$('#nodecon').append(tbody);
|
||||
|
||||
$('#nodecon .delete').click(function(){
|
||||
$(this).parent().parent().remove();
|
||||
if ($('#nodecon tr').length == 1 ){
|
||||
$('#nodecon .nulltr').show();
|
||||
}
|
||||
});
|
||||
}
|
||||
},{ icon: rdata.status ? 1 : 2 }, 2000);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function addBalance(){
|
||||
layer.open({
|
||||
type: 1,
|
||||
area: ['750px','460px'],
|
||||
title: '创建负载',
|
||||
closeBtn: 1,
|
||||
shift: 5,
|
||||
shadeClose: true,
|
||||
btn:['提交','关闭'],
|
||||
content: "<form class='bt-form pd20'>\
|
||||
<div class='line'>\
|
||||
<span class='tname'>域名</span>\
|
||||
<div class='info-r'><textarea name='load_domain' class='bt-input-text mr5' placeholder='' style='width:95%;resize: none;height:90px;line-height:20px;'></textarea></div>\
|
||||
</div>\
|
||||
<div class='line'>\
|
||||
<span class='tname'>负载名称</span>\
|
||||
<div class='info-r'>\
|
||||
<input name='upstream_name' class='bt-input-text mr5' placeholder='负载名称,可以是英文字母和下划线,不能使用中文' type='text' style='width:95%' value=''>\
|
||||
</div>\
|
||||
</div>\
|
||||
<div class='line'>\
|
||||
<span class='tname'>节点调度</span>\
|
||||
<div class='info-r'>\
|
||||
<select name='node_algo'>\
|
||||
<option value='polling'>轮询[默认]</option>\
|
||||
<option value='ip_hash'>ip_hash</option>\
|
||||
<option value='fair'>fair</option>\
|
||||
<option value='url_hash'>url_hash</option>\
|
||||
<option value='least_conn'>least_conn</option>\
|
||||
</select>\
|
||||
</div>\
|
||||
</div>\
|
||||
<div class='line'>\
|
||||
<span class='tname'>节点健康检查</span>\
|
||||
<div class='info-r'>\
|
||||
<input type='checkbox' name='node_health_check' checked>\
|
||||
</div>\
|
||||
</div>\
|
||||
<div class='line'>\
|
||||
<span class='tname'>节点</span>\
|
||||
<div class='info-r'>\
|
||||
<div class='table-con divtable' style='max-height:120px;overflow:auto; margin-bottom:8px;width:95%'>\
|
||||
<table class='table table-hover' id='fixTable3'>\
|
||||
<thead>\
|
||||
<tr>\
|
||||
<th width='120'>IP地址</th>\
|
||||
<th width='60'>端口</th>\
|
||||
<th width='120'>验证路径</th>\
|
||||
<th width='60'>状态</th>\
|
||||
<th width='60'>权重</th>\
|
||||
<th width='60'>阀值</th>\
|
||||
<th width='120'>恢复时间</th>\
|
||||
<th width='80' class='text-right'>操作</th>\
|
||||
</tr>\
|
||||
</thead>\
|
||||
<tbody id='nodecon'>\
|
||||
<tr class='nulltr'>\
|
||||
<td colspan='8' align='center'>当前节点为空,请至少添加一个普通节点</td>\
|
||||
</tr>\
|
||||
</tbody>\
|
||||
</table>\
|
||||
</div>\
|
||||
<span class='btn btn-success btn-sm add_node' style='vertical-align:0'>添加节点</span>\
|
||||
</div>\
|
||||
</div>\
|
||||
</form>",
|
||||
success:function(){
|
||||
$('textarea[name="load_domain"]').attr('placeholder','每行填写一个域名,默认为80端口。\n泛解析添加方法 *.domain.com\n如另加端口格式为 www.domain.com:88');
|
||||
var rval = getRandomString(6);
|
||||
$('input[name="upstream_name"]').val('load_balance_'+rval);
|
||||
|
||||
$('.add_node').click(function(){
|
||||
addNode();
|
||||
});
|
||||
},
|
||||
yes:function(index) {
|
||||
var data = {};
|
||||
|
||||
var upstream_name = $('input[name="upstream_name"]').val();
|
||||
if (upstream_name == ''){
|
||||
layer.msg('负载名称不能为空!',{icon:0,time:2000,shade: [0.3, '#000']});
|
||||
return;
|
||||
}
|
||||
|
||||
var domain = $('textarea[name="load_domain"]').val().replace('http://','').replace('https://','').split("\n");
|
||||
if (domain[0] == ''){
|
||||
layer.msg('域名不能为空!',{icon:0,time:2000,shade: [0.3, '#000']});
|
||||
return;
|
||||
}
|
||||
|
||||
var domainlist = '';
|
||||
for(var i=1; i<domain.length; i++){
|
||||
domainlist += '"'+domain[i]+'",';
|
||||
}
|
||||
domain ='{"domain":"'+domain[0]+'","domainlist":['+domainlist+'],"count":'+domain.length+'}';//拼接json
|
||||
data['domain'] = domain;
|
||||
data['upstream_name'] = upstream_name;
|
||||
|
||||
data['node_algo'] = $('select[name="node_algo"]').val();
|
||||
|
||||
data['node_health_check'] = 'fail';
|
||||
if ($('input[name="node_health_check"]').prop('checked')){
|
||||
data['node_health_check'] = 'ok';
|
||||
}
|
||||
|
||||
var node_list = [];
|
||||
$('#nodecon tr').each(function(){
|
||||
|
||||
var ip = $(this).find('td').eq(0).text();
|
||||
var port = $(this).find('td').eq(1).text();
|
||||
|
||||
if (port == ''){return;}
|
||||
|
||||
var path = $(this).find('td').eq(2).text();
|
||||
var state = $(this).find('select[name="state"]').val();
|
||||
var weight = $(this).find('input[name="weight"]').val();
|
||||
var max_fails = $(this).find('input[name="max_fails"]').val();
|
||||
var fail_timeout = $(this).find('input[name="fail_timeout"]').val();
|
||||
|
||||
var tmp = {
|
||||
ip:ip,
|
||||
port:port,
|
||||
path:path,
|
||||
state:state,
|
||||
weight:weight,
|
||||
max_fails:max_fails,
|
||||
fail_timeout:fail_timeout,
|
||||
}
|
||||
node_list.push(tmp);
|
||||
});
|
||||
data['node_list'] = node_list;
|
||||
ooPostCallbak('add_load_balance', data, function(rdata){
|
||||
var rdata = $.parseJSON(rdata.data);
|
||||
showMsg(rdata.msg, function(){
|
||||
layer.close(index);
|
||||
loadBalanceListRender();
|
||||
},{ icon: rdata.status ? 1 : 2 }, 2000);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function editBalance(data, row){
|
||||
layer.open({
|
||||
type: 1,
|
||||
area: ['750px','400px'],
|
||||
title: '编辑负载',
|
||||
closeBtn: 1,
|
||||
shift: 5,
|
||||
shadeClose: true,
|
||||
btn:['提交','关闭'],
|
||||
content: "<form class='bt-form pd20'>\
|
||||
<div class='line'>\
|
||||
<span class='tname'>负载名称</span>\
|
||||
<div class='info-r'><input name='upstream_name' class='bt-input-text mr5' type='text' style='width:95%;background: rgb(238, 238, 238);' value='' readonly></div>\
|
||||
</div>\
|
||||
<div class='line'>\
|
||||
<span class='tname'>节点调度</span>\
|
||||
<div class='info-r'>\
|
||||
<select name='node_algo'>\
|
||||
<option value='polling'>轮询[默认]</option>\
|
||||
<option value='ip_hash'>ip_hash</option>\
|
||||
<option value='fair'>fair</option>\
|
||||
<option value='url_hash'>url_hash</option>\
|
||||
<option value='least_conn'>least_conn</option>\
|
||||
</select>\
|
||||
</div>\
|
||||
</div>\
|
||||
<div class='line'>\
|
||||
<span class='tname'>节点健康检查</span>\
|
||||
<div class='info-r'>\
|
||||
<input type='checkbox' name='node_health_check'>\
|
||||
</div>\
|
||||
</div>\
|
||||
<div class='line'>\
|
||||
<span class='tname'>节点</span>\
|
||||
<div class='info-r'>\
|
||||
<div class='table-con divtable' style='max-height:120px;overflow:auto; margin-bottom:8px;width:95%'>\
|
||||
<table class='table table-hover' id='fixTable3'>\
|
||||
<thead>\
|
||||
<tr>\
|
||||
<th width='120'>IP地址</th>\
|
||||
<th width='60'>端口</th>\
|
||||
<th width='120'>验证路径</th>\
|
||||
<th width='60'>状态</th>\
|
||||
<th width='60'>权重</th>\
|
||||
<th width='60'>阀值</th>\
|
||||
<th width='120'>恢复时间</th>\
|
||||
<th width='80' class='text-right'>操作</th>\
|
||||
</tr>\
|
||||
</thead>\
|
||||
<tbody id='nodecon'>\
|
||||
<tr class='nulltr'>\
|
||||
<td colspan='8' align='center'>当前节点为空,请至少添加一个普通节点</td>\
|
||||
</tr>\
|
||||
</tbody>\
|
||||
</table>\
|
||||
</div>\
|
||||
<span class='btn btn-success btn-sm add_node' style='vertical-align:0'>添加节点</span>\
|
||||
</div>\
|
||||
</div>\
|
||||
</form>",
|
||||
success:function(){
|
||||
$('input[name="upstream_name"]').val(data['upstream_name']);
|
||||
$('select[name="node_algo"]').val(data['node_algo']);
|
||||
|
||||
$('input[name="node_health_check"]').prop('checked',false);
|
||||
if (data['node_health_check'] == 'ok'){
|
||||
$('input[name="node_health_check"]').prop('checked',true);
|
||||
}
|
||||
|
||||
var node_list = data['node_list'];
|
||||
if (node_list.length>0){
|
||||
$('#nodecon .nulltr').hide();
|
||||
}
|
||||
|
||||
var state_option_list = {
|
||||
'1':'参与者',
|
||||
'2':'备份',
|
||||
'0':'停用',
|
||||
}
|
||||
|
||||
for (var n in node_list) {
|
||||
|
||||
var tbody = '<tr>';
|
||||
tbody +='<td>'+node_list[n]['ip']+'</td>';
|
||||
tbody +='<td>'+node_list[n]['port']+'</td>';
|
||||
tbody +='<td>'+node_list[n]['path']+'</td>';
|
||||
|
||||
tbody +="<td><select name='state'>";
|
||||
|
||||
for (i in state_option_list) {
|
||||
if (i == node_list[n]['state']){
|
||||
tbody +="<option value='"+i+"' selected>"+state_option_list[i]+"</option>";
|
||||
} else{
|
||||
tbody +="<option value='"+i+"'>"+state_option_list[i]+"</option>";
|
||||
}
|
||||
}
|
||||
tbody +="</select></td>";
|
||||
|
||||
tbody +='<td><input type="number" name="weight" value="'+node_list[n]['weight']+'" style="width:50px"></td>';
|
||||
tbody +='<td><input type="number" name="max_fails" value="'+node_list[n]['max_fails']+'" style="width:50px"></td>';
|
||||
tbody +='<td><input type="number" name="fail_timeout" value="'+node_list[n]['fail_timeout']+'" style="width:50px"></td>';
|
||||
tbody +='<td class="text-right" width="50"><a class="btlink minus delete">删除</a></td>';
|
||||
tbody += '</tr>';
|
||||
$('#nodecon').append(tbody);
|
||||
}
|
||||
|
||||
$('#nodecon .delete').click(function(){
|
||||
$(this).parent().parent().remove();
|
||||
if ($('#nodecon tr').length == 1 ){
|
||||
$('#nodecon .nulltr').show();
|
||||
}
|
||||
});
|
||||
|
||||
$('.add_node').click(function(){
|
||||
addNode();
|
||||
});
|
||||
},
|
||||
yes:function(index) {
|
||||
var data = {};
|
||||
|
||||
data['node_algo'] = $('select[name="node_algo"]').val();
|
||||
data['node_health_check'] = 'fail';
|
||||
if ($('input[name="node_health_check"]').prop('checked')){
|
||||
data['node_health_check'] = 'ok';
|
||||
}
|
||||
|
||||
var node_list = [];
|
||||
$('#nodecon tr').each(function(){
|
||||
|
||||
var ip = $(this).find('td').eq(0).text();
|
||||
var port = $(this).find('td').eq(1).text();
|
||||
|
||||
if (port == ''){return;}
|
||||
|
||||
var path = $(this).find('td').eq(2).text();
|
||||
var state = $(this).find('select[name="state"]').val();
|
||||
var weight = $(this).find('input[name="weight"]').val();
|
||||
var max_fails = $(this).find('input[name="max_fails"]').val();
|
||||
var fail_timeout = $(this).find('input[name="fail_timeout"]').val();
|
||||
|
||||
var tmp = {
|
||||
ip:ip,
|
||||
port:port,
|
||||
path:path,
|
||||
state:state,
|
||||
weight:weight,
|
||||
max_fails:max_fails,
|
||||
fail_timeout:fail_timeout,
|
||||
}
|
||||
node_list.push(tmp);
|
||||
});
|
||||
data['node_list'] = node_list;
|
||||
data['row'] = row;
|
||||
ooPostCallbak('edit_load_balance', data, function(rdata){
|
||||
var rdata = $.parseJSON(rdata.data);
|
||||
showMsg(rdata.msg, function(){
|
||||
layer.close(index);
|
||||
loadBalanceListRender();
|
||||
},{ icon: rdata.status ? 1 : 2 }, 2000);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function loadBalanceListRender(){
|
||||
ooPost('load_balance_list', {}, function(rdata){
|
||||
var rdata = $.parseJSON(rdata.data);
|
||||
var alist = rdata.data;
|
||||
|
||||
var tbody = '';
|
||||
for (var i = 0; i < alist.length; i++) {
|
||||
tbody += '<tr>';
|
||||
tbody += '<td>'+alist[i]['domain']+'</td>';
|
||||
tbody += '<td>'+alist[i]['upstream_name']+'</td>';
|
||||
tbody += '<td>'+alist[i]['node_list'].length+'</td>';
|
||||
tbody += '<td><a class="btlink log_look" data-row="'+i+'">查看</a></td>';
|
||||
tbody += '<td><a class="btlink health_status" data-row="'+i+'">查看</a></td>';
|
||||
tbody += '<td style="text-align: right;"><a class="btlink edit" data-row="'+i+'">修改</a> | <a class="btlink delete" data-row="'+i+'">删除</a></td>';
|
||||
tbody += '</tr>';
|
||||
}
|
||||
|
||||
$('#nodeTable').html(tbody);
|
||||
$('.nodeTablePage .Pcount').text('共'+alist.length+'条');
|
||||
$('#nodeTable .edit').click(function(){
|
||||
var row = $(this).data('row');
|
||||
editBalance(alist[row],row);
|
||||
});
|
||||
|
||||
$('#nodeTable .log_look').click(function(){
|
||||
var row = $(this).data('row');
|
||||
var args = {'domain':alist[row]['domain']};
|
||||
pluginRollingLogs('op_load_balance','','get_logs',JSON.stringify(args),20);
|
||||
});
|
||||
|
||||
$('#nodeTable .health_status').click(function(){
|
||||
var row = $(this).data('row');
|
||||
ooPost('get_health_status', {row:row}, function(rdata){
|
||||
var rdata = $.parseJSON(rdata.data);
|
||||
|
||||
var tval = '';
|
||||
for (var i = 0; i < rdata.data.length; i++) {
|
||||
tval += '<tr>';
|
||||
tval += '<td>'+rdata.data[i]['name']+'</td>';
|
||||
|
||||
if (typeof(rdata.data[i]['down']) != 'undefined' && rdata.data[i]['down']){
|
||||
tval += '<td><span style="color:red;">不正常</span></td>';
|
||||
} else{
|
||||
tval += '<td><span class="btlink">正常</span></td>';
|
||||
}
|
||||
tval += '</tr>';
|
||||
}
|
||||
|
||||
var tbody = "<div class='bt-form pd20'>\
|
||||
<div>\
|
||||
<div id='gitea_table' class='divtable' style='margin-top:5px;'>\
|
||||
<table class='table table-hover'>\
|
||||
<thead>\
|
||||
<tr>\
|
||||
<th width='120'>地址</th>\
|
||||
<th width='60'>状态</th>\
|
||||
</tr>\
|
||||
</thead>\
|
||||
<tbody>"+tval+"</tbody>\
|
||||
</table>\
|
||||
</div>\
|
||||
</div>\
|
||||
</div>";
|
||||
|
||||
layer.open({
|
||||
type: 1,
|
||||
area: ['500px','300px'],
|
||||
title: '节点状态',
|
||||
closeBtn: 1,
|
||||
shift: 5,
|
||||
shadeClose: true,
|
||||
btn:['提交','关闭'],
|
||||
content:tbody,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
$('#nodeTable .delete').click(function(){
|
||||
var row = $(this).data('row');
|
||||
ooPost('load_balance_delete', {row:row}, function(rdata){
|
||||
var rdata = $.parseJSON(rdata.data);
|
||||
showMsg(rdata.msg, function(){
|
||||
loadBalanceListRender();
|
||||
},{ icon: rdata.status ? 1 : 2 }, 2000);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
function loadBalanceList() {
|
||||
var body = '<div class="bt-box active" style="display: block;">\
|
||||
<div class="mb10">\
|
||||
<button class="btn btn-success btn-sm" data-index="0" onclick="addBalance()">添加负载</button>\
|
||||
<div class="divtable mt10">\
|
||||
<table class="table table-hover">\
|
||||
<thead>\
|
||||
<tr>\
|
||||
<th>网站</th>\
|
||||
<th>负载名称</th>\
|
||||
<th>节点</th>\
|
||||
<th>日志</th>\
|
||||
<th>状态</th>\
|
||||
<th width="100" style="text-align: right;">操作</th>\
|
||||
</tr>\
|
||||
</thead>\
|
||||
<tbody id="nodeTable"></tbody>\
|
||||
</table>\
|
||||
<div class="nodeTablePage page" data-type="nodePage">\
|
||||
<div><span class="Pcount">共0条</span></div>\
|
||||
</div>\
|
||||
</div>\
|
||||
</div>\
|
||||
</div>\
|
||||
</div>';
|
||||
$(".soft-man-con").html(body);
|
||||
loadBalanceListRender();
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
local hc = require "resty.upstream.healthcheck"
|
||||
local ok, err = hc.spawn_checker {
|
||||
shm = "healthcheck",
|
||||
type = "http",
|
||||
upstream = "{$UPSTREAM_NAME}",
|
||||
http_req = "GET / HTTP/1.0\r\nHost: {$UPSTREAM_NAME}\r\n\r\n",
|
||||
interval = 2000,
|
||||
timeout = 6000,
|
||||
fall = 3,
|
||||
rise = 2,
|
||||
valid_statuses = {200, 302},
|
||||
concurrency = 20,
|
||||
}
|
||||
|
||||
if not ok then
|
||||
ngx.log(ngx.ERR, "=======> load balance health checker error: ", err)
|
||||
return
|
||||
end
|
||||
@@ -1,4 +1,16 @@
|
||||
{
|
||||
"hook":[
|
||||
{
|
||||
"tag":"site_cb",
|
||||
"site_cb": {
|
||||
"title":"网站统计",
|
||||
"name":"op_waf",
|
||||
"add":{"func":"reload"},
|
||||
"update":{"func":"reload"},
|
||||
"delete":{"func":"reload"}
|
||||
}
|
||||
}
|
||||
],
|
||||
"title":"OP防火墙",
|
||||
"tip":"soft",
|
||||
"name":"op_waf",
|
||||
@@ -12,5 +24,5 @@
|
||||
"home":"https://github.com/loveshell/ngx_lua_waf",
|
||||
"date":"2019-04-21",
|
||||
"pid": "1",
|
||||
"versions": ["0.2.5"]
|
||||
"versions": ["0.2.6"]
|
||||
}
|
||||
@@ -344,13 +344,22 @@ local function waf_cc_increase()
|
||||
local make_uri = "/"..make_uri_str
|
||||
|
||||
if params['uri_request_args']['token'] then
|
||||
ngx.header.content_type = "application/json"
|
||||
local args_token = params['uri_request_args']['token']
|
||||
if args_token == make_token then
|
||||
ngx.shared.waf_limit:set(cache_token, 1, config['safe_verify']['time'])
|
||||
ngx.shared.waf_limit:set(cache_token, 1, tonumber(config['safe_verify']['time']))
|
||||
local data = get_return_state(0, "ok")
|
||||
ngx.say(json.encode(data))
|
||||
ngx.exit(200)
|
||||
end
|
||||
|
||||
-- C:D("debug[args]:"..tostring(params['uri_request_args']['debug']))
|
||||
-- if params['uri_request_args']['debug'] == 'ok' then
|
||||
-- ngx.header.content_type = "application/json"
|
||||
-- local data = get_return_state(0, "ok")
|
||||
-- ngx.say(json.encode(data))
|
||||
-- ngx.exit(200)
|
||||
-- end
|
||||
end
|
||||
|
||||
local cc_html = ngx.re.gsub(cc_safe_js_html, "{uri}", make_uri_str)
|
||||
|
||||
@@ -204,8 +204,8 @@ def initDreplace():
|
||||
mw.writeFile(file_bin, content)
|
||||
mw.execShell('chmod +x ' + file_bin)
|
||||
|
||||
# config replace
|
||||
confReplace()
|
||||
# config replace
|
||||
confReplace()
|
||||
|
||||
# systemd
|
||||
# /usr/lib/systemd/system
|
||||
|
||||
@@ -59,10 +59,21 @@ Install_openresty()
|
||||
mkdir -p ${openrestyDir}
|
||||
echo '正在安装脚本文件...' > $install_tmp
|
||||
|
||||
# wget -O openresty-1.21.4.1.tar.gz https://openresty.org/download/openresty-1.21.4.1.tar.gz
|
||||
if [ ! -f ${openrestyDir}/openresty-${VERSION}.tar.gz ];then
|
||||
wget -O ${openrestyDir}/openresty-${VERSION}.tar.gz https://openresty.org/download/openresty-${VERSION}.tar.gz
|
||||
wget --no-check-certificate -O ${openrestyDir}/openresty-${VERSION}.tar.gz https://openresty.org/download/openresty-${VERSION}.tar.gz -T 3
|
||||
fi
|
||||
|
||||
DOWNLOAD_SIZE=`wc -c ${openrestyDir}/openresty-${VERSION}.tar.gz | awk '{print $1}'`
|
||||
if [ "$DOWNLOAD_SIZE" == "0" ];then
|
||||
echo 'download failed, download again'
|
||||
rm -rf ${openrestyDir}/openresty-${VERSION}.tar.gz
|
||||
fi
|
||||
|
||||
# Last Download Method
|
||||
if [ ! -f ${openrestyDir}/openresty-${VERSION}.tar.gz ];then
|
||||
wget --no-check-certificate -O ${openrestyDir}/openresty-${VERSION}.tar.gz https://dl.midoks.me/soft/openresty/openresty-${VERSION}.tar.gz -T 3
|
||||
fi
|
||||
|
||||
cd ${openrestyDir} && tar -zxvf openresty-${VERSION}.tar.gz
|
||||
|
||||
|
||||
@@ -72,7 +72,6 @@ if [ "${action}" == "install" ] && [ -d ${serverPath}/php/${type} ];then
|
||||
cd ${rootPath}/plugins/php/versions/common && bash gettext.sh install ${type}
|
||||
cd ${rootPath}/plugins/php/versions/common && bash redis.sh install ${type}
|
||||
cd ${rootPath}/plugins/php/versions/common && bash memcached.sh install ${type}
|
||||
cd ${rootPath}/plugins/php/versions/common && bash zlib.sh install ${type}
|
||||
|
||||
if [ "${type}" -gt "72" ];then
|
||||
cd ${rootPath}/plugins/php/versions/common && bash zip.sh install ${type}
|
||||
|
||||
@@ -10,7 +10,6 @@ sourcePath=${serverPath}/source
|
||||
sysName=`uname`
|
||||
install_tmp=${rootPath}/tmp/mw_install.pl
|
||||
|
||||
|
||||
function version_gt() { test "$(echo "$@" | tr " " "\n" | sort -V | head -n 1)" != "$1"; }
|
||||
function version_le() { test "$(echo "$@" | tr " " "\n" | sort -V | head -n 1)" == "$1"; }
|
||||
function version_lt() { test "$(echo "$@" | tr " " "\n" | sort -rV | head -n 1)" != "$1"; }
|
||||
@@ -29,6 +28,12 @@ cd ${rootPath}/plugins/php/lib && /bin/bash freetype_new.sh
|
||||
cd ${rootPath}/plugins/php/lib && /bin/bash zlib.sh
|
||||
cd ${rootPath}/plugins/php/lib && /bin/bash libzip.sh
|
||||
|
||||
# redat ge 8
|
||||
which yum
|
||||
if [ "$?" == "0" ];then
|
||||
cd ${rootPath}/plugins/php/lib && /bin/bash oniguruma.sh
|
||||
fi
|
||||
|
||||
if [ ! -d $sourcePath/php/php${PHP_VER} ];then
|
||||
|
||||
if [ ! -f $sourcePath/php/php-${version}.tar.xz ];then
|
||||
|
||||
@@ -28,6 +28,12 @@ mkdir -p $serverPath/php
|
||||
cd ${rootPath}/plugins/php/lib && /bin/bash freetype_new.sh
|
||||
cd ${rootPath}/plugins/php/lib && /bin/bash zlib.sh
|
||||
|
||||
# redat ge 8
|
||||
which yum
|
||||
if [ "$?" == "0" ];then
|
||||
cd ${rootPath}/plugins/php/lib && /bin/bash oniguruma.sh
|
||||
fi
|
||||
|
||||
if [ ! -d $sourcePath/php/php${PHP_VER} ];then
|
||||
|
||||
if [ ! -f $sourcePath/php/php-${version}.tar.xz ];then
|
||||
|
||||
@@ -28,6 +28,11 @@ mkdir -p $serverPath/php
|
||||
cd ${rootPath}/plugins/php/lib && /bin/bash freetype_new.sh
|
||||
cd ${rootPath}/plugins/php/lib && /bin/bash zlib.sh
|
||||
|
||||
# redat ge 8
|
||||
which yum
|
||||
if [ "$?" == "0" ];then
|
||||
cd ${rootPath}/plugins/php/lib && /bin/bash oniguruma.sh
|
||||
fi
|
||||
|
||||
if [ ! -d $sourcePath/php/php${PHP_VER} ];then
|
||||
|
||||
|
||||
@@ -28,6 +28,11 @@ mkdir -p $serverPath/php
|
||||
cd ${rootPath}/plugins/php/lib && /bin/bash freetype_new.sh
|
||||
cd ${rootPath}/plugins/php/lib && /bin/bash zlib.sh
|
||||
|
||||
# redat ge 8
|
||||
which yum
|
||||
if [ "$?" == "0" ];then
|
||||
cd ${rootPath}/plugins/php/lib && /bin/bash oniguruma.sh
|
||||
fi
|
||||
|
||||
if [ ! -d $sourcePath/php/php${PHP_VER} ];then
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
resetPluginWinHeight(500);
|
||||
$.getScript( "/plugins/file?name=phpmyadmin&f=js/phpmyadmin.js", function(){
|
||||
pluginService('phpmyadmin');
|
||||
});
|
||||
|
||||
@@ -47,7 +47,8 @@ Install_phpmyadmin()
|
||||
|
||||
mkdir -p ${serverPath}/phpmyadmin
|
||||
mkdir -p ${serverPath}/source/phpmyadmin
|
||||
|
||||
echo "${1}" > ${serverPath}/phpmyadmin/version.pl
|
||||
|
||||
VER=$1
|
||||
|
||||
FDIR=phpMyAdmin-${VER}-all-languages
|
||||
@@ -67,7 +68,7 @@ Install_phpmyadmin()
|
||||
cd $serverPath/phpmyadmin/ && mv $FDIR phpmyadmin
|
||||
|
||||
|
||||
echo "${1}" > ${serverPath}/phpmyadmin/version.pl
|
||||
|
||||
echo '安装完成' > $install_tmp
|
||||
|
||||
cd ${rootPath} && python3 ${rootPath}/plugins/phpmyadmin/index.py start
|
||||
|
||||
@@ -26,7 +26,6 @@ AutoRename no
|
||||
AnonymousCantUpload no
|
||||
MaxDiskUsage 99
|
||||
CustomerProof yes
|
||||
PassivePortRange 48000 50000
|
||||
PIDFile {$SERVER_PATH}/pureftp/etc/pure-ftpd.pid
|
||||
PureDB {$SERVER_PATH}/pureftp/etc/pureftpd.pdb
|
||||
|
||||
|
||||
@@ -9,6 +9,11 @@ serverPath=$(dirname "$rootPath")
|
||||
|
||||
install_tmp=${rootPath}/tmp/mw_install.pl
|
||||
|
||||
|
||||
if [ -f ${rootPath}/bin/activate ];then
|
||||
source ${rootPath}/bin/activate
|
||||
fi
|
||||
|
||||
sysName=`uname`
|
||||
echo "use system: ${sysName}"
|
||||
|
||||
|
||||
@@ -214,7 +214,8 @@ def initdStatus():
|
||||
if mw.isAppleSystem():
|
||||
return "Apple Computer does not support"
|
||||
|
||||
shell_cmd = 'systemctl status redis | grep loaded | grep "enabled;"'
|
||||
shell_cmd = 'systemctl status ' + \
|
||||
getPluginName() + ' | grep loaded | grep "enabled;"'
|
||||
data = mw.execShell(shell_cmd)
|
||||
if data[0] == '':
|
||||
return 'fail'
|
||||
@@ -225,7 +226,7 @@ def initdInstall():
|
||||
if mw.isAppleSystem():
|
||||
return "Apple Computer does not support"
|
||||
|
||||
mw.execShell('systemctl enable redis')
|
||||
mw.execShell('systemctl enable ' + getPluginName())
|
||||
return 'ok'
|
||||
|
||||
|
||||
@@ -233,7 +234,7 @@ def initdUinstall():
|
||||
if mw.isAppleSystem():
|
||||
return "Apple Computer does not support"
|
||||
|
||||
mw.execShell('systemctl disable redis')
|
||||
mw.execShell('systemctl disable ' + getPluginName())
|
||||
return 'ok'
|
||||
|
||||
|
||||
|
||||
@@ -1,14 +1,3 @@
|
||||
|
||||
function str2Obj(str){
|
||||
var data = {};
|
||||
kv = str.split('&');
|
||||
for(i in kv){
|
||||
v = kv[i].split('=');
|
||||
data[v[0]] = v[1];
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
function redisPost(method, version, args,callback){
|
||||
var loadT = layer.msg('正在获取...', { icon: 16, time: 0, shade: 0.3 });
|
||||
|
||||
@@ -18,7 +7,7 @@ function redisPost(method, version, args,callback){
|
||||
req_data['version'] = version;
|
||||
|
||||
if (typeof(args) == 'string'){
|
||||
req_data['args'] = JSON.stringify(str2Obj(args));
|
||||
req_data['args'] = JSON.stringify(toArrayObject(args));
|
||||
} else {
|
||||
req_data['args'] = JSON.stringify(args);
|
||||
}
|
||||
@@ -46,7 +35,7 @@ function redisPostCallbak(method, version, args,callback){
|
||||
args['version'] = version;
|
||||
|
||||
if (typeof(args) == 'string'){
|
||||
req_data['args'] = JSON.stringify(str2Obj(args));
|
||||
req_data['args'] = JSON.stringify(toArrayObject(args));
|
||||
} else {
|
||||
req_data['args'] = JSON.stringify(args);
|
||||
}
|
||||
|
||||
@@ -16,6 +16,10 @@ bash ${rootPath}/scripts/getos.sh
|
||||
OSNAME=`cat ${rootPath}/data/osname.pl`
|
||||
|
||||
|
||||
if [ -f ${rootPath}/bin/activate ];then
|
||||
source ${rootPath}/bin/activate
|
||||
fi
|
||||
|
||||
if id www &> /dev/null ;then
|
||||
echo "www uid is `id -u www`"
|
||||
echo "www shell is `grep "^www:" /etc/passwd |cut -d':' -f7 `"
|
||||
|
||||
@@ -0,0 +1,127 @@
|
||||
#
|
||||
# Discuz Sphinx Config File
|
||||
#
|
||||
|
||||
indexer
|
||||
{
|
||||
mem_limit = 32M
|
||||
write_buffer = 64M
|
||||
}
|
||||
|
||||
searchd
|
||||
{
|
||||
listen = 9312
|
||||
listen = 9306:mysql41
|
||||
log = {$SERVER_APP}/index/searchd.log
|
||||
query_log = {$SERVER_APP}/index/query.log
|
||||
read_timeout = 5
|
||||
max_children = 0
|
||||
pid_file = {$SERVER_APP}/index/searchd.pid
|
||||
seamless_rotate = 1
|
||||
preopen_indexes = 1
|
||||
unlink_old = 1
|
||||
#workers = threads # for RT to work
|
||||
binlog_path = {$SERVER_APP}/index/binlog
|
||||
}
|
||||
|
||||
|
||||
source pre_forum_thread
|
||||
{
|
||||
type = mysql
|
||||
sql_host = 127.0.0.1
|
||||
sql_user = bbs
|
||||
sql_pass = bbs
|
||||
sql_db = bbs
|
||||
sql_port = 3306
|
||||
sql_query_pre = SET NAMES UTF8
|
||||
sql_query_pre = SET SESSION query_cache_type=OFF
|
||||
sql_query_pre = REPLACE INTO bbs_common_sphinxcounter SELECT 1, MAX(tid) FROM bbs_forum_thread
|
||||
sql_query = SELECT t.tid as id,t.tid,t.subject,t.digest,t.displayorder,t.authorid,t.lastpost,t.special \
|
||||
FROM bbs_forum_thread AS t WHERE t.tid>=$start AND t.tid<=$end
|
||||
sql_query_range = SELECT (SELECT MIN(tid) FROM bbs_forum_thread),maxid FROM bbs_common_sphinxcounter WHERE indexid=1
|
||||
|
||||
sql_range_step = 5000
|
||||
sql_attr_uint = tid
|
||||
|
||||
sql_attr_uint = digest
|
||||
sql_attr_uint = displayorder
|
||||
sql_attr_uint = authorid
|
||||
sql_attr_uint = special
|
||||
sql_attr_timestamp =lastpost
|
||||
}
|
||||
|
||||
index pre_forum_thread
|
||||
{
|
||||
source = pre_forum_thread
|
||||
path = {$SERVER_APP}/index/db/pre_forum_thread/index
|
||||
|
||||
min_word_len = 2
|
||||
html_strip = 1
|
||||
ngram_len = 1
|
||||
ngram_chars = U+3000..U+2FA1F
|
||||
}
|
||||
|
||||
|
||||
# threads_minute
|
||||
source pre_forum_thread_minute : pre_forum_thread
|
||||
{
|
||||
sql_query_pre = SET NAMES UTF8
|
||||
sql_query_pre = SET SESSION query_cache_type=OFF
|
||||
sql_query_range = SELECT maxid-1,(SELECT MAX(tid) FROM bbs_forum_thread) FROM bbs_common_sphinxcounter WHERE indexid=1
|
||||
}
|
||||
|
||||
# threads_minute
|
||||
index pre_forum_thread_minute : pre_forum_thread
|
||||
{
|
||||
source = pre_forum_thread_minute
|
||||
path = {$SERVER_APP}/index/db/pre_forum_thread/pre_forum_thread_minute
|
||||
}
|
||||
|
||||
#posts
|
||||
source pre_forum_post : pre_forum_thread
|
||||
{
|
||||
type = mysql
|
||||
sql_query_pre =
|
||||
sql_query_pre = SET NAMES UTF8
|
||||
sql_query_pre = SET SESSION query_cache_type=OFF
|
||||
sql_query_pre = REPLACE INTO bbs_common_sphinxcounter SELECT 2, MAX(pid) FROM bbs_forum_post
|
||||
sql_query = SELECT p.pid AS id,p.tid,p.subject,p.message,t.digest,t.displayorder,t.authorid,t.lastpost,t.special \
|
||||
FROM bbs_forum_post AS p LEFT JOIN bbs_forum_thread AS t USING(tid) where p.pid >=$start and p.pid <=$end \
|
||||
AND p.first=1
|
||||
sql_query_range = SELECT (SELECT MIN(pid) FROM bbs_forum_post),maxid FROM bbs_common_sphinxcounter WHERE indexid=2
|
||||
sql_range_step = 5000
|
||||
sql_attr_uint = tid
|
||||
sql_attr_uint = digest
|
||||
sql_attr_uint= displayorder
|
||||
sql_attr_uint = authorid
|
||||
sql_attr_uint = special
|
||||
sql_attr_timestamp = lastpost
|
||||
}
|
||||
|
||||
#posts
|
||||
index pre_forum_post
|
||||
{
|
||||
source = pre_forum_post
|
||||
path = {$SERVER_APP}/index/db/pre_forum_thread/pre_forum_post
|
||||
|
||||
min_word_len = 2
|
||||
html_strip = 1
|
||||
ngram_len = 1
|
||||
ngram_chars = U+3000..U+2FA1F
|
||||
}
|
||||
|
||||
#pre_forum_post_minute
|
||||
source pre_forum_post_minute : pre_forum_post
|
||||
{
|
||||
sql_query_pre = SET NAMES UTF8
|
||||
sql_query_pre = SET SESSION query_cache_type=OFF
|
||||
sql_query_range = SELECT maxid-1,(SELECT MAX(pid) FROM bbs_forum_post) FROM bbs_common_sphinxcounter WHERE indexid=2
|
||||
}
|
||||
|
||||
#pre_forum_post_minute
|
||||
index pre_forum_post_minute : pre_forum_post
|
||||
{
|
||||
source = pre_forum_thread
|
||||
path = {$SERVER_APP}/index/db/pre_forum_thread/pre_forum_post_minute
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
.code span {display: block;margin-left: 15px;margin-bottom: 0;}
|
||||
</style>
|
||||
<script type="text/javascript">
|
||||
resetPluginWinWidth(800);
|
||||
resetPluginWinWidth(850);
|
||||
$.getScript( "/plugins/file?name=supervisor&f=js/supervisor.js", function(){
|
||||
pluginService('supervisor');
|
||||
});
|
||||
|
||||
@@ -220,7 +220,8 @@ def getSupList():
|
||||
infos = fr.readlines()
|
||||
for line in infos:
|
||||
if "command=" in line.strip():
|
||||
d["command"] = line.strip().split('=')[1]
|
||||
# d["command"] = line.strip().split('=')[1]
|
||||
d["command"] = "子配置查看"
|
||||
if "user=" in line.strip():
|
||||
d["user"] = line.strip().split('=')[1]
|
||||
if "priority=" in line.strip():
|
||||
@@ -329,6 +330,27 @@ def startJob():
|
||||
return mw.returnJson(True, action + '[' + name + ']成功!')
|
||||
|
||||
|
||||
def restartJob():
|
||||
args = getArgs()
|
||||
data = checkArgs(args, ['name', 'status'])
|
||||
if not data[0]:
|
||||
return data[1]
|
||||
|
||||
supCtl = 'supervisorctl -c ' + getServerDir() + "/supervisor.conf"
|
||||
|
||||
name = args['name']
|
||||
status = args['status']
|
||||
|
||||
cmd = supCtl + " stop " + name
|
||||
data = mw.execShell(cmd)
|
||||
cmd = supCtl + " start " + name
|
||||
data = mw.execShell(cmd)
|
||||
|
||||
if data[1] != '':
|
||||
return mw.returnJson(False, '[' + name + ']重启失败!')
|
||||
return mw.returnJson(True, '[' + name + ']重启成功!')
|
||||
|
||||
|
||||
def delJob():
|
||||
args = getArgs()
|
||||
data = checkArgs(args, ['name'])
|
||||
@@ -440,8 +462,9 @@ def configTpl():
|
||||
pathFile = os.listdir(path)
|
||||
tmp = []
|
||||
for one in pathFile:
|
||||
file = path + '/' + one
|
||||
tmp.append(file)
|
||||
if one.endswith(".ini"):
|
||||
file = path + '/' + one
|
||||
tmp.append(file)
|
||||
return mw.getJson(tmp)
|
||||
|
||||
|
||||
@@ -567,6 +590,8 @@ if __name__ == "__main__":
|
||||
print(addJob())
|
||||
elif func == 'start_job':
|
||||
print(startJob())
|
||||
elif func == 'restart_job':
|
||||
print(restartJob())
|
||||
elif func == 'del_job':
|
||||
print(delJob())
|
||||
elif func == 'update_job':
|
||||
|
||||
@@ -70,6 +70,7 @@ function supList(page, search){
|
||||
|
||||
list += '<td style="text-align:right">\
|
||||
<a href="javascript:;" class="btlink" onclick="startOrStop(\''+rdata.data[i]['program']+'\',\''+sup_status+'\')" title="启动|停止">'+sup_status_desc+'</a> | ' +
|
||||
'<a href="javascript:;" class="btlink" onclick="restartJob(\''+rdata.data[i]['program']+'\',\''+sup_status+'\')" title="重启">重启</a> | ' +
|
||||
'<a href="javascript:;" class="btlink" onclick="updateJob(\''+rdata.data[i]['program']+'\')">修改</a> | ' +
|
||||
'<a href="javascript:;" class="btlink" onclick="delJob(\''+rdata.data[i]['program']+'\')" title="删除">删除</a>' +
|
||||
'</td>';
|
||||
@@ -128,6 +129,16 @@ function startOrStop(name,status){
|
||||
});
|
||||
}
|
||||
|
||||
function restartJob(name,status){
|
||||
myPost('restart_job',{'name':name,'status':status}, function(data){
|
||||
var rdata = $.parseJSON(data.data);
|
||||
layer.msg(rdata.msg,{icon:rdata.status?1:2});
|
||||
setTimeout(function(){
|
||||
supList(1,10);
|
||||
},2000);
|
||||
});
|
||||
}
|
||||
|
||||
function updateJob(name){
|
||||
myPost('get_job_info',{'name':name},function(data){
|
||||
var rdata = $.parseJSON(data.data);
|
||||
|
||||
@@ -0,0 +1,162 @@
|
||||
# ---> Python
|
||||
# Byte-compiled / optimized / DLL files
|
||||
__pycache__/
|
||||
*.py[cod]
|
||||
*$py.class
|
||||
|
||||
# C extensions
|
||||
*.so
|
||||
|
||||
# Distribution / packaging
|
||||
.Python
|
||||
build/
|
||||
develop-eggs/
|
||||
dist/
|
||||
downloads/
|
||||
eggs/
|
||||
.eggs/
|
||||
lib/
|
||||
lib64/
|
||||
parts/
|
||||
sdist/
|
||||
var/
|
||||
wheels/
|
||||
share/python-wheels/
|
||||
*.egg-info/
|
||||
.installed.cfg
|
||||
*.egg
|
||||
MANIFEST
|
||||
|
||||
# PyInstaller
|
||||
# Usually these files are written by a python script from a template
|
||||
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
||||
*.manifest
|
||||
*.spec
|
||||
|
||||
# Installer logs
|
||||
pip-log.txt
|
||||
pip-delete-this-directory.txt
|
||||
|
||||
# Unit test / coverage reports
|
||||
htmlcov/
|
||||
.tox/
|
||||
.nox/
|
||||
.coverage
|
||||
.coverage.*
|
||||
.cache
|
||||
nosetests.xml
|
||||
coverage.xml
|
||||
*.cover
|
||||
*.py,cover
|
||||
.hypothesis/
|
||||
.pytest_cache/
|
||||
cover/
|
||||
|
||||
# Translations
|
||||
*.mo
|
||||
*.pot
|
||||
|
||||
# Django stuff:
|
||||
*.log
|
||||
local_settings.py
|
||||
db.sqlite3
|
||||
db.sqlite3-journal
|
||||
|
||||
# Flask stuff:
|
||||
instance/
|
||||
.webassets-cache
|
||||
|
||||
# Scrapy stuff:
|
||||
.scrapy
|
||||
|
||||
# Sphinx documentation
|
||||
docs/_build/
|
||||
|
||||
# PyBuilder
|
||||
.pybuilder/
|
||||
target/
|
||||
|
||||
# Jupyter Notebook
|
||||
.ipynb_checkpoints
|
||||
|
||||
# IPython
|
||||
profile_default/
|
||||
ipython_config.py
|
||||
|
||||
# pyenv
|
||||
# For a library or package, you might want to ignore these files since the code is
|
||||
# intended to run in multiple environments; otherwise, check them in:
|
||||
# .python-version
|
||||
|
||||
# pipenv
|
||||
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
||||
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
||||
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
||||
# install all needed dependencies.
|
||||
#Pipfile.lock
|
||||
|
||||
# poetry
|
||||
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
||||
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
||||
# commonly ignored for libraries.
|
||||
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
||||
#poetry.lock
|
||||
|
||||
# pdm
|
||||
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
||||
#pdm.lock
|
||||
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
|
||||
# in version control.
|
||||
# https://pdm.fming.dev/#use-with-ide
|
||||
.pdm.toml
|
||||
|
||||
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
||||
__pypackages__/
|
||||
|
||||
# Celery stuff
|
||||
celerybeat-schedule
|
||||
celerybeat.pid
|
||||
|
||||
# SageMath parsed files
|
||||
*.sage.py
|
||||
|
||||
# Environments
|
||||
.env
|
||||
.venv
|
||||
env/
|
||||
venv/
|
||||
ENV/
|
||||
env.bak/
|
||||
venv.bak/
|
||||
|
||||
# Spyder project settings
|
||||
.spyderproject
|
||||
.spyproject
|
||||
|
||||
# Rope project settings
|
||||
.ropeproject
|
||||
|
||||
# mkdocs documentation
|
||||
/site
|
||||
|
||||
# mypy
|
||||
.mypy_cache/
|
||||
.dmypy.json
|
||||
dmypy.json
|
||||
|
||||
# Pyre type checker
|
||||
.pyre/
|
||||
|
||||
# pytype static type analyzer
|
||||
.pytype/
|
||||
|
||||
# Cython debug symbols
|
||||
cython_debug/
|
||||
|
||||
# PyCharm
|
||||
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
||||
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
||||
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
||||
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
||||
#.idea/
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
Executable
+958
@@ -0,0 +1,958 @@
|
||||
{
|
||||
"open": false,
|
||||
"service": {
|
||||
"open": true,
|
||||
"name": "服务加固",
|
||||
"ps": "保护系统服务,开启后将无法添加和删除服务,部分软件无法安装!",
|
||||
"paths": [
|
||||
{
|
||||
"path": "/etc/rc.d",
|
||||
"chattr": "i",
|
||||
"s_mode": 509,
|
||||
"d_mode": 509
|
||||
},
|
||||
{
|
||||
"path": "/etc/rc.d/init.d",
|
||||
"chattr": "i",
|
||||
"s_mode": 493,
|
||||
"d_mode": 493
|
||||
},
|
||||
{
|
||||
"path": "/etc/rc.d/rc0.d",
|
||||
"chattr": "i",
|
||||
"s_mode": 493,
|
||||
"d_mode": 493
|
||||
},
|
||||
{
|
||||
"path": "/etc/rc.d/rc1.d",
|
||||
"chattr": "i",
|
||||
"s_mode": 493,
|
||||
"d_mode": 493
|
||||
},
|
||||
{
|
||||
"path": "/etc/rc.d/rc2.d",
|
||||
"chattr": "i",
|
||||
"s_mode": 493,
|
||||
"d_mode": 493
|
||||
},
|
||||
{
|
||||
"path": "/etc/rc.d/rc3.d",
|
||||
"chattr": "i",
|
||||
"s_mode": 493,
|
||||
"d_mode": 493
|
||||
},
|
||||
{
|
||||
"path": "/etc/rc.d/rc4.d",
|
||||
"chattr": "i",
|
||||
"s_mode": 493,
|
||||
"d_mode": 493
|
||||
},
|
||||
{
|
||||
"path": "/etc/rc.d/rc5.d",
|
||||
"chattr": "i",
|
||||
"s_mode": 493,
|
||||
"d_mode": 493
|
||||
},
|
||||
{
|
||||
"path": "/etc/rc.d/rc6.d",
|
||||
"chattr": "i",
|
||||
"s_mode": 493,
|
||||
"d_mode": 493
|
||||
},
|
||||
{
|
||||
"path": "/etc/rc.d/rc.local",
|
||||
"chattr": "i",
|
||||
"s_mode": 493,
|
||||
"d_mode": 493
|
||||
},
|
||||
{
|
||||
"path": "/etc/init.d",
|
||||
"chattr": "i",
|
||||
"s_mode": 493,
|
||||
"d_mode": 493
|
||||
},
|
||||
{
|
||||
"path": "/etc/rc0.d",
|
||||
"chattr": "i",
|
||||
"s_mode": 493,
|
||||
"d_mode": 493
|
||||
},
|
||||
{
|
||||
"path": "/etc/rc1.d",
|
||||
"chattr": "i",
|
||||
"s_mode": 493,
|
||||
"d_mode": 493
|
||||
},
|
||||
{
|
||||
"path": "/etc/rc2.d",
|
||||
"chattr": "i",
|
||||
"s_mode": 493,
|
||||
"d_mode": 493
|
||||
},
|
||||
{
|
||||
"path": "/etc/rc3.d",
|
||||
"chattr": "i",
|
||||
"s_mode": 493,
|
||||
"d_mode": 493
|
||||
},
|
||||
{
|
||||
"path": "/etc/rc4.d",
|
||||
"chattr": "i",
|
||||
"s_mode": 493,
|
||||
"d_mode": 493
|
||||
},
|
||||
{
|
||||
"path": "/etc/rc5.d",
|
||||
"chattr": "i",
|
||||
"s_mode": 493,
|
||||
"d_mode": 493
|
||||
},
|
||||
{
|
||||
"path": "/etc/rc6.d",
|
||||
"chattr": "i",
|
||||
"s_mode": 493,
|
||||
"d_mode": 493
|
||||
},
|
||||
{
|
||||
"path": "/etc/rcS.d",
|
||||
"chattr": "i",
|
||||
"s_mode": 493,
|
||||
"d_mode": 493
|
||||
},
|
||||
{
|
||||
"path": "/etc/systemd",
|
||||
"chattr": "i",
|
||||
"s_mode": 493,
|
||||
"d_mode": 493
|
||||
},
|
||||
{
|
||||
"path": "/lib/systemd",
|
||||
"chattr": "i",
|
||||
"s_mode": 493,
|
||||
"d_mode": 493
|
||||
}
|
||||
]
|
||||
},
|
||||
"home": {
|
||||
"open": true,
|
||||
"name": "环境变量加固",
|
||||
"ps": "保护用户环境变量不被修改,开启后无法自定义用户环境变量!",
|
||||
"paths": [
|
||||
{
|
||||
"path": "/root/.bash_history",
|
||||
"chattr": "a",
|
||||
"s_mode": 420,
|
||||
"d_mode": 420
|
||||
},
|
||||
{
|
||||
"path": "/root/.bashrc",
|
||||
"chattr": "i",
|
||||
"s_mode": 420,
|
||||
"d_mode": 420
|
||||
},
|
||||
{
|
||||
"path": "/root/.bash_logout",
|
||||
"chattr": "i",
|
||||
"s_mode": 420,
|
||||
"d_mode": 420
|
||||
},
|
||||
{
|
||||
"path": "/root/.bash_profile",
|
||||
"chattr": "i",
|
||||
"s_mode": 420,
|
||||
"d_mode": 420
|
||||
},
|
||||
{
|
||||
"path": "/root/.profile",
|
||||
"chattr": "i",
|
||||
"s_mode": 420,
|
||||
"d_mode": 420
|
||||
},
|
||||
{
|
||||
"path": "/etc/profile",
|
||||
"chattr": "i",
|
||||
"s_mode": 420,
|
||||
"d_mode": 420
|
||||
},
|
||||
{
|
||||
"path": "/etc/bash.bashrc",
|
||||
"chattr": "i",
|
||||
"s_mode": 420,
|
||||
"d_mode": 420
|
||||
},
|
||||
{
|
||||
"path": "/etc/sysctl.conf",
|
||||
"chattr": "i",
|
||||
"s_mode": 420,
|
||||
"d_mode": 420
|
||||
},
|
||||
{
|
||||
"path": "/etc/sysctl.d",
|
||||
"chattr": "i",
|
||||
"s_mode": 420,
|
||||
"d_mode": 420
|
||||
}
|
||||
]
|
||||
},
|
||||
"user": {
|
||||
"open": true,
|
||||
"name": "用户加固",
|
||||
"ps": "保护用户,开启后将无法添加删除用户和修改用户密码!",
|
||||
"paths": [
|
||||
{
|
||||
"path": "/etc/passwd",
|
||||
"chattr": "i",
|
||||
"s_mode": 420,
|
||||
"d_mode": 420
|
||||
},
|
||||
{
|
||||
"path": "/etc/group",
|
||||
"chattr": "i",
|
||||
"s_mode": 420,
|
||||
"d_mode": 420
|
||||
},
|
||||
{
|
||||
"path": "/usr/sbin/groupadd",
|
||||
"chattr": "i",
|
||||
"s_mode": 488,
|
||||
"d_mode": 420
|
||||
},
|
||||
{
|
||||
"path": "/usr/sbin/useradd",
|
||||
"chattr": "i",
|
||||
"s_mode": 488,
|
||||
"d_mode": 420
|
||||
},
|
||||
{
|
||||
"path": "/usr/bin/passwd",
|
||||
"chattr": "i",
|
||||
"s_mode": 509,
|
||||
"d_mode": 420
|
||||
}
|
||||
]
|
||||
},
|
||||
"bin": {
|
||||
"open": true,
|
||||
"name": "关键目录加固",
|
||||
"ps": "保护系统关键文件不被修改替换!",
|
||||
"paths": [
|
||||
{
|
||||
"path": "/usr/bin",
|
||||
"chattr": "i",
|
||||
"s_mode": 365,
|
||||
"d_mode": 365
|
||||
},
|
||||
{
|
||||
"path": "/usr/sbin",
|
||||
"chattr": "i",
|
||||
"s_mode": 365,
|
||||
"d_mode": 365
|
||||
},
|
||||
{
|
||||
"path": "/etc/bashrc",
|
||||
"chattr": "i",
|
||||
"s_mode": 420,
|
||||
"d_mode": 420
|
||||
},
|
||||
{
|
||||
"path": "/usr/local/bin",
|
||||
"chattr": "i",
|
||||
"s_mode": 365,
|
||||
"d_mode": 365
|
||||
},
|
||||
{
|
||||
"path": "/usr/local/sbin",
|
||||
"chattr": "i",
|
||||
"s_mode": 365,
|
||||
"d_mode": 365
|
||||
},
|
||||
{
|
||||
"path": "/sbin",
|
||||
"chattr": "i",
|
||||
"s_mode": 365,
|
||||
"d_mode": 365
|
||||
},
|
||||
{
|
||||
"path": "/bin",
|
||||
"chattr": "i",
|
||||
"s_mode": 365,
|
||||
"d_mode": 365
|
||||
}
|
||||
]
|
||||
},
|
||||
"cron": {
|
||||
"open": true,
|
||||
"name": "计划任务加固",
|
||||
"ps": "保护计划任务不被篡改,开启后无法添加删除计划任务!",
|
||||
"paths": [
|
||||
{
|
||||
"path": "/usr/bin/crontab",
|
||||
"chattr": "i",
|
||||
"s_mode": 509,
|
||||
"d_mode": 420
|
||||
},
|
||||
{
|
||||
"path": "/etc/crontab",
|
||||
"chattr": "i",
|
||||
"s_mode": 420,
|
||||
"d_mode": 420
|
||||
},
|
||||
{
|
||||
"path": "/etc/cron.d",
|
||||
"chattr": "i",
|
||||
"s_mode": 509,
|
||||
"d_mode": 509
|
||||
},
|
||||
{
|
||||
"path": "/etc/cron.daily",
|
||||
"chattr": "i",
|
||||
"s_mode": 509,
|
||||
"d_mode": 420
|
||||
},
|
||||
{
|
||||
"path": "/etc/cron.hourly",
|
||||
"chattr": "i",
|
||||
"s_mode": 509,
|
||||
"d_mode": 420
|
||||
},
|
||||
{
|
||||
"path": "/etc/cron.monthly",
|
||||
"chattr": "i",
|
||||
"s_mode": 509,
|
||||
"d_mode": 420
|
||||
},
|
||||
{
|
||||
"path": "/etc/cron.weekly",
|
||||
"chattr": "i",
|
||||
"s_mode": 509,
|
||||
"d_mode": 420
|
||||
},
|
||||
{
|
||||
"path": "/etc/anacrontab",
|
||||
"chattr": "i",
|
||||
"s_mode": 384,
|
||||
"d_mode": 384
|
||||
},
|
||||
{
|
||||
"path": "/var/spool/cron",
|
||||
"chattr": "i",
|
||||
"s_mode": 448,
|
||||
"d_mode": 448
|
||||
},
|
||||
{
|
||||
"path": "/var/spool/cron/root",
|
||||
"chattr": "i",
|
||||
"s_mode": 384,
|
||||
"d_mode": 384
|
||||
},
|
||||
{
|
||||
"path": "/var/spool/anacron",
|
||||
"chattr": "i",
|
||||
"s_mode": 509,
|
||||
"d_mode": 509
|
||||
}
|
||||
]
|
||||
},
|
||||
"ssh": {
|
||||
"open": true,
|
||||
"name": "SSH服务加固",
|
||||
"ps": "保护SSH不被暴力破解,记录用户登录日志",
|
||||
"cycle": 120,
|
||||
"limit": 3600,
|
||||
"limit_count": 3
|
||||
},
|
||||
"process": {
|
||||
"open": true,
|
||||
"name": "异常进程监控",
|
||||
"ps": "监控服务器进程列表,发现异常的进程后立即结束",
|
||||
"process_white": [
|
||||
"pip",
|
||||
"pip3",
|
||||
"yum",
|
||||
"apt-get",
|
||||
"apt",
|
||||
"redis-cli",
|
||||
"memcached",
|
||||
"sshd",
|
||||
"vm",
|
||||
"vim",
|
||||
"htop",
|
||||
"top",
|
||||
"sh",
|
||||
"bash",
|
||||
"zip",
|
||||
"gzip",
|
||||
"rsync",
|
||||
"tar",
|
||||
"unzip",
|
||||
"rar",
|
||||
"unrar",
|
||||
"php",
|
||||
"composer",
|
||||
"pkill",
|
||||
"mongo",
|
||||
"mongod",
|
||||
"php-fpm",
|
||||
"php-fpm5.6",
|
||||
"php-fpm7.0",
|
||||
"php-fpm7.1",
|
||||
"php-fpm7.2",
|
||||
"php-fpm7.3",
|
||||
"php-fpm7.4",
|
||||
"php-fpm8.1",
|
||||
"php-fpm8.2",
|
||||
"nginx",
|
||||
"httpd",
|
||||
"lsof",
|
||||
"ps",
|
||||
"vi",
|
||||
"vim",
|
||||
"redis-server",
|
||||
"mysqld",
|
||||
"mysqld_safe",
|
||||
"mysql",
|
||||
"pure-ftpd",
|
||||
"sparse_dd",
|
||||
"stunnel",
|
||||
"squeezed",
|
||||
"vncterm",
|
||||
"awk",
|
||||
"ruby",
|
||||
"postgres",
|
||||
"mpathalert",
|
||||
"vncterm",
|
||||
"multipathd",
|
||||
"fe",
|
||||
"elasticsyslog",
|
||||
"syslogd",
|
||||
"v6d",
|
||||
"xapi",
|
||||
"screen",
|
||||
"runsvdir",
|
||||
"svlogd",
|
||||
"java",
|
||||
"udevd",
|
||||
"ntpd",
|
||||
"irqbalance",
|
||||
"qmgr",
|
||||
"wpa_supplicant",
|
||||
"mysqld_safe",
|
||||
"sftp-server",
|
||||
"lvmetad",
|
||||
"gitlab-web",
|
||||
"pure-ftpd",
|
||||
"auditd",
|
||||
"master",
|
||||
"dbus-daemon",
|
||||
"tapdisk",
|
||||
"init",
|
||||
"ksoftirqd",
|
||||
"kworker",
|
||||
"kmpathd",
|
||||
"kmpath_handlerd",
|
||||
"python",
|
||||
"kdmflush",
|
||||
"bioset",
|
||||
"crond",
|
||||
"kthreadd",
|
||||
"migration",
|
||||
"rcu_sched",
|
||||
"kjournald",
|
||||
"gcc",
|
||||
"gcc++",
|
||||
"nginx",
|
||||
"mysqld",
|
||||
"php-cgi",
|
||||
"login",
|
||||
"firewalld",
|
||||
"iptables",
|
||||
"systemd",
|
||||
"network",
|
||||
"dhclient",
|
||||
"systemd-journald",
|
||||
"chrony",
|
||||
"chronyd",
|
||||
"chronyc",
|
||||
"NetworkManager",
|
||||
"systemd-logind",
|
||||
"systemd-udevd",
|
||||
"polkitd",
|
||||
"tuned",
|
||||
"rsyslogd",
|
||||
"AliYunDunUpdate",
|
||||
"AliYunDun",
|
||||
"du",
|
||||
"sendmail",
|
||||
"gunicorn",
|
||||
"python2",
|
||||
"python3",
|
||||
"python34",
|
||||
"python2.6",
|
||||
"runsv",
|
||||
"dd",
|
||||
"mkfs",
|
||||
"fdisk",
|
||||
"systemd-resolve",
|
||||
"rpm",
|
||||
"cc1",
|
||||
"cc1plus",
|
||||
"as",
|
||||
"acme.sh",
|
||||
"cc",
|
||||
"du",
|
||||
"grep",
|
||||
"awk",
|
||||
"sed",
|
||||
"cut",
|
||||
"free",
|
||||
"df",
|
||||
"firewall-cmd",
|
||||
"ufw",
|
||||
"echo",
|
||||
"ls",
|
||||
"cp",
|
||||
"mv",
|
||||
"rm",
|
||||
"diff",
|
||||
"ln",
|
||||
"cat",
|
||||
"more",
|
||||
"wtmp",
|
||||
"date",
|
||||
"e2fsck",
|
||||
"gunzip",
|
||||
"ifconfig",
|
||||
"ip",
|
||||
"route",
|
||||
"ping",
|
||||
"scp",
|
||||
"telnet",
|
||||
"cd",
|
||||
"comm",
|
||||
"touch",
|
||||
"man",
|
||||
"w",
|
||||
"who",
|
||||
"last",
|
||||
"clock",
|
||||
"uname",
|
||||
"su",
|
||||
"uptime",
|
||||
"vmstat",
|
||||
"mount",
|
||||
"umount",
|
||||
"mkdir",
|
||||
"mkswap",
|
||||
"swapon",
|
||||
"e2fsck",
|
||||
"tune2fs",
|
||||
"groupadd",
|
||||
"useradd",
|
||||
"passwd",
|
||||
"userdel",
|
||||
"chown",
|
||||
"chmod",
|
||||
"chgrp",
|
||||
"id",
|
||||
"mail",
|
||||
"gzip",
|
||||
"bzip2",
|
||||
"bunzip2",
|
||||
"networking",
|
||||
"ssh",
|
||||
"find",
|
||||
"locate",
|
||||
"slocate",
|
||||
"dir",
|
||||
"vdir",
|
||||
"pwd",
|
||||
"rename",
|
||||
"rmdir",
|
||||
"updatedb",
|
||||
"whereis",
|
||||
"which",
|
||||
"compress",
|
||||
"ar",
|
||||
"arj",
|
||||
"gzexe",
|
||||
"bzip2",
|
||||
"cksum",
|
||||
"cmp",
|
||||
"col",
|
||||
"colrm",
|
||||
"csplit",
|
||||
"diff3",
|
||||
"emacs",
|
||||
"join",
|
||||
"head",
|
||||
"sort",
|
||||
"wc",
|
||||
"uniq",
|
||||
"tail",
|
||||
"sum",
|
||||
"ulimit",
|
||||
"pkill",
|
||||
"kill",
|
||||
"killall",
|
||||
"pidof",
|
||||
"pstree",
|
||||
"watch",
|
||||
"pgrep",
|
||||
"dumpe2fs",
|
||||
"mke2fs",
|
||||
"sync",
|
||||
"lsyncd",
|
||||
"tune2fs",
|
||||
"basename",
|
||||
"file",
|
||||
"locate/slocate",
|
||||
"ls/dir/vdir",
|
||||
"bzcat",
|
||||
"bzip2recover",
|
||||
"bzless/bzmore",
|
||||
"cpio",
|
||||
"dump",
|
||||
"lha",
|
||||
"resotre",
|
||||
"unarj",
|
||||
"uncompress",
|
||||
"zcat",
|
||||
"zforce",
|
||||
"zipinfo",
|
||||
"znew",
|
||||
"diffstat",
|
||||
"ed",
|
||||
"ex",
|
||||
"expand",
|
||||
"fmt",
|
||||
"fold",
|
||||
"grep/egrep/fgrep",
|
||||
"ispell",
|
||||
"jed",
|
||||
"joe",
|
||||
"less",
|
||||
"look",
|
||||
"od",
|
||||
"paste",
|
||||
"pico",
|
||||
"spell",
|
||||
"split",
|
||||
"tac",
|
||||
"tee",
|
||||
"tr",
|
||||
"unexpand",
|
||||
"alias",
|
||||
"bg",
|
||||
"bind",
|
||||
"declare",
|
||||
"dirs",
|
||||
"enable",
|
||||
"eval",
|
||||
"exec",
|
||||
"exit",
|
||||
"export",
|
||||
"fc",
|
||||
"fg",
|
||||
"hash",
|
||||
"history",
|
||||
"jobs",
|
||||
"logout",
|
||||
"popd",
|
||||
"pushd",
|
||||
"set",
|
||||
"shopt",
|
||||
"umask",
|
||||
"unalias",
|
||||
"unset",
|
||||
"accept",
|
||||
"cancel",
|
||||
"disable",
|
||||
"lp",
|
||||
"lpadmin",
|
||||
"lpc",
|
||||
"lpq",
|
||||
"lpr",
|
||||
"lprm",
|
||||
"lpstat",
|
||||
"pr",
|
||||
"reject",
|
||||
"bc",
|
||||
"cal",
|
||||
"clear",
|
||||
"consoletype",
|
||||
"ctrlaltdel",
|
||||
"dircolors",
|
||||
"eject",
|
||||
"halt",
|
||||
"hostid",
|
||||
"hwclock",
|
||||
"info",
|
||||
"md5sum",
|
||||
"letsencrypt",
|
||||
"mandb",
|
||||
"mesg",
|
||||
"mtools",
|
||||
"mtoolstest",
|
||||
"poweroff",
|
||||
"reboot",
|
||||
"shutdown",
|
||||
"sleep",
|
||||
"stat",
|
||||
"talk",
|
||||
"wall",
|
||||
"whatis",
|
||||
"whoami",
|
||||
"write",
|
||||
"cmsgoagent.linu",
|
||||
"yes",
|
||||
"chfn",
|
||||
"chsh",
|
||||
"finger",
|
||||
"gpasswd",
|
||||
"groupdel",
|
||||
"groupmod",
|
||||
"groups",
|
||||
"grpck",
|
||||
"grpconv",
|
||||
"grpunconv",
|
||||
"logname",
|
||||
"pwck",
|
||||
"pwconv",
|
||||
"dd",
|
||||
"mariadbd",
|
||||
"pwunconv",
|
||||
"usermod",
|
||||
"users",
|
||||
"nice",
|
||||
"nohup",
|
||||
"renice",
|
||||
"badblocks",
|
||||
"blockdev",
|
||||
"chattr",
|
||||
"convertquota",
|
||||
"e2image",
|
||||
"e2label",
|
||||
"edquota",
|
||||
"fail2ban-server",
|
||||
"findfs",
|
||||
"fsck",
|
||||
"grub",
|
||||
"hdparm",
|
||||
"lilo",
|
||||
"lsattr",
|
||||
"mkbootdisk",
|
||||
"mkinitrd",
|
||||
"mkisofs",
|
||||
"mknod",
|
||||
"mktemp",
|
||||
"parted",
|
||||
"quota",
|
||||
"quotacheck",
|
||||
"xargs",
|
||||
"bcm-agent",
|
||||
"bcm-si",
|
||||
"quotaoff",
|
||||
"quotaon",
|
||||
"quotastat",
|
||||
"repquota",
|
||||
"swapoff",
|
||||
"depmod",
|
||||
"dmesg",
|
||||
"insmod",
|
||||
"iostat",
|
||||
"ipcs",
|
||||
"kernelversion",
|
||||
"lsmod",
|
||||
"modinfo",
|
||||
"modprobe",
|
||||
"mpstat",
|
||||
"rmmod",
|
||||
"sar",
|
||||
"slabtop",
|
||||
"sysctl",
|
||||
"tload",
|
||||
"startx",
|
||||
"xauth",
|
||||
"xhost",
|
||||
"xinit",
|
||||
"xlsatoms",
|
||||
"xlsclients",
|
||||
"xlsfonts",
|
||||
"xset",
|
||||
"chroot",
|
||||
"nmap",
|
||||
"ntfs-3g",
|
||||
"sftp",
|
||||
"slogin",
|
||||
"sudo",
|
||||
"awk/gawk",
|
||||
"expr",
|
||||
"gdb",
|
||||
"ldd",
|
||||
"make",
|
||||
"nm",
|
||||
"perl",
|
||||
"test",
|
||||
"arch",
|
||||
"at",
|
||||
"atq",
|
||||
"atrm",
|
||||
"batch",
|
||||
"chkconfig",
|
||||
"crontab",
|
||||
"lastb",
|
||||
"logrotate",
|
||||
"logsave",
|
||||
"logwatch",
|
||||
"lsusb",
|
||||
"patch",
|
||||
"runlevel",
|
||||
"service",
|
||||
"telinit",
|
||||
"dnsdomainname",
|
||||
"domainname",
|
||||
"hostname",
|
||||
"ifcfg",
|
||||
"ifdown",
|
||||
"ifup",
|
||||
"stmpd",
|
||||
"nisdomainname",
|
||||
"ypdomainname",
|
||||
"arp",
|
||||
"arping",
|
||||
"arpwatch",
|
||||
"dig",
|
||||
"elinks",
|
||||
"elm",
|
||||
"ftp",
|
||||
"host",
|
||||
"ipcalc",
|
||||
"lynx",
|
||||
"ncftp",
|
||||
"netstat",
|
||||
"nslookup",
|
||||
"pine",
|
||||
"dhclient-script",
|
||||
"rsh",
|
||||
"tftp",
|
||||
"tracepath",
|
||||
"traceroute",
|
||||
"wget",
|
||||
"arptables",
|
||||
"iptables-save",
|
||||
"iptables-restore",
|
||||
"tcpdump",
|
||||
"ab",
|
||||
"apachectl",
|
||||
"exportfs",
|
||||
"htdigest",
|
||||
"htpasswd",
|
||||
"mailq",
|
||||
"mysqladmin",
|
||||
"msqldump",
|
||||
"mysqlimport",
|
||||
"mysqlshow",
|
||||
"nfsstat",
|
||||
"showmount",
|
||||
"smbclient",
|
||||
"smbmount",
|
||||
"smbpasswd",
|
||||
"squid",
|
||||
"pickup",
|
||||
"local",
|
||||
"localedef",
|
||||
"bounce",
|
||||
"smtp",
|
||||
"smtpd",
|
||||
"trivial-rewrite",
|
||||
"xe-daemon",
|
||||
"cleanup",
|
||||
"nm-dispatcher",
|
||||
"lsinitrd",
|
||||
"barad_agent",
|
||||
"stop.sh",
|
||||
"YDService",
|
||||
"agetty",
|
||||
"systemctl",
|
||||
"AliSecureCheckA",
|
||||
"containerd",
|
||||
"containerd-shim",
|
||||
"certbot-auto",
|
||||
"oneav",
|
||||
"oneavd",
|
||||
"oneav_service_m",
|
||||
"s3fs",
|
||||
"bosfs",
|
||||
"cosfs",
|
||||
"flock",
|
||||
"raidcheck",
|
||||
"run-parts",
|
||||
"man-db.cron",
|
||||
"YDLive",
|
||||
"sgagent"
|
||||
],
|
||||
"process_white_rule": [
|
||||
"vif",
|
||||
"node",
|
||||
"pm2",
|
||||
"npm",
|
||||
"yarn",
|
||||
"qemu",
|
||||
"scsi_eh",
|
||||
"xcp",
|
||||
"xen",
|
||||
"docker",
|
||||
"yunsuo",
|
||||
"scsi",
|
||||
"jbd2",
|
||||
"ext4",
|
||||
"xfs",
|
||||
"aliyun",
|
||||
"kswapd",
|
||||
"PM2",
|
||||
"yunsuo",
|
||||
"mkfs",
|
||||
"Ali",
|
||||
"watchdog",
|
||||
"kworker",
|
||||
"ksoftirqd",
|
||||
"migration",
|
||||
"mysql",
|
||||
"/www/server/",
|
||||
"cmsgoagent",
|
||||
"python",
|
||||
"python3",
|
||||
"ifdown",
|
||||
"node"
|
||||
],
|
||||
"process_exclude": [
|
||||
"php-fpm",
|
||||
"mysqld",
|
||||
"mongod",
|
||||
"dockerd",
|
||||
"docker-containerd",
|
||||
"memcached",
|
||||
"jsvc",
|
||||
"jsvc.exec",
|
||||
"nginx",
|
||||
"node",
|
||||
"pm2",
|
||||
"npm",
|
||||
"yarn",
|
||||
"httpd",
|
||||
"gunicorn",
|
||||
"configure",
|
||||
"make",
|
||||
"curl",
|
||||
"wget",
|
||||
"anacron",
|
||||
"mysqldump",
|
||||
"node",
|
||||
"php",
|
||||
"mysql",
|
||||
"netstat",
|
||||
"redis",
|
||||
"postfix"
|
||||
]
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 812 B |
Executable
+24
@@ -0,0 +1,24 @@
|
||||
<div class="bt-form">
|
||||
<div class="bt-w-main">
|
||||
<div class="bt-w-menu">
|
||||
<p class="bgw" onclick="pluginService('system_safe');">服务</p>
|
||||
<p onclick="pluginInitD('system_safe');">自启动</p>
|
||||
<p onclick="ssConfigList();">防护配置</p>
|
||||
<p onclick="ssLockAddress();">封锁IP</p>
|
||||
<p onclick="ssLogAudit();">日志审计</p>
|
||||
<p onclick="ssOpLog();">操作日志</p>
|
||||
</div>
|
||||
<div class="bt-w-con pd15">
|
||||
<div class="soft-man-con"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript" src="/plugins/file?name=system_safe&f=js/app.js"></script>
|
||||
<script type="text/javascript">
|
||||
resetPluginWinWidth(800);
|
||||
resetPluginWinHeight(500);
|
||||
$.getScript("/plugins/file?name=system_safe&f=js/app.js", function(){
|
||||
pluginService('system_safe');
|
||||
});
|
||||
</script>
|
||||
Executable
+20
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"sort": 1,
|
||||
"ps": "提供灵活的系统加固功能,防止系统被植入木马,支持服务器日志审计功能",
|
||||
"name": "system_safe",
|
||||
"title": "系统加固",
|
||||
"shell": "install.sh",
|
||||
"versions":["1.0"],
|
||||
"updates":["1.0"],
|
||||
"tip": "soft",
|
||||
"icon":"ico.png",
|
||||
"checks": "server/system_safe",
|
||||
"path": "server/system_safe",
|
||||
"display": 1,
|
||||
"author": "midoks",
|
||||
"date": "2022-01-12",
|
||||
"home": "",
|
||||
"type": 0,
|
||||
"pid": "4"
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
[Unit]
|
||||
Description=system_safe server daemon
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=forking
|
||||
ExecStart={$SERVER_PATH}/init.d/system_safe start
|
||||
ExecStop={$SERVER_PATH}/init.d/system_safe stop
|
||||
ExecReload={$SERVER_PATH}/init.d/system_safe reload
|
||||
ExecRestart={$SERVER_PATH}/init.d/system_safe restart
|
||||
KillMode=process
|
||||
Restart=on-failure
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
@@ -0,0 +1,94 @@
|
||||
#!/bin/bash
|
||||
# chkconfig: 2345 55 25
|
||||
# description:system_safe
|
||||
|
||||
### BEGIN INIT INFO
|
||||
# Provides: system_safe
|
||||
# Required-Start: $all
|
||||
# Required-Stop: $all
|
||||
# Default-Start: 2 3 4 5
|
||||
# Default-Stop: 0 1 6
|
||||
# Short-Description: starts system_safe
|
||||
# Description: starts the system_safe
|
||||
### END INIT INFO
|
||||
|
||||
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
|
||||
mw_path={$SERVER_PATH}
|
||||
rootPath=$(dirname "$mw_path")
|
||||
PATH=$PATH:$mw_path/bin
|
||||
|
||||
if [ -f $rootPath/mdserver-web/bin/activate ];then
|
||||
source $rootPath/mdserver-web/bin/activate
|
||||
fi
|
||||
|
||||
sys_start()
|
||||
{
|
||||
isStart=$(ps aux |grep -E "(system_safe)"|grep -v grep|grep -v '/bin/bash'|grep -v 'system_safe/system_safe.py start' | grep -v 'system_safe/system_safe.py reload' | grep -v 'system_safe/system_safe.py restart' | grep -v systemctl | grep -v '/bin/sh' | awk '{print $2}'|xargs)
|
||||
if [ "$isStart" == '' ];then
|
||||
echo -e "Starting system_safe service... \c"
|
||||
cd $rootPath/mdserver-web
|
||||
nohup python3 plugins/system_safe/system_safe.py bg_start &> $mw_path/service.log &
|
||||
sleep 0.5
|
||||
isStart=$(ps aux |grep -E "(system_safe)"|grep -v grep|awk '{print $2}'|xargs)
|
||||
if [ "$isStart" == '' ];then
|
||||
echo -e "\033[31mfailed\033[0m"
|
||||
echo '------------------------------------------------------'
|
||||
cat $mw_path/service.log
|
||||
echo '------------------------------------------------------'
|
||||
echo -e "\033[31mError: system_safe service startup failed.\033[0m"
|
||||
return;
|
||||
fi
|
||||
echo -e "\033[32mdone\033[0m"
|
||||
else
|
||||
echo "Starting system_safe service (pid $isStart) already running"
|
||||
fi
|
||||
}
|
||||
|
||||
sys_stop()
|
||||
{
|
||||
echo -e "Stopping system_safe service... \c";
|
||||
pids=$(ps aux |grep -E "(system_safe)"|grep -v grep|grep -v '/bin/bash'|grep -v systemctl | grep -v 'system_safe/system_safe.py bg_stop'|grep -v 'system_safe/system_safe.py stop' | grep -v 'system_safe/system_safe.py reload' | grep -v 'system_safe/system_safe.py restart' |awk '{print $2}'|xargs)
|
||||
arr=($pids)
|
||||
for p in ${arr[@]}
|
||||
do
|
||||
kill -9 $p
|
||||
done
|
||||
cd $rootPath/mdserver-web
|
||||
python3 plugins/system_safe/system_safe.py bg_stop
|
||||
echo -e "\033[32mdone\033[0m"
|
||||
}
|
||||
|
||||
sys_status()
|
||||
{
|
||||
isStart=$(ps aux |grep -E "(system_safe)"|grep -v grep|grep -v systemctl|awk '{print $2}'|xargs)
|
||||
if [ "$isStart" != '' ];then
|
||||
echo -e "\033[32msystem_safe service (pid $isStart) already running\033[0m"
|
||||
else
|
||||
echo -e "\033[31msystem_safe service not running\033[0m"
|
||||
fi
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
'start')
|
||||
sys_start
|
||||
;;
|
||||
'stop')
|
||||
sys_stop
|
||||
;;
|
||||
'restart')
|
||||
sys_stop
|
||||
sleep 0.2
|
||||
sys_start
|
||||
;;
|
||||
'reload')
|
||||
sys_stop
|
||||
sleep 0.2
|
||||
sys_start
|
||||
;;
|
||||
'status')
|
||||
sys_status
|
||||
;;
|
||||
*)
|
||||
echo "Usage: systemctl {start|stop|restart|reload} system_safe"
|
||||
;;
|
||||
esac
|
||||
Executable
+47
@@ -0,0 +1,47 @@
|
||||
#!/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
|
||||
SYSOS=`uname`
|
||||
VERSION=$2
|
||||
APP_NAME=system_safe
|
||||
|
||||
Install_App()
|
||||
{
|
||||
echo '正在安装脚本文件...' > $install_tmp
|
||||
mkdir -p $serverPath/system_safe
|
||||
echo "$VERSION" > $serverPath/system_safe/version.pl
|
||||
echo 'install complete' > $install_tmp
|
||||
|
||||
#初始化
|
||||
cd ${serverPath}/mdserver-web && python3 plugins/system_safe/system_safe.py start $VERSION
|
||||
cd ${serverPath}/mdserver-web && python3 plugins/system_safe/system_safe.py initd_install $VERSION
|
||||
}
|
||||
|
||||
Uninstall_App()
|
||||
{
|
||||
|
||||
if [ -f /usr/lib/systemd/system/${APP_NAME}.service ] || [ -f /lib/systemd/system/${APP_NAME}.service ] ;then
|
||||
systemctl stop ${APP_NAME}
|
||||
systemctl disable ${APP_NAME}
|
||||
rm -rf /usr/lib/systemd/system/${APP_NAME}.service
|
||||
rm -rf /lib/systemd/system/${APP_NAME}.service
|
||||
systemctl daemon-reload
|
||||
fi
|
||||
|
||||
rm -rf $serverPath/system_safe
|
||||
echo "uninstall completed" > $install_tmp
|
||||
}
|
||||
|
||||
action=$1
|
||||
if [ "${1}" == 'install' ];then
|
||||
Install_App
|
||||
else
|
||||
Uninstall_App
|
||||
fi
|
||||
@@ -0,0 +1,606 @@
|
||||
function ssPost(method,args,callback){
|
||||
var _args = null;
|
||||
if (typeof(args) == 'string'){
|
||||
_args = JSON.stringify(toArrayObject(args));
|
||||
} else {
|
||||
_args = JSON.stringify(args);
|
||||
}
|
||||
|
||||
var loadT = layer.msg('正在获取...', { icon: 16, time: 0, shade: 0.3 });
|
||||
|
||||
|
||||
|
||||
var req_data = {};
|
||||
req_data['name'] = 'system_safe';
|
||||
req_data['script'] = 'system_safe';
|
||||
req_data['func'] = method;
|
||||
req_data['args'] = _args;
|
||||
$.post('/plugins/run', 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 ssAsyncPost(method,args){
|
||||
var _args = null;
|
||||
if (typeof(args) == 'string'){
|
||||
_args = JSON.stringify(toArrayObject(args));
|
||||
} else {
|
||||
_args = JSON.stringify(args);
|
||||
}
|
||||
return syncPost('/plugins/run', {name:'system_safe', func:method, args:_args});
|
||||
}
|
||||
|
||||
function ssPostCallbak(method, args, callback){
|
||||
var loadT = layer.msg('正在获取...', { icon: 16, time: 0, shade: 0.3 });
|
||||
|
||||
var req_data = {};
|
||||
req_data['name'] = 'system_safe';
|
||||
req_data['func'] = method;
|
||||
req_data['script'] = 'system_safe';
|
||||
args['version'] = '1.0';
|
||||
|
||||
|
||||
if (typeof(args) == 'string'){
|
||||
req_data['args'] = JSON.stringify(toArrayObject(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 getSafeConfigPathList(tag){
|
||||
ssPost('get_safe_data', {tag:tag}, function(rdata){
|
||||
var rdata = $.parseJSON(rdata.data);
|
||||
var slist = rdata.data.paths;
|
||||
|
||||
var body = '';
|
||||
for (var i = 0; i < slist.length; i++) {
|
||||
body += "<tr>";
|
||||
body += "<td>"+slist[i]['path']+"</td>";
|
||||
|
||||
if (slist[i]['chattr'] == 'i'){
|
||||
body += "<td>只读</td>";
|
||||
} else if (slist[i]['chattr'] == 'a'){
|
||||
body += "<td>追加</td>";
|
||||
} else{
|
||||
body += "<td>只读</td>";
|
||||
}
|
||||
|
||||
if (rdata.msg['open']){
|
||||
body += "<td>"+slist[i]['d_mode']+"</td>";
|
||||
body += "<td><a class='btlink'>已保护</a></td>";
|
||||
} else {
|
||||
body += "<td>"+slist[i]['s_mode']+"</td>";
|
||||
body += "<td><a style='color:red;'>未保护</a></td>";
|
||||
}
|
||||
body += "<td style='text-align: right;'><a class='btlink safe_path_delete' row='"+i+"'>删除</a></td>";
|
||||
body += "</tr>";
|
||||
}
|
||||
|
||||
$('#safe-file-table tbody').html(body);
|
||||
$('.safe_path_delete').click(function(){
|
||||
var id = $(this).attr('row');
|
||||
ssPost('del_safe_path',{tag:tag,index:id}, function(rdata){
|
||||
var rdata = $.parseJSON(rdata.data);
|
||||
showMsg(rdata.msg, function(){
|
||||
getSafeConfigPathList(tag);
|
||||
},{icon:rdata.status?1:2,shade: [0.3, '#000']},2000);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function setSafeConfigPath(tag, alist){
|
||||
|
||||
layer.open({
|
||||
type: 1,
|
||||
area: ['700px','535px'],
|
||||
title: '配置【'+alist['name']+'】',
|
||||
content: "<form class='bt-form pd20'>\
|
||||
<div style='border-bottom:#ccc 1px solid;margin-bottom:10px;padding-bottom:10px'>\
|
||||
<input class='bt-input-text' name='s_path' id='s_path' type='text' value='' style='width:370px;margin-right:5px;' placeholder='被保护的文件或目录完整路径'>\
|
||||
<a class='glyphicon cursor glyphicon-folder-open' onclick='changePath(\"s_path\")' style='color:#edca5c;margin-right:20px;font-size:16px'></a>\
|
||||
<select class='bt-input-text' name='chattr'>\
|
||||
<option value='i'>只读</option>\
|
||||
<option value='a'>追加</option>\
|
||||
</select>\
|
||||
<input class='bt-input-text mr5' name='d_mode' type='text' style='width:120px;' placeholder='权限'>\
|
||||
<button type='button' class='btn btn-success btn-sm va0 pull-right add_safe_config'>添加</button>\
|
||||
</div>\
|
||||
<div class='divtable'>\
|
||||
<div id='safe-file-table' class='table_head_fix' style='max-height:300px;overflow:auto;border:#ddd 1px solid'>\
|
||||
<table class='table table-hover' style='border:none'>\
|
||||
<thead>\
|
||||
<tr>\
|
||||
<th width='360'>路径</th>\
|
||||
<th>模式</th>\
|
||||
<th>权限</th>\
|
||||
<th>状态</th>\
|
||||
<th style='text-align: right;'>操作</th>\
|
||||
</tr>\
|
||||
</thead>\
|
||||
<tbody></tbody>\
|
||||
</table>\
|
||||
</div>\
|
||||
</div>\
|
||||
<ul class='help-info-text c7 ptb10' style='margin-top: 5px;'>\
|
||||
<li>【只读】无法修改、创建、删除文件和目录</li>\
|
||||
<li>【追加】只能追加内容,不能删除或修改原有内容</li>\
|
||||
<li>【权限】设置文件或目录在受保护状态下的权限(非继承),关闭保护后权限自动还原</li>\
|
||||
<li>【如何填写权限】请填写Linux权限代号,如:644、755、600、555等,如果不填写,则使用文件原来的权限</li>\
|
||||
</ul>\
|
||||
</form>",
|
||||
success:function(){
|
||||
|
||||
$('.add_safe_config').click(function(){
|
||||
var path = $('input[name="s_path"]').val();
|
||||
var chattr = $('select[name="chattr"]').val();
|
||||
var d_mode = $('input[name="d_mode"]').val();
|
||||
ssPost('add_safe_path',{tag:tag,path:path,chattr:chattr,d_mode:d_mode}, function(rdata){
|
||||
var rdata = $.parseJSON(rdata.data);
|
||||
showMsg(rdata.msg, function(){
|
||||
getSafeConfigPathList(tag);
|
||||
},{icon:rdata.status?1:2,shade: [0.3, '#000']},2000);
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
getSafeConfigPathList(tag);
|
||||
|
||||
|
||||
}
|
||||
|
||||
function setSafeConfigSsh(tag, alist){
|
||||
|
||||
|
||||
function setSafeConfigSshData(){
|
||||
ssPost('get_ssh_data', {}, function(rdata){
|
||||
var rdata = $.parseJSON(rdata.data);
|
||||
var info = rdata.data;
|
||||
|
||||
$('input[name="s_cycle"]').val(info['cycle']);
|
||||
$('input[name="s_limit_count"]').val(info['limit_count']);
|
||||
$('input[name="s_limit"]').val(info['limit']);
|
||||
});
|
||||
}
|
||||
layer.open({
|
||||
type: 1,
|
||||
area: ['700px','210px'],
|
||||
title: '配置【'+alist['name']+'】',
|
||||
content: "<form class='bt-form pd20'>\
|
||||
<div style='border-bottom:#ccc 1px solid;margin-bottom:10px;padding-bottom:10px'>\
|
||||
在(检测周期)\
|
||||
<input class='bt-input-text' min='30' max='1800' name='s_cycle' type='number' value='120' style='width:80px;margin-right:5px;'>\
|
||||
秒内,登录错误(检测阈值)\
|
||||
<input class='bt-input-text' min='30' max='1800' name='s_limit_count' type='number' value='120' style='width:80px;margin-right:5px;'>\
|
||||
次,封锁(封锁时间)\
|
||||
<input min='60' class='bt-input-text' name='s_limit' type='number' value='3600' style='width:80px;margin-right:12px;'>\
|
||||
<button type='button' class='btn btn-success btn-sm va0 pull-right save_safe_ssh'>保存</button>\
|
||||
</div>\
|
||||
<ul class='help-info-text c7 ptb10' style='margin-top: 5px;'>\
|
||||
<li>触发以上策略后,客户端IP将被封锁一段时间</li>\
|
||||
<li>请在面板日志或操作日志中查看封锁记录</li>\
|
||||
<li>请在面板日志或操作日志中查看SSH成功登录的记录</li>\
|
||||
</ul>\
|
||||
</form>",
|
||||
success:function(){
|
||||
setSafeConfigSshData();
|
||||
|
||||
$('.save_safe_ssh').click(function(){
|
||||
var cycle = $('input[name="s_cycle"]').val();
|
||||
var limit_count = $('input[name="s_limit_count"]').val();
|
||||
var limit = $('input[name="s_limit"]').val();
|
||||
ssPost('save_safe_ssh',{cycle:cycle,limit_count:limit_count,limit:limit}, function(rdata){
|
||||
var rdata = $.parseJSON(rdata.data);
|
||||
showMsg(rdata.msg, function(){
|
||||
setSafeConfigSshData();
|
||||
},{icon:rdata.status?1:2,shade: [0.3, '#000']},2000);
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function setSafeConfigProcessList(tag){
|
||||
ssPost('get_process_data', {}, function(rdata){
|
||||
var rdata = $.parseJSON(rdata.data);
|
||||
var slist = rdata.data.process_white;
|
||||
|
||||
var body = '';
|
||||
for (var i = 0; i < slist.length; i++) {
|
||||
body += "<tr>\
|
||||
<td>"+slist[i]+"</td>\
|
||||
<td style='text-align: right;'><a class='btlink safe_path_delete' row='"+i+"'>删除</a></td>\
|
||||
</tr>";
|
||||
}
|
||||
|
||||
$('#safe-file-table tbody').html(body);
|
||||
$('.safe_path_delete').click(function(){
|
||||
var id = $(this).attr('row');
|
||||
ssPost('del_safe_proccess_name',{tag:tag,index:id}, function(rdata){
|
||||
var rdata = $.parseJSON(rdata.data);
|
||||
showMsg(rdata.msg, function(){
|
||||
setSafeConfigProcessList(tag);
|
||||
},{icon:rdata.status?1:2,shade: [0.3, '#000']},2000);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function setSafeConfigProcess(tag, alist){
|
||||
layer.open({
|
||||
type: 1,
|
||||
area: ['700px','535px'],
|
||||
title: '配置【进程白名单】',
|
||||
content: "<form class='bt-form pd20'>\
|
||||
<div style='border-bottom:#ccc 1px solid;margin-bottom:10px;padding-bottom:10px'>\
|
||||
<input class='bt-input-text' name='s_name' id='s_name' type='text' value='' style='width:370px;margin-right:5px;' placeholder='完整的进程名'>\
|
||||
<button type='button' class='btn btn-success btn-sm va0 pull-right add_process_white'>添加</button>\
|
||||
</div>\
|
||||
<div class='divtable'>\
|
||||
<div id='safe-file-table' class='table_head_fix' style='max-height:300px;overflow:auto;border:#ddd 1px solid'>\
|
||||
<table class='table table-hover' style='border:none'>\
|
||||
<thead>\
|
||||
<tr>\
|
||||
<th width='360'>进程名称</th>\
|
||||
<th style='text-align: right;'>操作</th>\
|
||||
</tr>\
|
||||
</thead>\
|
||||
<tbody></tbody>\
|
||||
</table>\
|
||||
</div>\
|
||||
</div>\
|
||||
<ul class='help-info-text c7 ptb10' style='margin-top: 5px;'>\
|
||||
<li>【进程名称】请填写完整的进程名称,如: mysqld</li>\
|
||||
<li>【说明】在白名单列表中的进程将不再检测范围,建议将常用软件的进程添加进白名单</li>\
|
||||
</ul>\
|
||||
</form>",
|
||||
success:function(){
|
||||
$('.add_process_white').click(function(){
|
||||
var process_name = $('input[name="s_name"]').val();
|
||||
ssPost('add_process_white',{process_name:process_name}, function(rdata){
|
||||
var rdata = $.parseJSON(rdata.data);
|
||||
showMsg(rdata.msg, function(){
|
||||
setSafeConfigProcessList(tag);
|
||||
},{icon:rdata.status?1:2,shade: [0.3, '#000']},2000);
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
setSafeConfigProcessList(tag);
|
||||
|
||||
|
||||
}
|
||||
|
||||
function setSafeConfig(tag, alist){
|
||||
|
||||
if ($.inArray(tag, ['bin', 'service', 'home', 'user', 'bin', 'cron'])>-1){
|
||||
setSafeConfigPath(tag,alist);
|
||||
}
|
||||
|
||||
if ($.inArray(tag, ['ssh'])>-1){
|
||||
setSafeConfigSsh(tag,alist);
|
||||
}
|
||||
|
||||
if ($.inArray(tag, ['process'])>-1){
|
||||
setSafeConfigProcess(tag,alist);
|
||||
}
|
||||
}
|
||||
|
||||
//设置安全状态
|
||||
function setSafeStatus(obj,tag){
|
||||
var o = $(obj).prev();
|
||||
var status = $(o).prop('checked');
|
||||
ssPost('set_safe_status', {tag:tag,status:!status}, function(rdata){
|
||||
var rdata = $.parseJSON(rdata.data);
|
||||
|
||||
if (!rdata.status){
|
||||
layer.msg(rdata.msg,{icon:0,time:2000,shade: [0.3, '#000']});
|
||||
$(o).prop('checked',status);
|
||||
return;
|
||||
}
|
||||
layer.msg("配置成功!",{icon:1,time:2000,shade: [0.3, '#000']});
|
||||
});
|
||||
}
|
||||
|
||||
function ssConfigList(){
|
||||
|
||||
ssPost('conf',{},function(rdata){
|
||||
var rdata = $.parseJSON(rdata.data);
|
||||
var libs = rdata.data;
|
||||
// console.log(libs);
|
||||
var body = '';
|
||||
for (var i in libs) {
|
||||
|
||||
if (i == 'open'){
|
||||
continue;
|
||||
}
|
||||
|
||||
var checked = '';
|
||||
if (libs[i].open){
|
||||
checked = 'checked';
|
||||
}
|
||||
|
||||
body += '<tr>' +
|
||||
'<td>' + libs[i].name + '</td>' +
|
||||
'<td>' + libs[i].ps + '</td>' +
|
||||
'<td>\
|
||||
<div class="ssh-item">\
|
||||
<input class="btswitch btswitch-ios" id="sys_service_'+i +'" type="checkbox" '+checked+'>\
|
||||
<label class="btswitch-btn service_switch" for="sys_service_'+i+'" style="width: 2em; height: 1.1em;padding:1px;"></label>\
|
||||
</div>\
|
||||
</td>'+
|
||||
'<td style="text-align: right;"><a id="conf_sys_service_'+i+'" class="btlink set_safe_config">配置</a></td>' +
|
||||
'</tr>';
|
||||
}
|
||||
|
||||
var con = '<div class="divtable" id="system_safe_list" style="margin-right:10px;max-height: 320px; overflow: auto; margin-right: 0px;">' +
|
||||
'<table class="table table-hover" width="100%" cellspacing="0" cellpadding="0" border="0">' +
|
||||
'<thead>' +
|
||||
'<tr>' +
|
||||
'<th>名称</th>' +
|
||||
'<th>描述</th>' +
|
||||
'<th width="40">状态</th>' +
|
||||
'<th style="text-align: right;" width="50">操作</th>' +
|
||||
'</tr>' +
|
||||
'</thead>' +
|
||||
'<tbody>' + body + '</tbody>' +
|
||||
'</table>' +
|
||||
'</div>' +
|
||||
'<ul class="help-info-text c7 pull-left">\
|
||||
<li>开启系统加固功能后,一些如软件安装等敏感操作将被禁止</li>\
|
||||
<li>开启【SSH服务加固】之后,用户登录SSH的行为将受到监控,若连续多次登录失败,将采取封IP措施</li>\
|
||||
<li>【异常进程监控】与【SSH服务加固】会占用一定服务器开销</li>\
|
||||
<li><span style="color:red;">【注意】如果您需要安装软件或插件,请先将系统加固关闭!</span></li>\
|
||||
</ul>';
|
||||
|
||||
$('.soft-man-con').html(con);
|
||||
|
||||
$('#system_safe_list .service_switch').click(function(){
|
||||
var val = $(this).prev().attr('id');
|
||||
val = val.replace('sys_service_','');
|
||||
setSafeStatus(this,val);
|
||||
});
|
||||
|
||||
$('.set_safe_config').click(function(){
|
||||
var name = $(this).attr('id');
|
||||
// console.log(name);
|
||||
name = name.replace('conf_sys_service_','');
|
||||
setSafeConfig(name, libs[name]);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function ssOpLogList(p){
|
||||
ssPost('op_log',{p:p},function(rdata){
|
||||
var rdata = $.parseJSON(rdata.data);
|
||||
var plist = rdata.data.data;
|
||||
|
||||
var body = '';
|
||||
for (var i = 0; i < plist.length; i++) {
|
||||
body += "<tr>\
|
||||
<td><em class='dlt-num'>" + plist[i].addtime + "</em></td>\
|
||||
<td>" + plist[i].log + "</td>\
|
||||
</tr>";
|
||||
}
|
||||
|
||||
$("#system_safe_log_list tbody").html(body);
|
||||
$("#system_safe_log_page").html(rdata.data.page);
|
||||
});
|
||||
}
|
||||
|
||||
function ssOpLog(){
|
||||
var con = '<div class="divtable" id="system_safe_log_list" style="margin-right:10px;max-height: 380px; overflow: auto; margin-right: 0px;">\
|
||||
<table class="table table-hover" width="100%" cellspacing="0" cellpadding="0" border="0">\
|
||||
<thead><tr><th style="width:135px;">时间</th><th>详情</th></tr></thead>\
|
||||
<tbody></tbody>\
|
||||
</table>\
|
||||
</div>\
|
||||
<div id="system_safe_log_page" class="dataTables_paginate paging_bootstrap page"></div>';
|
||||
$('.soft-man-con').html(con);
|
||||
ssOpLogList(1);
|
||||
}
|
||||
|
||||
|
||||
function ssLogAuditList(){
|
||||
ssPost('get_sys_logfiles',{},function(rdata){
|
||||
var rdata = $.parseJSON(rdata.data);
|
||||
var plist = rdata.data;
|
||||
var option = '';
|
||||
// console.log(plist);
|
||||
for (var i = 0; i < plist.length; i++) {
|
||||
option += '<option value="'+plist[i]['name']+'">'+plist[i]['name'] +' - '+plist[i]['title']+'</option>';
|
||||
}
|
||||
|
||||
$("#system_safe_log_audit").html(option);
|
||||
var log_name = $('#system_safe_log_audit option:first').val();
|
||||
ssLogAuditFile(log_name);
|
||||
|
||||
$('#system_safe_log_audit').change(function(){
|
||||
var log_name = $('#system_safe_log_audit option:selected').val();
|
||||
ssLogAuditFile(log_name);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function ssLogAuditFileRenderString(data){
|
||||
|
||||
var tbody = '<textarea style="margin: 0px;width: 100%;height: 380px;background-color: #333;color:#fff; padding:0 5px" id="system_safe_log_audit_str"></textarea>';
|
||||
$("#system_safe_log_audit_list").html(tbody);
|
||||
var ob = document.getElementById('system_safe_log_audit_str');
|
||||
ob.scrollTop = ob.scrollHeight;
|
||||
|
||||
$("#system_safe_log_audit_str").html(data);
|
||||
}
|
||||
|
||||
function ssLogAuditFileRenderObject(plist){
|
||||
|
||||
var pre_html = '<table class="table table-hover" width="100%" cellspacing="0" cellpadding="0" border="0">\
|
||||
<thead><tr><th>时间</th><th>角色</th><th>事件</th></tr></thead>\
|
||||
<tbody></tbody>\
|
||||
</table>';
|
||||
$("#system_safe_log_audit_list").html(pre_html);
|
||||
|
||||
if (plist.length>0){
|
||||
var tmp = plist[0];
|
||||
// console.log(tmp);
|
||||
var thead = '';
|
||||
tbody += '<tr>'
|
||||
for (var i in tmp) {
|
||||
tbody+='<th>'+ i + '</th>';
|
||||
}
|
||||
tbody += '</tr>';
|
||||
$("#system_safe_log_audit_list thead").html(tbody);
|
||||
}
|
||||
|
||||
|
||||
var tbody = '';
|
||||
for (var i = 0; i < plist.length; i++) {
|
||||
tbody += '<tr>';
|
||||
for (var vv in plist[i]) {
|
||||
tbody+= '<td>'+ plist[i][vv] + '</td>'
|
||||
}
|
||||
tbody += '</tr>';
|
||||
}
|
||||
|
||||
$("#system_safe_log_audit_list tbody").html(tbody);
|
||||
}
|
||||
|
||||
function ssLogAuditFile(log_name){
|
||||
// ssPost('get_sys_log',{log_name:log_name},function(rdata){
|
||||
// try{
|
||||
// var rdata = $.parseJSON(rdata.data);
|
||||
// if (typeof(rdata.data) == 'object'){
|
||||
|
||||
// if (!rdata.status){
|
||||
// layer.msg(rdata.msg,{icon:0,time:2000,shade: [0.3, '#000']});
|
||||
// return;
|
||||
// }
|
||||
// var plist = rdata.data;
|
||||
// ssLogAuditFileRenderObject(plist);
|
||||
// }
|
||||
// }catch(e){
|
||||
// if (typeof(rdata.data) == 'string'){
|
||||
// ssLogAuditFileRenderString(rdata.data);
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
|
||||
ssPostCallbak('get_sys_log',{log_name:log_name},function(rdata){
|
||||
try{
|
||||
var rdata = $.parseJSON(rdata.data);
|
||||
if (typeof(rdata.data) == 'object'){
|
||||
if (!rdata.status){
|
||||
layer.msg(rdata.msg,{icon:0,time:2000,shade: [0.3, '#000']});
|
||||
return;
|
||||
}
|
||||
var plist = rdata.data;
|
||||
ssLogAuditFileRenderObject(plist);
|
||||
}
|
||||
}catch(e){
|
||||
if (typeof(rdata.data) == 'string'){
|
||||
ssLogAuditFileRenderString(rdata.data);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function ssLogAudit(){
|
||||
var con = '<select id="system_safe_log_audit" class="bt-input-text mr20" style="width:50%;margin-bottom: 3px;">\
|
||||
<option value="0">请选择</option>\
|
||||
</select>\
|
||||
<div class="divtable" id="system_safe_log_audit_list" style="margin-right:10px;height: 380px; overflow: auto; margin-right: 0px;"></div>';
|
||||
$('.soft-man-con').html(con);
|
||||
ssLogAuditList();
|
||||
}
|
||||
|
||||
function ssLockAddressList(){
|
||||
ssPost('get_ssh_limit_info',{},function(rdata){
|
||||
var rdata = $.parseJSON(rdata.data);
|
||||
var libs = rdata.data;
|
||||
var tbody = '';
|
||||
for (var i in libs) {
|
||||
var end_time = libs[i].end;
|
||||
var time_title = '手动解封';
|
||||
if (end_time != '0'){
|
||||
time_title = '自动解封时间:'+end_time;
|
||||
}
|
||||
tbody += '<tr>' +
|
||||
'<td style="width:100px;">' + libs[i].address + '</td>' +
|
||||
'<td style="width:100px;">'+time_title+'</td>' +
|
||||
'<td style="text-align: right;"><a ip="'+libs[i].address+'" class="btlink remove_ssh_limit">立即解封</a></td>' +
|
||||
'</tr>';
|
||||
}
|
||||
|
||||
$('#system_lock_address tbody').html(tbody);
|
||||
$('#system_lock_address .remove_ssh_limit').click(function(){
|
||||
var address = $(this).attr('ip');
|
||||
ssPost('remove_ssh_limit', {ip:address}, function(rdata){
|
||||
var rdata = $.parseJSON(rdata.data);
|
||||
showMsg(rdata.msg, function(){
|
||||
ssLockAddressList();
|
||||
},{icon:rdata.status?1:2,shade: [0.3, '#000']},2000);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function ssLockAddress(){
|
||||
|
||||
var con = '<div style="margin-bottom:10px;">\
|
||||
<input class="bt-input-text" name="s_address" type="text" value="" style="width:250px;margin-right:12px;" placeholder="IP地址">\
|
||||
<button class="btn btn-success btn-sm va0 add_lock_address">添加</button>\
|
||||
</div>\
|
||||
<div class="divtable" id="system_lock_address" style="margin-right:10px;max-height: 320px; overflow: auto; margin-right: 0px;">' +
|
||||
'<table class="table table-hover" width="100%" cellspacing="0" cellpadding="0" border="0">' +
|
||||
'<thead>' +
|
||||
'<tr>' +
|
||||
'<th>IP</th>' +
|
||||
'<th>解封时间</th>' +
|
||||
'<th style="text-align: right;" width="50">操作</th>' +
|
||||
'</tr>' +
|
||||
'</thead>' +
|
||||
'<tbody></tbody>' +
|
||||
'</table>' +
|
||||
'</div>' +
|
||||
'<ul class="help-info-text c7 pull-left">\
|
||||
<li>【封锁IP】此处封锁的IP仅针对SSH服务,即被封锁的IP将无法连接SSH</li>\
|
||||
<li>【添加】手动添加的IP封锁只能手动解封!</li>\
|
||||
</ul>';
|
||||
|
||||
$('.soft-man-con').html(con);
|
||||
|
||||
$('.add_lock_address').click(function(){
|
||||
var address = $('input[name="s_address"]').val();
|
||||
ssPost('add_ssh_limit', {ip:address}, function(rdata){
|
||||
var rdata = $.parseJSON(rdata.data);
|
||||
showMsg(rdata.msg, function(){
|
||||
ssLockAddressList();
|
||||
},{icon:rdata.status?1:2,shade: [0.3, '#000']},2000);
|
||||
});
|
||||
});
|
||||
ssLockAddressList();
|
||||
}
|
||||
Executable
+1140
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"open": true,
|
||||
"excludePath": [ "cache", "threadcache", "log", "logs", "config", "runtime", "temp","tmp","caches","tmps"],
|
||||
"protectExt": [ "php", "html", "htm", "shtml", "tpl", "js", "css", "jsp", "do" ]
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 556 B |
Executable
+1163
File diff suppressed because it is too large
Load Diff
Executable
+628
@@ -0,0 +1,628 @@
|
||||
# coding:utf-8
|
||||
|
||||
import sys
|
||||
import io
|
||||
import os
|
||||
import time
|
||||
import json
|
||||
import re
|
||||
import psutil
|
||||
from datetime import datetime
|
||||
|
||||
sys.dont_write_bytecode = True
|
||||
sys.path.append(os.getcwd() + "/class/core")
|
||||
import mw
|
||||
|
||||
app_debug = False
|
||||
if mw.isAppleSystem():
|
||||
app_debug = True
|
||||
|
||||
|
||||
class App:
|
||||
|
||||
__total = 'total.json'
|
||||
__sites = []
|
||||
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
def getPluginName(self):
|
||||
return 'tamper_proof_py'
|
||||
|
||||
def getPluginDir(self):
|
||||
return mw.getPluginDir() + '/' + self.getPluginName()
|
||||
|
||||
def getServerDir(self):
|
||||
return mw.getServerDir() + '/' + self.getPluginName()
|
||||
|
||||
def getInitDFile(self):
|
||||
if app_debug:
|
||||
return '/tmp/' + self.getPluginName()
|
||||
return '/etc/init.d/' + self.getPluginName()
|
||||
|
||||
def getInitDTpl(self):
|
||||
path = self.getPluginDir() + "/init.d/" + self.getPluginName() + ".tpl"
|
||||
return path
|
||||
|
||||
def getArgs(self):
|
||||
args = sys.argv[2:]
|
||||
tmp = {}
|
||||
args_len = len(args)
|
||||
|
||||
if args_len == 1:
|
||||
t = args[0].strip('{').strip('}')
|
||||
if t.strip() == '':
|
||||
tmp = []
|
||||
else:
|
||||
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(self, 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 getTotal(self, siteName=None, day=None):
|
||||
defaultTotal = {"total": 0, "delete": 0,
|
||||
"create": 0, "modify": 0, "move": 0}
|
||||
if siteName:
|
||||
total = {}
|
||||
total_path = self.getServerDir() + '/sites/' + siteName + '/' + self.__total
|
||||
if not os.path.exists(total_path):
|
||||
total['site'] = defaultTotal
|
||||
else:
|
||||
total_data = mw.readFile(total_path)
|
||||
if total_data['site']:
|
||||
total['site'] = json.loads(total_data['site'])
|
||||
else:
|
||||
total['site'] = defaultTotal
|
||||
|
||||
if not day:
|
||||
day = time.strftime("%Y-%m-%d", time.localtime())
|
||||
total_day_path = self.getServerDir() + '/sites/' + siteName + '/day/total.json'
|
||||
if not os.path.exists(total_day_path):
|
||||
total['day'] = defaultTotal
|
||||
else:
|
||||
total['day'] = mw.readFile(total_day_path)
|
||||
if total['day']:
|
||||
total['day'] = json.loads(total['day'])
|
||||
else:
|
||||
total['day'] = defaultTotal
|
||||
else:
|
||||
filename = self.getServerDir() + '/sites/' + self.__total
|
||||
if os.path.exists(filename):
|
||||
total = json.loads(mw.readFile(filename))
|
||||
else:
|
||||
total = defaultTotal
|
||||
return total
|
||||
|
||||
def getSites(self):
|
||||
sites_path = self.getServerDir() + '/sites.json'
|
||||
t = mw.readFile(sites_path)
|
||||
if not os.path.exists(sites_path) or not t:
|
||||
mw.writeFile(sites_path, '[]')
|
||||
data = json.loads(mw.readFile(sites_path))
|
||||
|
||||
is_write = False
|
||||
rm_keys = ['lock', 'bak_open']
|
||||
for i in data:
|
||||
i_keys = i.keys()
|
||||
if not 'open' in i_keys:
|
||||
i['open'] = False
|
||||
for o in rm_keys:
|
||||
if o in i_keys:
|
||||
if i[o]:
|
||||
i['open'] = True
|
||||
i.pop(o)
|
||||
is_write = True
|
||||
if is_write:
|
||||
mw.writeFile(sites_path, json.dumps(data))
|
||||
|
||||
self.__sites = data
|
||||
return data
|
||||
|
||||
def writeSites(self, data):
|
||||
mw.writeFile(self.getServerDir() + '/sites.json', json.dumps(data))
|
||||
# mw.ExecShell('/etc/init.d/bt_tamper_proof reload')
|
||||
|
||||
def __getFind(self, siteName):
|
||||
data = self.getSites()
|
||||
for siteInfo in data:
|
||||
if siteName == siteInfo['siteName']:
|
||||
return siteInfo
|
||||
return None
|
||||
|
||||
def writeLog(self, log):
|
||||
mw.writeLog('防篡改程序', log)
|
||||
|
||||
def saveSiteConfig(self, siteInfo):
|
||||
data = self.getSites()
|
||||
for i in range(len(data)):
|
||||
if data[i]['siteName'] != siteInfo['siteName']:
|
||||
continue
|
||||
data[i] = siteInfo
|
||||
break
|
||||
self.writeSites(data)
|
||||
|
||||
def syncSites(self):
|
||||
data = self.getSites()
|
||||
sites = mw.M('sites').field('name,path').select()
|
||||
|
||||
config_path = self.getPluginDir() + '/conf/config.json'
|
||||
config = json.loads(mw.readFile(config_path))
|
||||
names = []
|
||||
n = 0
|
||||
|
||||
# print(config)
|
||||
for siteTmp in sites:
|
||||
names.append(siteTmp['name'])
|
||||
siteInfo = self.__getFind(siteTmp['name'])
|
||||
if siteInfo:
|
||||
if siteInfo['path'] != siteTmp['path']:
|
||||
siteInfo['path'] = siteTmp['path']
|
||||
self.saveSiteConfig(siteInfo)
|
||||
data = self.getSites()
|
||||
continue
|
||||
siteInfo = {}
|
||||
siteInfo['siteName'] = siteTmp['name']
|
||||
siteInfo['path'] = siteTmp['path']
|
||||
siteInfo['open'] = False
|
||||
siteInfo['excludePath'] = config['excludePath']
|
||||
siteInfo['protectExt'] = config['protectExt']
|
||||
data.append(siteInfo)
|
||||
n += 1
|
||||
|
||||
newData = []
|
||||
for siteInfoTmp in data:
|
||||
if siteInfoTmp['siteName'] in names:
|
||||
newData.append(siteInfoTmp)
|
||||
else:
|
||||
mw.execShell("rm -rf " + self.getServerDir() +
|
||||
'/sites/' + siteInfoTmp['siteName'])
|
||||
n += 1
|
||||
if n > 0:
|
||||
self.writeSites(newData)
|
||||
self.__sites = None
|
||||
|
||||
def initDreplace(self):
|
||||
file_tpl = self.getInitDTpl()
|
||||
service_path = self.getServerDir()
|
||||
|
||||
initD_path = service_path + '/init.d'
|
||||
if not os.path.exists(initD_path):
|
||||
os.mkdir(initD_path)
|
||||
|
||||
# init.d
|
||||
file_bin = initD_path + '/' + self.getPluginName()
|
||||
if not os.path.exists(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)
|
||||
|
||||
# systemd
|
||||
# /usr/lib/systemd/system
|
||||
systemDir = mw.systemdCfgDir()
|
||||
systemService = systemDir + '/tamper_proof_py.service'
|
||||
systemServiceTpl = self.getPluginDir() + '/init.d/tamper_proof_py.service.tpl'
|
||||
if os.path.exists(systemDir) and not os.path.exists(systemService):
|
||||
se_content = mw.readFile(systemServiceTpl)
|
||||
se_content = se_content.replace('{$SERVER_PATH}', service_path)
|
||||
mw.writeFile(systemService, se_content)
|
||||
mw.execShell('systemctl daemon-reload')
|
||||
|
||||
return file_bin
|
||||
|
||||
def getDays(self, path):
|
||||
days = []
|
||||
if not os.path.exists(path):
|
||||
os.makedirs(path)
|
||||
for dirname in os.listdir(path):
|
||||
if dirname == '..' or dirname == '.' or dirname == 'total.json':
|
||||
continue
|
||||
if not os.path.isdir(path + '/' + dirname):
|
||||
continue
|
||||
days.append(dirname)
|
||||
days = sorted(days, reverse=True)
|
||||
return days
|
||||
|
||||
def status(self):
|
||||
'''
|
||||
状态
|
||||
'''
|
||||
initd_file = self.getServerDir() + '/init.d/' + self.getPluginName()
|
||||
if not os.path.exists(initd_file):
|
||||
return 'stop'
|
||||
cmd = initd_file + ' status|grep already'
|
||||
data = mw.execShell(cmd)
|
||||
if data[0] != '':
|
||||
return 'start'
|
||||
return 'stop'
|
||||
|
||||
def tpOp(self, method):
|
||||
file = self.initDreplace()
|
||||
if not mw.isAppleSystem():
|
||||
cmd = 'systemctl ' + method + ' ' + self.getPluginName()
|
||||
data = mw.execShell(cmd)
|
||||
if data[1] == '':
|
||||
return mw.returnJson(True, '操作成功')
|
||||
return mw.returnJson(False, '操作失败')
|
||||
|
||||
cmd = file + ' ' + method
|
||||
data = mw.execShell(cmd)
|
||||
if data[1] == '':
|
||||
return mw.returnJson(True, '操作成功')
|
||||
return mw.returnJson(False, '操作失败')
|
||||
|
||||
def start(self):
|
||||
return self.tpOp('start')
|
||||
|
||||
def restart(self):
|
||||
return self.tpOp('restart')
|
||||
|
||||
def service_admin(self):
|
||||
if mw.isAppleSystem():
|
||||
return mw.returnJson(False, '仅支持Linux!')
|
||||
|
||||
args = self.getArgs()
|
||||
check = self.checkArgs(args, ['serviceStatus'])
|
||||
if not check[0]:
|
||||
return check[1]
|
||||
|
||||
method = args['serviceStatus']
|
||||
return self.tpOp(method)
|
||||
|
||||
def initd_status(self):
|
||||
if mw.isAppleSystem():
|
||||
return "Apple Computer does not support"
|
||||
shell_cmd = 'systemctl status %s | grep loaded | grep "enabled;"' % (
|
||||
self.getPluginName())
|
||||
data = mw.execShell(shell_cmd)
|
||||
if data[0] == '':
|
||||
return 'fail'
|
||||
return 'ok'
|
||||
|
||||
def initd_install(self):
|
||||
if mw.isAppleSystem():
|
||||
return "Apple Computer does not support"
|
||||
|
||||
mw.execShell('systemctl enable ' + self.getPluginName())
|
||||
return 'ok'
|
||||
|
||||
def initd_uninstall(self):
|
||||
if mw.isAppleSystem():
|
||||
return "Apple Computer does not support"
|
||||
|
||||
mw.execShell('systemctl disable ' + self.getPluginName())
|
||||
return 'ok'
|
||||
|
||||
def set_site_status(self):
|
||||
args = self.getArgs()
|
||||
check = self.checkArgs(args, ['siteName'])
|
||||
if not check[0]:
|
||||
return check[1]
|
||||
|
||||
siteName = args['siteName']
|
||||
siteInfo = self.__getFind(siteName)
|
||||
if not siteInfo:
|
||||
return mw.returnJson(False, '指定站点不存在!')
|
||||
try:
|
||||
siteInfo['open'] = not siteInfo['open']
|
||||
except:
|
||||
siteInfo['open'] = not siteInfo['open']
|
||||
|
||||
m_logs = {True: '开启', False: '关闭'}
|
||||
self.writeLog('%s站点[%s]防篡改保护' %
|
||||
(m_logs[siteInfo['open']], siteInfo['siteName']))
|
||||
self.siteReload(siteInfo)
|
||||
self.saveSiteConfig(siteInfo)
|
||||
self.restart()
|
||||
return mw.returnJson(True, '设置成功!')
|
||||
|
||||
def get_run_logs(self):
|
||||
log_file = self.getServerDir() + '/service.log'
|
||||
return mw.returnJson(True, mw.getLastLine(log_file, 200))
|
||||
|
||||
# 取文件指定尾行数
|
||||
def getNumLines(self, path, num, p=1):
|
||||
pyVersion = sys.version_info[0]
|
||||
try:
|
||||
import cgi
|
||||
if not os.path.exists(path):
|
||||
return ""
|
||||
start_line = (p - 1) * num
|
||||
count = start_line + num
|
||||
fp = open(path, 'rb')
|
||||
buf = ""
|
||||
fp.seek(-1, 2)
|
||||
if fp.read(1) == "\n":
|
||||
fp.seek(-1, 2)
|
||||
data = []
|
||||
b = True
|
||||
n = 0
|
||||
for i in range(count):
|
||||
while True:
|
||||
newline_pos = str.rfind(str(buf), "\n")
|
||||
pos = fp.tell()
|
||||
if newline_pos != -1:
|
||||
if n >= start_line:
|
||||
line = buf[newline_pos + 1:]
|
||||
try:
|
||||
data.append(json.loads(cgi.escape(line)))
|
||||
except:
|
||||
pass
|
||||
buf = buf[:newline_pos]
|
||||
n += 1
|
||||
break
|
||||
else:
|
||||
if pos == 0:
|
||||
b = False
|
||||
break
|
||||
to_read = min(4096, pos)
|
||||
fp.seek(-to_read, 1)
|
||||
t_buf = fp.read(to_read)
|
||||
if pyVersion == 3:
|
||||
if type(t_buf) == bytes:
|
||||
t_buf = t_buf.decode('utf-8')
|
||||
buf = t_buf + buf
|
||||
fp.seek(-to_read, 1)
|
||||
if pos - to_read == 0:
|
||||
buf = "\n" + buf
|
||||
if not b:
|
||||
break
|
||||
fp.close()
|
||||
except:
|
||||
return []
|
||||
if len(data) >= 2000:
|
||||
arr = []
|
||||
for d in data:
|
||||
arr.insert(0, json.dumps(d))
|
||||
mw.writeFile(path, "\n".join(arr))
|
||||
return data
|
||||
|
||||
def get_safe_logs(self):
|
||||
|
||||
args = self.getArgs()
|
||||
check = self.checkArgs(args, ['siteName'])
|
||||
if not check[0]:
|
||||
return check[1]
|
||||
|
||||
siteName = args['siteName']
|
||||
|
||||
data = {}
|
||||
path = self.getPluginDir() + '/sites/' + siteName + '/day'
|
||||
data['days'] = self.getDays(path)
|
||||
|
||||
if not data['days']:
|
||||
data['logs'] = []
|
||||
else:
|
||||
p = 1
|
||||
if hasattr(args, 'p'):
|
||||
p = args['p']
|
||||
|
||||
day = data['days'][0]
|
||||
if hasattr(args, 'day'):
|
||||
day = args['day']
|
||||
data['get_day'] = day
|
||||
logs_path = path + '/' + day + '/logs.json'
|
||||
data['logs'] = self.getNumLines(logs_path, 2000, int(p))
|
||||
return mw.returnJson(True, 'ok', data)
|
||||
|
||||
def get_site_find(self):
|
||||
args = self.getArgs()
|
||||
check = self.checkArgs(args, ['siteName'])
|
||||
if not check[0]:
|
||||
return check[1]
|
||||
|
||||
siteName = args['siteName']
|
||||
data = self.__getFind(siteName)
|
||||
return mw.returnJson(True, 'ok', data)
|
||||
|
||||
def siteReload(self, siteInfo):
|
||||
cmd = "python3 {} {}".format(
|
||||
mw.getPluginDir() + '/tamper_proof_service.py unlock', siteInfo['path'])
|
||||
mw.execShell(cmd)
|
||||
tip_file = mw.getServerDir() + '/tips/' + siteInfo['siteName'] + '.pl'
|
||||
if os.path.exists(tip_file):
|
||||
os.remove(tip_file)
|
||||
|
||||
def remove_protect_ext(self):
|
||||
args = self.getArgs()
|
||||
check = self.checkArgs(args, ['siteName', 'protectExt'])
|
||||
if not check[0]:
|
||||
return check[1]
|
||||
|
||||
siteName = args['siteName']
|
||||
protectExt = args['protectExt'].strip()
|
||||
|
||||
siteInfo = self.__getFind(siteName)
|
||||
|
||||
if not siteInfo:
|
||||
return mw.returnJson(False, '指定站点不存在!')
|
||||
if not protectExt:
|
||||
return mw.returnJson(False, '被删除的保护列表不能为空')
|
||||
|
||||
for protectExt in protectExt.split(','):
|
||||
if not protectExt in siteInfo['protectExt']:
|
||||
continue
|
||||
siteInfo['protectExt'].remove(protectExt)
|
||||
self.writeLog('站点[%s]从受保护列表中删除[.%s]' %
|
||||
(siteInfo['siteName'], protectExt))
|
||||
self.siteReload(siteInfo)
|
||||
self.saveSiteConfig(siteInfo)
|
||||
return mw.returnJson(True, '删除成功!')
|
||||
|
||||
def add_protect_ext(self):
|
||||
args = self.getArgs()
|
||||
check = self.checkArgs(args, ['siteName', 'protectExt'])
|
||||
if not check[0]:
|
||||
return check[1]
|
||||
|
||||
siteName = args['siteName']
|
||||
protectExt = args['protectExt'].strip()
|
||||
|
||||
siteInfo = self.__getFind(siteName)
|
||||
if not siteInfo:
|
||||
return mw.returnJson(False, '指定站点不存在!')
|
||||
protectExt = protectExt.lower()
|
||||
for protectExt in protectExt.split("\n"):
|
||||
if protectExt[0] == '/':
|
||||
if os.path.isdir(protectExt):
|
||||
continue
|
||||
if protectExt in siteInfo['protectExt']:
|
||||
continue
|
||||
siteInfo['protectExt'].insert(0, protectExt)
|
||||
self.writeLog('站点[%s]添加文件类型或文件名[.%s]到受保护列表' %
|
||||
(siteInfo['siteName'], protectExt))
|
||||
self.siteReload(siteInfo)
|
||||
self.saveSiteConfig(siteInfo)
|
||||
return mw.returnJson(True, '添加成功!')
|
||||
|
||||
def add_excloud(self):
|
||||
args = self.getArgs()
|
||||
check = self.checkArgs(args, ['siteName', 'excludePath'])
|
||||
if not check[0]:
|
||||
return check[1]
|
||||
|
||||
siteName = args['siteName']
|
||||
excludePath = args['excludePath'].strip()
|
||||
siteInfo = self.__getFind(siteName)
|
||||
if not siteInfo:
|
||||
return mw.returnJson(False, '指定站点不存在!')
|
||||
|
||||
if not excludePath:
|
||||
return mw.returnJson(False, '排除内容不能为空')
|
||||
|
||||
for excludePath in excludePath.split('\n'):
|
||||
if not excludePath:
|
||||
continue
|
||||
if excludePath.find('/') != -1:
|
||||
if not os.path.exists(excludePath):
|
||||
continue
|
||||
excludePath = excludePath.lower()
|
||||
if excludePath[-1] == '/':
|
||||
excludePath = excludePath[:-1]
|
||||
if excludePath in siteInfo['excludePath']:
|
||||
continue
|
||||
siteInfo['excludePath'].insert(0, excludePath)
|
||||
self.writeLog('站点[%s]添加排除目录名[%s]到排除列表' %
|
||||
(siteInfo['siteName'], excludePath))
|
||||
|
||||
self.siteReload(siteInfo)
|
||||
self.saveSiteConfig(siteInfo)
|
||||
return mw.returnJson(True, '添加成功!')
|
||||
|
||||
def remove_excloud(self):
|
||||
args = self.getArgs()
|
||||
check = self.checkArgs(args, ['siteName', 'excludePath'])
|
||||
if not check[0]:
|
||||
return check[1]
|
||||
|
||||
siteName = args['siteName']
|
||||
siteInfo = self.__getFind(siteName)
|
||||
excludePath = args['excludePath'].strip()
|
||||
if excludePath == '':
|
||||
return mw.returnJson(False, '排除文件或目录不能为空')
|
||||
if not siteInfo:
|
||||
return mw.returnJson(False, '指定站点不存在!')
|
||||
|
||||
for excludePath in excludePath.split(','):
|
||||
if not excludePath:
|
||||
continue
|
||||
if not excludePath in siteInfo['excludePath']:
|
||||
continue
|
||||
siteInfo['excludePath'].remove(excludePath)
|
||||
self.writeLog('站点[%s]从排除列表中删除目录名[%s]' %
|
||||
(siteInfo['siteName'], excludePath))
|
||||
self.siteReload(siteInfo)
|
||||
self.saveSiteConfig(siteInfo)
|
||||
return mw.returnJson(True, '删除成功!')
|
||||
|
||||
def sim_test(self):
|
||||
args = self.getArgs()
|
||||
check = self.checkArgs(args, ['path'])
|
||||
if not check[0]:
|
||||
return check[1]
|
||||
|
||||
path = args['path'].strip()
|
||||
if not os.path.exists(path):
|
||||
return mw.returnJson(False, "此目录不存在")
|
||||
|
||||
# 判断是否安装php
|
||||
import site_api
|
||||
php_version = site_api.site_api().getPhpVersion()
|
||||
if not php_version:
|
||||
return mw.returnJson(False, "未安装PHP测试失败")
|
||||
|
||||
php_path = '/www/server/php/' + php_version[1]['version'] + '/bin/php'
|
||||
php_name = path + "/" + str(int(time.time())) + ".php"
|
||||
if os.path.exists(php_name):
|
||||
mw.execShell("rm -rf %s" % php_name)
|
||||
# 写入
|
||||
cmd = php_path + \
|
||||
" -r \"file_put_contents('{}','{}');\"".format(php_name, php_name)
|
||||
mw.execShell(cmd)
|
||||
time.sleep(0.5)
|
||||
if os.path.exists(php_name):
|
||||
if os.path.exists(php_name):
|
||||
mw.execShell("rm -rf %s" % php_name)
|
||||
return mw.returnJson(False, "拦截失败,可能未开启防篡改")
|
||||
return mw.returnJson(True, "拦截成功")
|
||||
|
||||
def set_site_status_all(self):
|
||||
args = self.getArgs()
|
||||
check = self.checkArgs(args, ['siteNames', 'siteState'])
|
||||
if not check[0]:
|
||||
return check[1]
|
||||
|
||||
sites = self.getSites()
|
||||
siteState = True if args['siteState'] == '1' else False
|
||||
siteNames = json.loads(args['siteNames'])
|
||||
m_logs = {True: '开启', False: '关闭'}
|
||||
for i in range(len(sites)):
|
||||
if sites[i]['siteName'] in siteNames:
|
||||
sites[i]['open'] = siteState
|
||||
self.writeLog('%s站点[%s]防篡改保护' %
|
||||
(m_logs[siteState], sites[i]['siteName']))
|
||||
self.writeSites(sites)
|
||||
return mw.returnJson(True, '批量设置成功')
|
||||
|
||||
def get_index(self):
|
||||
self.syncSites()
|
||||
args = self.getArgs()
|
||||
day = None
|
||||
if 'day' in args:
|
||||
day = args['day']
|
||||
|
||||
ser_status = self.status()
|
||||
ser_status_bool = False
|
||||
if ser_status == 'start':
|
||||
ser_status_bool = True
|
||||
data = {}
|
||||
data['open'] = ser_status_bool
|
||||
data['total'] = self.getTotal()
|
||||
data['sites'] = self.getSites()
|
||||
for i in range(len(data['sites'])):
|
||||
data['sites'][i]['total'] = self.getTotal(
|
||||
data['sites'][i]['siteName'], day)
|
||||
return mw.returnJson(True, 'ok', data)
|
||||
|
||||
def get_speed(self):
|
||||
print("12")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
func = sys.argv[1]
|
||||
classApp = App()
|
||||
try:
|
||||
data = eval("classApp." + func + "()")
|
||||
print(data)
|
||||
except Exception as e:
|
||||
print(mw.getTracebackInfo())
|
||||
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"title": "网站防篡改程序[PY]",
|
||||
"tip": "lib",
|
||||
"name": "tamper_proof_py",
|
||||
"type": "soft",
|
||||
"ps": "事件型防篡改程序,可有效保护网站重要文件不被木马篡改",
|
||||
"versions": "1.0",
|
||||
"shell": "install.sh",
|
||||
"checks": "server/tamper_proof_py",
|
||||
"path": "server/tamper_proof_py",
|
||||
"author": "midoks",
|
||||
"home": "",
|
||||
"date":"2022-01-18",
|
||||
"pid":"4"
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
[Unit]
|
||||
Description=tamper_proof_py server daemon
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=forking
|
||||
ExecStart={$SERVER_PATH}/init.d/tamper_proof_py start
|
||||
ExecStop={$SERVER_PATH}/init.d/tamper_proof_py stop
|
||||
ExecReload={$SERVER_PATH}/init.d/tamper_proof_py reload
|
||||
ExecRestart={$SERVER_PATH}/init.d/tamper_proof_py restart
|
||||
KillMode=process
|
||||
Restart=on-failure
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
@@ -0,0 +1,95 @@
|
||||
#!/bin/bash
|
||||
# chkconfig: 2345 55 25
|
||||
# description:tamper_proof_service
|
||||
|
||||
### BEGIN INIT INFO
|
||||
# Provides: tamper_proof_service
|
||||
# Required-Start: $all
|
||||
# Required-Stop: $all
|
||||
# Default-Start: 2 3 4 5
|
||||
# Default-Stop: 0 1 6
|
||||
# Short-Description: starts tamper_proof_service
|
||||
# Description: starts the tamper_proof_service
|
||||
### END INIT INFO
|
||||
|
||||
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
|
||||
mw_path={$SERVER_PATH}
|
||||
rootPath=$(dirname "$mw_path")
|
||||
PATH=$PATH:$mw_path/bin
|
||||
|
||||
if [ -f $rootPath/mdserver-web/bin/activate ];then
|
||||
source $rootPath/mdserver-web/bin/activate
|
||||
fi
|
||||
|
||||
# cd /www/server/mdserver-web && python3 plugins/tamper_proof_py/tamper_proof_service.py start
|
||||
sys_start()
|
||||
{
|
||||
isStart=$(ps aux |grep -E "(tamper_proof_service)"|grep -v grep |grep -v 'tamper_proof_py/tamper_proof_service.py start' | grep -v 'tamper_proof_py/tamper_proof_service.py reload' | grep -v 'tamper_proof_py/tamper_proof_service.py restart' | grep -v systemctl | grep -v '/bin/sh' | grep -v '/bin/bash' | awk '{print $2}'|xargs)
|
||||
if [ "$isStart" == '' ];then
|
||||
echo -e "Starting tamper_proof_service... \c"
|
||||
cd $rootPath/mdserver-web
|
||||
nohup python3 plugins/tamper_proof_py/tamper_proof_service.py start &> $mw_path/service.log &
|
||||
sleep 0.5
|
||||
isStart=$(ps aux |grep -E "(tamper_proof_service)"|grep -v grep|awk '{print $2}'|xargs)
|
||||
if [ "$isStart" == '' ];then
|
||||
echo -e "\033[31mfailed\033[0m"
|
||||
echo '------------------------------------------------------'
|
||||
cat $mw_path/service.log
|
||||
echo '------------------------------------------------------'
|
||||
echo -e "\033[31mError: tamper_proof_service startup failed.\033[0m"
|
||||
return;
|
||||
fi
|
||||
echo -e "\033[32mdone\033[0m"
|
||||
else
|
||||
echo "Starting tamper_proof_service (pid $isStart) already running"
|
||||
fi
|
||||
}
|
||||
|
||||
sys_stop()
|
||||
{
|
||||
echo -e "Stopping tamper_proof_service... \c";
|
||||
pids=$(ps aux |grep -E "(tamper_proof_service)"|grep -v grep|grep -v '/bin/bash'|grep -v systemctl | grep -v 'tamper_proof_py/tamper_proof_service.py stop' | grep -v 'tamper_proof_py/tamper_proof_service.py reload' | grep -v 'tamper_proof_py/tamper_proof_service.py restart' |awk '{print $2}'|xargs)
|
||||
arr=($pids)
|
||||
for p in ${arr[@]}
|
||||
do
|
||||
kill -9 $p
|
||||
done
|
||||
cd $rootPath/mdserver-web
|
||||
python3 plugins/tamper_proof_py/tamper_proof_service.py stop
|
||||
echo -e "\033[32mdone\033[0m"
|
||||
}
|
||||
|
||||
sys_status()
|
||||
{
|
||||
isStart=$(ps aux |grep -E "(tamper_proof_service)"|grep -v grep|grep -v "init.d/tamper_proof_py"|grep -v systemctl|awk '{print $2}'|xargs)
|
||||
if [ "$isStart" != '' ];then
|
||||
echo -e "\033[32mtamper_proof_service (pid $isStart) already running\033[0m"
|
||||
else
|
||||
echo -e "\033[32mtamper_proof_service not running\033[0m"
|
||||
fi
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
'start')
|
||||
sys_start
|
||||
;;
|
||||
'stop')
|
||||
sys_stop
|
||||
;;
|
||||
'restart')
|
||||
sys_stop
|
||||
sleep 0.2
|
||||
sys_start
|
||||
;;
|
||||
'reload')
|
||||
sys_stop
|
||||
sleep 0.2
|
||||
sys_start
|
||||
;;
|
||||
'status')
|
||||
sys_status
|
||||
;;
|
||||
*)
|
||||
echo "Usage: systemctl {start|stop|restart|reload} tamper_proof_service"
|
||||
;;
|
||||
esac
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user