mirror of
https://github.com/midoks/mdserver-web.git
synced 2026-10-10 20:59:26 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
19f9390020 | ||
|
|
10a4401259 | ||
|
|
ed7ab76cd6 | ||
|
|
ccfe1bac74 | ||
|
|
0c2071bc5d | ||
|
|
2d503ab05a | ||
|
|
0f204b48dd | ||
|
|
ac586267c5 | ||
|
|
897619f126 | ||
|
|
5fef08797d | ||
|
|
b43c3a7294 | ||
|
|
423b145b7f | ||
|
|
93333a4915 | ||
|
|
b3708abcb6 | ||
|
|
f8c2580773 | ||
|
|
4609d5588d | ||
|
|
cbeb44779f | ||
|
|
7c848aa372 | ||
|
|
015fca8145 | ||
|
|
54cc5fbad5 | ||
|
|
66f66dd408 | ||
|
|
24de9d5988 | ||
|
|
7dc5fdc88e | ||
|
|
2f912b4ddd | ||
|
|
0931cb9f9c | ||
|
|
bc98a80de6 | ||
|
|
9e3ad237b5 | ||
|
|
40a6ce7aa7 | ||
|
|
85bedbf56b | ||
|
|
5575710d7e | ||
|
|
df442f7fff | ||
|
|
89e665b369 | ||
|
|
42f845a7e2 | ||
|
|
a226bc9fbb | ||
|
|
b2f9935abb | ||
|
|
d8a22ba5ee | ||
|
|
be09821778 | ||
|
|
4f0f440f2c | ||
|
|
9cd46a7f9f | ||
|
|
66c875584f | ||
|
|
f14d2fddc7 | ||
|
|
fa2dda6ee4 | ||
|
|
73c8117a67 | ||
|
|
5f42e94da7 | ||
|
|
c31a95dd4b | ||
|
|
19ec0ddcb9 | ||
|
|
5e24086476 | ||
|
|
72934000b0 | ||
|
|
8a240e2c9c | ||
|
|
9f081359b0 | ||
|
|
679a1f0d05 | ||
|
|
4533e87bef | ||
|
|
47a60b41a8 | ||
|
|
b06100d0dc | ||
|
|
e5591cc59e | ||
|
|
9831216ca4 | ||
|
|
57e36c5fdb | ||
|
|
35904bd79d | ||
|
|
f16a2a7fec | ||
|
|
0b4b8a62aa | ||
|
|
ca4fa30cdb | ||
|
|
90c024dfe5 | ||
|
|
e634c44797 | ||
|
|
8eea4072f6 | ||
|
|
a0886e1a3d | ||
|
|
b93d77c907 | ||
|
|
a148e27211 | ||
|
|
3cd9b52d2a | ||
|
|
37206916e4 | ||
|
|
d36d2fa4b4 | ||
|
|
4591c9006b | ||
|
|
5b4ceb49df | ||
|
|
ba937c1e77 | ||
|
|
2b77254322 | ||
|
|
b27cb78f62 | ||
|
|
106af5b177 | ||
|
|
4b31160670 | ||
|
|
0593be9928 | ||
|
|
6602119ee7 | ||
|
|
2943d1f1b7 | ||
|
|
485ab6793c | ||
|
|
164a450784 | ||
|
|
f12db7e55f | ||
|
|
23e000afb3 | ||
|
|
5c77dd91e7 | ||
|
|
1c4140daec | ||
|
|
ad1035547d | ||
|
|
e61be60f71 | ||
|
|
9d6db1e847 | ||
|
|
76a417fee7 | ||
|
|
9e836148bb | ||
|
|
8d32e404e7 | ||
|
|
fb3b0f0ae6 | ||
|
|
6ad415fa5a | ||
|
|
79d2cc26b0 | ||
|
|
df0ad48348 | ||
|
|
b1024d1da1 | ||
|
|
5db1ad1535 | ||
|
|
b45fef8b0b | ||
|
|
22d4a9a809 | ||
|
|
0478356ea5 | ||
|
|
45e35c4396 | ||
|
|
eb5079a5ef | ||
|
|
a62e01e02e | ||
|
|
c58db08e5f | ||
|
|
6476fe1d2c | ||
|
|
8ea34d5736 | ||
|
|
4d4f43fa93 | ||
|
|
3e7b2ee6c1 | ||
|
|
0d16d3abf1 | ||
|
|
3923ea9dd6 | ||
|
|
e1292620c7 | ||
|
|
4e2b2e1f54 | ||
|
|
fcf75b652c | ||
|
|
9765b51969 | ||
|
|
0769183f61 | ||
|
|
845cc1a2ef | ||
|
|
16a95c12b4 | ||
|
|
0516aeb94f | ||
|
|
6b92ecebf9 | ||
|
|
9010c71051 | ||
|
|
fcca331224 | ||
|
|
e3a2f76f78 | ||
|
|
7e221454a3 | ||
|
|
ebecffca03 | ||
|
|
42f99fd7a2 | ||
|
|
b31ab0ae16 | ||
|
|
bec041aa01 | ||
|
|
8ded811295 | ||
|
|
f1c0b9f1ed | ||
|
|
d32a371b3a | ||
|
|
c0860cd275 | ||
|
|
bfd125fc4f | ||
|
|
a115ab28ba | ||
|
|
d21b126401 | ||
|
|
410bf03682 | ||
|
|
0a9f3de5c3 | ||
|
|
0ecadb918b | ||
|
|
e90b055f12 | ||
|
|
02877dc23c | ||
|
|
e22439af4c | ||
|
|
298c777971 | ||
|
|
39cf12f51a | ||
|
|
276bc480cf | ||
|
|
f0b2820034 | ||
|
|
ba65103df4 | ||
|
|
ae64b70f10 | ||
|
|
56ea2dd6f4 | ||
|
|
1633b9fca7 | ||
|
|
cb7a79953f | ||
|
|
5c12d9d6a6 | ||
|
|
244ae40969 | ||
|
|
e2b7fec286 | ||
|
|
4cc2bc16c0 | ||
|
|
24a4872058 | ||
|
|
91a9788706 | ||
|
|
2a6ef8853d | ||
|
|
56358508c8 | ||
|
|
976b94464e | ||
|
|
d166a0ccfb | ||
|
|
7c5c389629 | ||
|
|
f447b527eb | ||
|
|
a251714989 | ||
|
|
ea27f817e3 | ||
|
|
b6fb47fc16 | ||
|
|
fa540d516d | ||
|
|
4b068d2a52 | ||
|
|
50f5289e2e | ||
|
|
1ba20a4ea7 | ||
|
|
e18067b2f0 | ||
|
|
025f19728f | ||
|
|
248496021a | ||
|
|
d56a73f0f7 | ||
|
|
a2b68ebce1 | ||
|
|
93b92f2b17 | ||
|
|
f5219bf79b | ||
|
|
cc1d99d9c9 | ||
|
|
f7101db942 | ||
|
|
97ae9d17bf | ||
|
|
a5624e7e3c | ||
|
|
0be42900c1 | ||
|
|
9722e1ca64 | ||
|
|
63a20506a0 | ||
|
|
9b334e416f | ||
|
|
7805956cdf | ||
|
|
04ffd0ad45 | ||
|
|
f6e7055c2b | ||
|
|
77167655e8 | ||
|
|
24e2d0a3db | ||
|
|
29795074fe | ||
|
|
e017675b4d | ||
|
|
74a9897deb | ||
|
|
f593e77d35 | ||
|
|
8b9ab7f0b8 | ||
|
|
02951833cc | ||
|
|
08e300d065 | ||
|
|
776e4c2418 | ||
|
|
cbe439815d | ||
|
|
5c43222e4f | ||
|
|
a6fe7e2fe3 | ||
|
|
6f6523836d | ||
|
|
650a57350c | ||
|
|
736b34e834 | ||
|
|
d29682fd19 | ||
|
|
59c9058426 | ||
|
|
dbd32201c5 | ||
|
|
55158a67fc | ||
|
|
49dfe99a14 | ||
|
|
165672f9fd | ||
|
|
3bf03aa0b2 | ||
|
|
8ccbe8e7a6 | ||
|
|
1d54f90c95 | ||
|
|
000de62093 | ||
|
|
7ed82a796a | ||
|
|
4ad7e4c3f3 | ||
|
|
e1c17d8926 | ||
|
|
47cc40d0dd | ||
|
|
1a66d91885 | ||
|
|
01fbe11831 | ||
|
|
d834965d79 | ||
|
|
b6eeb79500 | ||
|
|
460d6c4e02 | ||
|
|
c6089bd480 | ||
|
|
3d18d4bc6f | ||
|
|
61954b820f | ||
|
|
dee67c6ea2 | ||
|
|
2fdaf1d482 | ||
|
|
8af986a4c5 | ||
|
|
c3a13b66e6 | ||
|
|
78111fd408 | ||
|
|
efeaa3f0b5 | ||
|
|
aed5e1aa63 | ||
|
|
44211065a0 | ||
|
|
364d38cc05 | ||
|
|
b38bfd7ada | ||
|
|
f05efd1693 | ||
|
|
c64b03135c | ||
|
|
860a50f025 | ||
|
|
5e9706ca23 | ||
|
|
d3d23fe7b9 | ||
|
|
af2aa2e083 | ||
|
|
bb52b17a12 | ||
|
|
17c68cb9b7 | ||
|
|
5c3fe16e9c | ||
|
|
81ce4e3445 | ||
|
|
9aaa5174bb | ||
|
|
8d9c89d281 | ||
|
|
62fa42f1ba | ||
|
|
502cb1595f | ||
|
|
c1e358e9fd | ||
|
|
7600ef1b30 | ||
|
|
b9057da526 | ||
|
|
99e143b686 | ||
|
|
0414f1f4de | ||
|
|
80f651d17a | ||
|
|
1a373eb876 | ||
|
|
5882b6b58e | ||
|
|
f876e56a2d | ||
|
|
ac98ec92e4 | ||
|
|
6cf6445c01 | ||
|
|
062a6def14 | ||
|
|
282a5451f8 | ||
|
|
b410f782e6 | ||
|
|
f4d997957c | ||
|
|
5551c7d341 | ||
|
|
642e028fca | ||
|
|
ffe5cd21e5 | ||
|
|
93679924f4 | ||
|
|
212e3c1066 | ||
|
|
ebd4baa6ff | ||
|
|
6d846144dc | ||
|
|
e9767ee6c7 | ||
|
|
b4a77f25f9 | ||
|
|
08098f48a0 | ||
|
|
478ebe95f0 | ||
|
|
bc48b85478 | ||
|
|
a5f7610230 | ||
|
|
98157bbc8b | ||
|
|
4e0792b139 | ||
|
|
a171970c96 | ||
|
|
38490fd462 | ||
|
|
b9726cc23f | ||
|
|
e047696fba | ||
|
|
bea5a0896a | ||
|
|
c15ddb64e8 | ||
|
|
e4e3cbd68e | ||
|
|
fd8b27d3f1 | ||
|
|
497a1632c0 | ||
|
|
5e991a9708 | ||
|
|
0e49874d38 | ||
|
|
a93b99bca7 | ||
|
|
4d541c175c | ||
|
|
588de95004 | ||
|
|
8850d73ea3 | ||
|
|
feca7c7d7c | ||
|
|
1507368ea7 | ||
|
|
ce74ec97fb | ||
|
|
1fd5e2c3f6 | ||
|
|
79e23fe0c7 | ||
|
|
ab0c62c73a | ||
|
|
e72de994ad | ||
|
|
364a84cc6d | ||
|
|
40072c6423 | ||
|
|
2d56f71588 | ||
|
|
d7a8b87473 | ||
|
|
7c8c2c655c | ||
|
|
8ea870b2a7 | ||
|
|
7e1317a400 | ||
|
|
6569a4af3b | ||
|
|
31ee85a523 | ||
|
|
acf6384318 | ||
|
|
539426d585 | ||
|
|
f8401414d3 | ||
|
|
e3cbdb9420 | ||
|
|
823126dad6 | ||
|
|
6d3c8d6679 | ||
|
|
da2ee9c6f4 | ||
|
|
0b4299d6c3 | ||
|
|
0830419658 | ||
|
|
85bfcd7447 | ||
|
|
729b7e0bcc | ||
|
|
4dbaf5d0f8 | ||
|
|
cbad208be6 | ||
|
|
f7992d8eae | ||
|
|
8c7c344ea9 | ||
|
|
2a52aa61c1 | ||
|
|
8d06bd94b8 | ||
|
|
8f53747515 | ||
|
|
d7a997052d | ||
|
|
324e98b639 | ||
|
|
7aebb728f8 | ||
|
|
c386a2a57a | ||
|
|
6e5c4917d9 | ||
|
|
d5d9ae51c5 | ||
|
|
ca39f0da3a | ||
|
|
41cdbb43fc | ||
|
|
6f3897886e | ||
|
|
6b1bfdfeca | ||
|
|
a07a37f256 | ||
|
|
896512cf3e | ||
|
|
60602e68f5 | ||
|
|
7066eb2632 | ||
|
|
ddfdebced2 | ||
|
|
4913cc9ed6 | ||
|
|
6427bb794d | ||
|
|
77bc7c85f8 | ||
|
|
54a90a2e99 | ||
|
|
e4a9c32caa | ||
|
|
13b9711d4a | ||
|
|
af15d6a592 | ||
|
|
132580ea6c | ||
|
|
262ab0ab73 | ||
|
|
1e19d70fa1 | ||
|
|
48b8d530ca | ||
|
|
1f35c5b8fa | ||
|
|
574b87f5b5 | ||
|
|
88be69ffc7 | ||
|
|
87e49e3244 | ||
|
|
4a392126cd | ||
|
|
c0489ebb44 | ||
|
|
ed65f63a37 | ||
|
|
2b4ff60de0 | ||
|
|
8069bf51ab | ||
|
|
369b53e2fd | ||
|
|
1cf0c1636b | ||
|
|
060fe39331 | ||
|
|
8bec4058e2 | ||
|
|
61d30d6f77 | ||
|
|
7daae8a129 | ||
|
|
ab2c9e450e | ||
|
|
24c269bf4c | ||
|
|
8f0c8fd800 | ||
|
|
a0e29a2bc2 | ||
|
|
94cab2e71a | ||
|
|
266b9fa5c2 | ||
|
|
31de8edc4a | ||
|
|
1e59eda9a9 | ||
|
|
36c3fcb395 | ||
|
|
ea8f0523d5 | ||
|
|
71625b7c0e | ||
|
|
408a62c755 |
@@ -36,7 +36,7 @@ Talk is cheap, show me the code. -- linus
|
||||
```
|
||||
|
||||
- [兼容性测试报告](/compatibility.md)
|
||||
- [常用命令说明](/cmd.md) [ mw default ] [ mw update_dev ]
|
||||
- [常用命令说明](/cmd.md) [ mw default ] [ mw dev ]
|
||||
|
||||
### 特别赞助
|
||||
|
||||
@@ -45,7 +45,7 @@ Talk is cheap, show me the code. -- linus
|
||||
### 主要插件介绍
|
||||
|
||||
* OpenResty - 轻量级,占有内存少,并发能力强。
|
||||
* PHP[53-84] - PHP是世界上最好的编程语言。
|
||||
* PHP[53-85] - PHP是世界上最好的编程语言。
|
||||
* MySQL - 一种关系数据库管理系统。
|
||||
* MariaDB - 是MySQL的一个重要分支。
|
||||
* MySQL[community] - 一种关系数据库管理系统。
|
||||
@@ -108,28 +108,23 @@ docker run -itd --name mw-server --privileged=true -p 7200:7200 -p 80:80 -p 443:
|
||||
```
|
||||
|
||||
|
||||
### 版本更新 0.18.0
|
||||
### 版本更新 0.18.2
|
||||
|
||||
- 重新架构面板。
|
||||
- PHP84正式版。
|
||||
- 加入alist插件。
|
||||
- 数据管理-常用命令。
|
||||
- 插件读取优化(加入缓存+定时检查状态)。
|
||||
- 恢复面板书签。
|
||||
- 常规更新。
|
||||
- 备份目录功能支持排除目录。
|
||||
- 其他细节优化。
|
||||
|
||||
### JSDelivr安装地址
|
||||
|
||||
- 初始安装
|
||||
|
||||
```
|
||||
curl --insecure -fsSL https://cdn.jsdelivr.net/gh/midoks/mdserver-web@latest/scripts/install.sh | bash
|
||||
bash <(curl --insecure -fsSL https://cdn.jsdelivr.net/gh/midoks/mdserver-web@latest/scripts/install.sh)
|
||||
```
|
||||
|
||||
- 直接更新
|
||||
|
||||
```
|
||||
curl --insecure -fsSL https://cdn.jsdelivr.net/gh/midoks/mdserver-web@latest/scripts/update.sh | bash
|
||||
bash <(curl --insecure -fsSL https://cdn.jsdelivr.net/gh/midoks/mdserver-web@latest/scripts/update.sh)
|
||||
```
|
||||
|
||||
- 卸载脚本
|
||||
@@ -143,14 +138,15 @@ wget --no-check-certificate -O uninstall.sh https://cdn.jsdelivr.net/gh/midoks/m
|
||||
- 初始安装
|
||||
|
||||
```
|
||||
curl --insecure -fsSL https://raw.githubusercontent.com/midoks/mdserver-web/master/scripts/install.sh | bash
|
||||
curl --insecure -fsSL https://code.midoks.icu/midoks/mdserver-web/raw/branch/master/scripts/install.sh | bash
|
||||
|
||||
bash <(curl --insecure -fsSL https://raw.githubusercontent.com/midoks/mdserver-web/dev/scripts/install.sh)
|
||||
bash <(curl --insecure -fsSL https://code.midoks.icu/midoks/mdserver-web/raw/branch/master/scripts/install.sh)
|
||||
```
|
||||
|
||||
- 直接更新
|
||||
|
||||
```
|
||||
curl --insecure -fsSL https://raw.githubusercontent.com/midoks/mdserver-web/master/scripts/update.sh | bash
|
||||
bash <(curl --insecure -fsSL https://raw.githubusercontent.com/midoks/mdserver-web/master/scripts/update.sh)
|
||||
```
|
||||
|
||||
- 卸载脚本
|
||||
@@ -165,24 +161,30 @@ wget --no-check-certificate -O uninstall.sh https://raw.githubusercontent.com/mi
|
||||
- 需已经安装mdserver-web
|
||||
|
||||
```
|
||||
curl --insecure -fsSL https://raw.githubusercontent.com/midoks/mdserver-web/dev/scripts/quick/app.sh | bash
|
||||
bash <(curl --insecure -fsSL https://raw.githubusercontent.com/midoks/mdserver-web/dev/scripts/quick/app.sh)
|
||||
```
|
||||
|
||||
|
||||
### DEV使用
|
||||
|
||||
```
|
||||
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
|
||||
bash <(curl --insecure -fsSL https://raw.githubusercontent.com/midoks/mdserver-web/dev/scripts/install.sh)
|
||||
bash <(curl --insecure -fsSL https://raw.githubusercontent.com/midoks/mdserver-web/dev/scripts/update.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)
|
||||
|
||||
wget --no-check-certificate -O install.sh https://raw.githubusercontent.com/midoks/mdserver-web/dev/scripts/install.sh && bash install.sh
|
||||
|
||||
wget --no-check-certificate -O uninstall.sh https://raw.githubusercontent.com/midoks/mdserver-web/dev/scripts/uninstall.sh && bash uninstall.sh
|
||||
|
||||
curl --insecure -fsSL https://raw.githubusercontent.com/midoks/mdserver-web/dev/scripts/quick/debug.sh | bash
|
||||
bash <(curl --insecure -fsSL https://raw.githubusercontent.com/midoks/mdserver-web/dev/scripts/quick/debug.sh)
|
||||
|
||||
curl --insecure -fsSL https://code.midoks.icu/midoks/mdserver-web/raw/branch/dev/scripts/install_dev.sh | bash
|
||||
curl --insecure -fsSL https://code.midoks.icu/midoks/mdserver-web/raw/branch/dev/scripts/update_dev.sh | bash
|
||||
bash <(curl --insecure -fsSL https://code.midoks.icu/midoks/mdserver-web/raw/branch/dev/scripts/install.sh)
|
||||
bash <(curl --insecure -fsSL https://code.midoks.icu/midoks/mdserver-web/raw/branch/dev/scripts/update.sh)
|
||||
|
||||
bash <(curl --insecure -fsSL https://code.midoks.icu/midoks/mdserver-web/raw/branch/dev/scripts/install_dev.sh)
|
||||
bash <(curl --insecure -fsSL https://code.midoks.icu/midoks/mdserver-web/raw/branch/dev/scripts/update_dev.sh)
|
||||
```
|
||||
|
||||
### 旧版安装/更新
|
||||
@@ -199,7 +201,7 @@ cd /www/server/mdserver-web && rm -rf lib64
|
||||
cd /www/server/mdserver-web && rm -rf bin
|
||||
cd /www/server/mdserver-web && rm -rf include
|
||||
|
||||
mw update/mw update_dev
|
||||
mw update/mw update_dev/mw dev
|
||||
```
|
||||
|
||||
### 捐赠地址 USDT(TRC20)
|
||||
|
||||
@@ -89,6 +89,8 @@ def initConf():
|
||||
"/var/log/messages.*",
|
||||
"/var/log/debug.*",
|
||||
"/var/log/syslog.*",
|
||||
"/var/log/syslog",
|
||||
"/var/log/mail.*",
|
||||
"/var/log/btmp.*",
|
||||
"/var/log/sa/sa*",
|
||||
"/var/log/sysstat/sa*",
|
||||
|
||||
@@ -170,7 +170,7 @@ class nosqlMongodb():
|
||||
keys = ["bind_ip", "port"]
|
||||
|
||||
result['host'] = '127.0.0.1'
|
||||
rep = 'port\s*=\s*(.*)'
|
||||
rep = r'port\s*=\s*(.*)'
|
||||
ip_re = re.search(rep, mgdb_content)
|
||||
if ip_re:
|
||||
result['port'] = int(ip_re.groups()[0].strip())
|
||||
|
||||
@@ -4,5 +4,5 @@
|
||||
|
||||
### 安装
|
||||
```
|
||||
rm -rf /www/server/mdserver-web/plugins/dztasks && cd /www/server/mdserver-web/plugins && rm -rf dztasks && git clone https://github.com/mw-plugin/dztasks && cd dztasks && rm -rf .git && cd /www/server/mdserver-web/plugins/dztasks && bash install.sh install 1.1
|
||||
rm -rf /www/server/mdserver-web/plugins/dztasks && cd /www/server/mdserver-web/plugins && rm -rf dztasks && git clone https://github.com/mw-plugin/dztasks && cd dztasks && rm -rf .git && cd /www/server/mdserver-web/plugins/dztasks && bash install.sh install 1.2
|
||||
```
|
||||
|
||||
@@ -275,14 +275,39 @@ def getDzPort():
|
||||
tmp = re.search(rep, content)
|
||||
return tmp.groups()[0].strip()
|
||||
|
||||
def homePage():
|
||||
def getDzUsername():
|
||||
file = getConf()
|
||||
content = mw.readFile(file)
|
||||
rep = r'user\s*=\s*(.*)'
|
||||
tmp = re.search(rep, content)
|
||||
return tmp.groups()[0].strip()
|
||||
|
||||
def getDzPassword():
|
||||
file = getConf()
|
||||
content = mw.readFile(file)
|
||||
rep = r'pass\s*=\s*(.*)'
|
||||
tmp = re.search(rep, content)
|
||||
return tmp.groups()[0].strip()
|
||||
|
||||
def getHomePage():
|
||||
http_port = getDzPort()
|
||||
ip = mw.getLocalIp()
|
||||
if mw.isAppleSystem():
|
||||
ip = '127.0.0.1'
|
||||
url = 'http://'+ip+":"+str(http_port)
|
||||
# print(url)
|
||||
return mw.returnJson(True, 'ok!', url)
|
||||
return url
|
||||
|
||||
def homePage():
|
||||
return mw.returnJson(True, 'ok!', getHomePage())
|
||||
|
||||
|
||||
def runInfo():
|
||||
data = {}
|
||||
data['url'] = getHomePage()
|
||||
data['user'] = getDzUsername()
|
||||
data['pass'] = getDzPassword()
|
||||
|
||||
return mw.returnJson(True, 'ok!', data)
|
||||
|
||||
if __name__ == "__main__":
|
||||
func = sys.argv[1]
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
"name": "dztasks",
|
||||
"title": "dztasks",
|
||||
"shell": "install.sh",
|
||||
"versions":["1.1"],
|
||||
"versions":["1.2"],
|
||||
"tip": "soft",
|
||||
"checks": "server/dztasks",
|
||||
"path": "server/dztasks",
|
||||
|
||||
@@ -33,7 +33,7 @@ Install_App()
|
||||
mkdir -p $serverPath/source/dztasks
|
||||
mkdir -p $serverPath/dztasks
|
||||
|
||||
FILE_TGZ=dztasks_v${VERSION}_${DZ_NAME}_${DZ_ARCH_NAME}.tar.gz
|
||||
FILE_TGZ=dztasks_${VERSION}_${DZ_NAME}_${DZ_ARCH_NAME}.tar.gz
|
||||
DZ_DIR=$serverPath/source/dztasks
|
||||
|
||||
echo $FILE_TGZ
|
||||
|
||||
@@ -60,11 +60,47 @@ function commonHomePage(){
|
||||
});
|
||||
}
|
||||
|
||||
function postCrossPort(data, url) {
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open('POST', url, true);
|
||||
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
|
||||
xhr.onreadystatechange = function() {
|
||||
if(xhr.readyState == 4 && xhr.status == 200) {
|
||||
console.log(xhr.responseText);
|
||||
}
|
||||
};
|
||||
xhr.send(data);
|
||||
}
|
||||
|
||||
function dzLogin(){
|
||||
|
||||
zdPost('run_info', '', {}, function(data){
|
||||
var rdata = $.parseJSON(data.data);
|
||||
var info = rdata.data;
|
||||
var post_url = info['url']+'/do_login';
|
||||
|
||||
$("#toSite").attr('action',post_url);
|
||||
$("#username").val(info['user']);
|
||||
$("#password").val(info['pass']);
|
||||
layer.msg('正在打开dztasks',{icon:16,shade: [0.3, '#000'],time:2000});
|
||||
|
||||
setTimeout(function(){
|
||||
$("#toSite").submit();
|
||||
},2000);
|
||||
});
|
||||
}
|
||||
|
||||
function dzCommonFunc(){
|
||||
var con = '';
|
||||
con += '<hr/><p class="conf_p" style="text-align:center;">\
|
||||
<button class="btn btn-default btn-sm" onclick="commonHomePage()">主页</button>\
|
||||
<button class="btn btn-default btn-sm" onclick="commonHomePage()">主页</button> \
|
||||
<button class="btn btn-default btn-sm" onclick="dzLogin()">直接登陆</button>\
|
||||
</p>';
|
||||
|
||||
con += '<form id="toSite" action="" method="post" style="display: none;" target="_blank">\
|
||||
<input type="text" name="username" id="username" value="">\
|
||||
<input type="password" name="password" id="password" value="">\
|
||||
</form>';
|
||||
$(".soft-man-con").html(con);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"ps": "Gitea是一个开源社区驱动的轻量级代码托管解决方案。",
|
||||
"name": "gitea",
|
||||
"title": "Gitea",
|
||||
"versions": ["1.17.2","1.18.5","1.22.1"],
|
||||
"versions": ["1.17.2","1.18.5","1.22.1","1.24.3"],
|
||||
"tip": "soft",
|
||||
"install_pre_inspection":false,
|
||||
"uninstall_pre_inspection":true,
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 752 B |
Executable
+31
@@ -0,0 +1,31 @@
|
||||
<style>
|
||||
.overflow_hide {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
vertical-align: middle;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div class="bt-form">
|
||||
<div class='plugin_version'></div>
|
||||
<div class="bt-w-main">
|
||||
<div class="bt-w-menu">
|
||||
<p class="bgw" onclick="pluginService('grafana');">服务</p>
|
||||
<p onclick="pluginInitD('grafana');">自启动</p>
|
||||
<p onclick="gCommonFunc($('.plugin_version').attr('version'));">常用功能</p>
|
||||
<p onclick="pluginConfig('grafana',$('.plugin_version').attr('version'),'conf');">配置</p>
|
||||
<p onclick="pluginLogs('grafana','','run_log');">运行日志</p>
|
||||
<p onclick="gReadme();">相关说明</p>
|
||||
|
||||
</div>
|
||||
<div class="bt-w-con pd15">
|
||||
<div class="soft-man-con" style="height: 520px; overflow: auto;"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
$.getScript( "/plugins/file?name=grafana&f=js/grafana.js", function(){
|
||||
pluginService('grafana', $('.plugin_version').attr('version'));
|
||||
});
|
||||
</script>
|
||||
Executable
+235
@@ -0,0 +1,235 @@
|
||||
# coding:utf-8
|
||||
|
||||
import sys
|
||||
import io
|
||||
import os
|
||||
import time
|
||||
import re
|
||||
|
||||
web_dir = os.getcwd() + "/web"
|
||||
if os.path.exists(web_dir):
|
||||
sys.path.append(web_dir)
|
||||
os.chdir(web_dir)
|
||||
|
||||
import core.mw as mw
|
||||
|
||||
app_debug = False
|
||||
if mw.isAppleSystem():
|
||||
app_debug = True
|
||||
|
||||
|
||||
def getPluginName():
|
||||
return 'grafana'
|
||||
|
||||
|
||||
def getPluginDir():
|
||||
return mw.getPluginDir() + '/' + getPluginName()
|
||||
|
||||
|
||||
def getServerDir():
|
||||
return mw.getServerDir() + '/' + getPluginName()
|
||||
|
||||
|
||||
def getInitDFile():
|
||||
current_os = mw.getOs()
|
||||
if current_os == 'darwin':
|
||||
return '/tmp/' + getPluginName()
|
||||
|
||||
if current_os.startswith('freebsd'):
|
||||
return '/etc/rc.d/' + getPluginName()
|
||||
|
||||
return '/etc/init.d/' + getPluginName()
|
||||
|
||||
|
||||
def getConf():
|
||||
path = getServerDir() + "/conf/defaults.ini"
|
||||
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 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 getPidFile():
|
||||
file = getConf()
|
||||
content = mw.readFile(file)
|
||||
rep = r'pidfile\s*(.*)'
|
||||
tmp = re.search(rep, content)
|
||||
return tmp.groups()[0].strip()
|
||||
|
||||
def status():
|
||||
cmd = "ps aux|grep grafana |grep -v grep | grep -v python | grep -v mdserver-web | awk '{print $2}'"
|
||||
data = mw.execShell(cmd)
|
||||
if data[0] == '':
|
||||
return 'stop'
|
||||
return 'start'
|
||||
|
||||
def getInstallVerion():
|
||||
version_pl = getServerDir() + "/version.pl"
|
||||
version = mw.readFile(version_pl).strip()
|
||||
return version
|
||||
|
||||
def contentReplace(content):
|
||||
service_path = mw.getServerDir()
|
||||
content = content.replace('{$ROOT_PATH}', mw.getFatherDir())
|
||||
content = content.replace('{$SERVER_PATH}', service_path)
|
||||
return content
|
||||
|
||||
|
||||
def openPort():
|
||||
try:
|
||||
from utils.firewall import Firewall as MwFirewall
|
||||
MwFirewall.instance().addAcceptPort('3000', 'grafana', 'port')
|
||||
return port
|
||||
except Exception as e:
|
||||
return "Release failed {}".format(e)
|
||||
return True
|
||||
|
||||
|
||||
def initDreplace():
|
||||
# 初始化OP配置
|
||||
init_file = getServerDir() + '/init.pl'
|
||||
if not os.path.exists(init_file):
|
||||
openPort()
|
||||
mw.writeFile(init_file, 'ok')
|
||||
|
||||
# systemd
|
||||
systemDir = mw.systemdCfgDir()
|
||||
systemService = systemDir + '/' + getPluginName() + '.service'
|
||||
if os.path.exists(systemDir) and not os.path.exists(systemService):
|
||||
systemServiceTpl = getPluginDir() + '/init.d/' + getPluginName() + '.service.tpl'
|
||||
service_path = mw.getServerDir()
|
||||
content = mw.readFile(systemServiceTpl)
|
||||
content = content.replace('{$SERVER_PATH}', service_path)
|
||||
mw.writeFile(systemService, content)
|
||||
mw.execShell('systemctl daemon-reload')
|
||||
|
||||
return True
|
||||
|
||||
|
||||
def gOp(method):
|
||||
initDreplace()
|
||||
|
||||
data = mw.execShell('systemctl ' + method + ' '+getPluginName())
|
||||
mw.execShell('systemctl ' + method + ' '+getPluginName())
|
||||
if data[1] == '':
|
||||
return 'ok'
|
||||
return data[1]
|
||||
|
||||
|
||||
def start():
|
||||
return gOp('start')
|
||||
|
||||
def stop():
|
||||
return gOp('stop')
|
||||
|
||||
def restart():
|
||||
return gOp('restart')
|
||||
|
||||
def reload():
|
||||
return gOp('reload')
|
||||
|
||||
def initdStatus():
|
||||
current_os = mw.getOs()
|
||||
if current_os == 'darwin':
|
||||
return "Apple Computer does not support"
|
||||
|
||||
shell_cmd = 'systemctl status grafana|grep loaded|grep "enabled;"'
|
||||
data = mw.execShell(shell_cmd)
|
||||
if data[0] == '':
|
||||
return 'fail'
|
||||
return 'ok'
|
||||
|
||||
|
||||
def initdInstall():
|
||||
current_os = mw.getOs()
|
||||
if current_os == 'darwin':
|
||||
return "Apple Computer does not support"
|
||||
|
||||
data = mw.execShell('systemctl enable grafana')
|
||||
if data[1] != '':
|
||||
return data[1]
|
||||
return 'ok'
|
||||
|
||||
|
||||
def initdUinstall():
|
||||
current_os = mw.getOs()
|
||||
if current_os == 'darwin':
|
||||
return "Apple Computer does not support"
|
||||
|
||||
data = mw.execShell('systemctl disable grafana')
|
||||
if data[1] != '':
|
||||
return data[1]
|
||||
return 'ok'
|
||||
|
||||
def runLog():
|
||||
return getServerDir() + "/data/log/grafana.log"
|
||||
|
||||
def grafanaUrl():
|
||||
ip = mw.getLocalIp()
|
||||
return 'http://'+ip+':'+"3000"
|
||||
|
||||
def installPreInspection():
|
||||
return 'ok'
|
||||
|
||||
|
||||
def uninstallPreInspection():
|
||||
return 'ok'
|
||||
|
||||
|
||||
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 == 'install_pre_inspection':
|
||||
print(installPreInspection())
|
||||
elif func == 'uninstall_pre_inspection':
|
||||
print(uninstallPreInspection())
|
||||
elif func == 'conf':
|
||||
print(getConf())
|
||||
elif func == 'run_log':
|
||||
print(runLog())
|
||||
elif func == 'grafana_url':
|
||||
print(grafanaUrl())
|
||||
else:
|
||||
print('error')
|
||||
Executable
+17
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"sort": 7,
|
||||
"ps": "Grafana是查询、可视化、警报观测平台",
|
||||
"name": "grafana",
|
||||
"title": "grafana",
|
||||
"shell": "install.sh",
|
||||
"versions":["12.1.0"],
|
||||
"tip": "soft",
|
||||
"checks": "server/grafana",
|
||||
"path": "server/grafana",
|
||||
"display": 1,
|
||||
"author": "midoks",
|
||||
"date": "2025-08-01",
|
||||
"home": "https://grafana.com/grafana/download",
|
||||
"type": 0,
|
||||
"pid": "5"
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
[Unit]
|
||||
Description=Grafana instance
|
||||
Documentation=http://docs.grafana.org
|
||||
After=network-online.target
|
||||
[Service]
|
||||
Type=simple
|
||||
User=grafana
|
||||
Group=grafana
|
||||
Restart=on-failure
|
||||
ExecStart={$SERVER_PATH}/bin/grafana server --config={$SERVER_PATH}/grafana/conf/defa.defaults --homepath={$SERVER_PATH}/grafana
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
Executable
+85
@@ -0,0 +1,85 @@
|
||||
#!/bin/bash
|
||||
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin:/opt/homebrew/bin
|
||||
export PATH
|
||||
|
||||
# https://www.cnblogs.com/n00dle/p/16916044.html
|
||||
# cd /www/server/mdserver-web/plugins/grafana && /bin/bash install.sh install 12.1.0
|
||||
# cd /www/server/mdserver-web && python3 /www/server/mdserver-web/plugins/grafana/index.py start
|
||||
|
||||
curPath=`pwd`
|
||||
rootPath=$(dirname "$curPath")
|
||||
rootPath=$(dirname "$rootPath")
|
||||
serverPath=$(dirname "$rootPath")
|
||||
|
||||
VERSION=$2
|
||||
|
||||
sysArch=`arch`
|
||||
sysName=`uname`
|
||||
echo "use system: ${sysName}"
|
||||
|
||||
OSNAME=`bash ${rootPath}/scripts/getos.sh`
|
||||
if [ "" == "$OSNAME" ];then
|
||||
OSNAME=`cat ${rootPath}/data/osname.pl`
|
||||
fi
|
||||
|
||||
if [ "macos" == "$OSNAME" ];then
|
||||
echo "不支持Macox"
|
||||
exit
|
||||
fi
|
||||
|
||||
if [ -f ${rootPath}/bin/activate ];then
|
||||
source ${rootPath}/bin/activate
|
||||
fi
|
||||
|
||||
if id grafana &> /dev/null ;then
|
||||
echo "grafana uid is `id -u grafana`"
|
||||
echo "grafana shell is `grep "^grafana:" /etc/passwd |cut -d':' -f7 `"
|
||||
else
|
||||
groupadd grafana
|
||||
useradd -g grafana -s /bin/bash grafana
|
||||
fi
|
||||
|
||||
Install_App()
|
||||
{
|
||||
echo '正在安装脚本文件...'
|
||||
mkdir -p $serverPath/source/grafana
|
||||
|
||||
mkdir -p $serverPath/grafana
|
||||
echo "${VERSION}" > $serverPath/grafana/version.pl
|
||||
|
||||
shell_file=${curPath}/versions/${VERSION}/linux.sh
|
||||
|
||||
if [ -f $shell_file ];then
|
||||
bash -x $shell_file install ${VERSION}
|
||||
else
|
||||
echo '不支持...'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
#初始化
|
||||
cd ${rootPath} && python3 ${rootPath}/plugins/grafana/index.py start
|
||||
cd ${rootPath} && python3 ${rootPath}/plugins/grafana/index.py initd_install
|
||||
|
||||
echo 'Grafana安装完成'
|
||||
}
|
||||
|
||||
Uninstall_App()
|
||||
{
|
||||
shell_file=${curPath}/versions/${VERSION}/linux.sh
|
||||
if [ -f $shell_file ];then
|
||||
bash -x $shell_file uninstall ${VERSION}
|
||||
fi
|
||||
|
||||
cd ${rootPath} && python3 ${rootPath}/plugins/grafana/index.py stop
|
||||
cd ${rootPath} && python3 ${rootPath}/plugins/grafana/index.py initd_uninstall
|
||||
|
||||
rm -rf $serverPath/grafana
|
||||
echo 'Grafana卸载完成'
|
||||
}
|
||||
|
||||
action=$1
|
||||
if [ "${1}" == 'install' ];then
|
||||
Install_App
|
||||
else
|
||||
Uninstall_App
|
||||
fi
|
||||
Executable
+97
@@ -0,0 +1,97 @@
|
||||
function gPost(method, version, args,callback){
|
||||
var loadT = layer.msg('正在获取...', { icon: 16, time: 0, shade: 0.3 });
|
||||
|
||||
var req_data = {};
|
||||
req_data['name'] = 'grafana';
|
||||
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 gPostCallbak(method, version, args,callback){
|
||||
var loadT = layer.msg('正在获取...', { icon: 16, time: 0, shade: 0.3 });
|
||||
|
||||
var req_data = {};
|
||||
req_data['name'] = 'grafana';
|
||||
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 gCommonFunc(){
|
||||
var con = '<hr/><p class="conf_p" style="text-align:center;">\
|
||||
<button id="grafana_url" class="btn btn-default btn-sm">获取连接地址</button>\
|
||||
</p>';
|
||||
|
||||
$(".soft-man-con").html(con);
|
||||
|
||||
$('#grafana_url').click(function(){
|
||||
gPost('grafana_url', '', {}, function(rdata){
|
||||
layer.open({
|
||||
title: "Grafana连接",
|
||||
area: ['600px', '180px'],
|
||||
type:1,
|
||||
closeBtn: 1,
|
||||
shadeClose: false,
|
||||
btn:["复制","取消"],
|
||||
content: '<div class="pd15">\
|
||||
<div class="divtable">\
|
||||
<pre class="layui-code">'+rdata.data+'</pre>\
|
||||
</div>\
|
||||
</div>',
|
||||
success:function(){
|
||||
copyText(rdata.data);
|
||||
},
|
||||
yes:function(){
|
||||
copyText(rdata.data);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function gReadme(){
|
||||
var readme = '<ul class="help-info-text c7">';
|
||||
readme += '<li>初始化账户:admin/admin</li>';
|
||||
readme += '<li>https://grafana.com/grafana/download</li>';
|
||||
readme += '</ul>';
|
||||
|
||||
$('.soft-man-con').html(readme);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
#!/bin/bash
|
||||
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
|
||||
export PATH
|
||||
|
||||
curPath=`pwd`
|
||||
rootPath=$(dirname "$curPath")
|
||||
rootPath=$(dirname "$rootPath")
|
||||
serverPath=$(dirname "$rootPath")
|
||||
sourcePath=${serverPath}/source
|
||||
sysName=`uname`
|
||||
|
||||
SYS_VERSION_ID=`cat /etc/*-release | grep VERSION_ID | awk -F = '{print $2}' | awk -F "\"" '{print $2}'`
|
||||
|
||||
VERSION=$2
|
||||
|
||||
sysArch=`arch`
|
||||
sysName=`uname`
|
||||
|
||||
ARCH_NAME=amd64
|
||||
if [ "$sysArch" == "arm64" ];then
|
||||
ARCH_NAME=arm64
|
||||
elif [ "$sysArch" == "x86_64" ]; then
|
||||
ARCH_NAME=amd64
|
||||
elif [ "$sysArch" == "aarch64" ]; then
|
||||
ARCH_NAME=aarch64
|
||||
fi
|
||||
|
||||
FILE_TGZ=grafana-${VERSION}.linux-${ARCH_NAME}.tar.gz
|
||||
|
||||
# 检查是否通
|
||||
Install_App()
|
||||
{
|
||||
SourceDir=$serverPath/source/grafana
|
||||
InstallDir=$serverPath/grafana
|
||||
mkdir -p ${SourceDir}
|
||||
mkdir -p ${InstallDir}
|
||||
|
||||
if [ ! -f ${SourceDir}/${FILE_TGZ} ];then
|
||||
wget --no-check-certificate -O ${SourceDir}/${FILE_TGZ} https://dl.grafana.com/oss/release/${FILE_TGZ}
|
||||
fi
|
||||
|
||||
if [ ! -d $InstallDir/bin/grafana ];then
|
||||
cd ${SourceDir} && tar -zxvf ${FILE_TGZ}
|
||||
cd ${SourceDir}/grafana-v*
|
||||
cp -rf ./* $InstallDir
|
||||
fi
|
||||
|
||||
chown -R grafana:grafana $InstallDir
|
||||
}
|
||||
|
||||
Uninstall_App()
|
||||
{
|
||||
echo "卸载成功"
|
||||
}
|
||||
|
||||
action=${1}
|
||||
if [ "${1}" == 'install' ];then
|
||||
Install_App
|
||||
else
|
||||
Uninstall_App
|
||||
fi
|
||||
@@ -0,0 +1,69 @@
|
||||
auth_enabled: false
|
||||
|
||||
server:
|
||||
http_listen_port: 3100
|
||||
grpc_listen_port: 9096
|
||||
log_level: debug
|
||||
grpc_server_max_concurrent_streams: 1000
|
||||
|
||||
common:
|
||||
instance_addr: 127.0.0.1
|
||||
path_prefix: /tmp/loki
|
||||
storage:
|
||||
filesystem:
|
||||
chunks_directory: /tmp/loki/chunks
|
||||
rules_directory: /tmp/loki/rules
|
||||
replication_factor: 1
|
||||
ring:
|
||||
kvstore:
|
||||
store: inmemory
|
||||
|
||||
query_range:
|
||||
results_cache:
|
||||
cache:
|
||||
embedded_cache:
|
||||
enabled: true
|
||||
max_size_mb: 100
|
||||
|
||||
limits_config:
|
||||
metric_aggregation_enabled: true
|
||||
|
||||
schema_config:
|
||||
configs:
|
||||
- from: 2020-10-24
|
||||
store: tsdb
|
||||
object_store: filesystem
|
||||
schema: v13
|
||||
index:
|
||||
prefix: index_
|
||||
period: 24h
|
||||
|
||||
pattern_ingester:
|
||||
enabled: true
|
||||
metric_aggregation:
|
||||
loki_address: localhost:3100
|
||||
|
||||
ruler:
|
||||
alertmanager_url: http://localhost:9093
|
||||
|
||||
frontend:
|
||||
encoding: protobuf
|
||||
|
||||
query_engine:
|
||||
# 新版本有效参数
|
||||
max_concurrent: 20
|
||||
timeout: 3m
|
||||
|
||||
|
||||
# By default, Loki will send anonymous, but uniquely-identifiable usage and configuration
|
||||
# analytics to Grafana Labs. These statistics are sent to https://stats.grafana.org/
|
||||
#
|
||||
# Statistics help us better understand how Loki is used, and they show us performance
|
||||
# levels for most users. This helps us prioritize features and documentation.
|
||||
# For more information on what's sent, look at
|
||||
# https://github.com/grafana/loki/blob/main/pkg/analytics/stats.go
|
||||
# Refer to the buildReport method to see what goes into a report.
|
||||
#
|
||||
# If you would like to disable reporting, uncomment the following lines:
|
||||
#analytics:max_query_lookback
|
||||
# reporting_enabled: false
|
||||
@@ -0,0 +1,64 @@
|
||||
auth_enabled: false
|
||||
|
||||
server:
|
||||
http_listen_port: 3100
|
||||
grpc_listen_port: 9096
|
||||
log_level: debug
|
||||
grpc_server_max_concurrent_streams: 1000
|
||||
|
||||
common:
|
||||
instance_addr: 127.0.0.1
|
||||
path_prefix: {$APP_PATH}/loki
|
||||
storage:
|
||||
filesystem:
|
||||
chunks_directory: {$APP_PATH}/loki/chunks
|
||||
rules_directory: {$APP_PATH}/loki/rules
|
||||
replication_factor: 1
|
||||
ring:
|
||||
kvstore:
|
||||
store: inmemory
|
||||
|
||||
query_range:
|
||||
results_cache:
|
||||
cache:
|
||||
embedded_cache:
|
||||
enabled: true
|
||||
max_size_mb: 100
|
||||
|
||||
limits_config:
|
||||
metric_aggregation_enabled: true
|
||||
|
||||
schema_config:
|
||||
configs:
|
||||
- from: 2020-10-24
|
||||
store: tsdb
|
||||
object_store: filesystem
|
||||
schema: v13
|
||||
index:
|
||||
prefix: index_
|
||||
period: 24h
|
||||
|
||||
pattern_ingester:
|
||||
enabled: true
|
||||
metric_aggregation:
|
||||
loki_address: localhost:3100
|
||||
|
||||
ruler:
|
||||
alertmanager_url: http://localhost:9093
|
||||
|
||||
frontend:
|
||||
encoding: protobuf
|
||||
|
||||
|
||||
# By default, Loki will send anonymous, but uniquely-identifiable usage and configuration
|
||||
# analytics to Grafana Labs. These statistics are sent to https://stats.grafana.org/
|
||||
#
|
||||
# Statistics help us better understand how Loki is used, and they show us performance
|
||||
# levels for most users. This helps us prioritize features and documentation.
|
||||
# For more information on what's sent, look at
|
||||
# https://github.com/grafana/loki/blob/main/pkg/analytics/stats.go
|
||||
# Refer to the buildReport method to see what goes into a report.
|
||||
#
|
||||
# If you would like to disable reporting, uncomment the following lines:
|
||||
#analytics:
|
||||
# reporting_enabled: false
|
||||
@@ -0,0 +1,26 @@
|
||||
server:
|
||||
http_listen_port: 9080 #云服务器需开放9080端口
|
||||
grpc_listen_port: 0
|
||||
|
||||
positions:
|
||||
filename: {$APP_PATH}/positions.yaml #positions存放路径在promtail工具地址下
|
||||
|
||||
clients:
|
||||
- url: http://127.0.0.1:3100/loki/api/v1/push #修改为loki服务器IP
|
||||
|
||||
scrape_configs:
|
||||
- job_name: web
|
||||
static_configs:
|
||||
- targets:
|
||||
- localhost
|
||||
labels:
|
||||
job: "web"
|
||||
__path__: {$LOG_PATH}/web_nohup.out
|
||||
|
||||
- job_name: portal
|
||||
static_configs:
|
||||
- targets:
|
||||
- localhost
|
||||
labels:
|
||||
job: "portal"
|
||||
__path__: {$LOG_PATH}/portal_nohup.out
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 20 KiB |
Executable
+31
@@ -0,0 +1,31 @@
|
||||
<style>
|
||||
.overflow_hide {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
vertical-align: middle;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div class="bt-form">
|
||||
<div class='plugin_version'></div>
|
||||
<div class="bt-w-main">
|
||||
<div class="bt-w-menu">
|
||||
<p class="bgw" onclick="pluginService('loki');">服务</p>
|
||||
<p onclick="pluginInitD('loki');">自启动</p>
|
||||
<!-- <p onclick="gCommonFunc($('.plugin_version').attr('version'));">常用功能</p> -->
|
||||
<p onclick="pluginConfig('loki',$('.plugin_version').attr('version'),'conf');">Loki配置</p>
|
||||
<p onclick="pluginConfig('loki',$('.plugin_version').attr('version'),'promtail_conf');">Promtail配置</p>
|
||||
<p onclick="gReadme();">相关说明</p>
|
||||
|
||||
</div>
|
||||
<div class="bt-w-con pd15">
|
||||
<div class="soft-man-con" style="height: 520px; overflow: auto;"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
$.getScript( "/plugins/file?name=loki&f=js/loki.js", function(){
|
||||
pluginService('loki', $('.plugin_version').attr('version'));
|
||||
});
|
||||
</script>
|
||||
Executable
+287
@@ -0,0 +1,287 @@
|
||||
# coding:utf-8
|
||||
|
||||
import sys
|
||||
import io
|
||||
import os
|
||||
import time
|
||||
import re
|
||||
|
||||
web_dir = os.getcwd() + "/web"
|
||||
if os.path.exists(web_dir):
|
||||
sys.path.append(web_dir)
|
||||
os.chdir(web_dir)
|
||||
|
||||
import core.mw as mw
|
||||
|
||||
app_debug = False
|
||||
if mw.isAppleSystem():
|
||||
app_debug = True
|
||||
|
||||
|
||||
def getPluginName():
|
||||
return 'loki'
|
||||
|
||||
|
||||
def getPluginDir():
|
||||
return mw.getPluginDir() + '/' + getPluginName()
|
||||
|
||||
|
||||
def getServerDir():
|
||||
return mw.getServerDir() + '/' + getPluginName()
|
||||
|
||||
|
||||
def getInitDFile():
|
||||
current_os = mw.getOs()
|
||||
if current_os == 'darwin':
|
||||
return '/tmp/' + getPluginName()
|
||||
|
||||
if current_os.startswith('freebsd'):
|
||||
return '/etc/rc.d/' + getPluginName()
|
||||
|
||||
return '/etc/init.d/' + getPluginName()
|
||||
|
||||
|
||||
def getConf():
|
||||
path = getServerDir() + "/conf/loki-config.yaml"
|
||||
return path
|
||||
|
||||
def getPromtailConf():
|
||||
path = getServerDir() + "/conf/promtail-config.yaml"
|
||||
return path
|
||||
|
||||
def getConfTpl():
|
||||
path = getPluginDir() + "/conf/loki-config.yaml"
|
||||
return path
|
||||
|
||||
def getPromtailConfTpl():
|
||||
path = getPluginDir() + "/conf/promtail-config.yaml"
|
||||
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 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 getPidFile():
|
||||
file = getConf()
|
||||
content = mw.readFile(file)
|
||||
rep = r'pidfile\s*(.*)'
|
||||
tmp = re.search(rep, content)
|
||||
return tmp.groups()[0].strip()
|
||||
|
||||
def status():
|
||||
cmd = "ps aux|grep loki |grep -v grep | grep -v python | grep -v mdserver-web | awk '{print $2}'"
|
||||
data = mw.execShell(cmd)
|
||||
if data[0] == '':
|
||||
return 'stop'
|
||||
return 'start'
|
||||
|
||||
def getInstallVerion():
|
||||
version_pl = getServerDir() + "/version.pl"
|
||||
version = mw.readFile(version_pl).strip()
|
||||
return version
|
||||
|
||||
def contentReplace(content):
|
||||
service_path = mw.getServerDir()
|
||||
content = content.replace('{$ROOT_PATH}', mw.getFatherDir())
|
||||
content = content.replace('{$SERVER_PATH}', service_path)
|
||||
content = content.replace('{$APP_PATH}', service_path+"/loki")
|
||||
content = content.replace('{$LOG_PATH}', service_path+"/loki/logs")
|
||||
return content
|
||||
|
||||
|
||||
# def openPort():
|
||||
# try:
|
||||
# from utils.firewall import Firewall as MwFirewall
|
||||
# MwFirewall.instance().addAcceptPort('3000', 'grafana', 'port')
|
||||
# return port
|
||||
# except Exception as e:
|
||||
# return "Release failed {}".format(e)
|
||||
# return True
|
||||
|
||||
|
||||
def initDreplace():
|
||||
# 初始化OP配置
|
||||
init_file = getServerDir() + '/init.pl'
|
||||
if not os.path.exists(init_file):
|
||||
# openPort()
|
||||
mw.writeFile(init_file, 'ok')
|
||||
|
||||
conf_dir = getServerDir()+'/conf'
|
||||
if not os.path.exists(conf_dir):
|
||||
mw.execShell('mkdir -p ' + conf_dir)
|
||||
|
||||
file_tpl = getConfTpl()
|
||||
dst_file = getConf()
|
||||
if not os.path.exists(dst_file):
|
||||
content = mw.readFile(file_tpl)
|
||||
content = contentReplace(content)
|
||||
mw.writeFile(dst_file, content)
|
||||
|
||||
|
||||
file_tpl = getPromtailConfTpl()
|
||||
dst_file = getPromtailConf()
|
||||
if not os.path.exists(dst_file):
|
||||
content = mw.readFile(file_tpl)
|
||||
content = contentReplace(content)
|
||||
mw.writeFile(dst_file, content)
|
||||
|
||||
# systemd
|
||||
systemDir = mw.systemdCfgDir()
|
||||
systemService = systemDir + '/' + getPluginName() + '.service'
|
||||
if os.path.exists(systemDir) and not os.path.exists(systemService):
|
||||
systemServiceTpl = getPluginDir() + '/init.d/' + getPluginName() + '.service.tpl'
|
||||
service_path = mw.getServerDir()
|
||||
content = mw.readFile(systemServiceTpl)
|
||||
content = content.replace('{$SERVER_PATH}', service_path)
|
||||
mw.writeFile(systemService, content)
|
||||
mw.execShell('systemctl daemon-reload')
|
||||
|
||||
# systemd
|
||||
systemDir = mw.systemdCfgDir()
|
||||
systemService = systemDir + '/promtail.service'
|
||||
if os.path.exists(systemDir) and not os.path.exists(systemService):
|
||||
systemServiceTpl = getPluginDir() + '/init.d/promtail.service.tpl'
|
||||
service_path = mw.getServerDir()
|
||||
content = mw.readFile(systemServiceTpl)
|
||||
content = content.replace('{$SERVER_PATH}', service_path)
|
||||
mw.writeFile(systemService, content)
|
||||
mw.execShell('systemctl daemon-reload')
|
||||
|
||||
return True
|
||||
|
||||
|
||||
def gOp(method):
|
||||
initDreplace()
|
||||
|
||||
data = mw.execShell('systemctl ' + method + ' '+getPluginName())
|
||||
if data[1] != '':
|
||||
return data[1]
|
||||
|
||||
data = mw.execShell('systemctl ' + method + ' promtail')
|
||||
if data[1] != '':
|
||||
return data[1]
|
||||
return 'ok'
|
||||
|
||||
|
||||
def start():
|
||||
return gOp('start')
|
||||
|
||||
def stop():
|
||||
return gOp('stop')
|
||||
|
||||
def restart():
|
||||
return gOp('restart')
|
||||
|
||||
def reload():
|
||||
return gOp('reload')
|
||||
|
||||
def initdStatus():
|
||||
current_os = mw.getOs()
|
||||
if current_os == 'darwin':
|
||||
return "Apple Computer does not support"
|
||||
|
||||
shell_cmd = 'systemctl status loki|grep loaded|grep "enabled;"'
|
||||
data = mw.execShell(shell_cmd)
|
||||
if data[0] == '':
|
||||
return 'fail'
|
||||
|
||||
shell_cmd = 'systemctl status promtail|grep loaded|grep "enabled;"'
|
||||
data = mw.execShell(shell_cmd)
|
||||
if data[0] == '':
|
||||
return 'fail'
|
||||
return 'ok'
|
||||
|
||||
|
||||
def initdInstall():
|
||||
current_os = mw.getOs()
|
||||
if current_os == 'darwin':
|
||||
return "Apple Computer does not support"
|
||||
|
||||
data = mw.execShell('systemctl enable loki')
|
||||
if data[1] != '':
|
||||
return data[1]
|
||||
|
||||
data = mw.execShell('systemctl enable promtail')
|
||||
if data[1] != '':
|
||||
return data[1]
|
||||
return 'ok'
|
||||
|
||||
|
||||
def initdUinstall():
|
||||
current_os = mw.getOs()
|
||||
if current_os == 'darwin':
|
||||
return "Apple Computer does not support"
|
||||
|
||||
data = mw.execShell('systemctl disable loki')
|
||||
if data[1] != '':
|
||||
return data[1]
|
||||
|
||||
data = mw.execShell('systemctl enable promtail')
|
||||
if data[1] != '':
|
||||
return data[1]
|
||||
return 'ok'
|
||||
|
||||
def grafanaUrl():
|
||||
ip = mw.getLocalIp()
|
||||
return 'http://'+ip+':'+"3100"
|
||||
|
||||
def installPreInspection():
|
||||
return 'ok'
|
||||
|
||||
|
||||
def uninstallPreInspection():
|
||||
return 'ok'
|
||||
|
||||
|
||||
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 == 'install_pre_inspection':
|
||||
print(installPreInspection())
|
||||
elif func == 'uninstall_pre_inspection':
|
||||
print(uninstallPreInspection())
|
||||
elif func == 'conf':
|
||||
print(getConf())
|
||||
elif func == 'promtail_conf':
|
||||
print(getPromtailConf())
|
||||
elif func == 'grafana_url':
|
||||
print(grafanaUrl())
|
||||
else:
|
||||
print('error')
|
||||
Executable
+17
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"sort": 7,
|
||||
"ps": "Grafana/Loki是一个日志聚合系统",
|
||||
"name": "loki",
|
||||
"title": "loki",
|
||||
"shell": "install.sh",
|
||||
"versions":["3.5.3"],
|
||||
"tip": "soft",
|
||||
"checks": "server/loki",
|
||||
"path": "server/loki",
|
||||
"display": 1,
|
||||
"author": "midoks",
|
||||
"date": "2025-08-02",
|
||||
"home": "https://github.com/grafana/loki",
|
||||
"type": 0,
|
||||
"pid": "5"
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
[Unit]
|
||||
Description=Loki Log Aggregation System
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
ExecStart={$SERVER_PATH}/loki/bin/loki -config.file={$SERVER_PATH}/loki/conf/loki-config.yaml
|
||||
Restart=always
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
@@ -0,0 +1,10 @@
|
||||
[Unit]
|
||||
Description=Promtail System
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
ExecStart={$SERVER_PATH}/loki/bin/promtail -config.file={$SERVER_PATH}/loki/conf/promtail-config.yaml
|
||||
Restart=always
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
Executable
+84
@@ -0,0 +1,84 @@
|
||||
#!/bin/bash
|
||||
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin:/opt/homebrew/bin
|
||||
export PATH
|
||||
|
||||
# https://www.cnblogs.com/n00dle/p/16916044.html
|
||||
# cd /www/server/mdserver-web/plugins/loki && /bin/bash install.sh install 3.5.3
|
||||
# cd /www/server/mdserver-web && python3 /www/server/mdserver-web/plugins/loki/index.py start
|
||||
|
||||
curPath=`pwd`
|
||||
rootPath=$(dirname "$curPath")
|
||||
rootPath=$(dirname "$rootPath")
|
||||
serverPath=$(dirname "$rootPath")
|
||||
|
||||
VERSION=$2
|
||||
|
||||
sysArch=`arch`
|
||||
sysName=`uname`
|
||||
echo "use system: ${sysName}"
|
||||
|
||||
OSNAME=`bash ${rootPath}/scripts/getos.sh`
|
||||
if [ "" == "$OSNAME" ];then
|
||||
OSNAME=`cat ${rootPath}/data/osname.pl`
|
||||
fi
|
||||
|
||||
if [ "macos" == "$OSNAME" ];then
|
||||
echo "不支持Macox"
|
||||
exit
|
||||
fi
|
||||
|
||||
if [ -f ${rootPath}/bin/activate ];then
|
||||
source ${rootPath}/bin/activate
|
||||
fi
|
||||
|
||||
# if id grafana &> /dev/null ;then
|
||||
# echo "grafana uid is `id -u grafana`"
|
||||
# echo "grafana shell is `grep "^grafana:" /etc/passwd |cut -d':' -f7 `"
|
||||
# else
|
||||
# groupadd grafana
|
||||
# useradd -g grafana -s /bin/bash grafana
|
||||
# fi
|
||||
|
||||
Install_App()
|
||||
{
|
||||
echo '正在安装脚本文件...'
|
||||
mkdir -p $serverPath/source/grafana
|
||||
mkdir -p $serverPath/loki
|
||||
echo "${VERSION}" > $serverPath/loki/version.pl
|
||||
|
||||
shell_file=${curPath}/versions/${VERSION}/linux.sh
|
||||
|
||||
if [ -f $shell_file ];then
|
||||
bash -x $shell_file install ${VERSION}
|
||||
else
|
||||
echo '不支持...'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
#初始化
|
||||
cd ${rootPath} && python3 ${rootPath}/plugins/loki/index.py start
|
||||
cd ${rootPath} && python3 ${rootPath}/plugins/loki/index.py initd_install
|
||||
|
||||
echo 'Grafana/Loki安装完成'
|
||||
}
|
||||
|
||||
Uninstall_App()
|
||||
{
|
||||
shell_file=${curPath}/versions/${VERSION}/linux.sh
|
||||
if [ -f $shell_file ];then
|
||||
bash -x $shell_file uninstall ${VERSION}
|
||||
fi
|
||||
|
||||
cd ${rootPath} && python3 ${rootPath}/plugins/loki/index.py stop
|
||||
cd ${rootPath} && python3 ${rootPath}/plugins/loki/index.py initd_uninstall
|
||||
|
||||
rm -rf $serverPath/loki
|
||||
echo 'Grafana/Loki卸载完成'
|
||||
}
|
||||
|
||||
action=$1
|
||||
if [ "${1}" == 'install' ];then
|
||||
Install_App
|
||||
else
|
||||
Uninstall_App
|
||||
fi
|
||||
Executable
+96
@@ -0,0 +1,96 @@
|
||||
function gPost(method, version, args,callback){
|
||||
var loadT = layer.msg('正在获取...', { icon: 16, time: 0, shade: 0.3 });
|
||||
|
||||
var req_data = {};
|
||||
req_data['name'] = 'loki';
|
||||
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 gPostCallbak(method, version, args,callback){
|
||||
var loadT = layer.msg('正在获取...', { icon: 16, time: 0, shade: 0.3 });
|
||||
|
||||
var req_data = {};
|
||||
req_data['name'] = 'loki';
|
||||
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 gCommonFunc(){
|
||||
var con = '<hr/><p class="conf_p" style="text-align:center;">\
|
||||
<button id="grafana_url" class="btn btn-default btn-sm">获取连接地址</button>\
|
||||
</p>';
|
||||
|
||||
$(".soft-man-con").html(con);
|
||||
|
||||
$('#grafana_url').click(function(){
|
||||
gPost('grafana_url', '', {}, function(rdata){
|
||||
layer.open({
|
||||
title: "Grafana连接",
|
||||
area: ['600px', '180px'],
|
||||
type:1,
|
||||
closeBtn: 1,
|
||||
shadeClose: false,
|
||||
btn:["复制","取消"],
|
||||
content: '<div class="pd15">\
|
||||
<div class="divtable">\
|
||||
<pre class="layui-code">'+rdata.data+'</pre>\
|
||||
</div>\
|
||||
</div>',
|
||||
success:function(){
|
||||
copyText(rdata.data);
|
||||
},
|
||||
yes:function(){
|
||||
copyText(rdata.data);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function gReadme(){
|
||||
var readme = '<ul class="help-info-text c7">';
|
||||
readme += '<li>https://github.com/grafana/loki</li>';
|
||||
readme += '</ul>';
|
||||
|
||||
$('.soft-man-con').html(readme);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
#!/bin/bash
|
||||
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
|
||||
export PATH
|
||||
|
||||
curPath=`pwd`
|
||||
rootPath=$(dirname "$curPath")
|
||||
rootPath=$(dirname "$rootPath")
|
||||
serverPath=$(dirname "$rootPath")
|
||||
sourcePath=${serverPath}/source
|
||||
sysName=`uname`
|
||||
|
||||
SYS_VERSION_ID=`cat /etc/*-release | grep VERSION_ID | awk -F = '{print $2}' | awk -F "\"" '{print $2}'`
|
||||
|
||||
VERSION=$2
|
||||
|
||||
sysArch=`arch`
|
||||
sysName=`uname`
|
||||
|
||||
ARCH_NAME=amd64
|
||||
if [ "$sysArch" == "arm64" ];then
|
||||
ARCH_NAME=arm64
|
||||
elif [ "$sysArch" == "x86_64" ]; then
|
||||
ARCH_NAME=amd64
|
||||
elif [ "$sysArch" == "aarch64" ]; then
|
||||
ARCH_NAME=aarch64
|
||||
fi
|
||||
|
||||
FILE_TGZ=loki-linux-${ARCH_NAME}.zip
|
||||
PT_FILE_TGZ=promtail-linux-${ARCH_NAME}.zip
|
||||
|
||||
# 检查是否通
|
||||
Install_App()
|
||||
{
|
||||
SourceDir=$serverPath/source/grafana
|
||||
InstallDir=$serverPath/loki
|
||||
mkdir -p ${SourceDir}
|
||||
mkdir -p ${InstallDir}
|
||||
mkdir -p ${InstallDir}/bin
|
||||
mkdir -p ${InstallDir}/logs
|
||||
mkdir -p ${InstallDir}/data/{chunks,rules,boltdb-shipper-active,boltdb-shipper-cache}
|
||||
|
||||
if [ ! -f ${SourceDir}/${FILE_TGZ} ];then
|
||||
wget --no-check-certificate -O ${SourceDir}/${FILE_TGZ} https://github.com/grafana/loki/releases/download/v${VERSION}/${FILE_TGZ}
|
||||
fi
|
||||
|
||||
if [ ! -f ${SourceDir}/${PT_FILE_TGZ} ];then
|
||||
wget --no-check-certificate -O ${SourceDir}/${PT_FILE_TGZ} https://github.com/grafana/loki/releases/download/v${VERSION}/${PT_FILE_TGZ}
|
||||
fi
|
||||
|
||||
if [ ! -f $InstallDir/bin/loki ];then
|
||||
cd ${SourceDir} && unzip ${FILE_TGZ}
|
||||
cp -rf ./loki-linux-${ARCH_NAME} ${InstallDir}/bin/loki
|
||||
rm -rf ./loki-linux-${ARCH_NAME}
|
||||
fi
|
||||
|
||||
if [ ! -f $InstallDir/bin/promtail ];then
|
||||
cd ${SourceDir} && unzip ${PT_FILE_TGZ}
|
||||
cp -rf ./promtail-linux-${ARCH_NAME} ${InstallDir}/bin/promtail
|
||||
rm -rf ./promtail-linux-${ARCH_NAME}
|
||||
fi
|
||||
}
|
||||
|
||||
Uninstall_App()
|
||||
{
|
||||
echo "卸载成功"
|
||||
}
|
||||
|
||||
# StandardOutput=syslog
|
||||
# StandardError=syslog
|
||||
# SyslogIdentifier=loki
|
||||
|
||||
# # 资源限制 (根据服务器配置调整)
|
||||
# MemoryLimit=1G
|
||||
# CPUQuota=200%
|
||||
|
||||
curl -v -H "Content-Type: application/json" -XPOST "http://localhost:3100/loki/api/v1/push" \
|
||||
-d "{\"streams\": [{\"stream\": {\"test\": \"test\"}, \"values\": [[\"$timestamp\", \"test message\"]]}]}"
|
||||
|
||||
action=${1}
|
||||
if [ "${1}" == 'install' ];then
|
||||
Install_App
|
||||
else
|
||||
Uninstall_App
|
||||
fi
|
||||
@@ -0,0 +1,471 @@
|
||||
# coding:utf-8
|
||||
|
||||
import sys
|
||||
import io
|
||||
import os
|
||||
import time
|
||||
import subprocess
|
||||
import re
|
||||
import json
|
||||
|
||||
|
||||
web_dir = os.getcwd() + "/web"
|
||||
if os.path.exists(web_dir):
|
||||
sys.path.append(web_dir)
|
||||
os.chdir(web_dir)
|
||||
|
||||
import core.mw as mw
|
||||
|
||||
|
||||
def getServerDir():
|
||||
return mw.getServerDir() + '/mysql'
|
||||
|
||||
def getPluginDir():
|
||||
return mw.getPluginDir() + '/mysql'
|
||||
|
||||
def getConf():
|
||||
path = getServerDir() + '/etc/my.cnf'
|
||||
return path
|
||||
|
||||
def getDbPort():
|
||||
file = getConf()
|
||||
content = mw.readFile(file)
|
||||
rep = r'port\s*=\s*(.*)'
|
||||
tmp = re.search(rep, content)
|
||||
return tmp.groups()[0].strip()
|
||||
|
||||
def getSocketFile():
|
||||
file = getConf()
|
||||
content = mw.readFile(file)
|
||||
rep = r'socket\s*=\s*(.*)'
|
||||
tmp = re.search(rep, content)
|
||||
return tmp.groups()[0].strip()
|
||||
|
||||
def pSqliteDb(dbname='databases'):
|
||||
file = getServerDir() + '/mysql.db'
|
||||
name = 'mysql'
|
||||
|
||||
conn = mw.M(dbname).dbPos(getServerDir(), name)
|
||||
return conn
|
||||
|
||||
def pMysqlDb():
|
||||
# pymysql
|
||||
db = mw.getMyORM()
|
||||
|
||||
db.setPort(getDbPort())
|
||||
db.setSocket(getSocketFile())
|
||||
# db.setCharset("utf8")
|
||||
db.setPwd(pSqliteDb('config').where('id=?', (1,)).getField('mysql_root'))
|
||||
return db
|
||||
|
||||
class sphinxMake():
|
||||
|
||||
pdb = None
|
||||
psdb = None
|
||||
|
||||
pkey_name_cache = {}
|
||||
delta = 'sph_counter'
|
||||
ver = ''
|
||||
|
||||
|
||||
def __init__(self):
|
||||
self.pdb = pMysqlDb()
|
||||
|
||||
def setDeltaName(self, name):
|
||||
self.delta = name
|
||||
return True
|
||||
|
||||
def setVersion(self, ver):
|
||||
self.ver = ver
|
||||
|
||||
def createSql(self, db):
|
||||
conf = '''
|
||||
CREATE TABLE IF NOT EXISTS `{$DB_NAME}`.`{$TABLE_NAME}` (
|
||||
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`table` varchar(200) NOT NULL,
|
||||
`max_id` bigint(20) unsigned NOT NULL DEFAULT '0',
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `table_uniq` (`table`),
|
||||
KEY `table` (`table`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=1 CHARSET=utf8mb4;
|
||||
'''
|
||||
conf = conf.replace("{$TABLE_NAME}", self.delta)
|
||||
conf = conf.replace("{$DB_NAME}", db)
|
||||
return conf
|
||||
|
||||
def eqVerField(self, field):
|
||||
|
||||
if field == 'sql_attr_timestamp':
|
||||
return 'attr_bigint'
|
||||
|
||||
if field == 'sql_attr_bigint':
|
||||
return 'attr_bigint'
|
||||
|
||||
if field == 'sql_attr_float':
|
||||
return 'attr_float'
|
||||
|
||||
if field == 'sql_field_string':
|
||||
return 'field_string'
|
||||
|
||||
return field
|
||||
|
||||
def pathVerName(self):
|
||||
ver = self.ver.replace(".1",'')
|
||||
# if float(ver) >= 3.6:
|
||||
# return 'datadir'
|
||||
return 'path'
|
||||
|
||||
def getTablePk(self, db, table):
|
||||
key = db+'_'+table
|
||||
if key in self.pkey_name_cache:
|
||||
return self.pkey_name_cache[key]
|
||||
|
||||
# SHOW INDEX FROM bbs.bbs_ucenter_vars WHERE Key_name = 'PRIMARY'
|
||||
pkey_sql = "SHOW INDEX FROM {}.{} WHERE Key_name = 'PRIMARY';".format(db,table,);
|
||||
pkey_data = self.pdb.query(pkey_sql)
|
||||
|
||||
# print(db, table)
|
||||
# print(pkey_data)
|
||||
key = ''
|
||||
if len(pkey_data) == 1:
|
||||
pkey_name = pkey_data[0]['Column_name']
|
||||
sql = "select COLUMN_NAME,DATA_TYPE from information_schema.COLUMNS where `TABLE_SCHEMA`='{}' and `TABLE_NAME` = '{}' and `COLUMN_NAME`='{}';"
|
||||
sql = sql.format(db,table,pkey_name,)
|
||||
# print(sql)
|
||||
fields = self.pdb.query(sql)
|
||||
|
||||
if len(fields) == 1:
|
||||
# print(fields[0]['DATA_TYPE'])
|
||||
if mw.inArray(['bigint','smallint','tinyint','int','mediumint'], fields[0]['DATA_TYPE']):
|
||||
key = pkey_name
|
||||
return key
|
||||
|
||||
|
||||
def getTableFieldStr(self, db, table):
|
||||
sql = "select COLUMN_NAME,DATA_TYPE from information_schema.COLUMNS where `TABLE_SCHEMA`='{}' and `TABLE_NAME` = '{}';"
|
||||
sql = sql.format(db,table,)
|
||||
fields = self.pdb.query(sql)
|
||||
|
||||
field_str = ''
|
||||
for x in range(len(fields)):
|
||||
field_str += '`'+fields[x]['COLUMN_NAME']+'`,'
|
||||
|
||||
field_str = field_str.strip(',')
|
||||
return field_str
|
||||
|
||||
def makeSphinxHeader(self):
|
||||
conf = '''
|
||||
indexer {
|
||||
mem_limit = 1G
|
||||
}
|
||||
|
||||
searchd
|
||||
{
|
||||
listen = 127.0.0.1:9322
|
||||
listen = 127.0.0.1:9326:mysql
|
||||
listen = 127.0.0.1:9328:http
|
||||
log = /var/log/manticore/searchd.log
|
||||
query_log = /var/log/manticore/query.log
|
||||
pid_file = /var/run/manticore/searchd.pid
|
||||
}
|
||||
'''
|
||||
conf = conf.replace("{$server_dir}", mw.getServerDir())
|
||||
return conf
|
||||
|
||||
def makeSphinxDbSourceRangeSql(self, db, table):
|
||||
pkey_name = self.getTablePk(db,table)
|
||||
sql = "SELECT min("+pkey_name+"), max("+pkey_name+") FROM "+table
|
||||
return sql
|
||||
|
||||
def makeSphinxDbSourceQuerySql(self, db, table):
|
||||
pkey_name = self.getTablePk(db,table)
|
||||
field_str = self.getTableFieldStr(db,table)
|
||||
# print(field_str)
|
||||
if pkey_name == 'id':
|
||||
sql = "SELECT " + field_str + " FROM " + table + " where id >= $start AND id <= $end"
|
||||
else:
|
||||
sql = "SELECT `"+pkey_name+'` as `id`,' + field_str + " FROM " + table + " where "+pkey_name+" >= $start AND "+pkey_name+" <= $end"
|
||||
return sql
|
||||
|
||||
|
||||
def makeSphinxDbSourceDeltaRange(self, db, table):
|
||||
pkey_name = self.getTablePk(db,table)
|
||||
conf = "SELECT (SELECT max_id FROM `{$SPH_TABLE}` where `table`='{$TABLE_NAME}') as min, (SELECT max({$PK_NAME}) FROM {$TABLE_NAME}) as max"
|
||||
conf = conf.replace("{$DB_NAME}", db)
|
||||
conf = conf.replace("{$TABLE_NAME}", table)
|
||||
conf = conf.replace("{$SPH_TABLE}", self.delta)
|
||||
conf = conf.replace("{$PK_NAME}", pkey_name)
|
||||
return conf
|
||||
|
||||
def makeSphinxDbSourcePost(self, db, table):
|
||||
pkey_name = self.getTablePk(db,table)
|
||||
conf = "sql_query_post = UPDATE {$SPH_TABLE} SET max_id=(SELECT MAX({$PK_NAME}) FROM {$TABLE_NAME}) where `table`='{$TABLE_NAME}'"
|
||||
# conf = "REPLACE INTO {$SPH_TABLE} (`table`,`max_id`) VALUES ('{$TABLE_NAME}',(SELECT MAX({$PK_NAME}) FROM {$TABLE_NAME}))"
|
||||
conf = conf.replace("{$DB_NAME}", db)
|
||||
conf = conf.replace("{$TABLE_NAME}", table)
|
||||
conf = conf.replace("{$SPH_TABLE}", self.delta)
|
||||
conf = conf.replace("{$PK_NAME}", pkey_name)
|
||||
return conf
|
||||
|
||||
def makeSphinxDbSourceDelta(self, db, table):
|
||||
conf = '''
|
||||
source {$DB_NAME}_{$TABLE_NAME}_delta:{$DB_NAME}_{$TABLE_NAME}
|
||||
{
|
||||
sql_query_pre = SET NAMES utf8
|
||||
sql_query_range = {$DELTA_RANGE}
|
||||
sql_query = {$DELTA_QUERY}
|
||||
{$DELTA_UPDATE}
|
||||
|
||||
{$SPH_FIELD}
|
||||
}
|
||||
|
||||
index {$DB_NAME}_{$TABLE_NAME}_delta:{$DB_NAME}_{$TABLE_NAME}
|
||||
{
|
||||
source = {$DB_NAME}_{$TABLE_NAME}_delta
|
||||
{$PATH_NAME} = {$server_dir}/manticoresearch/index/db/{$DB_NAME}.{$TABLE_NAME}/delta
|
||||
|
||||
html_strip = 1
|
||||
ngram_len = 1
|
||||
|
||||
{$SPH_FIELD_INDEX}
|
||||
}
|
||||
''';
|
||||
conf = conf.replace("{$server_dir}", mw.getServerDir())
|
||||
conf = conf.replace("{$PATH_NAME}", self.pathVerName())
|
||||
|
||||
conf = conf.replace("{$DB_NAME}", db)
|
||||
conf = conf.replace("{$TABLE_NAME}", table)
|
||||
|
||||
delta_range = self.makeSphinxDbSourceDeltaRange(db, table)
|
||||
conf = conf.replace("{$DELTA_RANGE}", delta_range)
|
||||
|
||||
delta_query = self.makeSphinxDbSourceQuerySql(db, table)
|
||||
conf = conf.replace("{$DELTA_QUERY}", delta_query)
|
||||
|
||||
delta_update = self.makeSphinxDbSourcePost(db, table)
|
||||
conf = conf.replace("{$DELTA_UPDATE}", delta_update)
|
||||
|
||||
|
||||
sph_field = self.makeSqlToSphinxTable(db, table)
|
||||
conf = self.makeSphinxDbFieldRepalce(conf, sph_field)
|
||||
|
||||
return conf;
|
||||
|
||||
def makeSphinxDbSource(self, db, table, create_sphinx_table = False):
|
||||
db_info = pSqliteDb('databases').field('username,password').where('name=?', (db,)).find()
|
||||
port = getDbPort()
|
||||
|
||||
conf = '''
|
||||
source {$DB_NAME}_{$TABLE_NAME}
|
||||
{
|
||||
type = mysql
|
||||
sql_host = 127.0.0.1
|
||||
sql_user = {$DB_USER}
|
||||
sql_pass = {$DB_PASS}
|
||||
sql_db = {$DB_NAME}
|
||||
sql_port = {$DB_PORT}
|
||||
|
||||
sql_query_pre = SET NAMES utf8
|
||||
|
||||
{$UPDATE}
|
||||
|
||||
sql_query_range = {$DB_RANGE_SQL}
|
||||
sql_range_step = 1000
|
||||
|
||||
sql_query = {$DB_QUERY_SQL}
|
||||
|
||||
{$SPH_FIELD}
|
||||
}
|
||||
|
||||
index {$DB_NAME}_{$TABLE_NAME}
|
||||
{
|
||||
source = {$DB_NAME}_{$TABLE_NAME}
|
||||
{$PATH_NAME} = {$server_dir}/manticoresearch/index/db/{$DB_NAME}.{$TABLE_NAME}/index
|
||||
|
||||
ngram_len = 1
|
||||
|
||||
{$SPH_FIELD_INDEX}
|
||||
}
|
||||
'''
|
||||
conf = conf.replace("{$server_dir}", mw.getServerDir())
|
||||
conf = conf.replace("{$PATH_NAME}", self.pathVerName())
|
||||
|
||||
conf = conf.replace("{$DB_NAME}", db)
|
||||
conf = conf.replace("{$TABLE_NAME}", table)
|
||||
conf = conf.replace("{$DB_USER}", db_info['username'])
|
||||
conf = conf.replace("{$DB_PASS}", db_info['password'])
|
||||
conf = conf.replace("{$DB_PORT}", port)
|
||||
|
||||
range_sql = self.makeSphinxDbSourceRangeSql(db, table)
|
||||
conf = conf.replace("{$DB_RANGE_SQL}", range_sql)
|
||||
|
||||
query_sql = self.makeSphinxDbSourceQuerySql(db, table)
|
||||
conf = conf.replace("{$DB_QUERY_SQL}", query_sql)
|
||||
|
||||
sph_field = self.makeSqlToSphinxTable(db, table)
|
||||
# conf = conf.replace("{$SPH_FIELD}", sph_field)
|
||||
|
||||
|
||||
conf = self.makeSphinxDbFieldRepalce(conf, sph_field)
|
||||
|
||||
if create_sphinx_table:
|
||||
update = self.makeSphinxDbSourcePost(db, table)
|
||||
conf = conf.replace("{$UPDATE}", update)
|
||||
else:
|
||||
conf = conf.replace("{$UPDATE}", '')
|
||||
|
||||
if create_sphinx_table:
|
||||
sph_sql = self.createSql(db)
|
||||
self.pdb.query(sph_sql)
|
||||
sql_find = "select * from {}.{} where `table`='{}'".format(db,self.delta,table)
|
||||
find_data = self.pdb.query(sql_find)
|
||||
if len(find_data) == 0:
|
||||
insert_sql = "insert into `{}`.`{}`(`table`,`max_id`) values ('{}',{}) ".format(db,self.delta,table,0)
|
||||
# print(insert_sql)
|
||||
self.pdb.execute(insert_sql)
|
||||
conf += self.makeSphinxDbSourceDelta(db,table)
|
||||
|
||||
# print(ver)
|
||||
# print(conf)
|
||||
|
||||
return conf
|
||||
|
||||
def makeSphinxDbFieldRepalce(self, content, sph_field):
|
||||
|
||||
content = content.replace("{$SPH_FIELD}", '')
|
||||
content = content.replace("{$SPH_FIELD_INDEX}", '')
|
||||
|
||||
return content
|
||||
|
||||
|
||||
def makeSqlToSphinxDb(self, db, table = [], is_delta = False):
|
||||
conf = ''
|
||||
|
||||
|
||||
for tn in table:
|
||||
pkey_name = self.getTablePk(db,tn)
|
||||
if pkey_name == '':
|
||||
continue
|
||||
conf += self.makeSphinxDbSource(db, tn,is_delta)
|
||||
|
||||
if len(table) == 0:
|
||||
tables = self.pdb.query("show tables in "+ db)
|
||||
for x in range(len(tables)):
|
||||
key = 'Tables_in_'+db
|
||||
table_name = tables[x][key]
|
||||
pkey_name = self.getTablePk(db, table_name, is_delta)
|
||||
if pkey_name == '':
|
||||
continue
|
||||
|
||||
if self.makeSqlToSphinxTableIsHaveFulltext(db, table_name):
|
||||
conf += self.makeSphinxDbSource(db, table_name)
|
||||
return conf
|
||||
|
||||
def makeSqlToSphinxTableIsHaveFulltext(self, db, table):
|
||||
sql = "select COLUMN_NAME,DATA_TYPE from information_schema.COLUMNS where `TABLE_SCHEMA`='{}' and `TABLE_NAME` = '{}';"
|
||||
sql = sql.format(db,table,)
|
||||
cols = self.pdb.query(sql)
|
||||
cols_len = len(cols)
|
||||
|
||||
for x in range(cols_len):
|
||||
data_type = cols[x]['DATA_TYPE']
|
||||
column_name = cols[x]['COLUMN_NAME']
|
||||
|
||||
if mw.inArray(['varchar'], data_type):
|
||||
return True
|
||||
if mw.inArray(['text','mediumtext','tinytext','longtext'], data_type):
|
||||
return True
|
||||
return False
|
||||
|
||||
def makeSqlToSphinxTable(self,db,table):
|
||||
pkey_name = self.getTablePk(db,table)
|
||||
sql = "select COLUMN_NAME,DATA_TYPE from information_schema.COLUMNS where `TABLE_SCHEMA`='{}' and `TABLE_NAME` = '{}';"
|
||||
sql = sql.format(db,table,)
|
||||
cols = self.pdb.query(sql)
|
||||
cols_len = len(cols)
|
||||
conf = ''
|
||||
run_pos = 0
|
||||
for x in range(cols_len):
|
||||
data_type = cols[x]['DATA_TYPE']
|
||||
column_name = cols[x]['COLUMN_NAME']
|
||||
# print(column_name+":"+data_type)
|
||||
|
||||
# if mw.inArray(['tinyint'], data_type):
|
||||
# conf += 'sql_attr_bool = '+ column_name + "\n"
|
||||
|
||||
if pkey_name == column_name:
|
||||
# run_pos += 1
|
||||
# conf += '\tsql_attr_bigint = '+column_name+"\n"
|
||||
continue
|
||||
|
||||
if mw.inArray(['enum'], data_type):
|
||||
run_pos += 1
|
||||
conf += '\t'+self.eqVerField('sql_attr_string')+' = '+ column_name + "\n"
|
||||
continue
|
||||
|
||||
if mw.inArray(['decimal'], data_type):
|
||||
run_pos += 1
|
||||
conf += '\t'+self.eqVerField('sql_attr_float')+' = '+ column_name + "\n"
|
||||
continue
|
||||
|
||||
if mw.inArray(['bigint','smallint','tinyint','int','mediumint'], data_type):
|
||||
run_pos += 1
|
||||
conf += '\t'+self.eqVerField('sql_attr_bigint')+' = '+ column_name + "\n"
|
||||
continue
|
||||
|
||||
|
||||
if mw.inArray(['float'], data_type):
|
||||
run_pos += 1
|
||||
conf += '\t'+self.eqVerField('sql_attr_float')+' = '+ column_name + "\n"
|
||||
continue
|
||||
|
||||
if mw.inArray(['char'], data_type):
|
||||
conf += '\t'+self.eqVerField('sql_attr_string')+' = '+ column_name + "\n"
|
||||
continue
|
||||
|
||||
if mw.inArray(['varchar'], data_type):
|
||||
run_pos += 1
|
||||
conf += '\t'+self.eqVerField('sql_field_string')+' = '+ column_name + "\n"
|
||||
continue
|
||||
|
||||
if mw.inArray(['text','mediumtext','tinytext','longtext'], data_type):
|
||||
run_pos += 1
|
||||
conf += '\t'+self.eqVerField('sql_field_string')+' = '+ column_name + "\n"
|
||||
continue
|
||||
|
||||
if mw.inArray(['datetime','date'], data_type):
|
||||
run_pos += 1
|
||||
conf += '\t'+self.eqVerField('sql_attr_timestamp')+' = '+ column_name + "\n"
|
||||
continue
|
||||
|
||||
return conf
|
||||
|
||||
def checkDbName(self, db):
|
||||
filter_db = ['information_schema','performance_schema','sys','mysql']
|
||||
if db in filter_db:
|
||||
return False
|
||||
return True
|
||||
|
||||
def makeSqlToSphinx(self, db, tables = [], is_delta = False):
|
||||
conf = ''
|
||||
conf += self.makeSphinxHeader()
|
||||
conf += self.makeSqlToSphinxDb(db, tables, is_delta)
|
||||
return conf
|
||||
|
||||
def makeSqlToSphinxAll(self):
|
||||
filter_db = ['information_schema','performance_schema','sys','mysql']
|
||||
|
||||
dblist = self.pdb.query('show databases')
|
||||
|
||||
conf = ''
|
||||
conf += self.makeSphinxHeader()
|
||||
|
||||
# conf += makeSqlToSphinxDb(pdb, 'bbs')
|
||||
for x in range(len(dblist)):
|
||||
dbname = dblist[x]['Database']
|
||||
if mw.inArray(filter_db, dbname):
|
||||
continue
|
||||
conf += self.makeSqlToSphinxDb(dbname)
|
||||
return conf
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Executable
+27
@@ -0,0 +1,27 @@
|
||||
indexer {
|
||||
mem_limit = 1G
|
||||
}
|
||||
|
||||
searchd {
|
||||
listen = 127.0.0.1:9322
|
||||
listen = 127.0.0.1:9326:mysql
|
||||
listen = 127.0.0.1:9328:http
|
||||
log = /var/log/manticore/searchd.log
|
||||
query_log = /var/log/manticore/query.log
|
||||
pid_file = /var/run/manticore/searchd.pid
|
||||
data_dir = /var/lib/manticore
|
||||
workers = threads
|
||||
binlog_path = /var/lib/manticore
|
||||
max_children = 1000
|
||||
max_matches = 1000000
|
||||
}
|
||||
|
||||
|
||||
index mydocs
|
||||
{
|
||||
type = rt
|
||||
path = /usr/share/doc/manticore/README.Debian
|
||||
rt_field = title
|
||||
rt_attr_json = j
|
||||
}
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 2.2 KiB |
Executable
+36
@@ -0,0 +1,36 @@
|
||||
|
||||
<style>
|
||||
|
||||
#table xm-select{
|
||||
min-height: 30px;
|
||||
line-height: 30px;
|
||||
}
|
||||
|
||||
#table xm-select *{
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
</style>
|
||||
<div class="bt-form">
|
||||
<div class="bt-w-main">
|
||||
<div class="bt-w-menu">
|
||||
<p class="bgw" onclick="pluginService('manticoresearch');">服务</p>
|
||||
<p onclick="pluginInitD('manticoresearch');">自启动</p>
|
||||
<p onclick="pluginConfigTpl('manticoresearch','', 'conf','config_tpl','read_config_tpl',tryRebuildIndex);">配置修改</p>
|
||||
<p onclick="pluginLogs('manticoresearch','','run_log',30);">运行日志</p>
|
||||
<p onclick="pluginLogs('manticoresearch','','query_log', 30);">查询日志</p>
|
||||
<p onclick="mcsRunStatus();">运行状态</p>
|
||||
<p onclick="mcsCommonFunc();">常用功能</p>
|
||||
<p onclick="mcsReadme();">说明</p>
|
||||
</div>
|
||||
<div class="bt-w-con pd15">
|
||||
<div class="soft-man-con" style="height:425px;overflow: auto;"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
resetPluginWinHeight(500);
|
||||
$.getScript( "/plugins/file?name=manticoresearch&f=js/manticoresearch.js", function(){
|
||||
pluginService('manticoresearch');
|
||||
});
|
||||
</script>
|
||||
Executable
+507
@@ -0,0 +1,507 @@
|
||||
# coding:utf-8
|
||||
|
||||
import sys
|
||||
import io
|
||||
import os
|
||||
import time
|
||||
import re
|
||||
import string
|
||||
import subprocess
|
||||
|
||||
web_dir = os.getcwd() + "/web"
|
||||
if os.path.exists(web_dir):
|
||||
sys.path.append(web_dir)
|
||||
os.chdir(web_dir)
|
||||
|
||||
import core.mw as mw
|
||||
|
||||
app_debug = False
|
||||
if mw.isAppleSystem():
|
||||
app_debug = True
|
||||
|
||||
def getPluginName():
|
||||
return 'manticoresearch'
|
||||
|
||||
def getSeName():
|
||||
return 'manticore'
|
||||
|
||||
def getPluginDir():
|
||||
return mw.getPluginDir() + '/' + getPluginName()
|
||||
|
||||
sys.path.append(getPluginDir() +"/class")
|
||||
|
||||
def getServerDir():
|
||||
return mw.getServerDir() + '/' + getPluginName()
|
||||
|
||||
|
||||
def getInitDFile():
|
||||
if app_debug:
|
||||
return '/tmp/' + getPluginName()
|
||||
return '/etc/init.d/' + getPluginName()
|
||||
|
||||
|
||||
def getConfTpl():
|
||||
path = getPluginDir() + "/conf/manticore.conf"
|
||||
return path
|
||||
|
||||
|
||||
def getConf():
|
||||
path = "/etc/manticoresearch/manticore.conf"
|
||||
return path
|
||||
|
||||
|
||||
def getInitDTpl():
|
||||
path = getPluginDir() + "/init.d/" + getPluginName() + ".tpl"
|
||||
return path
|
||||
|
||||
|
||||
def getArgs():
|
||||
args = sys.argv[2:]
|
||||
tmp = {}
|
||||
args_len = len(args)
|
||||
|
||||
if args_len == 1:
|
||||
t = args[0].strip('{').strip('}')
|
||||
t = t.split(':')
|
||||
tmp[t[0]] = t[1]
|
||||
elif args_len > 1:
|
||||
for i in range(len(args)):
|
||||
t = args[i].split(':')
|
||||
tmp[t[0]] = t[1]
|
||||
return tmp
|
||||
|
||||
|
||||
def checkArgs(data, ck=[]):
|
||||
for i in range(len(ck)):
|
||||
if not ck[i] in data:
|
||||
return (False, mw.returnJson(False, '参数:(' + ck[i] + ')没有!'))
|
||||
return (True, mw.returnJson(True, 'ok'))
|
||||
|
||||
|
||||
def configTpl():
|
||||
path = getPluginDir() + '/tpl'
|
||||
pathFile = os.listdir(path)
|
||||
tmp = []
|
||||
for one in pathFile:
|
||||
file = path + '/' + one
|
||||
tmp.append(file)
|
||||
return mw.getJson(tmp)
|
||||
|
||||
|
||||
def readConfigTpl():
|
||||
args = getArgs()
|
||||
data = checkArgs(args, ['file'])
|
||||
if not data[0]:
|
||||
return data[1]
|
||||
|
||||
content = mw.readFile(args['file'])
|
||||
content = contentReplace(content)
|
||||
return mw.returnJson(True, 'ok', content)
|
||||
|
||||
|
||||
def contentReplace(content):
|
||||
service_path = mw.getServerDir()
|
||||
content = content.replace('{$ROOT_PATH}', mw.getFatherDir())
|
||||
content = content.replace('{$SERVER_PATH}', service_path)
|
||||
content = content.replace('{$SERVER_APP}', service_path + '/'+getPluginName())
|
||||
return content
|
||||
|
||||
|
||||
def status():
|
||||
cmd = "ps -ef|grep manticore |grep -v grep | grep -v mdserver-web | awk '{print $2}'"
|
||||
data = mw.execShell(cmd)
|
||||
# print(data)
|
||||
if data[0] == '':
|
||||
return 'stop'
|
||||
return 'start'
|
||||
|
||||
|
||||
def mkdirAll():
|
||||
content = mw.readFile(getConf())
|
||||
rep = r'path\s*=\s*(.*)'
|
||||
p = re.compile(rep)
|
||||
tmp = p.findall(content)
|
||||
|
||||
for x in tmp:
|
||||
if x.find('binlog') != -1:
|
||||
mw.execShell('mkdir -p ' + x)
|
||||
else:
|
||||
mw.execShell('mkdir -p ' + os.path.dirname(x))
|
||||
mw.execShell("chown -R manticore:manticore "+x)
|
||||
|
||||
def isInitFile():
|
||||
path = getServerDir() + '/init.pl'
|
||||
if os.path.exists(path):
|
||||
return True
|
||||
mw.writeFile(path, 'ok')
|
||||
return False
|
||||
|
||||
def initDreplace():
|
||||
|
||||
dirs_list = [
|
||||
"/var/log/manticore",
|
||||
"/var/run/manticore",
|
||||
"/var/lib/manticore"
|
||||
]
|
||||
|
||||
for d in dirs_list:
|
||||
if not os.path.exists(d):
|
||||
mw.execShell('mkdir -p ' + d)
|
||||
|
||||
mw.execShell("chown -R manticore:manticore /var/run/manticore")
|
||||
|
||||
|
||||
# config replace
|
||||
conf_bin = getConf()
|
||||
if not os.path.exists(conf_bin) or not isInitFile():
|
||||
conf_content = mw.readFile(getConfTpl())
|
||||
conf_content = contentReplace(conf_content)
|
||||
mw.writeFile(getConf(), conf_content)
|
||||
mkdirAll()
|
||||
|
||||
return "ok"
|
||||
|
||||
|
||||
def checkIndexSph():
|
||||
content = mw.readFile(getConf())
|
||||
rep = r'path\s*=\s*(.*)'
|
||||
p = re.compile(rep)
|
||||
tmp = p.findall(content)
|
||||
for x in tmp:
|
||||
if x.find('binlog') != -1:
|
||||
continue
|
||||
else:
|
||||
p = x + '.sph'
|
||||
if os.path.exists(p):
|
||||
return False
|
||||
return True
|
||||
|
||||
def mcsOp(method):
|
||||
initDreplace()
|
||||
data = mw.execShell('systemctl ' + method + ' ' + getSeName())
|
||||
if data[1] == '':
|
||||
return 'ok'
|
||||
return 'fail'
|
||||
|
||||
|
||||
def start():
|
||||
import tool_cron
|
||||
tool_cron.createBgTask()
|
||||
return mcsOp('start')
|
||||
|
||||
|
||||
def stop():
|
||||
import tool_cron
|
||||
tool_cron.removeBgTask()
|
||||
return mcsOp('stop')
|
||||
|
||||
|
||||
def restart():
|
||||
return mcsOp('restart')
|
||||
|
||||
|
||||
def reload():
|
||||
return mcsOp('restart')
|
||||
|
||||
|
||||
def rebuild():
|
||||
cmd = 'indexer --all --rotate'
|
||||
data = mw.execShell(cmd)
|
||||
if data[0].find('successfully')<0:
|
||||
return data[0].replace("\n","<br/>")
|
||||
return 'ok'
|
||||
|
||||
|
||||
def initdStatus():
|
||||
service_name = getSeName()
|
||||
shell_cmd = 'systemctl status '+service_name+' | grep loaded | grep "enabled;"'
|
||||
data = mw.execShell(shell_cmd)
|
||||
if data[0] == '':
|
||||
return 'fail'
|
||||
return 'ok'
|
||||
|
||||
|
||||
def initdInstall():
|
||||
service_name = getSeName()
|
||||
mw.execShell('systemctl enable '+service_name)
|
||||
return 'ok'
|
||||
|
||||
|
||||
def initdUinstall():
|
||||
service_name = getSeName()
|
||||
mw.execShell('systemctl disable '+service_name)
|
||||
return 'ok'
|
||||
|
||||
|
||||
def runLog():
|
||||
path = getConf()
|
||||
content = mw.readFile(path)
|
||||
rep = r'log\s*=\s*(.*)'
|
||||
tmp = re.search(rep, content)
|
||||
return tmp.groups()[0]
|
||||
|
||||
|
||||
def getMainPort():
|
||||
path = getConf()
|
||||
content = mw.readFile(path)
|
||||
rep = r'listen\s*=\s*(.*)'
|
||||
conf = re.search(rep, content)
|
||||
port_line = conf.groups()[0]
|
||||
return port_line.split(":")[1]
|
||||
|
||||
def getMysqlPort():
|
||||
path = getConf()
|
||||
content = mw.readFile(path)
|
||||
rep = r'listen\s*=\s*(.*):mysql'
|
||||
conf = re.search(rep, content)
|
||||
port_line = conf.groups()[0]
|
||||
return port_line.split(":")[1]
|
||||
|
||||
def getHttpPort():
|
||||
path = getConf()
|
||||
content = mw.readFile(path)
|
||||
rep = r'listen\s*=\s*(.*):http'
|
||||
conf = re.search(rep, content)
|
||||
port_line = conf.groups()[0]
|
||||
return port_line.split(":")[1]
|
||||
|
||||
|
||||
def queryLog():
|
||||
path = getConf()
|
||||
content = mw.readFile(path)
|
||||
rep = r'query_log\s*=\s*(.*)'
|
||||
tmp = re.search(rep, content)
|
||||
return tmp.groups()[0]
|
||||
|
||||
|
||||
def runStatus():
|
||||
s = status()
|
||||
if s != 'start':
|
||||
return mw.returnJson(False, '没有启动程序')
|
||||
|
||||
sys.path.append(getPluginDir() + "/class")
|
||||
import sphinxapi
|
||||
|
||||
sh = sphinxapi.SphinxClient()
|
||||
port = getMainPort()
|
||||
sh.SetServer('127.0.0.1', port)
|
||||
info_status = sh.Status()
|
||||
|
||||
if info_status is None:
|
||||
return mw.returnJson(False,'无法获取运行状态!')
|
||||
|
||||
rData = {}
|
||||
for x in range(len(info_status)):
|
||||
rData[info_status[x][0]] = info_status[x][1]
|
||||
|
||||
return mw.returnJson(True, 'ok', rData)
|
||||
|
||||
def runStatusTest():
|
||||
s = status()
|
||||
if s != 'start':
|
||||
return mw.returnJson(False, '没有启动程序')
|
||||
|
||||
sys.path.append(getPluginDir() + "/class")
|
||||
import sphinxapi
|
||||
|
||||
sh = sphinxapi.SphinxClient()
|
||||
port = getMainPort()
|
||||
sh.SetServer('127.0.0.1', port)
|
||||
info_status = sh.Status()
|
||||
|
||||
rData = {}
|
||||
for x in range(len(info_status)):
|
||||
rData[info_status[x][0]] = info_status[x][1]
|
||||
|
||||
return mw.returnJson(True, 'ok', rData)
|
||||
|
||||
|
||||
def sphinxConfParse():
|
||||
file = getConf()
|
||||
bin_dir = getServerDir()
|
||||
content = mw.readFile(file)
|
||||
rep = r'index\s(.*)'
|
||||
sindex = re.findall(rep, content)
|
||||
indexlen = len(sindex)
|
||||
cmd = {}
|
||||
cmd['cmd'] = "indexer -c " + getConf()
|
||||
|
||||
cmd['index'] = []
|
||||
cmd_index = []
|
||||
cmd_delta = []
|
||||
if indexlen > 0:
|
||||
for x in range(indexlen):
|
||||
name = sindex[x].strip()
|
||||
if name == '':
|
||||
continue
|
||||
if name.find(':') != -1:
|
||||
cmd_delta.append(name.strip())
|
||||
else:
|
||||
cmd_index.append(name.strip())
|
||||
|
||||
# print(cmd_index)
|
||||
# print(cmd_delta)
|
||||
|
||||
for ci in cmd_index:
|
||||
val = {}
|
||||
val['index'] = ci
|
||||
|
||||
for cd in cmd_delta:
|
||||
cd = cd.replace(" ", '')
|
||||
if cd.find(":"+ci) > -1:
|
||||
val['delta'] = cd.split(":")[0].strip()
|
||||
break
|
||||
|
||||
cmd['index'].append(val)
|
||||
return cmd
|
||||
|
||||
|
||||
def sphinxCmd():
|
||||
data = sphinxConfParse()
|
||||
if 'index' in data:
|
||||
return mw.returnJson(True, 'ok', data)
|
||||
else:
|
||||
return mw.returnJson(False, 'no index')
|
||||
|
||||
def makeDbToSphinxTest():
|
||||
conf_file = getConf()
|
||||
import sphinx_make
|
||||
sph_make = sphinx_make.sphinxMake()
|
||||
conf = sph_make.makeSqlToSphinxAll()
|
||||
|
||||
mw.writeFile(conf_file,conf)
|
||||
print(conf)
|
||||
# makeSqlToSphinxTable()
|
||||
return True
|
||||
|
||||
def makeDbToSphinx():
|
||||
args = getArgs()
|
||||
check = checkArgs(args, ['db','tables','is_delta','is_cover'])
|
||||
if not check[0]:
|
||||
return check[1]
|
||||
|
||||
db = args['db']
|
||||
tables = args['tables']
|
||||
is_delta = args['is_delta']
|
||||
is_cover = args['is_cover']
|
||||
|
||||
if is_cover != 'yes':
|
||||
return mw.returnJson(False,'暂时仅支持覆盖!')
|
||||
|
||||
sph_file = getConf()
|
||||
|
||||
import sphinx_make
|
||||
sph_make = sphinx_make.sphinxMake()
|
||||
|
||||
version_pl = getServerDir() + "/version.pl"
|
||||
if os.path.exists(version_pl):
|
||||
version = mw.readFile(version_pl).strip()
|
||||
sph_make.setVersion(version)
|
||||
|
||||
if not sph_make.checkDbName(db):
|
||||
return mw.returnJson(False,'保留数据库名称,不可用!')
|
||||
is_delta_bool = False
|
||||
if is_delta == 'yes':
|
||||
is_delta_bool = True
|
||||
if is_cover == 'yes':
|
||||
tables = tables.split(',')
|
||||
content = sph_make.makeSqlToSphinx(db, tables, is_delta_bool)
|
||||
mw.writeFile(sph_file,content)
|
||||
mkdirAll()
|
||||
return mw.returnJson(True,'设置成功!')
|
||||
|
||||
return mw.returnJson(True,'测试中')
|
||||
|
||||
|
||||
# 全量更新
|
||||
def updateAll():
|
||||
data = sphinxConfParse()
|
||||
cmd = data['cmd']
|
||||
if not 'index' in data:
|
||||
return '无更新'
|
||||
index = data['index']
|
||||
|
||||
for x in range(len(index)):
|
||||
cmd_index = cmd + ' ' + index[x]['index'] + ' --rotate'
|
||||
print(cmd_index)
|
||||
os.system(cmd_index)
|
||||
return ''
|
||||
|
||||
#增量更新
|
||||
def updateDelta():
|
||||
data = sphinxConfParse()
|
||||
cmd = data['cmd']
|
||||
if not 'index' in data:
|
||||
return '无更新'
|
||||
index = data['index']
|
||||
|
||||
for x in range(len(index)):
|
||||
if 'delta' in index[x]:
|
||||
cmd_index = cmd + ' ' + index[x]['delta'] + ' --rotate'
|
||||
print(cmd_index)
|
||||
os.system(cmd_index)
|
||||
|
||||
cmd_index_merge = cmd + ' --merge ' + index[x]['index'] + ' ' + index[x]['delta'] + ' --rotate'
|
||||
print(cmd_index_merge)
|
||||
os.system(cmd_index_merge)
|
||||
else:
|
||||
print(index[x]['index'],'no delta')
|
||||
|
||||
return ''
|
||||
|
||||
def installPreInspection(version):
|
||||
if mw.isAppleSystem():
|
||||
return '不支持mac系统'
|
||||
return 'ok'
|
||||
|
||||
if __name__ == "__main__":
|
||||
version = "3.1.1"
|
||||
version_pl = getServerDir() + "/version.pl"
|
||||
if os.path.exists(version_pl):
|
||||
version = mw.readFile(version_pl).strip()
|
||||
|
||||
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 == 'rebuild':
|
||||
print(rebuild())
|
||||
elif func == 'initd_status':
|
||||
print(initdStatus())
|
||||
elif func == 'initd_install':
|
||||
print(initdInstall())
|
||||
elif func == 'initd_uninstall':
|
||||
print(initdUinstall())
|
||||
elif func == 'install_pre_inspection':
|
||||
print(installPreInspection(version))
|
||||
elif func == 'conf':
|
||||
print(getConf())
|
||||
elif func == 'config_tpl':
|
||||
print(configTpl())
|
||||
elif func == 'read_config_tpl':
|
||||
print(readConfigTpl())
|
||||
elif func == 'run_log':
|
||||
print(runLog())
|
||||
elif func == 'query_log':
|
||||
print(queryLog())
|
||||
elif func == 'run_status':
|
||||
print(runStatus())
|
||||
elif func == 'run_status_test':
|
||||
print(runStatusTest())
|
||||
elif func == 'sphinx_cmd':
|
||||
print(sphinxCmd())
|
||||
elif func == 'db_to_sphinx':
|
||||
print(makeDbToSphinx())
|
||||
elif func == 'update_all':
|
||||
print(updateAll())
|
||||
elif func == 'update_delta':
|
||||
print(updateDelta())
|
||||
else:
|
||||
print('error')
|
||||
Executable
+19
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"sort": 7,
|
||||
"ps": "SphinxSearch项目演变而来,专注于提升搜索效率与扩展性",
|
||||
"name": "manticoresearch",
|
||||
"title": "manticoresearch",
|
||||
"shell": "install.sh",
|
||||
"versions":["7.4.6"],
|
||||
"tip": "soft",
|
||||
"install_pre_inspection":true,
|
||||
"checks": "server/manticoresearch",
|
||||
"path": "server/manticoresearch",
|
||||
"display": 1,
|
||||
"author": "manticoresoftware",
|
||||
"date": "2025-07-21",
|
||||
"home": "https://github.com/manticoresoftware/manticoresearch/",
|
||||
"doc1": "https://manual.manticoresearch.com/Introduction",
|
||||
"type": 0,
|
||||
"pid": "2"
|
||||
}
|
||||
Executable
+32
@@ -0,0 +1,32 @@
|
||||
#!/bin/bash
|
||||
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin:/opt/homebrew/bin
|
||||
export PATH
|
||||
|
||||
curPath=`pwd`
|
||||
rootPath=$(dirname "$curPath")
|
||||
rootPath=$(dirname "$rootPath")
|
||||
serverPath=$(dirname "$rootPath")
|
||||
sysName=`uname`
|
||||
sysArch=`arch`
|
||||
|
||||
# cd /www/server/mdserver-web/plugins/manticoresearch && bash install.sh install 7.4.6
|
||||
# cd /www/server/mdserver-web && python3 plugins/manticoresearch/index.py run_status_test
|
||||
# systemctl status manticore
|
||||
# systemctl restart manticore
|
||||
|
||||
if [ -f ${rootPath}/bin/activate ];then
|
||||
source ${rootPath}/bin/activate
|
||||
fi
|
||||
|
||||
ACTION=$1
|
||||
VERSION=$2
|
||||
|
||||
which apt
|
||||
if [ "$?" == "0" ];then
|
||||
sh -x $curPath/versions/apt/install.sh $1 $2
|
||||
fi
|
||||
|
||||
which yum
|
||||
if [ "$?" == "0" ];then
|
||||
sh -x $curPath/versions/yum/install.sh $1 $2
|
||||
fi
|
||||
+310
@@ -0,0 +1,310 @@
|
||||
function spPostMin(method, args, callback){
|
||||
|
||||
var req_data = {};
|
||||
req_data['name'] = 'manticoresearch';
|
||||
req_data['func'] = method;
|
||||
|
||||
if (typeof(args) != 'undefined' && args!=''){
|
||||
req_data['args'] = JSON.stringify(args);
|
||||
}
|
||||
|
||||
$.post('/plugins/run', req_data, 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 myPost(method, args, callback, title){
|
||||
var _args = null;
|
||||
if (typeof(args) == 'string'){
|
||||
_args = JSON.stringify(toArrayObject(args));
|
||||
} else {
|
||||
_args = JSON.stringify(args);
|
||||
}
|
||||
|
||||
var _title = '正在获取...';
|
||||
if (typeof(title) != 'undefined'){
|
||||
_title = title;
|
||||
}
|
||||
|
||||
$.post('/plugins/run', {name:'mysql', func:method, args:_args}, function(data) {
|
||||
if (!data.status){
|
||||
layer.msg(data.msg,{icon:0,time:2000,shade: [0.3, '#000']});
|
||||
return;
|
||||
}
|
||||
|
||||
if(typeof(callback) == 'function'){
|
||||
callback(data);
|
||||
}
|
||||
},'json');
|
||||
}
|
||||
|
||||
|
||||
function spPost(method, args, callback){
|
||||
var loadT = layer.msg('正在获取...', { icon: 16, time: 0, shade: 0.3 });
|
||||
spPostMin(method,args,function(data){
|
||||
layer.close(loadT);
|
||||
if(typeof(callback) == 'function'){
|
||||
callback(data);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function mcsCommonFunc(){
|
||||
var con = '<button class="btn btn-default btn-sm" onclick="confirmRebuildIndex();">重建索引</button>';
|
||||
con += ' <button class="btn btn-default btn-sm" onclick="autoMakeConf();">自动创建配置</button>';
|
||||
$(".soft-man-con").html(con);
|
||||
}
|
||||
|
||||
function autoMakeConf(){
|
||||
var xm_db_list;
|
||||
|
||||
var con = '<ul class="help-info-text c7">';
|
||||
con += '<li style="color:red;">如果数据量比较大,第一次启动会失败!(可通过手动建立索引)</li>';
|
||||
con += '<li style="color:red;">以下内容,需手动加入计划任务。</li>';
|
||||
layer.open({
|
||||
type: 1,
|
||||
area: ['380px','350px'],
|
||||
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'>\
|
||||
<select class='bt-input-text mr5' name='dbname' style='width:100%'>\
|
||||
<option value=''>无</option>\
|
||||
</select>\
|
||||
</div>\
|
||||
</div>\
|
||||
<div class='line'>\
|
||||
<span class='tname'>选择表</span>\
|
||||
<div class='info-r'>\
|
||||
<div id='table'></div>\
|
||||
</div>\
|
||||
</div>\
|
||||
<div class='line'>\
|
||||
<span class='tname'>是否增量</span>\
|
||||
<div class='info-r'>\
|
||||
<select class='bt-input-text mr5' name='is_delta' style='width:100px'>\
|
||||
<option value='no'>否</option>\
|
||||
<option value='yes'>是</option>\
|
||||
</select>\
|
||||
</div>\
|
||||
</div>\
|
||||
<div class='line'>\
|
||||
<span class='tname'>是否覆盖配置</span>\
|
||||
<div class='info-r'>\
|
||||
<select class='bt-input-text mr5' name='is_cover' style='width:100px'>\
|
||||
<option value='yes'>是</option>\
|
||||
<option value='no'>否</option>\
|
||||
</select>\
|
||||
</div>\
|
||||
</div>\
|
||||
<ul class='help-info-text c7'>\
|
||||
<li style='color:red;'>具体配置,仍须手动修改!!!</li>\
|
||||
<li style='color:red;'>增量索引,需要有更新权限,主从分离时,需要主库配置</li>\
|
||||
</ul>\
|
||||
</form>\
|
||||
",
|
||||
|
||||
success:function(l,i){
|
||||
$(l).find('.layui-layer-content').css('overflow','visible');
|
||||
|
||||
xm_db_list = xmSelect.render({
|
||||
el: '#table',
|
||||
repeat: false,
|
||||
toolbar: {show: true},
|
||||
data: [],
|
||||
});
|
||||
|
||||
myPost('get_db_list', {"page":1,"page_size":20}, function(data){
|
||||
var rdata = $.parseJSON(data.data);
|
||||
var dblist = rdata.data;
|
||||
|
||||
var db_html = '';
|
||||
for (var i = 0; i < dblist.length; i++) {
|
||||
db_html += "<option value='"+dblist[i]['name']+"'>"+dblist[i]['name']+"</option>";
|
||||
}
|
||||
|
||||
if (dblist.length > 0){
|
||||
initDbSelect(dblist[0]['name']);
|
||||
}
|
||||
$('select[name="dbname"]').html(db_html);
|
||||
});
|
||||
|
||||
$('select[name="dbname"]').change(function(){
|
||||
var db = $('select[name="dbname"]').val();
|
||||
initDbSelect(db);
|
||||
});
|
||||
|
||||
},
|
||||
yes:function(index){
|
||||
var args = {}
|
||||
args['db'] = $('select[name="dbname"]').val();
|
||||
args['is_delta'] = $('select[name="is_delta"]').val();
|
||||
args['is_cover'] = $('select[name="is_cover"]').val();
|
||||
args['tables'] = xm_db_list.getValue('value').join(',');
|
||||
// console.log(args);
|
||||
spPost('db_to_sphinx', args, function(rdata){
|
||||
var rdata = $.parseJSON(rdata.data);
|
||||
// console.log(rdata);
|
||||
showMsg(rdata.msg,function(){
|
||||
if (rdata.status){
|
||||
layer.close(index);
|
||||
confirmRebuildIndex();
|
||||
}
|
||||
},{icon: rdata.status ? 1 : 2}, 2000);
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
function initDbSelect(db){
|
||||
if (db == ''){
|
||||
return;
|
||||
}
|
||||
getDbInfo(db, function(rdata){
|
||||
var rdata = $.parseJSON(rdata.data);
|
||||
var tables = rdata.tables;
|
||||
|
||||
var idx_db = [];
|
||||
for (var i = 0; i < tables.length; i++) {
|
||||
var t = {};
|
||||
t['name'] = tables[i]['table_name'];
|
||||
t['value'] = tables[i]['table_name'];
|
||||
idx_db.push(t);
|
||||
}
|
||||
xm_db_list = xmSelect.render({el: '#table', filterable: true,repeat: false,toolbar: {show: true},data: idx_db,});
|
||||
});
|
||||
}
|
||||
|
||||
function getDbInfo(db_name, callback){
|
||||
myPost('get_db_info', {name:db_name}, function(data){
|
||||
callback(data);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function rebuildIndex(){
|
||||
spPost('rebuild', '', function(data){
|
||||
if (data.data == 'ok'){
|
||||
layer.msg('重建成功!',{icon:1,time:2000,shade: [0.3, '#000']});
|
||||
} else {
|
||||
layer.msg(data.data,{icon:2,time:10000,shade: [0.3, '#000']});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function confirmRebuildIndex(){
|
||||
layer.confirm("是否重建索引?", {icon:3,closeBtn: 1} , function(){
|
||||
rebuildIndex();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function tryRebuildIndex(){
|
||||
layer.confirm("修改配置后,是否尝试重建索引!", {icon:3,closeBtn: 1} , function(){
|
||||
rebuildIndex();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function secToTime(s) {
|
||||
var t;
|
||||
if(s > -1){
|
||||
var hour = Math.floor(s/3600);
|
||||
var min = Math.floor(s/60) % 60;
|
||||
var sec = s % 60;
|
||||
if(hour < 10) {
|
||||
t = '0'+ hour + ":";
|
||||
} else {
|
||||
t = hour + ":";
|
||||
}
|
||||
|
||||
if(min < 10){t += "0";}
|
||||
t += min + ":";
|
||||
if(sec < 10){t += "0";}
|
||||
t += sec.toFixed(2);
|
||||
}
|
||||
return t;
|
||||
}
|
||||
|
||||
|
||||
function mcsRunStatus(){
|
||||
spPost('run_status', '', function(data){
|
||||
var rdata = $.parseJSON(data.data);
|
||||
if (!rdata['status']){
|
||||
layer.msg(rdata['msg'],{icon:2,time:2000,shade: [0.3, '#000']});
|
||||
return;
|
||||
}
|
||||
var idata = rdata.data;
|
||||
|
||||
var tbody = '';
|
||||
for (var i in idata) {
|
||||
tbody += '<tr><th>'+i+'</th><td>' + idata[i] + '</td><td colspan="2">'+i+'</td></tr>';
|
||||
}
|
||||
|
||||
var con = '<div class="divtable"><table class="table table-hover table-bordered" style="margin-bottom:10px;background-color:#fafafa">\
|
||||
<tbody>\
|
||||
<tr><th>运行时间</th><td>' + secToTime(idata.uptime) + '</td><th>每秒查询</th><td>' + parseInt(parseInt(idata.queries) / parseInt(idata.uptime)) + '</td></tr>\
|
||||
<tr><th>总连接次数</th><td>' + idata.connections + '</td><th>work_queue_length</th><td>' +idata.work_queue_length + '</td></tr>\
|
||||
<tr><th>agent_connect</th><td>' + idata.agent_connect+ '</td><th>workers_active</th><td>' + idata.workers_active + '</td></tr>\
|
||||
<tr><th>agent_retry</th><td>' + idata.agent_retry + '</td><th>workers_total</th><td>' + idata.workers_total + '</td></tr>\
|
||||
</tbody>\
|
||||
</table>\
|
||||
<table class="table table-hover table-bordered">\
|
||||
<thead style="display:none;"><th></th><th></th><th></th><th></th></thead>\
|
||||
<tbody>\
|
||||
'+tbody+'\
|
||||
<tbody>\
|
||||
</table>\
|
||||
</div>';
|
||||
|
||||
$(".soft-man-con").html(con);
|
||||
});
|
||||
}
|
||||
|
||||
function mcsReadme(){
|
||||
spPost('sphinx_cmd', '', function(data){
|
||||
var rdata = $.parseJSON(data.data);
|
||||
if (!rdata['status']){
|
||||
layer.msg(rdata['msg'],{icon:2,time:2000,shade: [0.3, '#000']});
|
||||
return;
|
||||
}
|
||||
|
||||
// console.log(rdata['data']);
|
||||
var con = '<ul class="help-info-text c7">';
|
||||
|
||||
con += '<li style="color:red;">如果数据量比较大,第一次启动会失败!(可通过手动建立索引)</li>';
|
||||
con += '<li style="color:red;">以下内容,需手动加入计划任务。</li>';
|
||||
|
||||
con += '<li>全量:' + rdata['data']['cmd'] + ' --all --rotate</li>';
|
||||
|
||||
//主索引
|
||||
for (var i = 0; i < rdata['data']['index'].length; i++) {
|
||||
var index_kv = rdata['data']['index'][i];
|
||||
var index = index_kv['index'];
|
||||
// console.log(index);
|
||||
con += '<li>主索引 :' + rdata['data']['cmd'] + ' '+ index +' --rotate</li>';
|
||||
if (typeof(index_kv['delta']) != 'undefined'){
|
||||
var delta = index_kv['delta'];
|
||||
con += '<li>增量索引 :' + rdata['data']['cmd'] + ' '+ delta +' --rotate</li>';
|
||||
con += '<li>合并索引 :' + rdata['data']['cmd'] + ' --merge '+ index + ' ' + delta +' --rotate</li>';
|
||||
}
|
||||
}
|
||||
con += '</ul>';
|
||||
|
||||
$(".soft-man-con").html(con);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,211 @@
|
||||
# coding:utf-8
|
||||
|
||||
import sys
|
||||
import io
|
||||
import os
|
||||
import time
|
||||
import json
|
||||
|
||||
web_dir = os.getcwd() + "/web"
|
||||
if os.path.exists(web_dir):
|
||||
sys.path.append(web_dir)
|
||||
os.chdir(web_dir)
|
||||
|
||||
import core.mw as mw
|
||||
from utils.crontab import crontab as MwCrontab
|
||||
|
||||
|
||||
|
||||
app_debug = False
|
||||
if mw.isAppleSystem():
|
||||
app_debug = True
|
||||
|
||||
|
||||
def getPluginName():
|
||||
return 'manticoresearch'
|
||||
|
||||
|
||||
def getPluginDir():
|
||||
return mw.getPluginDir() + '/' + getPluginName()
|
||||
|
||||
|
||||
def getServerDir():
|
||||
return mw.getServerDir() + '/' + getPluginName()
|
||||
|
||||
|
||||
def getTaskConf():
|
||||
conf = getServerDir() + "/cron_config.json"
|
||||
return conf
|
||||
|
||||
def getTaskDeltaConf():
|
||||
conf = getServerDir() + "/cron_delta_config.json"
|
||||
return conf
|
||||
|
||||
def getConfigData():
|
||||
conf = getTaskConf()
|
||||
if os.path.exists(conf):
|
||||
return json.loads(mw.readFile(getTaskConf()))
|
||||
return {
|
||||
"task_id": -1,
|
||||
"period": "day-n",
|
||||
"where1": "1",
|
||||
"hour": "0",
|
||||
"minute": "15",
|
||||
}
|
||||
|
||||
def getConfigDeltaData():
|
||||
conf = getTaskDeltaConf()
|
||||
if os.path.exists(conf):
|
||||
return json.loads(mw.readFile(getTaskDeltaConf()))
|
||||
return {
|
||||
"task_id": -1,
|
||||
"period": "minute-n",
|
||||
"where1": "3",
|
||||
"hour": "0",
|
||||
"minute": "0",
|
||||
}
|
||||
|
||||
|
||||
def createBgTask():
|
||||
removeBgTask()
|
||||
removeDeltaBgTask()
|
||||
|
||||
createBgTaskByName(getPluginName())
|
||||
createBgTaskDeltaByName(getPluginName())
|
||||
return True
|
||||
|
||||
|
||||
def createBgTaskByName(name):
|
||||
args = getConfigData()
|
||||
_name = "[勿删]全量更新[" + name + "]"
|
||||
res = mw.M("crontab").field("id, name").where("name=?", (_name,)).find()
|
||||
if res:
|
||||
return True
|
||||
|
||||
if "task_id" in args and args["task_id"] > 0:
|
||||
res = mw.M("crontab").field("id, name").where("id=?", (args["task_id"],)).find()
|
||||
if res and res["id"] == args["task_id"]:
|
||||
print("计划任务已经存在!")
|
||||
return True
|
||||
|
||||
mw_dir = mw.getPanelDir()
|
||||
cmd = '''
|
||||
mw_dir=%s
|
||||
rname=%s
|
||||
plugin_path=%s
|
||||
script_path=%s
|
||||
logs_file=$plugin_path/${rname}.log
|
||||
''' % (mw_dir, name, getServerDir(), getPluginDir())
|
||||
cmd += 'echo "★【`date +"%Y-%m-%d %H:%M:%S"`】 STSRT★" >> $logs_file' + "\n"
|
||||
cmd += 'echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" >> $logs_file' + "\n"
|
||||
cmd += 'echo "python3 $script_path/index.py update_all"' + "\n"
|
||||
cmd += 'cd $mw_dir && python3 $script_path/index.py update_all' + "\n"
|
||||
cmd += 'echo "【`date +"%Y-%m-%d %H:%M:%S"`】 END★" >> $logs_file' + "\n"
|
||||
cmd += 'echo "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" >> $logs_file' + "\n"
|
||||
|
||||
params = {
|
||||
'name': _name,
|
||||
'type': args['period'],
|
||||
'week': "",
|
||||
'where1': args['where1'],
|
||||
'hour': args['hour'],
|
||||
'minute': args['minute'],
|
||||
'save': "",
|
||||
'backup_to': "",
|
||||
'stype': "toShell",
|
||||
'sname': '',
|
||||
'sbody': cmd,
|
||||
'url_address': '',
|
||||
}
|
||||
|
||||
task_id = MwCrontab.instance().add(params)
|
||||
if task_id > 0:
|
||||
args["task_id"] = task_id
|
||||
args["name"] = name
|
||||
mw.writeFile(getTaskConf(), json.dumps(args))
|
||||
|
||||
def createBgTaskDeltaByName(name):
|
||||
args = getConfigDeltaData()
|
||||
_name = "[勿删]增量更新[" + name + "]"
|
||||
res = mw.M("crontab").field("id, name").where("name=?", (_name,)).find()
|
||||
if res:
|
||||
return True
|
||||
|
||||
if "task_id" in args and args["task_id"] > 0:
|
||||
res = mw.M("crontab").field("id, name").where("id=?", (args["task_id"],)).find()
|
||||
if res and res["id"] == args["task_id"]:
|
||||
print("计划任务已经存在!")
|
||||
return True
|
||||
|
||||
mw_dir = mw.getPanelDir()
|
||||
cmd = '''
|
||||
mw_dir=%s
|
||||
rname=%s
|
||||
plugin_path=%s
|
||||
script_path=%s
|
||||
logs_file=$plugin_path/${rname}.log
|
||||
''' % (mw_dir, name, getServerDir(), getPluginDir())
|
||||
cmd += 'echo "★【`date +"%Y-%m-%d %H:%M:%S"`】 STSRT★" >> $logs_file' + "\n"
|
||||
cmd += 'echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" >> $logs_file' + "\n"
|
||||
cmd += 'echo "python3 $script_path/index.py update_delta"' + "\n"
|
||||
cmd += 'cd $mw_dir && python3 $script_path/index.py update_delta' + "\n"
|
||||
cmd += 'echo "【`date +"%Y-%m-%d %H:%M:%S"`】 END★" >> $logs_file' + "\n"
|
||||
cmd += 'echo "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" >> $logs_file' + "\n"
|
||||
|
||||
params = {
|
||||
'name': _name,
|
||||
'type': args['period'],
|
||||
'week': "",
|
||||
'where1': args['where1'],
|
||||
'hour': args['hour'],
|
||||
'minute': args['minute'],
|
||||
'save': "",
|
||||
'backup_to': "",
|
||||
'stype': "toShell",
|
||||
'sname': '',
|
||||
'sbody': cmd,
|
||||
'url_address': '',
|
||||
}
|
||||
|
||||
task_id = MwCrontab.instance().add(params)
|
||||
if task_id > 0:
|
||||
args["task_id"] = task_id
|
||||
args["name"] = name
|
||||
mw.writeFile(getTaskConf(), json.dumps(args))
|
||||
|
||||
|
||||
def removeBgTask():
|
||||
cfg = getConfigData()
|
||||
if "task_id" in cfg and cfg["task_id"] > 0:
|
||||
res = mw.M("crontab").field("id, name").where(
|
||||
"id=?", (cfg["task_id"],)).find()
|
||||
if res and res["id"] == cfg["task_id"]:
|
||||
data = MwCrontab.instance().delete(cfg["task_id"])
|
||||
if data[0]:
|
||||
cfg["task_id"] = -1
|
||||
mw.writeFile(getTaskConf(), json.dumps(cfg))
|
||||
return True
|
||||
return False
|
||||
|
||||
def removeDeltaBgTask():
|
||||
cfg = getConfigDeltaData()
|
||||
if "task_id" in cfg and cfg["task_id"] > 0:
|
||||
res = mw.M("crontab").field("id, name").where(
|
||||
"id=?", (cfg["task_id"],)).find()
|
||||
if res and res["id"] == cfg["task_id"]:
|
||||
data = MwCrontab.instance().delete(cfg["task_id"])
|
||||
if data[0]:
|
||||
cfg["task_id"] = -1
|
||||
mw.writeFile(getTaskDeltaConf(), json.dumps(cfg))
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
if len(sys.argv) > 1:
|
||||
action = sys.argv[1]
|
||||
if action == "remove":
|
||||
removeBgTask()
|
||||
removeDeltaBgTask()
|
||||
elif action == "add":
|
||||
createBgTask()
|
||||
@@ -0,0 +1,107 @@
|
||||
#
|
||||
# Discuz manticore Config File
|
||||
#
|
||||
|
||||
searchd {
|
||||
listen = 127.0.0.1:9322
|
||||
listen = 127.0.0.1:9326:mysql
|
||||
listen = 127.0.0.1:9328:http
|
||||
log = /var/log/manticore/searchd.log
|
||||
query_log = /var/log/manticore/query.log
|
||||
pid_file = /var/run/manticore/searchd.pid
|
||||
#data_dir = /var/lib/manticore
|
||||
}
|
||||
|
||||
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 = 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
|
||||
}
|
||||
|
||||
|
||||
# threads_minute
|
||||
source pre_forum_thread_minute : pre_forum_thread
|
||||
{
|
||||
sql_query_pre = SET NAMES UTF8
|
||||
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 = SET NAMES UTF8
|
||||
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
|
||||
}
|
||||
|
||||
#pre_forum_post_minute
|
||||
source pre_forum_post_minute : pre_forum_post
|
||||
{
|
||||
sql_query_pre = SET NAMES UTF8
|
||||
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
|
||||
}
|
||||
|
||||
Executable
+9
@@ -0,0 +1,9 @@
|
||||
searchd {
|
||||
listen = 127.0.0.1:9322
|
||||
listen = 127.0.0.1:9326:mysql
|
||||
listen = 127.0.0.1:9328:http
|
||||
log = /var/log/manticore/searchd.log
|
||||
query_log = /var/log/manticore/query.log
|
||||
pid_file = /var/run/manticore/searchd.pid
|
||||
data_dir = /var/lib/manticore
|
||||
}
|
||||
+71
@@ -0,0 +1,71 @@
|
||||
#!/bin/bash
|
||||
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin:/opt/homebrew/bin
|
||||
export PATH
|
||||
|
||||
curPath=`pwd`
|
||||
rootPath=$(dirname "$curPath")
|
||||
rootPath=$(dirname "$rootPath")
|
||||
serverPath=$(dirname "$rootPath")
|
||||
sysName=`uname`
|
||||
sysArch=`arch`
|
||||
|
||||
if [ -f ${rootPath}/bin/activate ];then
|
||||
source ${rootPath}/bin/activate
|
||||
fi
|
||||
|
||||
VERSION=$2
|
||||
|
||||
Install_App()
|
||||
{
|
||||
echo '正在安装manticoresearch...'
|
||||
mkdir -p $serverPath/manticoresearch
|
||||
|
||||
MC_DIR=${serverPath}/source/manticoresearch
|
||||
mkdir -p $MC_DIR
|
||||
|
||||
wget --no-check-certificate -O $MC_DIR/manticore-repo.noarch.deb https://repo.manticoresearch.com/manticore-repo.noarch.deb
|
||||
dpkg -i $MC_DIR/manticore-repo.noarch.deb
|
||||
apt update -y
|
||||
apt -y install manticore manticore-extra
|
||||
|
||||
|
||||
echo "${VERSION}" > $serverPath/manticoresearch/version.pl
|
||||
|
||||
|
||||
cd ${rootPath} && python3 plugins/manticoresearch/index.py start ${VERSION}
|
||||
cd ${rootPath} && python3 plugins/manticoresearch/index.py initd_install ${VERSION}
|
||||
|
||||
if [ -d ${MC_DIR} ];then
|
||||
rm -rf ${MC_DIR}
|
||||
fi
|
||||
}
|
||||
|
||||
Uninstall_App()
|
||||
{
|
||||
cd ${rootPath} && python3 plugins/manticoresearch/index.py stop ${VERSION}
|
||||
cd ${rootPath} && python3 plugins/manticoresearch/index.py initd_uninstall ${VERSION}
|
||||
|
||||
apt -y remove manticore manticore-extra
|
||||
apt -y autoremove
|
||||
|
||||
if [ -d $serverPath/manticoresearch ];then
|
||||
rm -rf $serverPath/manticoresearch
|
||||
fi
|
||||
|
||||
if [ -f /usr/lib/systemd/system/manticore.service ] || [ -f /lib/systemd/system/manticore.service ];then
|
||||
systemctl stop manticore
|
||||
systemctl disable manticore
|
||||
rm -rf /usr/lib/systemd/system/manticore.service
|
||||
rm -rf /lib/systemd/system/manticore.service
|
||||
systemctl daemon-reload
|
||||
fi
|
||||
|
||||
echo "卸载manticoresearch成功"
|
||||
}
|
||||
|
||||
action=$1
|
||||
if [ "${1}" == 'install' ];then
|
||||
Install_App
|
||||
else
|
||||
Uninstall_App
|
||||
fi
|
||||
+67
@@ -0,0 +1,67 @@
|
||||
#!/bin/bash
|
||||
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin:/opt/homebrew/bin
|
||||
export PATH
|
||||
|
||||
curPath=`pwd`
|
||||
rootPath=$(dirname "$curPath")
|
||||
rootPath=$(dirname "$rootPath")
|
||||
serverPath=$(dirname "$rootPath")
|
||||
sysName=`uname`
|
||||
sysArch=`arch`
|
||||
|
||||
|
||||
if [ -f ${rootPath}/bin/activate ];then
|
||||
source ${rootPath}/bin/activate
|
||||
fi
|
||||
|
||||
VERSION=$2
|
||||
|
||||
Install_App()
|
||||
{
|
||||
echo '正在安装manticoresearch...'
|
||||
mkdir -p $serverPath/manticoresearch
|
||||
|
||||
MC_DIR=${serverPath}/source/manticoresearch
|
||||
mkdir -p $MC_DIR
|
||||
|
||||
yum install -y https://repo.manticoresearch.com/manticore-repo.noarch.rpm
|
||||
yum install -y manticore manticore-extra
|
||||
|
||||
echo "${VERSION}" > $serverPath/manticoresearch/version.pl
|
||||
|
||||
if [ -d ${MC_DIR} ];then
|
||||
rm -rf ${MC_DIR}
|
||||
fi
|
||||
|
||||
cd ${rootPath} && python3 plugins/manticoresearch/index.py start ${VERSION}
|
||||
cd ${rootPath} && python3 plugins/manticoresearch/index.py initd_install ${VERSION}
|
||||
}
|
||||
|
||||
Uninstall_App()
|
||||
{
|
||||
yum -y remove manticore manticore-extra
|
||||
|
||||
if [ -d $serverPath/manticoresearch ];then
|
||||
rm -rf $serverPath/manticoresearch
|
||||
fi
|
||||
|
||||
if [ -f /usr/lib/systemd/system/manticore.service ] || [ -f /lib/systemd/system/manticore.service ];then
|
||||
systemctl stop manticore
|
||||
systemctl disable manticore
|
||||
rm -rf /usr/lib/systemd/system/manticore.service
|
||||
rm -rf /lib/systemd/system/manticore.service
|
||||
systemctl daemon-reload
|
||||
fi
|
||||
|
||||
cd ${rootPath} && python3 plugins/manticoresearch/index.py stop ${VERSION}
|
||||
cd ${rootPath} && python3 plugins/manticoresearch/index.py initd_uninstall ${VERSION}
|
||||
|
||||
echo "卸载manticoresearch成功"
|
||||
}
|
||||
|
||||
action=$1
|
||||
if [ "${1}" == 'install' ];then
|
||||
Install_App
|
||||
else
|
||||
Uninstall_App
|
||||
fi
|
||||
@@ -8,7 +8,7 @@ rootPath=$(dirname "$rootPath")
|
||||
serverPath=$(dirname "$rootPath")
|
||||
|
||||
sys_os=`uname`
|
||||
VERSION=1.6.38
|
||||
VERSION=1.6.39
|
||||
|
||||
echo $sys_os
|
||||
|
||||
@@ -18,7 +18,7 @@ Install_mem(){
|
||||
echo '正在安装脚本文件...'
|
||||
|
||||
if [ ! -f $serverPath/source/memcached.tar.gz ];then
|
||||
wget --no-check-certificate -O $serverPath/source/memcached/memcached.tar.gz https://www.memcached.org/files/memcached-${VERSION}.tar.gz
|
||||
wget --no-check-certificate -O $serverPath/source/memcached/memcached.tar.gz https://www.memcached.org/files/memcached-${VERSION}.tar.gz
|
||||
fi
|
||||
|
||||
cd $serverPath/source/memcached && tar -zxvf memcached.tar.gz
|
||||
|
||||
@@ -10,7 +10,7 @@ serverPath=$(dirname "$rootPath")
|
||||
sysArch=`arch`
|
||||
sysName=`uname`
|
||||
|
||||
|
||||
# systemctl status mtg
|
||||
# cd /www/server/mdserver-web && python3 plugins/mtproxy/index.py url
|
||||
# cd /www/server/mdserver-web/plugins/mtproxy && /bin/bash install.sh install 1.0
|
||||
|
||||
|
||||
@@ -85,7 +85,7 @@ innodb_lock_wait_timeout = 120
|
||||
innodb_max_dirty_pages_pct = 90
|
||||
innodb_read_io_threads = 1
|
||||
innodb_write_io_threads = 1
|
||||
innodb_file_per_table=1
|
||||
innodb_file_per_table = 1
|
||||
binlog_expire_logs_seconds=604800
|
||||
|
||||
secure-file-priv={$SERVER_APP_PATH}/tmp
|
||||
|
||||
@@ -85,7 +85,7 @@ innodb_lock_wait_timeout = 120
|
||||
innodb_max_dirty_pages_pct = 90
|
||||
innodb_read_io_threads = 1
|
||||
innodb_write_io_threads = 1
|
||||
innodb_file_per_table=1
|
||||
innodb_file_per_table = 1
|
||||
binlog_expire_logs_seconds=604800
|
||||
|
||||
secure-file-priv={$SERVER_APP_PATH}/tmp
|
||||
|
||||
@@ -85,7 +85,7 @@ innodb_lock_wait_timeout = 120
|
||||
innodb_max_dirty_pages_pct = 90
|
||||
innodb_read_io_threads = 1
|
||||
innodb_write_io_threads = 1
|
||||
innodb_file_per_table=1
|
||||
innodb_file_per_table = 1
|
||||
binlog_expire_logs_seconds=604800
|
||||
|
||||
secure-file-priv={$SERVER_APP_PATH}/tmp
|
||||
|
||||
+70
-6
@@ -1283,6 +1283,8 @@ def getDbBackupList():
|
||||
rr = []
|
||||
for x in range(0, len(r)):
|
||||
p = bkDir + '/' + r[x]
|
||||
if not os.path.exists(p):
|
||||
continue
|
||||
data = {}
|
||||
data['name'] = r[x]
|
||||
|
||||
@@ -1477,27 +1479,90 @@ def syncToDatabases():
|
||||
msg = mw.getInfo('本次共同步了{1}个数据库!', (str(n),))
|
||||
return mw.returnJson(True, msg)
|
||||
|
||||
def adjust_password_policy(version):
|
||||
if version.startswith("8."):
|
||||
serverdir = getServerDir()
|
||||
mw.execShell(serverdir+f"/bin/mysql -u root -e \"SET GLOBAL validate_password.policy=LOW;\"")
|
||||
mw.execShell(serverdir+f"/bin/mysql -u root -e \"SET GLOBAL validate_password.length=4;\"")
|
||||
|
||||
def setRootPwdForce(new_password,version=''):
|
||||
# stop(version)
|
||||
# | awk '{print $2}'| xargs kill
|
||||
data = mw.execShell("ps -ef|grep mysql|grep -v plugins |grep -v grep | awk '{print $2}'| xargs kill")
|
||||
# print(data)
|
||||
time.sleep(1)
|
||||
|
||||
serverdir = getServerDir()
|
||||
|
||||
# 启动安全模式
|
||||
cmd_msafe = serverdir+"/bin/mysqld_safe --skip-grant-tables --skip-networking"
|
||||
# print("cmd_msafe",cmd_msafe)
|
||||
subprocess.Popen(cmd_msafe, stdout=subprocess.PIPE, shell=True,bufsize=4096, stderr=subprocess.PIPE)
|
||||
# 等待MySQL安全模式启动...
|
||||
time.sleep(5)
|
||||
|
||||
if version.startswith("5.5") or version.startswith("5.6"):
|
||||
cmd_mod_root = serverdir+f"/bin/mysql -u root -e \"UPDATE mysql.user SET Password=PASSWORD('{new_password}') WHERE user='root'; FLUSH PRIVILEGES;\""
|
||||
data = mw.execShell(cmd_mod_root)
|
||||
# print("修改root密码", cmd_mod_root)
|
||||
# print(data)
|
||||
else:
|
||||
cmd_clear_root = serverdir+"/bin/mysql -u root -e \"UPDATE mysql.user SET authentication_string = '' WHERE user = 'root'; FLUSH PRIVILEGES;\""
|
||||
data = mw.execShell(cmd_clear_root)
|
||||
# print(cmd_clear_root,"清空root密码",data)
|
||||
|
||||
data = mw.execShell("ps -ef|grep mysql|grep -v plugins |grep -v grep | awk '{print $2}'| xargs kill")
|
||||
# print("停止安全模式",data)
|
||||
|
||||
# 正常启动MySQL
|
||||
start(version)
|
||||
time.sleep(5)
|
||||
|
||||
if not version.startswith("5.5") and not version.startswith("5.6"):
|
||||
# 针对MySQL 8.0+调整密码策略
|
||||
if version.startswith("8."):
|
||||
adjust_password_policy(version)
|
||||
# 设置新密码
|
||||
cmd_newpass = serverdir+f"/bin/mysql -u root -e \"ALTER USER 'root'@'localhost' IDENTIFIED BY '{new_password}'; FLUSH PRIVILEGES;\""
|
||||
data = mw.execShell(cmd_newpass)
|
||||
# print("新密码",cmd_newpass)
|
||||
# print(data)
|
||||
|
||||
# 验证密码
|
||||
cmd = serverdir+f"/bin/mysql -u root -p'{new_password}' -e 'SHOW DATABASES;'"
|
||||
data = mw.execShell(cmd)
|
||||
if data[1] == '':
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def setRootPwd(version=''):
|
||||
args = getArgs()
|
||||
data = checkArgs(args, ['password'])
|
||||
if not data[0]:
|
||||
return data[1]
|
||||
password = args['password']
|
||||
|
||||
#强制修改
|
||||
force = 0
|
||||
if 'force' in args and args['force'] == '1':
|
||||
force = 1
|
||||
pSqliteDb('config').where('id=?', (1,)).save('mysql_root', (password,))
|
||||
return mw.returnJson(True, '【强制本地记录】数据库root密码修改成功(立马检查)!')
|
||||
if 'force' in args and args['force'] == '2':
|
||||
force = 2
|
||||
ok = setRootPwdForce(password,version)
|
||||
|
||||
password = args['password']
|
||||
pSqliteDb('config').where('id=?', (1,)).save('mysql_root', (password,))
|
||||
if ok and version.startswith("8"):
|
||||
pdb = pMysqlDb()
|
||||
pdb.query("SET GLOBAL validate_password.policy=MEDIUM;")
|
||||
return mw.returnJson(True, '【强制】数据库root密码修改成功!')
|
||||
|
||||
try:
|
||||
pdb = pMysqlDb()
|
||||
result = pdb.query("show databases")
|
||||
isError = isSqlError(result)
|
||||
if isError != None:
|
||||
if force == 1:
|
||||
pSqliteDb('config').where('id=?', (1,)).save('mysql_root', (password,))
|
||||
return mw.returnJson(True, '【强制修改】数据库root密码修改成功(不意为成功连接数据)!')
|
||||
return isError
|
||||
|
||||
if version.find('5.7') > -1 or version.find('8.0') > -1:
|
||||
@@ -3031,7 +3096,6 @@ def deleteSlaveFunc(sign = ''):
|
||||
db = pMysqlDb()
|
||||
slave_name = getSlaveName()
|
||||
if sign != '':
|
||||
sign = args['sign']
|
||||
db.query("stop {} for channel '{}'".format(slave_name,sign))
|
||||
db.query("reset {} all for channel '{}'".format(slave_name, sign))
|
||||
else:
|
||||
|
||||
@@ -12,6 +12,7 @@ export PATH
|
||||
# cd /www/server/mdserver-web && source bin/activate && python3 plugins/mysql/index.py init_slave_status
|
||||
# cd /www/server/mdserver-web && source bin/activate && python3 plugins/mysql/index.py install_pre_inspection
|
||||
# cd /www/server/mdserver-web && source bin/activate && python3 plugins/mysql/index.py set_slave_status {"close":"change"}
|
||||
# cd /www/server/mdserver-web && source bin/activate && python3 plugins/mysql/index.py set_root_pwd {"password":"root","force":"2"}
|
||||
curPath=`pwd`
|
||||
rootPath=$(dirname "$curPath")
|
||||
rootPath=$(dirname "$rootPath")
|
||||
|
||||
@@ -535,16 +535,16 @@ function setRootPwd(type, pwd){
|
||||
|
||||
var index = layer.open({
|
||||
type: 1,
|
||||
area: '500px',
|
||||
area: '800px',
|
||||
title: '修改数据库密码',
|
||||
closeBtn: 1,
|
||||
shift: 5,
|
||||
btn:["提交", "关闭", "复制ROOT密码", "强制修改"],
|
||||
btn:["提交", "关闭", "复制ROOT密码", "修改本地ROOT记录", "强改ROOT密码"],
|
||||
shadeClose: true,
|
||||
content: "<form class='bt-form pd20' id='mod_pwd'>\
|
||||
<div class='line'>\
|
||||
<span class='tname'>root密码</span>\
|
||||
<div class='info-r'><input class='bt-input-text mr5' type='text' name='password' id='MyPassword' style='width:330px' value='"+pwd+"' />\
|
||||
<div class='info-r'><input class='bt-input-text mr5' type='text' name='password' id='MyPassword' style='width:630px' value='"+pwd+"' />\
|
||||
<span title='随机密码' class='glyphicon glyphicon-repeat cursor' onclick='repeatPwd(16)'></span>\
|
||||
</div>\
|
||||
</div>\
|
||||
@@ -565,7 +565,7 @@ function setRootPwd(type, pwd){
|
||||
return false;
|
||||
},
|
||||
btn4:function(layerIndex){
|
||||
layer.confirm('强制修改,是为了在重建时使用,确定强制?', {
|
||||
layer.confirm('修改本地ROOT记录,确定修改?', {
|
||||
btn: ['确定', '取消']
|
||||
}, function(index, layero){
|
||||
layer.close(index);
|
||||
@@ -579,6 +579,22 @@ function setRootPwd(type, pwd){
|
||||
});
|
||||
});
|
||||
return false;
|
||||
},
|
||||
btn5:function(layerIndex){
|
||||
layer.confirm('强制修改MySQL密码,确定强制? (比较耗时)', {
|
||||
btn: ['确定', '取消']
|
||||
}, function(index, layero){
|
||||
layer.close(index);
|
||||
var password = $("#MyPassword").val();
|
||||
myPost('set_root_pwd', {password:password,force:'2'}, function(data){
|
||||
var rdata = $.parseJSON(data.data);
|
||||
showMsg(rdata.msg,function(){
|
||||
layer.close(layerIndex);
|
||||
dbList();
|
||||
},{icon: rdata.status ? 1 : 2});
|
||||
});
|
||||
});
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -11,6 +11,9 @@ events
|
||||
use {$EVENT_MODEL};
|
||||
worker_connections 51200;
|
||||
multi_accept on;
|
||||
|
||||
# file/video close the mutex lock when under high load
|
||||
# accept_mutex off;
|
||||
}
|
||||
|
||||
http
|
||||
@@ -32,14 +35,16 @@ http
|
||||
client_body_buffer_size 50m;
|
||||
client_max_body_size 50m;
|
||||
|
||||
# video big file opt
|
||||
# aio threads;
|
||||
directio 4m;
|
||||
output_buffers 16 512k;
|
||||
sendfile on;
|
||||
tcp_nopush on;
|
||||
tcp_nodelay on;
|
||||
|
||||
keepalive_timeout 60;
|
||||
|
||||
|
||||
|
||||
fastcgi_connect_timeout 300;
|
||||
fastcgi_send_timeout 300;
|
||||
fastcgi_read_timeout 300;
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
"name": "php-apt",
|
||||
"title": "PHP[APT]",
|
||||
"coexist": true,
|
||||
"versions": ["56","70","71","72","73","74","80","81","82","83","84"],
|
||||
"versions": ["56","70","71","72","73","74","80","81","82","83","84", "85"],
|
||||
"install_pre_inspection":true,
|
||||
"tip": "soft",
|
||||
"checks": "server/php-apt/VERSION",
|
||||
|
||||
@@ -57,10 +57,10 @@ if [ ! -f /etc/apt/sources.list.d/php.list ] && [ "$OSNAME" == "debian" ];then
|
||||
apt install -y apt-transport-https lsb-release ca-certificates curl
|
||||
cn=$(curl -fsSL -m 10 http://ipinfo.io/json | grep "\"country\": \"CN\"")
|
||||
if [ ! -z "$cn" ];then
|
||||
curl -sSLo /usr/share/keyrings/deb.sury.org-php.gpg https://mirror.sjtu.edu.cn/sury/php/apt.gpg
|
||||
curl -o /usr/share/keyrings/deb.sury.org-php.gpg https://mirror.sjtu.edu.cn/sury/php/apt.gpg
|
||||
sh -c 'echo "deb [signed-by=/usr/share/keyrings/deb.sury.org-php.gpg] https://mirror.sjtu.edu.cn/sury/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list'
|
||||
else
|
||||
curl -sSLo /usr/share/keyrings/deb.sury.org-php.gpg https://packages.sury.org/php/apt.gpg
|
||||
curl -o /usr/share/keyrings/deb.sury.org-php.gpg https://packages.sury.org/php/apt.gpg
|
||||
sh -c 'echo "deb [signed-by=/usr/share/keyrings/deb.sury.org-php.gpg] https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list'
|
||||
fi
|
||||
apt update -y
|
||||
|
||||
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")
|
||||
sourcePath=${serverPath}/source
|
||||
sysName=`uname`
|
||||
|
||||
#获取信息和版本
|
||||
# bash /www/server/mdsever-web/scripts/getos.sh
|
||||
bash ${rootPath}/scripts/getos.sh
|
||||
OSNAME=`cat ${rootPath}/data/osname.pl`
|
||||
VERSION_ID=`cat /etc/*-release | grep VERSION_ID | awk -F = '{print $2}' | awk -F "\"" '{print $2}'`
|
||||
|
||||
version=8.5
|
||||
PHP_VER=85
|
||||
|
||||
|
||||
Install_php()
|
||||
{
|
||||
#------------------------ install start ------------------------------------#
|
||||
apt -y install php${version} php${version}-fpm php${version}-dev
|
||||
if [ "$?" == "0" ];then
|
||||
mkdir -p $serverPath/php-apt/${PHP_VER}
|
||||
fi
|
||||
|
||||
#------------------------ install end ------------------------------------#
|
||||
}
|
||||
|
||||
Uninstall_php()
|
||||
{
|
||||
#------------------------ uninstall start ------------------------------------#
|
||||
apt -y remove php${version} php${version}-*
|
||||
rm -rf $serverPath/php-apt/${PHP_VER}
|
||||
echo "卸载php-${version}..."
|
||||
#------------------------ uninstall start ------------------------------------#
|
||||
}
|
||||
|
||||
action=${1}
|
||||
if [ "${1}" == 'install' ];then
|
||||
Install_php
|
||||
else
|
||||
Uninstall_php
|
||||
fi
|
||||
@@ -9,6 +9,7 @@ rootPath=$(dirname "$rootPath")
|
||||
serverPath=$(dirname "$rootPath")
|
||||
|
||||
# cd /www/server/mdserver-web/plugins/php-apt/versions && /bin/bash all_test.sh
|
||||
# cd /www/server/mdserver-web/plugins/php-apt && bash install.sh install 85
|
||||
|
||||
|
||||
# cd /www/server/mdserver-web && python3 /www/server/mdserver-web/plugins/php-apt/index.py start 5.6
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
"name": "php",
|
||||
"title": "PHP",
|
||||
"coexist": true,
|
||||
"versions": ["53","54","55","56","70","71","72","73","74","80","81","82","83","84"],
|
||||
"updates": ["5.3.29","5.4.45","5.6.36","7.0.30","7.1.33","7.2.32","7.3.20","7.4.30","8.0.30","8.1.29","8.2.27","8.3.15","8.4.2"],
|
||||
"versions": ["53","54","55","56","70","71","72","73","74","80","81","82","83","84","85"],
|
||||
"updates": ["5.3.29","5.4.45","5.6.36","7.0.30","7.1.33","7.2.32","7.3.20","7.4.30","8.0.30","8.1.29","8.2.27","8.3.15","8.4.2","8.5.0"],
|
||||
"tip": "soft",
|
||||
"install_pre_inspection":true,
|
||||
"checks": "server/php/VERSION/bin/php",
|
||||
|
||||
@@ -8,6 +8,8 @@ rootPath=$(dirname "$rootPath")
|
||||
serverPath=$(dirname "$rootPath")
|
||||
sysName=`uname`
|
||||
|
||||
# https://www.php.net/releases
|
||||
|
||||
if id www &> /dev/null ;then
|
||||
echo "www uid is `id -u www`"
|
||||
echo "www shell is `grep "^www:" /etc/passwd |cut -d':' -f7 `"
|
||||
|
||||
@@ -9,9 +9,9 @@ serverPath=$(dirname "$rootPath")
|
||||
sourcePath=${serverPath}/source
|
||||
sysName=`uname`
|
||||
|
||||
version=8.1.32
|
||||
version=8.1.33
|
||||
PHP_VER=81
|
||||
md5_file_ok=c582ac682a280bbc69bc2186c21eb7e3313cc73099be61a6bc1d2cd337cbf383
|
||||
md5_file_ok=9db83bf4590375562bc1a10b353cccbcf9fcfc56c58b7c8fb814e6865bb928d1
|
||||
Install_php()
|
||||
{
|
||||
#------------------------ install start ------------------------------------#
|
||||
|
||||
@@ -9,9 +9,9 @@ serverPath=$(dirname "$rootPath")
|
||||
sourcePath=${serverPath}/source
|
||||
sysName=`uname`
|
||||
|
||||
version=8.2.28
|
||||
version=8.2.29
|
||||
PHP_VER=82
|
||||
md5_file_ok=af8c9153153a7f489153b7a74f2f29a5ee36f5cb2c6c6929c98411a577e89c91
|
||||
md5_file_ok=475f991afd2d5b901fb410be407d929bc00c46285d3f439a02c59e8b6fe3589c
|
||||
Install_php()
|
||||
{
|
||||
#------------------------ install start ------------------------------------#
|
||||
|
||||
@@ -9,9 +9,9 @@ serverPath=$(dirname "$rootPath")
|
||||
sourcePath=${serverPath}/source
|
||||
sysName=`uname`
|
||||
|
||||
version=8.3.21
|
||||
version=8.3.23
|
||||
PHP_VER=83
|
||||
md5_file_ok=4dfb329f209a552c3716394fc123bb62e80a468b55ce27fc8cb0fd5f30b9dcd6
|
||||
md5_file_ok=08be64700f703bca6ff1284bf1fdaffa37ae1b9734b6559f8350248e8960a6db
|
||||
Install_php()
|
||||
{
|
||||
#------------------------ install start ------------------------------------#
|
||||
|
||||
@@ -9,9 +9,9 @@ serverPath=$(dirname "$rootPath")
|
||||
sourcePath=${serverPath}/source
|
||||
sysName=`uname`
|
||||
|
||||
version=8.4.7
|
||||
version=8.4.10
|
||||
PHP_VER=84
|
||||
md5_file_ok=e29f4c23be2816ed005aa3f06bbb8eae0f22cc133863862e893515fc841e65e3
|
||||
md5_file_ok=14983a9ef8800e6bc2d920739fd386054402f7976ca9cd7f711509496f0d2632
|
||||
Install_php()
|
||||
{
|
||||
#------------------------ install start ------------------------------------#
|
||||
|
||||
Executable
+174
@@ -0,0 +1,174 @@
|
||||
#!/bin/bash
|
||||
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin:/opt/homebrew/bin
|
||||
export PATH=$PATH:/opt/homebrew/bin
|
||||
|
||||
curPath=`pwd`
|
||||
rootPath=$(dirname "$curPath")
|
||||
rootPath=$(dirname "$rootPath")
|
||||
serverPath=$(dirname "$rootPath")
|
||||
sourcePath=${serverPath}/source
|
||||
sysName=`uname`
|
||||
|
||||
version=8.5.0beta1
|
||||
PHP_VER=85
|
||||
# md5_file_ok=14983a9ef8800e6bc2d920739fd386054402f7976ca9cd7f711509496f0d2632
|
||||
Install_php()
|
||||
{
|
||||
#------------------------ install start ------------------------------------#
|
||||
echo "安装php-${version} ..."
|
||||
mkdir -p $sourcePath/php
|
||||
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
|
||||
|
||||
# # ----------------------------------------------------------------------- #
|
||||
# # 中国优化安装
|
||||
# cn=$(curl -fsSL -m 10 -s http://ipinfo.io/json | grep "\"country\": \"CN\"")
|
||||
# LOCAL_ADDR=common
|
||||
# if [ ! -z "$cn" ];then
|
||||
# LOCAL_ADDR=cn
|
||||
# fi
|
||||
|
||||
# if [ "$LOCAL_ADDR" == "cn" ];then
|
||||
# if [ ! -f $sourcePath/php/php-${version}.tar.xz ];then
|
||||
# wget --no-check-certificate -O $sourcePath/php/php-${version}.tar.xz https://mirrors.nju.edu.cn/php/php-${version}.tar.xz
|
||||
# fi
|
||||
# fi
|
||||
# # ----------------------------------------------------------------------- #
|
||||
|
||||
|
||||
if [ ! -f $sourcePath/php/php-${version}.tar.xz ];then
|
||||
# wget --no-check-certificate -O $sourcePath/php/php-${version}.tar.xz https://www.php.net/distributions/php-${version}.tar.xz
|
||||
wget --no-check-certificate -O $sourcePath/php/php-${version}.tar.xz https://downloads.php.net/~edorian/php-${version}.tar.xz
|
||||
fi
|
||||
|
||||
#检测文件是否损坏.
|
||||
# if [ -f $sourcePath/php/php-${version}.tar.xz ];then
|
||||
# md5_file=`sha256sum $sourcePath/php/php-${version}.tar.xz | awk '{print $1}'`
|
||||
# if [ "${md5_file}" != "${md5_file_ok}" ]; then
|
||||
# echo "PHP${version} 下载文件不完整,重新安装"
|
||||
# rm -rf $sourcePath/php/php-${version}.tar.xz
|
||||
# fi
|
||||
# fi
|
||||
|
||||
cd $sourcePath/php && tar -Jxf $sourcePath/php/php-${version}.tar.xz
|
||||
mv $sourcePath/php/php-${version} $sourcePath/php/php${PHP_VER}
|
||||
fi
|
||||
|
||||
cd $sourcePath/php/php${PHP_VER}
|
||||
|
||||
OPTIONS='--without-iconv'
|
||||
|
||||
# if [ $sysName == 'Darwin' ]; then
|
||||
# OPTIONS="${OPTIONS} --with-curl"
|
||||
# fi
|
||||
|
||||
argon_version=`pkg-config libargon2 --modversion`
|
||||
if [ "$?" == "0" ];then
|
||||
OPTIONS="${OPTIONS} --with-password-argon2"
|
||||
fi
|
||||
|
||||
IS_64BIT=`getconf LONG_BIT`
|
||||
if [ "$IS_64BIT" == "64" ];then
|
||||
OPTIONS="${OPTIONS} --with-libdir=lib64"
|
||||
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=$(which free > /dev/null && 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 ------
|
||||
|
||||
# OPTIONS="${OPTIONS} --enable-debug"
|
||||
# OPTIONS="${OPTIONS} --enable-dtrace"
|
||||
|
||||
if [ "$sysName" == "Darwin" ];then
|
||||
BREW_DIR=`which brew`
|
||||
BREW_DIR=${BREW_DIR/\/bin\/brew/}
|
||||
|
||||
LIB_DEPEND_DIR=`brew info openssl | grep ${BREW_DIR}/Cellar/openssl | cut -d \ -f 1 | awk 'END {print}'`
|
||||
OPTIONS="$OPTIONS --with-openssl=$(brew --prefix openssl)"
|
||||
export PKG_CONFIG_PATH=$LIB_DEPEND_DIR/lib/pkgconfig
|
||||
export OPENSSL_CFLAGS="-I${LIB_DEPEND_DIR}/include"
|
||||
export OPENSSL_LIBS="-L/${LIB_DEPEND_DIR}/lib -lssl -lcrypto -lz"
|
||||
else
|
||||
cd ${rootPath}/plugins/php/lib && /bin/bash openssl_30.sh
|
||||
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$serverPath/lib/openssl30/lib/pkgconfig
|
||||
OPTIONS="$OPTIONS --with-openssl"
|
||||
fi
|
||||
|
||||
echo "$sourcePath/php/php${PHP_VER}"
|
||||
|
||||
if [ ! -d $serverPath/php/${PHP_VER} ];then
|
||||
cd $sourcePath/php/php${PHP_VER}
|
||||
# ./buildconf --force
|
||||
./configure \
|
||||
--prefix=$serverPath/php/${PHP_VER} \
|
||||
--exec-prefix=$serverPath/php/${PHP_VER} \
|
||||
--with-config-file-path=$serverPath/php/${PHP_VER}/etc \
|
||||
--enable-mysqlnd \
|
||||
--with-mysql=mysqlnd \
|
||||
--with-mysqli=mysqlnd \
|
||||
--with-pdo-mysql=mysqlnd \
|
||||
--with-mysqlnd-ssl \
|
||||
--enable-mbstring \
|
||||
--enable-ftp \
|
||||
--enable-sockets \
|
||||
--enable-simplexml \
|
||||
--enable-soap \
|
||||
--enable-posix \
|
||||
--enable-sysvmsg \
|
||||
--enable-sysvsem \
|
||||
--enable-sysvshm \
|
||||
--disable-intl \
|
||||
--disable-fileinfo \
|
||||
$OPTIONS \
|
||||
--enable-fpm
|
||||
make clean && make -j${cpuCore} && make install && make clean
|
||||
|
||||
# rm -rf $sourcePath/php/php${PHP_VER}
|
||||
fi
|
||||
#------------------------ install end ------------------------------------#
|
||||
}
|
||||
|
||||
Uninstall_php()
|
||||
{
|
||||
$serverPath/php/init.d/php${PHP_VER} stop
|
||||
rm -rf $serverPath/php/${PHP_VER}
|
||||
echo "卸载php-${version}..."
|
||||
}
|
||||
|
||||
action=${1}
|
||||
if [ "${1}" == 'install' ];then
|
||||
Install_php
|
||||
else
|
||||
Uninstall_php
|
||||
fi
|
||||
@@ -30,7 +30,7 @@ ROOT_DIR=$(cd "$(dirname "$0")"; pwd)
|
||||
# echo "php${PHP_VER} -- end"
|
||||
|
||||
|
||||
PHP_VER_LIST=(54 55 56 70 71 72 73 74 80 81 82 83 84)
|
||||
PHP_VER_LIST=(54 55 56 70 71 72 73 74 80 81 82 83 84 85)
|
||||
# PHP_VER_LIST=(81)
|
||||
for PHP_VER in ${PHP_VER_LIST[@]}; do
|
||||
echo "php${PHP_VER} -- start"
|
||||
@@ -41,7 +41,7 @@ for PHP_VER in ${PHP_VER_LIST[@]}; do
|
||||
done
|
||||
|
||||
cd $DIR
|
||||
PHP_VER_LIST=(54 55 56 70 71 72 73 74 80 81 82 83 84)
|
||||
PHP_VER_LIST=(54 55 56 70 71 72 73 74 80 81 82 83 84 85)
|
||||
# yar
|
||||
PHP_EXT_LIST=(ZendGuardLoader pdo mysqlnd sqlite3 openssl opcache mcrypt fileinfo \
|
||||
exif gd intl pcntl memcache memcached redis imagemagick xdebug \
|
||||
|
||||
@@ -28,7 +28,7 @@ ROOT_DIR=$(cd "$(dirname "$0")"; pwd)
|
||||
# echo "php${PHP_VER} -- end"
|
||||
|
||||
|
||||
PHP_VER_LIST=(53 54 55 56 70 71 72 73 74 80 81 82 83 84)
|
||||
PHP_VER_LIST=(53 54 55 56 70 71 72 73 74 80 81 82 83 84 85)
|
||||
# PHP_VER_LIST=(81)
|
||||
for PHP_VER in ${PHP_VER_LIST[@]}; do
|
||||
echo "php${PHP_VER} -- start"
|
||||
@@ -39,11 +39,11 @@ for PHP_VER in ${PHP_VER_LIST[@]}; do
|
||||
done
|
||||
|
||||
cd $DIR
|
||||
PHP_VER_LIST=(53 54 55 56 70 71 72 73 74 80 81 82 83 84)
|
||||
PHP_VER_LIST=(53 54 55 56 70 71 72 73 74 80 81 82 83 84 85)
|
||||
# yar
|
||||
PHP_EXT_LIST=(ZendGuardLoader pdo mysqlnd sqlite3 openssl opcache mcrypt fileinfo \
|
||||
exif gd intl pcntl memcache memcached redis imagemagick xdebug \
|
||||
swoole yac apc mongo mongodb solr seaslog mbstring iconv event)
|
||||
exif gd intl pcntl memcache memcached redis xdebug \
|
||||
swoole yac apc mongo mongodb seaslog mbstring iconv event)
|
||||
|
||||
for PHP_VER in ${PHP_VER_LIST[@]}; do
|
||||
echo "php${PHP_VER} -- start"
|
||||
|
||||
@@ -15,7 +15,7 @@ actionType=$1
|
||||
version=$2
|
||||
|
||||
LIBNAME=event
|
||||
LIBV=3.1.3
|
||||
LIBV=3.1.4
|
||||
|
||||
|
||||
if [ "$version" -lt "55" ];then
|
||||
@@ -24,7 +24,7 @@ if [ "$version" -lt "55" ];then
|
||||
fi
|
||||
|
||||
if [ "$version" -lt "83" ];then
|
||||
LIBV=3.0.8
|
||||
LIBV=3.1.4
|
||||
fi
|
||||
|
||||
LIB_PATH_NAME=lib/php
|
||||
|
||||
@@ -12,7 +12,7 @@ serverPath=$(dirname "$rootPath")
|
||||
sourcePath=${serverPath}/source/php
|
||||
SYS_ARCH=`arch`
|
||||
LIBNAME=imagick
|
||||
LIBV=3.7.0
|
||||
LIBV=3.8.0
|
||||
sysName=`uname`
|
||||
actionType=$1
|
||||
version=$2
|
||||
|
||||
@@ -21,7 +21,7 @@ if [ "$version" -lt "72" ];then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$version" == "84" ];then
|
||||
if [ "$version" -ge "84" ];then
|
||||
LIBV=1.0.7
|
||||
echo "not need"
|
||||
exit 1
|
||||
|
||||
@@ -12,7 +12,7 @@ serverPath=$(dirname "$rootPath")
|
||||
sourcePath=${serverPath}/source/php
|
||||
SYS_ARCH=`arch`
|
||||
LIBNAME=memcached
|
||||
LIBV=3.2.0
|
||||
LIBV=3.3.0
|
||||
sysName=`uname`
|
||||
actionType=$1
|
||||
version=$2
|
||||
|
||||
@@ -12,7 +12,7 @@ serverPath=$(dirname "$rootPath")
|
||||
sourcePath=${serverPath}/source/php
|
||||
SYS_ARCH=`arch`
|
||||
LIBNAME=solr
|
||||
LIBV=2.7.0
|
||||
LIBV=2.8.1
|
||||
sysName=`uname`
|
||||
actionType=$1
|
||||
version=$2
|
||||
@@ -101,6 +101,9 @@ Uninstall_lib()
|
||||
echo "php$version 未安装,请选择其它版本!"
|
||||
return
|
||||
fi
|
||||
|
||||
sed -i $BAK "/${LIBNAME}.so/d" $serverPath/php/$version/etc/php.ini
|
||||
sed -i $BAK "/${LIBNAME}/d" $serverPath/php/$version/etc/php.ini
|
||||
|
||||
extFile=$extDir${LIBNAME}.so
|
||||
if [ ! -f "$extFile" ];then
|
||||
@@ -108,9 +111,6 @@ Uninstall_lib()
|
||||
echo "php-$vphp not install ${LIBNAME}, Plese select other version!"
|
||||
return
|
||||
fi
|
||||
|
||||
sed -i $BAK "/${LIBNAME}.so/d" $serverPath/php/$version/etc/php.ini
|
||||
sed -i $BAK "/${LIBNAME}/d" $serverPath/php/$version/etc/php.ini
|
||||
|
||||
rm -f $extFile
|
||||
cd ${curPath} && bash ${rootPath}/plugins/php/versions/lib.sh $version restart
|
||||
|
||||
@@ -17,16 +17,23 @@ version=$2
|
||||
LIBNAME=swoole
|
||||
LIBV=5.1.6
|
||||
|
||||
if [ "$version" == "85" ];then
|
||||
echo "not need"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$version" -lt "70" ];then
|
||||
LIBV=1.10.1
|
||||
elif [ "$version" == "70" ];then
|
||||
LIBV=4.3.0
|
||||
elif [ "$version" == "71" ];then
|
||||
LIBV=4.5.2
|
||||
elif [ "$version" == "72" ] || [ "$version" == "73" ] || [ "$version" == "74" ];then
|
||||
elif [ "$version" -le "74" ];then
|
||||
LIBV=4.8.10
|
||||
elif [ "$version" -gt "74" ];then
|
||||
LIBV=5.1.6
|
||||
elif [ "$version" -lt "80" ];then
|
||||
LIBV=6.0.2
|
||||
elif [ "$version" -gt "80" ];then
|
||||
LIBV=6.0.2
|
||||
else
|
||||
echo 'other?'
|
||||
exit 0
|
||||
|
||||
@@ -12,21 +12,27 @@ serverPath=$(dirname "$rootPath")
|
||||
sourcePath=${serverPath}/source/php
|
||||
SYS_ARCH=`arch`
|
||||
LIBNAME=xdebug
|
||||
LIBV=3.1.5
|
||||
LIBV=3.4.5
|
||||
sysName=`uname`
|
||||
actionType=$1
|
||||
version=$2
|
||||
|
||||
if [ "$version" == "85" ];then
|
||||
echo "not need"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
if [ "$version" -lt "70" ];then
|
||||
LIBV=2.2.7
|
||||
fi
|
||||
|
||||
if [ "$version" -eq "70" ] || [ "$version" -eq "71" ];then
|
||||
if [ "$version" -le "80" ];then
|
||||
LIBV=2.7.0
|
||||
fi
|
||||
|
||||
if [ "$version" -gt "80" ];then
|
||||
LIBV=3.3.2
|
||||
LIBV=3.4.5
|
||||
fi
|
||||
|
||||
LIB_PATH_NAME=lib/php
|
||||
|
||||
@@ -12,7 +12,7 @@ serverPath=$(dirname "$rootPath")
|
||||
sourcePath=${serverPath}/source/php
|
||||
SYS_ARCH=`arch`
|
||||
LIBNAME=xhprof
|
||||
LIBV=2.3.7
|
||||
LIBV=2.3.10
|
||||
sysName=`uname`
|
||||
actionType=$1
|
||||
version=$2
|
||||
|
||||
@@ -78,7 +78,8 @@
|
||||
"81",
|
||||
"82",
|
||||
"83",
|
||||
"84"
|
||||
"84",
|
||||
"85"
|
||||
],
|
||||
"type": "加密库",
|
||||
"msg": "Sodium加密库的包装器",
|
||||
@@ -97,7 +98,8 @@
|
||||
"81",
|
||||
"82",
|
||||
"83",
|
||||
"84"
|
||||
"84",
|
||||
"85"
|
||||
],
|
||||
"type": "压缩",
|
||||
"msg": "压缩算法",
|
||||
@@ -116,7 +118,8 @@
|
||||
"81",
|
||||
"82",
|
||||
"83",
|
||||
"84"
|
||||
"84",
|
||||
"85"
|
||||
],
|
||||
"type": "运算库",
|
||||
"msg": "一个开源的数学运算库",
|
||||
@@ -139,7 +142,8 @@
|
||||
"81",
|
||||
"82",
|
||||
"83",
|
||||
"84"
|
||||
"84",
|
||||
"85"
|
||||
],
|
||||
"type": "缓存器",
|
||||
"msg": "用于加速PHP脚本!",
|
||||
@@ -163,7 +167,8 @@
|
||||
"81",
|
||||
"82",
|
||||
"83",
|
||||
"84"
|
||||
"84",
|
||||
"85"
|
||||
],
|
||||
"type": "通用扩展",
|
||||
"msg": "SSL",
|
||||
@@ -180,7 +185,9 @@
|
||||
"80",
|
||||
"81",
|
||||
"82",
|
||||
"83"
|
||||
"83",
|
||||
"84",
|
||||
"85"
|
||||
],
|
||||
"type": "通用扩展",
|
||||
"msg": "加密软件",
|
||||
@@ -201,7 +208,8 @@
|
||||
"81",
|
||||
"82",
|
||||
"83",
|
||||
"84"
|
||||
"84",
|
||||
"85"
|
||||
],
|
||||
"type": "通用扩展",
|
||||
"msg": "轻型目录访问协议",
|
||||
@@ -236,7 +244,8 @@
|
||||
"81",
|
||||
"82",
|
||||
"83",
|
||||
"84"
|
||||
"84",
|
||||
"85"
|
||||
],
|
||||
"type": "通用扩展",
|
||||
"msg": "高精度计算!",
|
||||
@@ -260,7 +269,8 @@
|
||||
"81",
|
||||
"82",
|
||||
"83",
|
||||
"84"
|
||||
"84",
|
||||
"85"
|
||||
],
|
||||
"type": "缓存器",
|
||||
"msg": "用于信号控制!",
|
||||
@@ -284,7 +294,8 @@
|
||||
"81",
|
||||
"82",
|
||||
"83",
|
||||
"84"
|
||||
"84",
|
||||
"85"
|
||||
],
|
||||
"type": "通用扩展",
|
||||
"msg": "编码转换!",
|
||||
@@ -306,7 +317,8 @@
|
||||
"81",
|
||||
"82",
|
||||
"83",
|
||||
"84"
|
||||
"84",
|
||||
"85"
|
||||
],
|
||||
"type": "通用扩展",
|
||||
"msg": "用于FILE!",
|
||||
@@ -327,7 +339,8 @@
|
||||
"81",
|
||||
"82",
|
||||
"83",
|
||||
"84"
|
||||
"84",
|
||||
"85"
|
||||
],
|
||||
"type": "通用扩展",
|
||||
"msg": "提供到libevent库的接口",
|
||||
@@ -349,7 +362,8 @@
|
||||
"81",
|
||||
"82",
|
||||
"83",
|
||||
"84"
|
||||
"84",
|
||||
"85"
|
||||
],
|
||||
"type": "通用扩展",
|
||||
"msg": "用于图像文件格式!",
|
||||
@@ -368,7 +382,8 @@
|
||||
"81",
|
||||
"82",
|
||||
"83",
|
||||
"84"
|
||||
"84",
|
||||
"85"
|
||||
],
|
||||
"type": "通用扩展",
|
||||
"msg": "序列化扩展!",
|
||||
@@ -392,7 +407,8 @@
|
||||
"81",
|
||||
"82",
|
||||
"83",
|
||||
"84"
|
||||
"84",
|
||||
"85"
|
||||
],
|
||||
"type": "通用扩展",
|
||||
"msg": "国际化与本地化!",
|
||||
@@ -416,7 +432,8 @@
|
||||
"81",
|
||||
"82",
|
||||
"83",
|
||||
"84"
|
||||
"84",
|
||||
"85"
|
||||
],
|
||||
"type": "通用扩展",
|
||||
"msg": "通用GD库!",
|
||||
@@ -440,7 +457,8 @@
|
||||
"81",
|
||||
"82",
|
||||
"83",
|
||||
"84"
|
||||
"84",
|
||||
"85"
|
||||
],
|
||||
"type": "通用扩展",
|
||||
"msg": "通用网络",
|
||||
@@ -464,7 +482,8 @@
|
||||
"81",
|
||||
"82",
|
||||
"83",
|
||||
"84"
|
||||
"84",
|
||||
"85"
|
||||
],
|
||||
"type": "通用扩展",
|
||||
"msg": "提供国际化支持",
|
||||
@@ -479,7 +498,8 @@
|
||||
"81",
|
||||
"82",
|
||||
"83",
|
||||
"84"
|
||||
"84",
|
||||
"85"
|
||||
],
|
||||
"type": "通用扩展",
|
||||
"msg": "命令行的支持",
|
||||
@@ -525,7 +545,8 @@
|
||||
"81",
|
||||
"82",
|
||||
"83",
|
||||
"84"
|
||||
"84",
|
||||
"85"
|
||||
],
|
||||
"type": "缓存器",
|
||||
"msg": "强大的内容缓存器,支持集群",
|
||||
@@ -549,7 +570,8 @@
|
||||
"81",
|
||||
"82",
|
||||
"83",
|
||||
"84"
|
||||
"84",
|
||||
"85"
|
||||
],
|
||||
"type": "缓存器",
|
||||
"msg": "更强大的内容缓存器,支持集群",
|
||||
@@ -598,7 +620,8 @@
|
||||
"81",
|
||||
"82",
|
||||
"83",
|
||||
"84"
|
||||
"84",
|
||||
"85"
|
||||
],
|
||||
"type": "通用扩展",
|
||||
"msg": "比GD更强大的图形库",
|
||||
@@ -620,7 +643,9 @@
|
||||
"80",
|
||||
"81",
|
||||
"82",
|
||||
"83"
|
||||
"83",
|
||||
"84",
|
||||
"85"
|
||||
],
|
||||
"type": "调试器",
|
||||
"msg": "不多说,不了解的不要安装",
|
||||
@@ -643,7 +668,9 @@
|
||||
"80",
|
||||
"81",
|
||||
"82",
|
||||
"83"
|
||||
"83",
|
||||
"84",
|
||||
"85"
|
||||
],
|
||||
"type": "性能分析",
|
||||
"msg": "不多说,不了解的不要安装!",
|
||||
@@ -665,7 +692,8 @@
|
||||
"80",
|
||||
"81",
|
||||
"82",
|
||||
"83"
|
||||
"83",
|
||||
"84"
|
||||
],
|
||||
"type": "通用扩展",
|
||||
"msg": "异步、并行、高性能网络通信引擎",
|
||||
@@ -689,7 +717,11 @@
|
||||
"73",
|
||||
"74",
|
||||
"80",
|
||||
"81"
|
||||
"81",
|
||||
"82",
|
||||
"83",
|
||||
"84",
|
||||
"85"
|
||||
],
|
||||
"type": "框架",
|
||||
"msg": "Phalcon是一个全栈PHP框架。",
|
||||
@@ -728,7 +760,9 @@
|
||||
"80",
|
||||
"81",
|
||||
"82",
|
||||
"83"
|
||||
"83",
|
||||
"84",
|
||||
"85"
|
||||
],
|
||||
"type": "通用扩展",
|
||||
"msg": "YAML-1.1解析器和发射器",
|
||||
@@ -762,7 +796,8 @@
|
||||
"81",
|
||||
"82",
|
||||
"83",
|
||||
"84"
|
||||
"84",
|
||||
"85"
|
||||
],
|
||||
"type": "通用扩展",
|
||||
"msg": "Mongodb数据库连接驱动",
|
||||
@@ -781,7 +816,8 @@
|
||||
"81",
|
||||
"82",
|
||||
"83",
|
||||
"84"
|
||||
"84",
|
||||
"85"
|
||||
],
|
||||
"type": "缓存器",
|
||||
"msg": "高性能无锁共享内存Cache",
|
||||
@@ -803,7 +839,9 @@
|
||||
"80",
|
||||
"81",
|
||||
"82",
|
||||
"83"
|
||||
"83",
|
||||
"84",
|
||||
"85"
|
||||
],
|
||||
"type": "大数据",
|
||||
"msg": "SOLR全文搜索服务",
|
||||
@@ -826,7 +864,8 @@
|
||||
"81",
|
||||
"82",
|
||||
"83",
|
||||
"84"
|
||||
"84",
|
||||
"85"
|
||||
],
|
||||
"type": "日志",
|
||||
"msg": "SeasLog高性能日志记录",
|
||||
@@ -850,7 +889,8 @@
|
||||
"81",
|
||||
"82",
|
||||
"83",
|
||||
"84"
|
||||
"84",
|
||||
"85"
|
||||
],
|
||||
"type": "压缩",
|
||||
"msg": "压缩组件",
|
||||
@@ -874,7 +914,8 @@
|
||||
"81",
|
||||
"82",
|
||||
"83",
|
||||
"84"
|
||||
"84",
|
||||
"85"
|
||||
],
|
||||
"type": "压缩",
|
||||
"msg": "压缩组件",
|
||||
|
||||
@@ -12,7 +12,7 @@ sysName=`uname`
|
||||
|
||||
postgreDir=${serverPath}/source/postgresql
|
||||
|
||||
VERSION=14.12
|
||||
VERSION=14.18
|
||||
|
||||
# su - postgres -c "/www/server/postgresql/bin/pg_ctl start -D /www/server/postgresql/data"
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ serverPath=$(dirname "$rootPath")
|
||||
sysName=`uname`
|
||||
|
||||
postgreDir=${serverPath}/source/postgresql
|
||||
VERSION=15.7
|
||||
VERSION=15.13
|
||||
|
||||
# su - postgres -c "/www/server/postgresql/bin/pg_ctl start -D /www/server/postgresql/data"
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ sysName=`uname`
|
||||
|
||||
postgreDir=${serverPath}/source/postgresql
|
||||
|
||||
VERSION=16.4
|
||||
VERSION=16.9
|
||||
|
||||
# su - postgres -c "/www/server/postgresql/bin/pg_ctl start -D /www/server/postgresql/data"
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ sysName=`uname`
|
||||
|
||||
postgreDir=${serverPath}/source/postgresql
|
||||
|
||||
VERSION=17.2
|
||||
VERSION=17.5
|
||||
|
||||
# su - postgres -c "/www/server/postgresql/bin/pg_ctl start -D /www/server/postgresql/data"
|
||||
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 2.6 KiB |
Executable
+30
@@ -0,0 +1,30 @@
|
||||
<style>
|
||||
.overflow_hide {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
vertical-align: middle;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div class="bt-form">
|
||||
<div class='plugin_version'></div>
|
||||
<div class="bt-w-main">
|
||||
<div class="bt-w-menu">
|
||||
<p class="bgw" onclick="pluginService('prometheus');">服务</p>
|
||||
<p onclick="pluginInitD('prometheus');">自启动</p>
|
||||
<p onclick="gCommonFunc($('.plugin_version').attr('version'));">常用功能</p>
|
||||
<p onclick="pluginConfig('prometheus',$('.plugin_version').attr('version'),'conf');">配置</p>
|
||||
<p onclick="gReadme();">相关说明</p>
|
||||
|
||||
</div>
|
||||
<div class="bt-w-con pd15">
|
||||
<div class="soft-man-con" style="height: 520px; overflow: auto;"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
$.getScript( "/plugins/file?name=prometheus&f=js/prometheus.js", function(){
|
||||
pluginService('prometheus', $('.plugin_version').attr('version'));
|
||||
});
|
||||
</script>
|
||||
Executable
+230
@@ -0,0 +1,230 @@
|
||||
# coding:utf-8
|
||||
|
||||
import sys
|
||||
import io
|
||||
import os
|
||||
import time
|
||||
import re
|
||||
|
||||
web_dir = os.getcwd() + "/web"
|
||||
if os.path.exists(web_dir):
|
||||
sys.path.append(web_dir)
|
||||
os.chdir(web_dir)
|
||||
|
||||
import core.mw as mw
|
||||
|
||||
app_debug = False
|
||||
if mw.isAppleSystem():
|
||||
app_debug = True
|
||||
|
||||
|
||||
def getPluginName():
|
||||
return 'prometheus'
|
||||
|
||||
|
||||
def getPluginDir():
|
||||
return mw.getPluginDir() + '/' + getPluginName()
|
||||
|
||||
|
||||
def getServerDir():
|
||||
return mw.getServerDir() + '/' + getPluginName()
|
||||
|
||||
|
||||
def getInitDFile():
|
||||
current_os = mw.getOs()
|
||||
if current_os == 'darwin':
|
||||
return '/tmp/' + getPluginName()
|
||||
|
||||
if current_os.startswith('freebsd'):
|
||||
return '/etc/rc.d/' + getPluginName()
|
||||
|
||||
return '/etc/init.d/' + getPluginName()
|
||||
|
||||
|
||||
def getConf():
|
||||
path = getServerDir() + "/prometheus.yml"
|
||||
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 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 getPidFile():
|
||||
file = getConf()
|
||||
content = mw.readFile(file)
|
||||
rep = r'pidfile\s*(.*)'
|
||||
tmp = re.search(rep, content)
|
||||
return tmp.groups()[0].strip()
|
||||
|
||||
def status():
|
||||
cmd = "ps aux|grep prometheus |grep -v grep | grep -v python | grep -v mdserver-web | awk '{print $2}'"
|
||||
data = mw.execShell(cmd)
|
||||
if data[0] == '':
|
||||
return 'stop'
|
||||
return 'start'
|
||||
|
||||
def getInstallVerion():
|
||||
version_pl = getServerDir() + "/version.pl"
|
||||
version = mw.readFile(version_pl).strip()
|
||||
return version
|
||||
|
||||
def contentReplace(content):
|
||||
service_path = mw.getServerDir()
|
||||
content = content.replace('{$ROOT_PATH}', mw.getFatherDir())
|
||||
content = content.replace('{$SERVER_PATH}', service_path)
|
||||
return content
|
||||
|
||||
|
||||
def openPort():
|
||||
try:
|
||||
from utils.firewall import Firewall as MwFirewall
|
||||
MwFirewall.instance().addAcceptPort('3000', 'prometheus', 'port')
|
||||
return port
|
||||
except Exception as e:
|
||||
return "Release failed {}".format(e)
|
||||
return True
|
||||
|
||||
|
||||
def initDreplace():
|
||||
# 初始化OP配置
|
||||
init_file = getServerDir() + '/init.pl'
|
||||
if not os.path.exists(init_file):
|
||||
# openPort()
|
||||
mw.writeFile(init_file, 'ok')
|
||||
|
||||
# systemd
|
||||
systemDir = mw.systemdCfgDir()
|
||||
systemService = systemDir + '/' + getPluginName() + '.service'
|
||||
if os.path.exists(systemDir) and not os.path.exists(systemService):
|
||||
systemServiceTpl = getPluginDir() + '/init.d/' + getPluginName() + '.service.tpl'
|
||||
service_path = mw.getServerDir()
|
||||
content = mw.readFile(systemServiceTpl)
|
||||
content = content.replace('{$SERVER_PATH}', service_path)
|
||||
mw.writeFile(systemService, content)
|
||||
mw.execShell('systemctl daemon-reload')
|
||||
|
||||
return True
|
||||
|
||||
|
||||
def gOp(method):
|
||||
initDreplace()
|
||||
|
||||
data = mw.execShell('systemctl ' + method + ' '+getPluginName())
|
||||
mw.execShell('systemctl ' + method + ' '+getPluginName())
|
||||
if data[1] == '':
|
||||
return 'ok'
|
||||
return data[1]
|
||||
|
||||
|
||||
def start():
|
||||
return gOp('start')
|
||||
|
||||
def stop():
|
||||
return gOp('stop')
|
||||
|
||||
def restart():
|
||||
return gOp('restart')
|
||||
|
||||
def reload():
|
||||
return gOp('reload')
|
||||
|
||||
def initdStatus():
|
||||
current_os = mw.getOs()
|
||||
if current_os == 'darwin':
|
||||
return "Apple Computer does not support"
|
||||
|
||||
shell_cmd = 'systemctl status prometheus|grep loaded|grep "enabled;"'
|
||||
data = mw.execShell(shell_cmd)
|
||||
if data[0] == '':
|
||||
return 'fail'
|
||||
return 'ok'
|
||||
|
||||
|
||||
def initdInstall():
|
||||
current_os = mw.getOs()
|
||||
if current_os == 'darwin':
|
||||
return "Apple Computer does not support"
|
||||
|
||||
data = mw.execShell('systemctl enable prometheus')
|
||||
if data[1] != '':
|
||||
return data[1]
|
||||
return 'ok'
|
||||
|
||||
|
||||
def initdUinstall():
|
||||
current_os = mw.getOs()
|
||||
if current_os == 'darwin':
|
||||
return "Apple Computer does not support"
|
||||
|
||||
data = mw.execShell('systemctl disable prometheus')
|
||||
if data[1] != '':
|
||||
return data[1]
|
||||
return 'ok'
|
||||
|
||||
def prometheusUrl():
|
||||
ip = mw.getLocalIp()
|
||||
return 'http://'+ip+':'+"9090"
|
||||
|
||||
def installPreInspection():
|
||||
return 'ok'
|
||||
|
||||
|
||||
def uninstallPreInspection():
|
||||
return 'ok'
|
||||
|
||||
|
||||
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 == 'install_pre_inspection':
|
||||
print(installPreInspection())
|
||||
elif func == 'uninstall_pre_inspection':
|
||||
print(uninstallPreInspection())
|
||||
elif func == 'conf':
|
||||
print(getConf())
|
||||
elif func == 'prometheus_url':
|
||||
print(prometheusUrl())
|
||||
else:
|
||||
print('error')
|
||||
Executable
+17
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"sort": 7,
|
||||
"ps": "监控系统与时间序列数据库",
|
||||
"name": "prometheus",
|
||||
"title": "prometheus",
|
||||
"shell": "install.sh",
|
||||
"versions":["3.5.0"],
|
||||
"tip": "soft",
|
||||
"checks": "server/prometheus",
|
||||
"path": "server/prometheus",
|
||||
"display": 1,
|
||||
"author": "midoks",
|
||||
"date": "2025-08-02",
|
||||
"home": "https://prometheus.io/download/",
|
||||
"type": 0,
|
||||
"pid": "5"
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
[Unit]
|
||||
Description=Prometheus
|
||||
Documentation=https://prometheus.io/docs/introduction/overview/
|
||||
Wants=network-online.target
|
||||
After=network-online.target
|
||||
[Service]
|
||||
Type=simple
|
||||
ExecReload=/bin/kill -HUP $MAINPID
|
||||
ExecStart={$SERVER_PATH}/prometheus/prometheus \
|
||||
--config.file={$SERVER_PATH}/prometheus/prometheus.yml \
|
||||
--storage.tsdb.path={$SERVER_PATH}/prometheus/data \
|
||||
--web.console.templates={$SERVER_PATH}/prometheus/consoles \
|
||||
--web.console.libraries={$SERVER_PATH}/prometheus/console_libraries \
|
||||
--web.listen-address=0.0.0.0:9090
|
||||
SyslogIdentifier=prometheus
|
||||
Restart=always
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
Executable
+85
@@ -0,0 +1,85 @@
|
||||
#!/bin/bash
|
||||
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin:/opt/homebrew/bin
|
||||
export PATH
|
||||
|
||||
# https://www.cnblogs.com/n00dle/p/16916044.html
|
||||
# cd /www/server/mdserver-web/plugins/prometheus && /bin/bash install.sh install 3.5.0
|
||||
# cd /www/server/mdserver-web && python3 /www/server/mdserver-web/plugins/prometheus/index.py start
|
||||
|
||||
curPath=`pwd`
|
||||
rootPath=$(dirname "$curPath")
|
||||
rootPath=$(dirname "$rootPath")
|
||||
serverPath=$(dirname "$rootPath")
|
||||
|
||||
VERSION=$2
|
||||
|
||||
sysArch=`arch`
|
||||
sysName=`uname`
|
||||
echo "use system: ${sysName}"
|
||||
|
||||
OSNAME=`bash ${rootPath}/scripts/getos.sh`
|
||||
if [ "" == "$OSNAME" ];then
|
||||
OSNAME=`cat ${rootPath}/data/osname.pl`
|
||||
fi
|
||||
|
||||
if [ "macos" == "$OSNAME" ];then
|
||||
echo "不支持Macox"
|
||||
exit
|
||||
fi
|
||||
|
||||
if [ -f ${rootPath}/bin/activate ];then
|
||||
source ${rootPath}/bin/activate
|
||||
fi
|
||||
|
||||
# if id prometheus &> /dev/null ;then
|
||||
# echo "prometheus uid is `id -u prometheus`"
|
||||
# echo "prometheus shell is `grep "^prometheus:" /etc/passwd |cut -d':' -f7 `"
|
||||
# else
|
||||
# groupadd prometheus
|
||||
# useradd -g prometheus -s /bin/bash prometheus
|
||||
# fi
|
||||
|
||||
Install_App()
|
||||
{
|
||||
echo '正在安装脚本文件...'
|
||||
mkdir -p $serverPath/source/prometheus
|
||||
|
||||
mkdir -p $serverPath/prometheus
|
||||
echo "${VERSION}" > $serverPath/prometheus/version.pl
|
||||
|
||||
shell_file=${curPath}/versions/${VERSION}/linux.sh
|
||||
|
||||
if [ -f $shell_file ];then
|
||||
bash -x $shell_file install ${VERSION}
|
||||
else
|
||||
echo '不支持...'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
#初始化
|
||||
cd ${rootPath} && python3 ${rootPath}/plugins/prometheus/index.py start
|
||||
cd ${rootPath} && python3 ${rootPath}/plugins/prometheus/index.py initd_install
|
||||
|
||||
echo 'Prometheus安装完成'
|
||||
}
|
||||
|
||||
Uninstall_App()
|
||||
{
|
||||
shell_file=${curPath}/versions/${VERSION}/linux.sh
|
||||
if [ -f $shell_file ];then
|
||||
bash -x $shell_file uninstall ${VERSION}
|
||||
fi
|
||||
|
||||
cd ${rootPath} && python3 ${rootPath}/plugins/prometheus/index.py stop
|
||||
cd ${rootPath} && python3 ${rootPath}/plugins/prometheus/index.py initd_uninstall
|
||||
|
||||
rm -rf $serverPath/prometheus
|
||||
echo 'Prometheus卸载完成'
|
||||
}
|
||||
|
||||
action=$1
|
||||
if [ "${1}" == 'install' ];then
|
||||
Install_App
|
||||
else
|
||||
Uninstall_App
|
||||
fi
|
||||
Executable
+96
@@ -0,0 +1,96 @@
|
||||
function gPost(method, version, args,callback){
|
||||
var loadT = layer.msg('正在获取...', { icon: 16, time: 0, shade: 0.3 });
|
||||
|
||||
var req_data = {};
|
||||
req_data['name'] = 'prometheus';
|
||||
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 gPostCallbak(method, version, args,callback){
|
||||
var loadT = layer.msg('正在获取...', { icon: 16, time: 0, shade: 0.3 });
|
||||
|
||||
var req_data = {};
|
||||
req_data['name'] = 'prometheus';
|
||||
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 gCommonFunc(){
|
||||
var con = '<hr/><p class="conf_p" style="text-align:center;">\
|
||||
<button id="prometheus_url" class="btn btn-default btn-sm">获取连接地址</button>\
|
||||
</p>';
|
||||
|
||||
$(".soft-man-con").html(con);
|
||||
|
||||
$('#prometheus_url').click(function(){
|
||||
gPost('prometheus_url', '', {}, function(rdata){
|
||||
layer.open({
|
||||
title: "prometheus连接",
|
||||
area: ['600px', '180px'],
|
||||
type:1,
|
||||
closeBtn: 1,
|
||||
shadeClose: false,
|
||||
btn:["复制","取消"],
|
||||
content: '<div class="pd15">\
|
||||
<div class="divtable">\
|
||||
<pre class="layui-code">'+rdata.data+'</pre>\
|
||||
</div>\
|
||||
</div>',
|
||||
success:function(){
|
||||
copyText(rdata.data);
|
||||
},
|
||||
yes:function(){
|
||||
copyText(rdata.data);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function gReadme(){
|
||||
var readme = '<ul class="help-info-text c7">';
|
||||
readme += '<li>https://prometheus.io/download</li>';
|
||||
readme += '</ul>';
|
||||
|
||||
$('.soft-man-con').html(readme);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
#!/bin/bash
|
||||
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
|
||||
export PATH
|
||||
|
||||
curPath=`pwd`
|
||||
rootPath=$(dirname "$curPath")
|
||||
rootPath=$(dirname "$rootPath")
|
||||
serverPath=$(dirname "$rootPath")
|
||||
sourcePath=${serverPath}/source
|
||||
sysName=`uname`
|
||||
|
||||
SYS_VERSION_ID=`cat /etc/*-release | grep VERSION_ID | awk -F = '{print $2}' | awk -F "\"" '{print $2}'`
|
||||
|
||||
VERSION=$2
|
||||
|
||||
sysArch=`arch`
|
||||
sysName=`uname`
|
||||
|
||||
ARCH_NAME=amd64
|
||||
if [ "$sysArch" == "arm64" ];then
|
||||
ARCH_NAME=arm64
|
||||
elif [ "$sysArch" == "x86_64" ]; then
|
||||
ARCH_NAME=amd64
|
||||
elif [ "$sysArch" == "aarch64" ]; then
|
||||
ARCH_NAME=aarch64
|
||||
fi
|
||||
|
||||
FILE_TGZ=prometheus-${VERSION}.linux-${ARCH_NAME}.tar.gz
|
||||
|
||||
# 检查是否通
|
||||
Install_App()
|
||||
{
|
||||
SourceDir=$serverPath/source/prometheus
|
||||
InstallDir=$serverPath/prometheus
|
||||
mkdir -p ${SourceDir}
|
||||
mkdir -p ${InstallDir}/bin
|
||||
|
||||
if [ ! -f ${SourceDir}/${FILE_TGZ} ];then
|
||||
wget --no-check-certificate -O ${SourceDir}/${FILE_TGZ} https://github.com/prometheus/prometheus/releases/download/v${VERSION}/${FILE_TGZ}
|
||||
fi
|
||||
|
||||
|
||||
|
||||
if [ ! -d $InstallDir/bin/prometheus ];then
|
||||
cd ${SourceDir} && tar -zxvf ${FILE_TGZ}
|
||||
cd ${SourceDir}/prometheus-${VERSION}.linux-${ARCH_NAME}
|
||||
cp -rf ./* $InstallDir
|
||||
fi
|
||||
}
|
||||
|
||||
Uninstall_App()
|
||||
{
|
||||
echo "卸载成功"
|
||||
}
|
||||
|
||||
action=${1}
|
||||
if [ "${1}" == 'install' ];then
|
||||
Install_App
|
||||
else
|
||||
Uninstall_App
|
||||
fi
|
||||
@@ -4,7 +4,7 @@
|
||||
"name": "redis",
|
||||
"title": "Redis",
|
||||
"shell": "install.sh",
|
||||
"versions":["4.0.14","5.0.14","6.0.20","6.2.16","7.0.15","7.2.8", "7.4.3", "8.0.1"],
|
||||
"versions":["4.0.14","5.0.14","6.0.20","6.2.16","7.0.15","7.2.9", "7.4.5", "8.0.3", "8.2.0"],
|
||||
"tip": "soft",
|
||||
"checks": "server/redis",
|
||||
"path": "server/redis",
|
||||
|
||||
@@ -30,7 +30,7 @@ Install_App()
|
||||
REDIS_DIR=$serverPath/source/redis
|
||||
|
||||
if [ ! -f $REDIS_DIR/${FILE_TGZ} ];then
|
||||
wget -O $REDIS_DIR/${FILE_TGZ} http://download.redis.io/releases/${FILE_TGZ}
|
||||
wget --no-check-certificate -O $REDIS_DIR/${FILE_TGZ} https://download.redis.io/releases/${FILE_TGZ}
|
||||
fi
|
||||
|
||||
cd $REDIS_DIR && tar -zxvf ${FILE_TGZ}
|
||||
|
||||
@@ -9,8 +9,12 @@ import re
|
||||
import json
|
||||
|
||||
|
||||
sys.path.append(os.getcwd() + "/class/core")
|
||||
import mw
|
||||
web_dir = os.getcwd() + "/web"
|
||||
if os.path.exists(web_dir):
|
||||
sys.path.append(web_dir)
|
||||
os.chdir(web_dir)
|
||||
|
||||
import core.mw as mw
|
||||
|
||||
|
||||
def getServerDir():
|
||||
@@ -26,14 +30,14 @@ def getConf():
|
||||
def getDbPort():
|
||||
file = getConf()
|
||||
content = mw.readFile(file)
|
||||
rep = 'port\s*=\s*(.*)'
|
||||
rep = r'port\s*=\s*(.*)'
|
||||
tmp = re.search(rep, content)
|
||||
return tmp.groups()[0].strip()
|
||||
|
||||
def getSocketFile():
|
||||
file = getConf()
|
||||
content = mw.readFile(file)
|
||||
rep = 'socket\s*=\s*(.*)'
|
||||
rep = r'socket\s*=\s*(.*)'
|
||||
tmp = re.search(rep, content)
|
||||
return tmp.groups()[0].strip()
|
||||
|
||||
|
||||
@@ -100,7 +100,7 @@ def contentReplace(content):
|
||||
service_path = mw.getServerDir()
|
||||
content = content.replace('{$ROOT_PATH}', mw.getFatherDir())
|
||||
content = content.replace('{$SERVER_PATH}', service_path)
|
||||
content = content.replace('{$SERVER_APP}', service_path + '/sphinx')
|
||||
content = content.replace('{$SERVER_APP}', service_path + '/'+getPluginName())
|
||||
return content
|
||||
|
||||
|
||||
@@ -183,7 +183,7 @@ def sphOp(method):
|
||||
file = initDreplace()
|
||||
|
||||
if not mw.isAppleSystem():
|
||||
data = mw.execShell('systemctl ' + method + ' sphinx')
|
||||
data = mw.execShell('systemctl ' + method + ' ' + getPluginName())
|
||||
if data[1] == '':
|
||||
return 'ok'
|
||||
return 'fail'
|
||||
@@ -385,6 +385,7 @@ def makeDbToSphinx():
|
||||
tables = tables.split(',')
|
||||
content = sph_make.makeSqlToSphinx(db, tables, is_delta_bool)
|
||||
mw.writeFile(sph_file,content)
|
||||
mkdirAll()
|
||||
return mw.returnJson(True,'设置成功!')
|
||||
|
||||
return mw.returnJson(True,'测试中')
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
"name": "sphinx",
|
||||
"title": "sphinx",
|
||||
"shell": "install.sh",
|
||||
"versions":["3.1.1","3.2.1","3.3.1","3.4.1","3.5.1","3.6.1","3.7.1"],
|
||||
"versions":["3.1.1","3.2.1","3.3.1","3.4.1","3.5.1","3.6.1","3.7.1","3.8.1"],
|
||||
"tip": "soft",
|
||||
"install_pre_inspection":true,
|
||||
"checks": "server/sphinx",
|
||||
|
||||
@@ -57,6 +57,8 @@ elif [ "$VERSION" == "3.6.1" ]; then
|
||||
VERSION_NUM=${VERSION}-c9dbeda
|
||||
elif [ "$VERSION" == "3.7.1" ]; then
|
||||
VERSION_NUM=${VERSION}-da9f8a4
|
||||
elif [ "$VERSION" == "3.8.1" ]; then
|
||||
VERSION_NUM=${VERSION}-d25e0bb
|
||||
fi
|
||||
|
||||
# echo $VERSION_NUM
|
||||
|
||||
@@ -34,6 +34,12 @@ net.ipv4.tcp_fin_timeout = 1
|
||||
net.ipv4.tcp_keepalive_time = 30
|
||||
net.ipv4.ip_local_port_range = 1024 65001
|
||||
|
||||
|
||||
# vm opt
|
||||
vm.dirty_ratio = 40
|
||||
vm.dirty_background_ratio = 10
|
||||
vm.swappiness = 10
|
||||
vm.vfs_cache_pressure = 500
|
||||
vm.overcommit_memory=1
|
||||
vm.max_map_count = 262144
|
||||
|
||||
|
||||
@@ -44,7 +44,6 @@ def send_msg(bot, tag='ad', trigger_time=300):
|
||||
lock_data[tag] = {'do_time': time.time()}
|
||||
mw.writeFile(lock_file, json.dumps(lock_data))
|
||||
# 信号只在一个周期内执行一次|end
|
||||
|
||||
keyboard = [
|
||||
[
|
||||
types.InlineKeyboardButton(
|
||||
@@ -54,10 +53,6 @@ def send_msg(bot, tag='ad', trigger_time=300):
|
||||
types.InlineKeyboardButton(
|
||||
text="18+资源采集", url='https://ckzy1.com')
|
||||
],
|
||||
[
|
||||
types.InlineKeyboardButton(
|
||||
text="桃花资源采集🚀 ", url='https://thzy.me')
|
||||
],
|
||||
[
|
||||
types.InlineKeyboardButton(
|
||||
text="代付-代实名-备案域名-国际云服务器", url='https://t.me/gjgzs2022')
|
||||
@@ -80,7 +75,7 @@ def send_msg(bot, tag='ad', trigger_time=300):
|
||||
types.InlineKeyboardButton(
|
||||
text="@ME", url='tg://user?id=5568699210'),
|
||||
types.InlineKeyboardButton(
|
||||
text="200rmb/月", url='tg://user?id=5568699210')
|
||||
text="300rmb/月", url='tg://user?id=5568699210')
|
||||
]
|
||||
]
|
||||
markup = types.InlineKeyboardMarkup(keyboard)
|
||||
|
||||
@@ -56,7 +56,6 @@ def send_msg(bot, tag='ad', trigger_time=300):
|
||||
|
||||
# https://t.me/gjgzs2022 | 22/m | @GJ_gzs
|
||||
# 实名认证/过人脸🕵️♀️各种账号处理✅ | 30/m| next,12/30 | @nngzs
|
||||
# 桃花资源采集| 13/m| next,7/13 | @xiaolizi1122
|
||||
# 18+资源采集| 4/m | next,1/14 | @liuxingyu123
|
||||
keyboard = [
|
||||
[
|
||||
@@ -67,10 +66,6 @@ def send_msg(bot, tag='ad', trigger_time=300):
|
||||
types.InlineKeyboardButton(
|
||||
text="18+资源采集", url='https://ckzy1.com')
|
||||
],
|
||||
[
|
||||
types.InlineKeyboardButton(
|
||||
text="桃花资源采集🚀 ", url='https://thzy.me')
|
||||
],
|
||||
[
|
||||
types.InlineKeyboardButton(
|
||||
text="代付-代实名-备案域名-国际云服务器", url='https://t.me/gjgzs2022')
|
||||
@@ -93,7 +88,7 @@ def send_msg(bot, tag='ad', trigger_time=300):
|
||||
types.InlineKeyboardButton(
|
||||
text="@ME", url='tg://user?id=5568699210'),
|
||||
types.InlineKeyboardButton(
|
||||
text="200RMB/月", url='tg://user?id=5568699210')
|
||||
text="300RMB/月", url='tg://user?id=5568699210')
|
||||
]
|
||||
]
|
||||
markup = types.InlineKeyboardMarkup(keyboard)
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
"name": "valkey",
|
||||
"title": "valkey",
|
||||
"shell": "install.sh",
|
||||
"versions":["8.0.1"],
|
||||
"versions":["8.0.1","8.1.3"],
|
||||
"tip": "soft",
|
||||
"checks": "server/valkey",
|
||||
"path": "server/valkey",
|
||||
|
||||
@@ -117,7 +117,7 @@ Install_App()
|
||||
|
||||
# 缓存数据
|
||||
GEO_VERSION=$(get_latest_release "P3TERX/GeoLite.mmdb")
|
||||
if [ ! -f $serverPath/source/webstats/GeoLite2-City.mmdb ];then
|
||||
if [ ! -s $serverPath/source/webstats/GeoLite2-City.mmdb ];then
|
||||
if [ "$LOCAL_ADDR" == "cn" ];then
|
||||
wget --no-check-certificate -O $serverPath/source/webstats/GeoLite2-City.mmdb https://dl.midoks.icu/soft/webstats/GeoLite2-City.mmdb
|
||||
else
|
||||
@@ -125,7 +125,7 @@ Install_App()
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -f $serverPath/source/webstats/GeoLite2-City.mmdb ];then
|
||||
if [ -s $serverPath/source/webstats/GeoLite2-City.mmdb ];then
|
||||
cp -rf $serverPath/source/webstats/GeoLite2-City.mmdb $serverPath/webstats/GeoLite2-City.mmdb
|
||||
fi
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@ pillow
|
||||
Jinja2>=2.11.2
|
||||
PyMySQL>=1.0.2
|
||||
whitenoise==5.3.0
|
||||
tldextract
|
||||
pyotp
|
||||
pytz
|
||||
supervisor
|
||||
|
||||
+141
-61
@@ -53,6 +53,9 @@ mw_start_panel()
|
||||
echo -e ".\c"
|
||||
sleep 0.5
|
||||
isStart=$(lsof -n -P -i:$port|grep LISTEN|grep -v grep|awk '{print $2}'|xargs)
|
||||
if [[ "$isStart" == "" ]];then
|
||||
isStart=$(ps -ef|grep python3|grep mdserver-web|grep app:app|awk '{print $2}'|xargs)
|
||||
fi
|
||||
let n+=1
|
||||
if [ $n -gt 60 ];then
|
||||
break;
|
||||
@@ -240,23 +243,140 @@ error_logs()
|
||||
tail -n 100 ${PANEL_DIR}/logs/panel_error.log
|
||||
}
|
||||
|
||||
# 00----00----00----00----00----00----00----00----00----00----00----00----00----00
|
||||
|
||||
function AutoSizeStr(){
|
||||
NAME_STR=$1
|
||||
NAME_NUM=$2
|
||||
|
||||
NAME_STR_LEN=`echo "$NAME_STR" | wc -L`
|
||||
NAME_NUM_LEN=`echo "$NAME_NUM" | wc -L`
|
||||
|
||||
fix_len=35
|
||||
remaining_len=`expr $fix_len - $NAME_STR_LEN - $NAME_NUM_LEN`
|
||||
FIX_SPACE=' '
|
||||
for ((ass_i=1;ass_i<=$remaining_len;ass_i++))
|
||||
do
|
||||
FIX_SPACE="$FIX_SPACE "
|
||||
done
|
||||
echo -e " ❖ ${1}${FIX_SPACE}${2})"
|
||||
}
|
||||
|
||||
function ChooseProxyURL(){
|
||||
clear
|
||||
echo -e '+---------------------------------------------------+'
|
||||
echo -e '| |'
|
||||
echo -e '| ============================================= |'
|
||||
echo -e '| |'
|
||||
echo -e '| 欢迎使用 Linux 一键安装mdserver-web面板源码 |'
|
||||
echo -e '| |'
|
||||
echo -e '| ============================================= |'
|
||||
echo -e '| |'
|
||||
echo -e '+---------------------------------------------------+'
|
||||
echo -e ''
|
||||
echo -e '#####################################################'
|
||||
echo -e ''
|
||||
echo -e ' 提供以下国内代理地址可供选择: '
|
||||
echo -e ''
|
||||
echo -e '#####################################################'
|
||||
echo -e ''
|
||||
cm_i=0
|
||||
for V in ${SOURCE_LIST_KEY[@]}; do
|
||||
num=`expr $cm_i + 1`
|
||||
AutoSizeStr "${V}" "$num"
|
||||
cm_i=`expr $cm_i + 1`
|
||||
done
|
||||
echo -e ''
|
||||
echo -e '#####################################################'
|
||||
echo -e ''
|
||||
echo -e " 系统时间 ${BLUE}$(date "+%Y-%m-%d %H:%M:%S")${PLAIN}"
|
||||
echo -e ''
|
||||
echo -e '#####################################################'
|
||||
CHOICE_A=$(echo -e "\n${BOLD}└─ 请选择并输入你想使用的代理地址 [ 1-${SOURCE_LIST_LEN} ]:${PLAIN}")
|
||||
|
||||
read -p "${CHOICE_A}" INPUT
|
||||
# echo $INPUT
|
||||
if [ "$INPUT" == "" ];then
|
||||
INPUT=1
|
||||
TMP_INPUT=`expr $INPUT - 1`
|
||||
INPUT_KEY=${SOURCE_LIST_KEY[$TMP_INPUT]}
|
||||
echo -e "\n默认选择[${BLUE}${INPUT_KEY}${PLAIN}]安装!"
|
||||
fi
|
||||
|
||||
if [ "$INPUT" -lt "0" ];then
|
||||
INPUT=1
|
||||
TMP_INPUT=`expr $INPUT - 1`
|
||||
INPUT_KEY=${SOURCE_LIST_KEY[$TMP_INPUT]}
|
||||
echo -e "\n低于边界错误!选择[${BLUE}${INPUT_KEY}${PLAIN}]安装!"
|
||||
sleep 2s
|
||||
fi
|
||||
|
||||
if [ "$INPUT" -gt "${SOURCE_LIST_LEN}" ];then
|
||||
INPUT=${SOURCE_LIST_LEN}
|
||||
TMP_INPUT=`expr $INPUT - 1`
|
||||
INPUT_KEY=${SOURCE_LIST_KEY[$TMP_INPUT]}
|
||||
echo -e "\n超出边界错误!选择[${BLUE}${INPUT_KEY}${PLAIN}]安装!"
|
||||
sleep 2s
|
||||
fi
|
||||
|
||||
INPUT=`expr $INPUT - 1`
|
||||
INPUT_KEY=${SOURCE_LIST_KEY[$INPUT]}
|
||||
HTTP_PREFIX=${PROXY_URL[$INPUT_KEY]}
|
||||
}
|
||||
|
||||
|
||||
mw_common_proxy(){
|
||||
HTTP_PREFIX="https://"
|
||||
LOCAL_ADDR=common
|
||||
cn=$(curl -fsSL -m 10 -s http://ipinfo.io/json | grep "\"country\": \"CN\"")
|
||||
if [ ! -z "$cn" ] || [ "$?" == "0" ] ;then
|
||||
LOCAL_ADDR=cn
|
||||
fi
|
||||
|
||||
if [ "$LOCAL_ADDR" != "common" ];then
|
||||
# https://github.akams.cn
|
||||
declare -A PROXY_URL
|
||||
PROXY_URL["gh_proxy_com"]="https://gh-proxy.com/"
|
||||
PROXY_URL["github_do"]="https://github.do/"
|
||||
PROXY_URL["gh_llkk_cc"]="https://gh.llkk.cc/https://"
|
||||
PROXY_URL["gh_felicity_ac_cn"]="https://gh.felicity.ac.cn/https://"
|
||||
PROXY_URL["ghfast_top"]="https://ghfast.top/"
|
||||
PROXY_URL["ghproxy_net"]="https://ghproxy.net/"
|
||||
PROXY_URL["gh_927223_xyz"]="https://gh.927223.xyz/https://"
|
||||
PROXY_URL["gh_proxy_net"]="https://gh-proxy.net/"
|
||||
|
||||
PROXY_URL["source"]="https://"
|
||||
|
||||
|
||||
SOURCE_LIST_KEY_SORT_TMP=$(echo ${!PROXY_URL[@]} | tr ' ' '\n' | sort -n)
|
||||
SOURCE_LIST_KEY=(${SOURCE_LIST_KEY_SORT_TMP//'\n'/})
|
||||
SOURCE_LIST_LEN=${#PROXY_URL[*]}
|
||||
fi
|
||||
|
||||
if [ "$LOCAL_ADDR" != "common" ];then
|
||||
ChooseProxyURL
|
||||
|
||||
if [ "$HTTP_PREFIX" != "https://" ];then
|
||||
DOMAIN=`echo $HTTP_PREFIX | sed 's|https://||g'`
|
||||
DOMAIN=`echo $DOMAIN | sed 's|/||g'`
|
||||
ping -c 3 $DOMAIN > /dev/null 2>&1
|
||||
if [ "$?" != "0" ];then
|
||||
echo "无效代理地址:${HTTP_PREFIX}"
|
||||
exit
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
mw_install(){
|
||||
if [ -f ${PANEL_DIR}/task.py ];then
|
||||
echo "与后续版本差异太大,不再提供更新"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
LOCAL_ADDR=common
|
||||
cn=$(curl -fsSL -m 10 -s http://ipinfo.io/json | grep "\"country\": \"CN\"")
|
||||
if [ ! -z "$cn" ] || [ "$?" == "0" ] ;then
|
||||
LOCAL_ADDR=cn
|
||||
fi
|
||||
|
||||
if [ "$LOCAL_ADDR" == "common" ];then
|
||||
curl --insecure -fsSL https://raw.githubusercontent.com/midoks/mdserver-web/master/scripts/install.sh | bash
|
||||
else
|
||||
curl --insecure -fsSL https://code.midoks.icu/midoks/mdserver-web/raw/branch/dev/scripts/install.sh | bash
|
||||
fi
|
||||
mw_common_proxy
|
||||
echo "bash <(curl -fsSL "${HTTP_PREFIX}raw.githubusercontent.com/midoks/mdserver-web/master/scripts/install.sh")"
|
||||
bash <(curl -fsSL "${HTTP_PREFIX}raw.githubusercontent.com/midoks/mdserver-web/master/scripts/install.sh")
|
||||
}
|
||||
|
||||
mw_update()
|
||||
@@ -266,17 +386,9 @@ mw_update()
|
||||
exit 0
|
||||
fi
|
||||
|
||||
LOCAL_ADDR=common
|
||||
cn=$(curl -fsSL -m 10 -s http://ipinfo.io/json | grep "\"country\": \"CN\"")
|
||||
if [ ! -z "$cn" ] || [ "$?" == "0" ] ;then
|
||||
LOCAL_ADDR=cn
|
||||
fi
|
||||
|
||||
if [ "$LOCAL_ADDR" == "common" ];then
|
||||
curl --insecure -fsSL https://raw.githubusercontent.com/midoks/mdserver-web/master/scripts/update.sh | bash
|
||||
else
|
||||
curl --insecure -fsSL https://code.midoks.icu/midoks/mdserver-web/raw/branch/dev/scripts/update.sh | bash
|
||||
fi
|
||||
mw_common_proxy
|
||||
echo "bash <(curl -fsSL "${HTTP_PREFIX}raw.githubusercontent.com/midoks/mdserver-web/master/scripts/update.sh")"
|
||||
bash <(curl -fsSL "${HTTP_PREFIX}raw.githubusercontent.com/midoks/mdserver-web/master/scripts/update.sh")
|
||||
}
|
||||
|
||||
mw_update_dev()
|
||||
@@ -285,18 +397,11 @@ mw_update_dev()
|
||||
echo "与后续版本差异太大,不再提供更新"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
mw_common_proxy
|
||||
echo "bash <(curl -fsSL "${HTTP_PREFIX}raw.githubusercontent.com/midoks/mdserver-web/dev/scripts/update_dev.sh")"
|
||||
bash <(curl -fsSL "${HTTP_PREFIX}raw.githubusercontent.com/midoks/mdserver-web/dev/scripts/update_dev.sh")
|
||||
|
||||
LOCAL_ADDR=common
|
||||
cn=$(curl -fsSL -m 10 -s http://ipinfo.io/json | grep "\"country\": \"CN\"")
|
||||
if [ ! -z "$cn" ] || [ "$?" == "0" ] ;then
|
||||
LOCAL_ADDR=cn
|
||||
fi
|
||||
|
||||
if [ "$LOCAL_ADDR" == "common" ];then
|
||||
curl --insecure -fsSL https://raw.githubusercontent.com/midoks/mdserver-web/dev/scripts/update_dev.sh | bash
|
||||
else
|
||||
curl --insecure -fsSL https://code.midoks.icu/midoks/mdserver-web/raw/branch/dev/scripts/update_dev.sh | bash
|
||||
fi
|
||||
cd ${PANEL_DIR}
|
||||
}
|
||||
|
||||
@@ -306,17 +411,10 @@ mw_update_venv()
|
||||
rm -rf ${PANEL_DIR}/lib64
|
||||
rm -rf ${PANEL_DIR}/lib
|
||||
|
||||
LOCAL_ADDR=common
|
||||
cn=$(curl -fsSL -m 10 -s http://ipinfo.io/json | grep "\"country\": \"CN\"")
|
||||
if [ ! -z "$cn" ] || [ "$?" == "0" ] ;then
|
||||
LOCAL_ADDR=cn
|
||||
fi
|
||||
mw_common_proxy
|
||||
echo "bash <(curl -fsSL "${HTTP_PREFIX}raw.githubusercontent.com/midoks/mdserver-web/dev/scripts/update_dev.sh")"
|
||||
bash <(curl -fsSL "${HTTP_PREFIX}raw.githubusercontent.com/midoks/mdserver-web/dev/scripts/update_dev.sh")
|
||||
|
||||
if [ "$LOCAL_ADDR" == "common" ];then
|
||||
curl --insecure -fsSL https://raw.githubusercontent.com/midoks/mdserver-web/dev/scripts/update_dev.sh | bash
|
||||
else
|
||||
curl --insecure -fsSL https://code.midoks.icu/midoks/mdserver-web/raw/branch/dev/scripts/update_dev.sh | bash
|
||||
fi
|
||||
cd ${PANEL_DIR}
|
||||
}
|
||||
|
||||
@@ -377,24 +475,6 @@ mw_debug(){
|
||||
gunicorn -b :$port -k eventlet -w 1 app:app
|
||||
}
|
||||
|
||||
|
||||
function AutoSizeStr(){
|
||||
NAME_STR=$1
|
||||
NAME_NUM=$2
|
||||
|
||||
NAME_STR_LEN=`echo "$NAME_STR" | wc -L`
|
||||
NAME_NUM_LEN=`echo "$NAME_NUM" | wc -L`
|
||||
|
||||
fix_len=35
|
||||
remaining_len=`expr $fix_len - $NAME_STR_LEN - $NAME_NUM_LEN`
|
||||
FIX_SPACE=' '
|
||||
for ((ass_i=1;ass_i<=$remaining_len;ass_i++))
|
||||
do
|
||||
FIX_SPACE="$FIX_SPACE "
|
||||
done
|
||||
echo -e " ❖ ${1}${FIX_SPACE}${2})"
|
||||
}
|
||||
|
||||
mw_connect_mysql(){
|
||||
# choose mysql login
|
||||
|
||||
|
||||
+151
-43
@@ -1,6 +1,20 @@
|
||||
#!/bin/bash
|
||||
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin:/opt/homebrew/bin
|
||||
export PATH
|
||||
|
||||
RED='\033[31m'
|
||||
GREEN='\033[32m'
|
||||
YELLOW='\033[33m'
|
||||
BLUE='\033[34m'
|
||||
PLAIN='\033[0m'
|
||||
BOLD='\033[1m'
|
||||
SUCCESS='[\033[32mOK\033[0m]'
|
||||
COMPLETE='[\033[32mDONE\033[0m]'
|
||||
WARN='[\033[33mWARN\033[0m]'
|
||||
ERROR='[\033[31mERROR\033[0m]'
|
||||
WORKING='[\033[34m*\033[0m]'
|
||||
|
||||
|
||||
# LANG=en_US.UTF-8
|
||||
is64bit=`getconf LONG_BIT`
|
||||
|
||||
@@ -12,9 +26,128 @@ if [ -f /www/server/mdserver-web/tools.py ];then
|
||||
fi
|
||||
|
||||
LOG_FILE=/var/log/mw-install.log
|
||||
|
||||
{
|
||||
|
||||
HTTP_PREFIX="https://"
|
||||
LOCAL_ADDR=common
|
||||
cn=$(curl -fsSL -m 10 -s http://ipinfo.io/json | grep "\"country\": \"CN\"")
|
||||
if [ ! -z "$cn" ] || [ "$?" == "0" ] ;then
|
||||
LOCAL_ADDR=cn
|
||||
fi
|
||||
|
||||
if [ "$LOCAL_ADDR" != "common" ];then
|
||||
declare -A PROXY_URL
|
||||
PROXY_URL["gh_proxy_com"]="https://gh-proxy.com/"
|
||||
PROXY_URL["github_do"]="https://github.do/"
|
||||
PROXY_URL["gh_llkk_cc"]="https://gh.llkk.cc/https://"
|
||||
PROXY_URL["gh_felicity_ac_cn"]="https://gh.felicity.ac.cn/https://"
|
||||
PROXY_URL["ghfast_top"]="https://ghfast.top/"
|
||||
PROXY_URL["ghproxy_net"]="https://ghproxy.net/"
|
||||
PROXY_URL["gh_927223_xyz"]="https://gh.927223.xyz/https://"
|
||||
PROXY_URL["gh_proxy_net"]="https://gh-proxy.net/"
|
||||
|
||||
PROXY_URL["source"]="https://"
|
||||
|
||||
|
||||
SOURCE_LIST_KEY_SORT_TMP=$(echo ${!PROXY_URL[@]} | tr ' ' '\n' | sort -n)
|
||||
SOURCE_LIST_KEY=(${SOURCE_LIST_KEY_SORT_TMP//'\n'/})
|
||||
SOURCE_LIST_LEN=${#PROXY_URL[*]}
|
||||
fi
|
||||
|
||||
|
||||
function AutoSizeStr(){
|
||||
NAME_STR=$1
|
||||
NAME_NUM=$2
|
||||
|
||||
NAME_STR_LEN=`echo "$NAME_STR" | wc -L`
|
||||
NAME_NUM_LEN=`echo "$NAME_NUM" | wc -L`
|
||||
|
||||
fix_len=35
|
||||
remaining_len=`expr $fix_len - $NAME_STR_LEN - $NAME_NUM_LEN`
|
||||
FIX_SPACE=' '
|
||||
for ((ass_i=1;ass_i<=$remaining_len;ass_i++))
|
||||
do
|
||||
FIX_SPACE="$FIX_SPACE "
|
||||
done
|
||||
echo -e " ❖ ${1}${FIX_SPACE}${2})"
|
||||
}
|
||||
|
||||
function ChooseProxyURL(){
|
||||
clear
|
||||
echo -e '+---------------------------------------------------+'
|
||||
echo -e '| |'
|
||||
echo -e '| ============================================= |'
|
||||
echo -e '| |'
|
||||
echo -e '| 欢迎使用 Linux 一键安装mdserver-web面板源码 |'
|
||||
echo -e '| |'
|
||||
echo -e '| ============================================= |'
|
||||
echo -e '| |'
|
||||
echo -e '+---------------------------------------------------+'
|
||||
echo -e ''
|
||||
echo -e '#####################################################'
|
||||
echo -e ''
|
||||
echo -e ' 提供以下国内代理地址可供选择: '
|
||||
echo -e ''
|
||||
echo -e '#####################################################'
|
||||
echo -e ''
|
||||
cm_i=0
|
||||
for V in ${SOURCE_LIST_KEY[@]}; do
|
||||
num=`expr $cm_i + 1`
|
||||
AutoSizeStr "${V}" "$num"
|
||||
cm_i=`expr $cm_i + 1`
|
||||
done
|
||||
echo -e ''
|
||||
echo -e '#####################################################'
|
||||
echo -e ''
|
||||
echo -e " 系统时间 ${BLUE}$(date "+%Y-%m-%d %H:%M:%S")${PLAIN}"
|
||||
echo -e ''
|
||||
echo -e '#####################################################'
|
||||
CHOICE_A=$(echo -e "\n${BOLD}└─ 请选择并输入你想使用的代理地址 [ 1-${SOURCE_LIST_LEN} ]:${PLAIN}")
|
||||
|
||||
read -p "${CHOICE_A}" INPUT
|
||||
# echo $INPUT
|
||||
if [ "$INPUT" == "" ];then
|
||||
INPUT=1
|
||||
TMP_INPUT=`expr $INPUT - 1`
|
||||
INPUT_KEY=${SOURCE_LIST_KEY[$TMP_INPUT]}
|
||||
echo -e "\n默认选择[${BLUE}${INPUT_KEY}${PLAIN}]安装!"
|
||||
fi
|
||||
|
||||
if [ "$INPUT" -lt "0" ];then
|
||||
INPUT=1
|
||||
TMP_INPUT=`expr $INPUT - 1`
|
||||
INPUT_KEY=${SOURCE_LIST_KEY[$TMP_INPUT]}
|
||||
echo -e "\n低于边界错误!选择[${BLUE}${INPUT_KEY}${PLAIN}]安装!"
|
||||
sleep 2s
|
||||
fi
|
||||
|
||||
if [ "$INPUT" -gt "${SOURCE_LIST_LEN}" ];then
|
||||
INPUT=${SOURCE_LIST_LEN}
|
||||
TMP_INPUT=`expr $INPUT - 1`
|
||||
INPUT_KEY=${SOURCE_LIST_KEY[$TMP_INPUT]}
|
||||
echo -e "\n超出边界错误!选择[${BLUE}${INPUT_KEY}${PLAIN}]安装!"
|
||||
sleep 2s
|
||||
fi
|
||||
|
||||
INPUT=`expr $INPUT - 1`
|
||||
INPUT_KEY=${SOURCE_LIST_KEY[$INPUT]}
|
||||
HTTP_PREFIX=${PROXY_URL[$INPUT_KEY]}
|
||||
}
|
||||
|
||||
if [ "$LOCAL_ADDR" != "common" ];then
|
||||
ChooseProxyURL
|
||||
|
||||
if [ "$HTTP_PREFIX" != "https://" ];then
|
||||
DOMAIN=`echo $HTTP_PREFIX | sed 's|https://||g'`
|
||||
DOMAIN=`echo $DOMAIN | sed 's|/||g'`
|
||||
ping -c 3 $DOMAIN > /dev/null 2>&1
|
||||
if [ "$?" != "0" ];then
|
||||
echo "无效代理地址:${DOMAIN}"
|
||||
exit
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -f /etc/motd ];then
|
||||
echo "welcome to mdserver-web panel" > /etc/motd
|
||||
fi
|
||||
@@ -62,6 +195,11 @@ elif grep -Eqi "Ubuntu" /etc/issue || grep -Eqi "Ubuntu" /etc/os-release; then
|
||||
OSNAME='ubuntu'
|
||||
# apt update -y
|
||||
apt install -y wget curl zip unzip tar cron
|
||||
elif grep -Eqi "Alpine" /etc/issue || grep -Eqi "Alpine" /etc/*-release; then
|
||||
OSNAME='alpine'
|
||||
apk update
|
||||
apk add devscripts -force-broken-world
|
||||
apk add wget zip unzip tar -force-broken-world
|
||||
else
|
||||
OSNAME='unknow'
|
||||
fi
|
||||
@@ -71,24 +209,8 @@ if [ "$EUID" -ne 0 ] && [ "$OSNAME" != "macos" ];then
|
||||
exit
|
||||
fi
|
||||
|
||||
|
||||
# HTTP_PREFIX="https://"
|
||||
# LOCAL_ADDR=common
|
||||
# ping -c 1 github.com > /dev/null 2>&1
|
||||
# if [ "$?" != "0" ];then
|
||||
# LOCAL_ADDR=cn
|
||||
# HTTP_PREFIX="https://mirror.ghproxy.com/"
|
||||
# fi
|
||||
|
||||
HTTP_PREFIX="https://"
|
||||
LOCAL_ADDR=common
|
||||
cn=$(curl -fsSL -m 10 -s http://ipinfo.io/json | grep "\"country\": \"CN\"")
|
||||
if [ ! -z "$cn" ] || [ "$?" == "0" ] ;then
|
||||
LOCAL_ADDR=cn
|
||||
HTTP_PREFIX="https://mirror.ghproxy.com/"
|
||||
fi
|
||||
|
||||
echo "local:${LOCAL_ADDR}"
|
||||
echo "LOCAL:${LOCAL_ADDR}"
|
||||
echo "OSNAME:${OSNAME}"
|
||||
|
||||
if [ $OSNAME != "macos" ];then
|
||||
if id www &> /dev/null ;then
|
||||
@@ -104,44 +226,30 @@ if [ $OSNAME != "macos" ];then
|
||||
mkdir -p /www/backup/database
|
||||
mkdir -p /www/backup/site
|
||||
|
||||
# https://cdn.jsdelivr.net/gh/midoks/mdserver-web@latest/scripts/install.sh
|
||||
if [ ! -d /www/server/mdserver-web ];then
|
||||
if [ "$LOCAL_ADDR" == "common" ];then
|
||||
curl --insecure -sSLo /tmp/master.zip ${HTTP_PREFIX}github.com/midoks/mdserver-web/archive/refs/heads/master.zip
|
||||
cd /tmp && unzip /tmp/master.zip
|
||||
mv -f /tmp/mdserver-web-master /www/server/mdserver-web
|
||||
rm -rf /tmp/master.zip
|
||||
rm -rf /tmp/mdserver-web-master
|
||||
else
|
||||
# curl --insecure -sSLo /tmp/master.zip https://code.midoks.icu/midoks/mdserver-web/archive/master.zip
|
||||
wget --no-check-certificate -O /tmp/master.zip https://code.midoks.icu/midoks/mdserver-web/archive/master.zip
|
||||
cd /tmp && unzip /tmp/master.zip
|
||||
mv -f /tmp/mdserver-web /www/server/mdserver-web
|
||||
rm -rf /tmp/master.zip
|
||||
rm -rf /tmp/mdserver-web
|
||||
fi
|
||||
|
||||
|
||||
curl --insecure -sSLo /tmp/master.tar.gz ${HTTP_PREFIX}github.com/midoks/mdserver-web/archive/refs/heads/master.tar.gz
|
||||
cd /tmp && tar -zxvf /tmp/master.tar.gz
|
||||
mv -f /tmp/mdserver-web-master /www/server/mdserver-web
|
||||
rm -rf /tmp/master.tar.gz
|
||||
rm -rf /tmp/mdserver-web-master
|
||||
fi
|
||||
|
||||
# install acme.sh
|
||||
if [ ! -d /root/.acme.sh ];then
|
||||
if [ "$LOCAL_ADDR" != "common" ];then
|
||||
curl --insecure -sSLo /tmp/acme.tar.gz https://gitee.com/neilpang/acme.sh/repository/archive/master.tar.gz
|
||||
tar xvzf /tmp/acme.tar.gz -C /tmp
|
||||
curl --insecure -sSLo /tmp/acme.sh-master.tar.gz ${HTTP_PREFIX}github.com/acmesh-official/acme.sh/archive/refs/heads/master.tar.gz
|
||||
tar xvzf /tmp/acme.sh-master.tar.gz -C /tmp
|
||||
cd /tmp/acme.sh-master
|
||||
bash acme.sh install
|
||||
fi
|
||||
|
||||
if [ ! -d /root/.acme.sh ];then
|
||||
curl https://get.acme.sh | sh
|
||||
else
|
||||
curl -fsSL https://get.acme.sh | bash
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "use system version: ${OSNAME}"
|
||||
if [ "${OSNAME}" == "macos" ];then
|
||||
curl --insecure -fsSL https://code.midoks.icu/midoks/mdserver-web/raw/branch/master/scripts/install/macos.sh | bash
|
||||
curl --insecure -fsSL ${HTTP_PREFIX}raw.githubusercontent.com/midoks/mdserver-web/refs/heads/dev/scripts/install/macos.sh | bash
|
||||
else
|
||||
cd /www/server/mdserver-web && bash scripts/install/${OSNAME}.sh
|
||||
fi
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user