mirror of
https://github.com/midoks/mdserver-web.git
synced 2026-10-10 11:19:26 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
29a3e606e1 | ||
|
|
d2b837f52c | ||
|
|
8984381ea2 | ||
|
|
ff015b19f7 | ||
|
|
1e71eedc19 | ||
|
|
fbce4a1abc | ||
|
|
d0cdab81d4 | ||
|
|
a69d5367d7 | ||
|
|
8d0ee48aa6 | ||
|
|
c24510e1e7 | ||
|
|
2e1c2e21b7 | ||
|
|
fee8c8c3db | ||
|
|
d94290019c | ||
|
|
27b914a905 | ||
|
|
ded25a7c87 | ||
|
|
5ba5da4cd1 | ||
|
|
cbb2a076e3 | ||
|
|
62df45da6a | ||
|
|
e441d8dc87 | ||
|
|
6d77e923b7 | ||
|
|
17a40802ae | ||
|
|
13bb828a95 | ||
|
|
eaa1a74dd6 | ||
|
|
80b615810c | ||
|
|
23fe4928e0 | ||
|
|
5a37c742e2 | ||
|
|
b94af58524 | ||
|
|
082c90b769 | ||
|
|
5012dc3a7b | ||
|
|
a6619b6e9d | ||
|
|
fe4ab5a013 | ||
|
|
ade3a5621f | ||
|
|
1cadeb3f59 | ||
|
|
05a2ba7f21 | ||
|
|
1759b6bcb1 | ||
|
|
a9e4c1b793 | ||
|
|
650b565fdf | ||
|
|
7ab974e565 | ||
|
|
95f8faf30f | ||
|
|
3d69e3723e | ||
|
|
4420bbc36c | ||
|
|
d5d96f6323 | ||
|
|
0bc9ed9d49 | ||
|
|
95e29d6266 | ||
|
|
207cef200f | ||
|
|
0082bcd159 | ||
|
|
f2a1674247 | ||
|
|
cd1a3de04a | ||
|
|
60a0bd7a65 | ||
|
|
a0696fc974 | ||
|
|
159660815b | ||
|
|
1c5a3f3c13 | ||
|
|
b36fc58839 | ||
|
|
0cd7a7dc9e | ||
|
|
52724dd5b2 | ||
|
|
dccea0e283 | ||
|
|
0f488b26d1 | ||
|
|
c3b60695c7 | ||
|
|
6fe205dbfb | ||
|
|
d8efd3f987 | ||
|
|
4c50e44e2c | ||
|
|
60717c3363 | ||
|
|
48388edcfc | ||
|
|
3c90a0fbe6 | ||
|
|
6eadb548a1 | ||
|
|
204be55c81 | ||
|
|
a44ac7606a | ||
|
|
67505f7aef | ||
|
|
369dc69364 | ||
|
|
1ffe197d69 | ||
|
|
6a584ccf7b | ||
|
|
43aba019c0 | ||
|
|
a0a61d3bbc | ||
|
|
9b008fcff9 | ||
|
|
e80162cfa9 | ||
|
|
30b02aea33 | ||
|
|
1cf49c24ef | ||
|
|
3bb0552ba6 | ||
|
|
b33be2ab84 | ||
|
|
8a4a63c85b | ||
|
|
640e8bbfa0 | ||
|
|
e6463e0286 | ||
|
|
c6cf6fef0b | ||
|
|
a428636e1c | ||
|
|
6fd145fa52 | ||
|
|
6164d462f3 | ||
|
|
d05e72e1d7 | ||
|
|
d9fbfcb184 | ||
|
|
660d95616d | ||
|
|
6160819920 | ||
|
|
c83b2d5bc5 | ||
|
|
44d529d32f | ||
|
|
b81e51c0e8 | ||
|
|
beccfe8519 | ||
|
|
9e774fb629 | ||
|
|
10c7ec8718 | ||
|
|
4bb9d0f002 | ||
|
|
39676d1a37 | ||
|
|
50f44afd82 | ||
|
|
9884bbd0e3 | ||
|
|
39853e39c7 | ||
|
|
894656741d | ||
|
|
93ef3659f2 | ||
|
|
3ccf084a53 | ||
|
|
aaa2b766a3 | ||
|
|
dc1f03b7ae | ||
|
|
36b50d3bf2 | ||
|
|
b9b7081eb4 | ||
|
|
808e65091d | ||
|
|
9b0c30e554 | ||
|
|
ffec30883f | ||
|
|
900dfc6ca7 | ||
|
|
203b4d11a8 | ||
|
|
2ba57ab05f | ||
|
|
4b11415f36 | ||
|
|
1ef0c4b8f0 | ||
|
|
4d85ed4e88 | ||
|
|
6c40e57ff6 | ||
|
|
19a4974537 | ||
|
|
6783e1507d | ||
|
|
8f3e722a0f | ||
|
|
3437d2e484 | ||
|
|
06e654ae2e | ||
|
|
c3103a23c6 | ||
|
|
55b38c2741 | ||
|
|
9f30c1968d | ||
|
|
d2455768ff | ||
|
|
6331155dc7 | ||
|
|
06d9695d33 | ||
|
|
80b35284ed | ||
|
|
27c38153b8 | ||
|
|
db62524dab | ||
|
|
190b858e46 | ||
|
|
be69e5838e | ||
|
|
b12122f53b | ||
|
|
33be35eb60 | ||
|
|
39b3f96ab5 | ||
|
|
7d214f74fd | ||
|
|
10aa140fe9 | ||
|
|
c68eaa9c61 | ||
|
|
3cc6021540 | ||
|
|
bfe7d49e07 | ||
|
|
c02aacb0d5 | ||
|
|
6d0f6fd171 | ||
|
|
712061e814 | ||
|
|
197dfa1b7e | ||
|
|
f21b66ddc0 | ||
|
|
5e086537d6 | ||
|
|
23532cb7e6 | ||
|
|
864ee5caec | ||
|
|
5db6d0332b | ||
|
|
eb9504658a | ||
|
|
a67389d611 | ||
|
|
f6d4609947 | ||
|
|
d2ddcebe3e | ||
|
|
fd2f2c0aa9 | ||
|
|
0aae3b0654 | ||
|
|
e56606ac61 | ||
|
|
54e11700c2 | ||
|
|
fe3b8de490 | ||
|
|
9874069100 | ||
|
|
9419d6d55b | ||
|
|
2f61facbda | ||
|
|
5cd8d7bf18 | ||
|
|
41f016050f | ||
|
|
d931790dd3 | ||
|
|
a81e63e131 | ||
|
|
30717079d4 | ||
|
|
3eb2fbb654 | ||
|
|
cf54a430eb | ||
|
|
04925c0534 | ||
|
|
6473755127 | ||
|
|
35f40fc8fc | ||
|
|
088a4ab969 | ||
|
|
3c00ddad75 | ||
|
|
5edd9baeb6 | ||
|
|
734548d764 | ||
|
|
e47d3a235d | ||
|
|
0a93015720 | ||
|
|
1078d71370 | ||
|
|
b482127044 | ||
|
|
27b6ee135c | ||
|
|
cc2000267d | ||
|
|
c1e3655923 | ||
|
|
b0a6181dca | ||
|
|
33e7efa440 | ||
|
|
6d7a38dc08 | ||
|
|
8a60965069 | ||
|
|
ef9d627095 | ||
|
|
b66acc8c2a | ||
|
|
fb56f6c190 | ||
|
|
af0f55e6ef | ||
|
|
fb95e2ad8d | ||
|
|
138a6d3e66 | ||
|
|
98b9065585 | ||
|
|
36c3fae920 | ||
|
|
70ee376958 | ||
|
|
47b2f1b009 | ||
|
|
f2a35b97b0 | ||
|
|
c26e5dc40d | ||
|
|
893b2d601c | ||
|
|
28964721ec | ||
|
|
5a2028d797 | ||
|
|
fcbe6a87df | ||
|
|
7f5cf75d68 | ||
|
|
c368638181 | ||
|
|
decc9d2b29 | ||
|
|
7da2a90712 | ||
|
|
7dd377460c | ||
|
|
6b6ae63aea | ||
|
|
cc9a4b5536 | ||
|
|
fd44a312f6 | ||
|
|
a5802b4280 | ||
|
|
d8c928dc02 | ||
|
|
339cdf662b | ||
|
|
1e2a174e30 | ||
|
|
2714538ad7 | ||
|
|
8a43f67801 | ||
|
|
f3f7ef4a3d | ||
|
|
3523f8d6c8 | ||
|
|
eb8c2b6ad5 | ||
|
|
438322361d | ||
|
|
c902f48931 | ||
|
|
e67a258e7a | ||
|
|
007993ed9e | ||
|
|
81171c0c7c | ||
|
|
15d07e4234 | ||
|
|
786fac9142 | ||
|
|
5499c8795f | ||
|
|
322698f345 | ||
|
|
f229e03f10 | ||
|
|
6024dbcdb6 | ||
|
|
c874ea44eb | ||
|
|
c70e4d1412 | ||
|
|
235c5e329e | ||
|
|
b77bfab5a8 | ||
|
|
890bbc4214 | ||
|
|
2f86f4d6ff | ||
|
|
c9ced293e8 | ||
|
|
43f081aac1 | ||
|
|
49aa411248 | ||
|
|
d597e15402 | ||
|
|
a74ee3faf4 | ||
|
|
cfe55ca196 | ||
|
|
2edffd36d0 | ||
|
|
c7077ec283 | ||
|
|
cfcd4c2050 | ||
|
|
2387af2880 | ||
|
|
72f825c0c4 | ||
|
|
fbe4857944 | ||
|
|
01fe75e553 | ||
|
|
2bd607edad | ||
|
|
9b9a806dee | ||
|
|
9bc6d392a0 | ||
|
|
26b5dc7cd4 | ||
|
|
80a690c431 | ||
|
|
71840ee1e2 | ||
|
|
fbdbb25a78 | ||
|
|
e546428596 | ||
|
|
a16259f718 | ||
|
|
df0b708462 | ||
|
|
b3c383327d | ||
|
|
8a9c99fb0d | ||
|
|
a22d90198c | ||
|
|
dcae829a1c | ||
|
|
de4e134be8 | ||
|
|
ba96e62126 | ||
|
|
990fb06567 | ||
|
|
71c1034d12 | ||
|
|
6582cbc09d | ||
|
|
52bad278cc | ||
|
|
e023490002 | ||
|
|
c1a7443597 | ||
|
|
3f57e7da07 | ||
|
|
0461bf3225 | ||
|
|
ac0a503aa7 | ||
|
|
706e9e98e7 | ||
|
|
d9e878d607 | ||
|
|
ceb5f21814 | ||
|
|
c8e689433b | ||
|
|
f2171aa159 | ||
|
|
6eccdd510e | ||
|
|
c9a00809a4 | ||
|
|
9f1d8e43e6 | ||
|
|
e8eda79a1a | ||
|
|
f25847d31d | ||
|
|
bda7dfa518 | ||
|
|
4115c29fe9 | ||
|
|
f73e378fd6 | ||
|
|
aa9ab55fec | ||
|
|
da5c44a747 | ||
|
|
ee55c998ba | ||
|
|
2e75a56502 | ||
|
|
a66279ba37 | ||
|
|
78bbae1f53 | ||
|
|
a87def4325 | ||
|
|
b84ac2daf1 | ||
|
|
7c9bf99669 | ||
|
|
599f6ecc51 | ||
|
|
47a17fbc46 | ||
|
|
80fa0ea62d | ||
|
|
83c78609a4 | ||
|
|
298d4b7981 | ||
|
|
dc6f4e03e7 | ||
|
|
8b0b2b2d72 | ||
|
|
d4087ce7f0 | ||
|
|
f92df461ba | ||
|
|
9e015bc08c | ||
|
|
4bffd9a22d | ||
|
|
e2ef42fbbc | ||
|
|
f10e05b7ee | ||
|
|
c15288cf09 | ||
|
|
2461307d64 | ||
|
|
95ec87346d | ||
|
|
f99c5b5fc4 | ||
|
|
adfd3bef2d | ||
|
|
c11631c0c3 | ||
|
|
4f87725101 | ||
|
|
3a6695bb0d | ||
|
|
dd3bcced66 | ||
|
|
81a163f744 | ||
|
|
19dd36fa8b | ||
|
|
9dcb028158 | ||
|
|
1ce841eac9 | ||
|
|
c99311dad9 | ||
|
|
d7dd126a48 | ||
|
|
ec8ab6bc45 | ||
|
|
d5b87f450d | ||
|
|
0016f85132 | ||
|
|
32a6b36297 | ||
|
|
8da60ffc6b | ||
|
|
64d65a5cac | ||
|
|
cf5b986d2e | ||
|
|
e1d0fc49bb | ||
|
|
68187ee7dd | ||
|
|
9f7a7c5e59 | ||
|
|
90b14d59b0 | ||
|
|
e8d1ea0a38 | ||
|
|
edf8a5534a | ||
|
|
87bceced80 | ||
|
|
db3350e85c | ||
|
|
56b3aae0c7 | ||
|
|
01d5b75d90 | ||
|
|
cbf3a15bf0 | ||
|
|
2f0f6eaed6 | ||
|
|
f0fcec44ff | ||
|
|
fcfdfe822a | ||
|
|
d8e08812f9 | ||
|
|
d0ba142933 | ||
|
|
b4e130c664 | ||
|
|
7503907f34 | ||
|
|
390df93477 | ||
|
|
abcf6250e3 | ||
|
|
70370fcb0b | ||
|
|
57e7021be2 | ||
|
|
45b7abd0fb | ||
|
|
a6d96bb4d8 | ||
|
|
2742ecfc67 | ||
|
|
60747c2f04 | ||
|
|
2b019a704a | ||
|
|
7e049a381b | ||
|
|
2f4cf46bcf | ||
|
|
706ee146b5 | ||
|
|
79b4d09d50 | ||
|
|
2f0797daab | ||
|
|
8e47c73f5c | ||
|
|
c90d752ae7 | ||
|
|
7c96bbe72f | ||
|
|
53134b7ecc | ||
|
|
bf859f7c7c | ||
|
|
0046d02ddf | ||
|
|
5a0e7a3b60 | ||
|
|
a74ca20d0e | ||
|
|
41109af522 | ||
|
|
b3b23994eb | ||
|
|
02f3a147aa | ||
|
|
10edf675f5 | ||
|
|
b07b6f0c94 | ||
|
|
002639936e | ||
|
|
aac516c8f8 | ||
|
|
efd07f6de2 | ||
|
|
fa17782573 | ||
|
|
9ee3aebc8c | ||
|
|
b778c8cdeb | ||
|
|
1d1e6b1d5b | ||
|
|
70012ea7ee | ||
|
|
0897fd9370 | ||
|
|
477b8b38fd | ||
|
|
e805910b1b | ||
|
|
2f9903753f | ||
|
|
53cd6377bb | ||
|
|
56cf0271b8 | ||
|
|
4fefb0efb2 | ||
|
|
222b8bc4de | ||
|
|
dc0e6fe78a | ||
|
|
22a21025af | ||
|
|
7cd102c40f | ||
|
|
5cd7a65737 | ||
|
|
c370486845 | ||
|
|
cb9857edf2 | ||
|
|
8fb3410366 | ||
|
|
659ef259b7 | ||
|
|
9d89a92b78 | ||
|
|
139f353034 | ||
|
|
908b1cf684 | ||
|
|
07dc74c283 | ||
|
|
61e136fb39 | ||
|
|
030e05b2cf | ||
|
|
24750cfdb2 | ||
|
|
975a69fce8 | ||
|
|
5f42f37ee2 | ||
|
|
9925daa363 | ||
|
|
2572bde607 | ||
|
|
572207105c | ||
|
|
2b8804e960 | ||
|
|
310409c52b | ||
|
|
01e95fa6fb | ||
|
|
848021a639 | ||
|
|
a679c0e90c | ||
|
|
8d9eb6302c | ||
|
|
f6663ad370 | ||
|
|
9964745e46 | ||
|
|
b570a4552a | ||
|
|
cd2655a6f9 | ||
|
|
608b40a110 | ||
|
|
a65d42ed2e | ||
|
|
b0d8d4bef8 | ||
|
|
d9f657c236 | ||
|
|
de02bcd800 | ||
|
|
1f8dbe1a5f | ||
|
|
8f4949cf8d | ||
|
|
6128186a2c | ||
|
|
7f707f9aac | ||
|
|
56c1cd88ee | ||
|
|
5d0b8b1877 | ||
|
|
e944c9fbc5 | ||
|
|
8cab94e26c | ||
|
|
edb26fd11c | ||
|
|
cfd3a07046 | ||
|
|
8d4ffc431a | ||
|
|
22b97ab255 | ||
|
|
8cfc5c5344 | ||
|
|
01c9633a1b | ||
|
|
160634d3d4 | ||
|
|
59b4ec32a6 | ||
|
|
08a2295cdc | ||
|
|
fb7dbd69e5 | ||
|
|
c212a30536 | ||
|
|
7a7acd3a4d | ||
|
|
f5edd83164 | ||
|
|
8ea3ac1a3c | ||
|
|
d241ceea3e | ||
|
|
6b3f50374a | ||
|
|
b3ceb03365 | ||
|
|
87b26a14df | ||
|
|
9046a09c0a | ||
|
|
8bbfdbbf66 | ||
|
|
fa2d5c690c | ||
|
|
681dfc96cb | ||
|
|
362f5eb427 | ||
|
|
b033bd1c73 | ||
|
|
ea94fa21d5 | ||
|
|
36c1541179 | ||
|
|
d5864db956 | ||
|
|
00008b657c | ||
|
|
3abed25d71 | ||
|
|
862ea95a77 | ||
|
|
63d624d084 | ||
|
|
c580076307 | ||
|
|
3fada81661 | ||
|
|
a3bd0c6bda | ||
|
|
454b036908 | ||
|
|
1af9b1ddaa | ||
|
|
5818fb46f1 | ||
|
|
1069fd5252 | ||
|
|
76229b6651 | ||
|
|
4c9e717559 | ||
|
|
9ae61517a4 | ||
|
|
952a173535 | ||
|
|
5b9b03a153 | ||
|
|
9475dbecfe | ||
|
|
5a64835969 | ||
|
|
8685f21ad9 | ||
|
|
500ccff90b | ||
|
|
85adb449c2 | ||
|
|
aa6748c09d | ||
|
|
05992b5f82 | ||
|
|
1a48e880d0 | ||
|
|
1da749aea9 | ||
|
|
bf121ee6f8 | ||
|
|
6b6e1f415f | ||
|
|
5535d56304 | ||
|
|
bbc0dee2b6 | ||
|
|
1da8f6bbb6 | ||
|
|
de15101a76 | ||
|
|
ee99d14df3 | ||
|
|
7bff08b3e5 | ||
|
|
faca0b183e | ||
|
|
700b9a7c61 | ||
|
|
53952d267e | ||
|
|
ff52646fd2 | ||
|
|
1dcd4520f1 | ||
|
|
21d86f0583 | ||
|
|
3e95e3aaf2 | ||
|
|
29c7367906 | ||
|
|
fc1e23f12d | ||
|
|
ae4af02909 | ||
|
|
6b8716ae59 | ||
|
|
661faf8503 | ||
|
|
d0881ff3eb | ||
|
|
b708d4821a | ||
|
|
2f18bf5fb2 | ||
|
|
2079076638 | ||
|
|
6ec2e4f29f | ||
|
|
a07ed61305 | ||
|
|
8031ea2c45 | ||
|
|
24d3fc18d6 | ||
|
|
4b200765aa | ||
|
|
994ee32fbf | ||
|
|
c6a742a932 | ||
|
|
478e03bca1 | ||
|
|
f4cff7bcf7 | ||
|
|
ff7d2f358e | ||
|
|
e114b07d7d | ||
|
|
272b13b29c | ||
|
|
8d875fe589 | ||
|
|
e85e6a7299 | ||
|
|
e8a3f8b014 | ||
|
|
585cd8b532 | ||
|
|
c89ee89061 | ||
|
|
ea7310502f | ||
|
|
507b34797d | ||
|
|
7baecfc4a0 | ||
|
|
8a1b64a524 | ||
|
|
89052225f9 | ||
|
|
b4c0030baa | ||
|
|
342dfe407c | ||
|
|
f9020d3c7f | ||
|
|
d9eb331f32 | ||
|
|
bc9b5ab511 | ||
|
|
b71e3196b8 | ||
|
|
69b8c609aa | ||
|
|
b1ff41350c | ||
|
|
ddc9defe51 | ||
|
|
2942e47630 | ||
|
|
b825ed9c76 | ||
|
|
5d2dd11163 | ||
|
|
253de5e70f | ||
|
|
a1e900f5c9 | ||
|
|
cf44889c74 | ||
|
|
abd48636ab | ||
|
|
cc0cdd62b8 | ||
|
|
0b95db3bd5 | ||
|
|
d473f0769f | ||
|
|
dd498c2cfc | ||
|
|
77b4d0452a | ||
|
|
924e1ddbec | ||
|
|
3213cee5f8 | ||
|
|
9fbf09f2ef | ||
|
|
fd3e074cc3 | ||
|
|
574007da2c | ||
|
|
ec6c1b2024 | ||
|
|
0dd6f47b2a | ||
|
|
968827480e | ||
|
|
4bce8bb56d | ||
|
|
00fa001c91 | ||
|
|
2f65839b9a | ||
|
|
c0aa4bcc1e | ||
|
|
4bb345abc4 | ||
|
|
3d552379bc | ||
|
|
2de399b70f | ||
|
|
7952570b45 | ||
|
|
00269662bf | ||
|
|
fb6dbde4c9 | ||
|
|
66a9ca2a5a | ||
|
|
2e9561dd86 | ||
|
|
47ff1e4458 | ||
|
|
9f49595bad | ||
|
|
3e6f4f32d5 | ||
|
|
ae69d58ee8 | ||
|
|
1788054cc4 | ||
|
|
20b20d3cce | ||
|
|
3fc3d90b6f | ||
|
|
cef6db80a2 | ||
|
|
59aab80eab | ||
|
|
53c2c71d3e | ||
|
|
d9d814202a | ||
|
|
941dbecfa2 | ||
|
|
cb7228c681 | ||
|
|
7ac1cb2944 | ||
|
|
0262d29218 | ||
|
|
5a955c2a33 | ||
|
|
dd25ebe1e9 | ||
|
|
e92151c9c5 | ||
|
|
16cc3eab40 | ||
|
|
87138fc41f | ||
|
|
0787bff959 | ||
|
|
8fc6855936 | ||
|
|
43f21b4d58 | ||
|
|
56e75bc4cf | ||
|
|
10190201c7 | ||
|
|
3db2aa0034 | ||
|
|
9fa93b5c84 | ||
|
|
fe3e9eec35 | ||
|
|
86a3922d4f | ||
|
|
aa50658245 | ||
|
|
8cd78d7dea | ||
|
|
f33bfa214f | ||
|
|
e231c38f1d | ||
|
|
a6a3cf7882 | ||
|
|
a1afe5e846 | ||
|
|
594e8c4b2b | ||
|
|
cc015bad61 | ||
|
|
bc9461dea6 | ||
|
|
0a25598c15 | ||
|
|
7a9a8a08b6 | ||
|
|
8eb728defa | ||
|
|
7f8ffbf178 | ||
|
|
cb0027e903 | ||
|
|
e0ebdd922d | ||
|
|
d6f43a86c9 | ||
|
|
dfe7becdb1 | ||
|
|
57f4162cb8 | ||
|
|
a9ce4f2e23 | ||
|
|
b501d62d91 | ||
|
|
45ffba1559 | ||
|
|
28d0fbe106 | ||
|
|
eeb8fee3b3 | ||
|
|
0e1fbdcfb9 | ||
|
|
df2744816b | ||
|
|
862c09778a | ||
|
|
8f9a1888ff | ||
|
|
66351dc3a7 | ||
|
|
55c4709c93 | ||
|
|
e27ae42270 | ||
|
|
70805de98e | ||
|
|
c0e09e43a2 | ||
|
|
b69a32c81f | ||
|
|
2431833cce | ||
|
|
a85d8ec429 | ||
|
|
ce5a6edeea | ||
|
|
aa195dea2c | ||
|
|
840a3c5911 | ||
|
|
ca87ab78b3 | ||
|
|
d9fc411168 | ||
|
|
e468ab16eb | ||
|
|
c545062d07 | ||
|
|
e620fd67e3 | ||
|
|
aa9a412e9a | ||
|
|
ad63a22a7e | ||
|
|
5b1e4d3e0a | ||
|
|
110e9b501e | ||
|
|
26de973b82 | ||
|
|
9adc0a8c38 | ||
|
|
08f75685fb | ||
|
|
dc59f24ce2 | ||
|
|
869843da82 | ||
|
|
01055e3403 | ||
|
|
43cfbc90a2 | ||
|
|
270fb15ebf | ||
|
|
4e7e4f5fb4 | ||
|
|
67530acf1d | ||
|
|
7a86ba4444 | ||
|
|
f4f29784d7 | ||
|
|
fafa64f2c7 | ||
|
|
41c7b0fb70 | ||
|
|
a779caea41 | ||
|
|
a8b97bf6d7 | ||
|
|
b31bfcb88a | ||
|
|
dbb95228b1 | ||
|
|
5ad4772c33 | ||
|
|
b270c1bfdc | ||
|
|
c8ccf4b1c8 | ||
|
|
6eb21ffbf9 | ||
|
|
58ce8db1d0 | ||
|
|
8b1bf28cf7 | ||
|
|
0e98e114fa | ||
|
|
4c93cd77e0 | ||
|
|
7044d27ca9 | ||
|
|
9168af0a9c | ||
|
|
f893eec0e4 | ||
|
|
574c7558b4 | ||
|
|
4901910a71 | ||
|
|
286be2a9f6 | ||
|
|
fed18880be | ||
|
|
b862cd2413 | ||
|
|
8c652c99da | ||
|
|
728677c702 | ||
|
|
4a023531e4 | ||
|
|
8d27ffbe91 | ||
|
|
afa32231ad | ||
|
|
e693d15a04 | ||
|
|
814d0cb925 | ||
|
|
6d95f7fd82 | ||
|
|
979c1fc530 | ||
|
|
c147ccd079 | ||
|
|
71b64b19a1 | ||
|
|
fdac352244 | ||
|
|
da5de004c4 | ||
|
|
8108ca7ee6 | ||
|
|
ba2fbbeb41 | ||
|
|
614e7af3c4 | ||
|
|
ec67913cda | ||
|
|
847353374f | ||
|
|
239d1de0ec | ||
|
|
5fefbb46a7 | ||
|
|
4288ccfc0c | ||
|
|
367aeddd2d | ||
|
|
76ec5b58cd | ||
|
|
f0cc9e2d54 | ||
|
|
b3630699ce | ||
|
|
dfe9a10a47 | ||
|
|
c34405a4d6 | ||
|
|
3068e3b033 | ||
|
|
10db173b31 | ||
|
|
3db40877cd | ||
|
|
adc7f2fe98 | ||
|
|
6dc81175ea | ||
|
|
c64183abe9 | ||
|
|
8eb2403e4b | ||
|
|
4c2178ea9c | ||
|
|
6702fb94a0 | ||
|
|
c4bc66e410 | ||
|
|
54a6a121ac | ||
|
|
1bb92d7f38 | ||
|
|
9a99a5e1c6 | ||
|
|
eeeff6e825 | ||
|
|
8ee5b0a4aa | ||
|
|
4ee5e41882 | ||
|
|
8c4820046a | ||
|
|
1b6f54e6a5 | ||
|
|
9ae7644710 | ||
|
|
0ab87b1da5 | ||
|
|
6b7457e660 | ||
|
|
b81deee461 | ||
|
|
59211703f8 | ||
|
|
3271e76d34 | ||
|
|
dca0955bb6 | ||
|
|
7af78883cc | ||
|
|
0f2db3f144 | ||
|
|
eb2c476b28 | ||
|
|
99a57d29af | ||
|
|
ed0afb6b86 | ||
|
|
2f005cbadd | ||
|
|
7bac4e0a6b | ||
|
|
2dad4189c8 | ||
|
|
5c1fe49e1b | ||
|
|
9a5cd7e834 | ||
|
|
78a032a18b | ||
|
|
b99a9d7d2f | ||
|
|
36c9628695 | ||
|
|
ccd7468ffe | ||
|
|
129b244ea9 | ||
|
|
716e39f947 | ||
|
|
a0167e7cf2 | ||
|
|
2c6dea64ab | ||
|
|
9605676dbe | ||
|
|
a4e7be46fb | ||
|
|
e2ce520041 | ||
|
|
d1fc41682e | ||
|
|
56918a1ba2 | ||
|
|
869788028c | ||
|
|
a262c6c0b7 | ||
|
|
54682ef02c | ||
|
|
093bf3910b | ||
|
|
0b65f50b4b | ||
|
|
a1995772ef | ||
|
|
fcef433ba3 | ||
|
|
6950f0c7c9 | ||
|
|
e987c4d27e | ||
|
|
25c72b299e | ||
|
|
8f4f182064 | ||
|
|
2cd37b988f | ||
|
|
040ef6e22b | ||
|
|
5dfd0508da | ||
|
|
b0b043f432 | ||
|
|
cfe063a6e7 | ||
|
|
22a5e147d2 | ||
|
|
648e4b3866 | ||
|
|
ffb5a66042 | ||
|
|
e1593b67fc | ||
|
|
871d7ef535 | ||
|
|
ac32c639fa | ||
|
|
997c8194b6 | ||
|
|
7334ec38fb | ||
|
|
cafc7989e9 | ||
|
|
2354d484ee | ||
|
|
f7ebdcb182 | ||
|
|
8305dc0ebe | ||
|
|
5923042bf1 | ||
|
|
00b162771f | ||
|
|
4b9ab17fcb | ||
|
|
946bd36e66 | ||
|
|
42f4e419cd | ||
|
|
f7c8b8cdb5 | ||
|
|
fdf8f30d90 | ||
|
|
0f1127e502 | ||
|
|
12c59f6ac6 | ||
|
|
1f3414f5bc | ||
|
|
94a6a3f64d | ||
|
|
812a520c43 | ||
|
|
a48429f9f8 | ||
|
|
9aa4bdfd19 | ||
|
|
7c3cde83df | ||
|
|
af00b1b127 | ||
|
|
8a0e8e9c17 | ||
|
|
982ee4f60f | ||
|
|
c735dab40d | ||
|
|
32b8cdf9bc | ||
|
|
fd7fa885ca | ||
|
|
f4642d3b69 | ||
|
|
f54be91744 | ||
|
|
4ecbfb3e58 | ||
|
|
309cf2825e | ||
|
|
ecbc0f6afe | ||
|
|
c402a1dc79 | ||
|
|
c949e8d0f2 | ||
|
|
195446ef86 | ||
|
|
e6a1fe58bc | ||
|
|
3a9b1b374d | ||
|
|
8bb0e744bb | ||
|
|
1182894326 | ||
|
|
77b03f4a21 | ||
|
|
72bc30e188 | ||
|
|
35c789fc00 | ||
|
|
738bf5d441 | ||
|
|
22a62e6cb8 | ||
|
|
a63a1b8b51 | ||
|
|
c51f885653 | ||
|
|
266a23b7eb | ||
|
|
48603b14da | ||
|
|
7e7e19455e | ||
|
|
7657ccb94e | ||
|
|
80ade55b69 | ||
|
|
a643c9b5f4 | ||
|
|
15dc4ae7cf | ||
|
|
030734cc93 | ||
|
|
1439d4edf6 | ||
|
|
d6a816b06e | ||
|
|
b6e1f46379 | ||
|
|
d926a69b59 | ||
|
|
0504ca3887 | ||
|
|
3f36019c2e | ||
|
|
b64e3b772f | ||
|
|
ff29679b42 | ||
|
|
5aca1ef708 | ||
|
|
95a84c7ac5 | ||
|
|
28c2335223 | ||
|
|
8ea87a47ea | ||
|
|
57058f5ab0 |
+24
-22
@@ -87,6 +87,7 @@ venv/
|
||||
ENV/
|
||||
env.bak/
|
||||
venv.bak/
|
||||
lib/python*
|
||||
|
||||
# Spyder project settings
|
||||
.spyderproject
|
||||
@@ -98,6 +99,12 @@ venv.bak/
|
||||
# mkdocs documentation
|
||||
/site
|
||||
|
||||
bin
|
||||
pyvenv.cfg
|
||||
include
|
||||
share
|
||||
pip-selfcheck.json
|
||||
|
||||
# mypy
|
||||
.mypy_cache/
|
||||
|
||||
@@ -108,7 +115,22 @@ tmp/*
|
||||
*.swp
|
||||
*.pem
|
||||
*.zip
|
||||
debug.out
|
||||
mdioks.session-journal
|
||||
*.session
|
||||
|
||||
logs/*
|
||||
|
||||
ssl/local
|
||||
ssl/nginx
|
||||
ssl/choose.pl
|
||||
|
||||
scripts/init.d/mw
|
||||
scripts/mdserver-web
|
||||
|
||||
data/api_login.txt
|
||||
data/sessions
|
||||
|
||||
data/*.db
|
||||
data/iplist.txt
|
||||
data/json/index.json
|
||||
@@ -122,27 +144,11 @@ data/default.pl
|
||||
data/backup.pl
|
||||
data/debug.pl
|
||||
data/default_site.pl
|
||||
|
||||
ssl/input.pl
|
||||
|
||||
lib/python*
|
||||
|
||||
bin
|
||||
pyvenv.cfg
|
||||
include
|
||||
share
|
||||
pip-selfcheck.json
|
||||
|
||||
scripts/init.d/mw
|
||||
scripts/mdserver-web
|
||||
|
||||
data/api_login.txt
|
||||
data/sessions
|
||||
data/ssl.pl
|
||||
|
||||
data/port.pl
|
||||
data/ipv6.pl
|
||||
data/restart.pl
|
||||
data/ssl.pl
|
||||
data/edate.pl
|
||||
data/osname.pl
|
||||
data/only_netio_counters.pl
|
||||
@@ -173,8 +179,4 @@ plugins/v2ray
|
||||
plugins/frp
|
||||
plugins/file_search
|
||||
plugins/proxysql
|
||||
debug.out
|
||||
|
||||
|
||||
mdioks.session-journal
|
||||
*.session
|
||||
plugins/tidb
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
|
||||
[](https://github.com/midoks/mdserver-web/wiki)
|
||||
[](https://www.jsdelivr.com/package/gh/midoks/mdserver-web)
|
||||
[](https://www.jsdelivr.com/package/gh/midoks/mdserver-web)
|
||||
|
||||
* SSH终端工具
|
||||
* 面板收藏功能
|
||||
@@ -110,10 +110,9 @@ docker run -itd --name mw-server --privileged=true -p 7200:7200 -p 80:80 -p 443:
|
||||
```
|
||||
|
||||
|
||||
### 版本更新 0.16.6
|
||||
### 版本更新 0.17.1
|
||||
|
||||
- openresty【1.25.3.1】配置更新,支持h3;
|
||||
- 修复php83的扩展bcmath在centos7安装出错。
|
||||
- 任务管理器-插件。
|
||||
|
||||
### JSDelivr安装地址
|
||||
|
||||
|
||||
+318
-222
@@ -28,7 +28,7 @@ from flask import request
|
||||
|
||||
class config_api:
|
||||
|
||||
__version = '0.16.6'
|
||||
__version = '0.17.1'
|
||||
__api_addr = 'data/api.json'
|
||||
|
||||
# 统一默认配置文件
|
||||
@@ -42,7 +42,7 @@ class config_api:
|
||||
'bind_domain' : 'data/bind_domain.pl', # 面板域名绑定
|
||||
'unauth_status' : 'data/unauthorized_status.pl', # URL路径未成功显示状态
|
||||
'auth_secret': 'data/auth_secret.pl', # 二次验证密钥
|
||||
'ssl':'data/ssl.pl', # ssl设置
|
||||
'ssl':'ssl/choose.pl', # ssl设置
|
||||
'hook_database' : 'data/hook_database.json', # 数据库钩子
|
||||
'hook_menu' : 'data/hook_menu.json', # 菜单钩子
|
||||
'hook_global_static' : 'data/hook_global_static.json', # 静态文件钩子
|
||||
@@ -362,19 +362,23 @@ class config_api:
|
||||
return mw.getJson(cert)
|
||||
|
||||
def getPanelSslData(self):
|
||||
cert = {}
|
||||
keyPath = 'ssl/private.pem'
|
||||
certPath = 'ssl/cert.pem'
|
||||
rdata = {}
|
||||
choose_file = self.__file['ssl']
|
||||
rdata['choose'] = mw.readFile(choose_file)
|
||||
|
||||
|
||||
keyPath = 'ssl/local/private.pem'
|
||||
certPath = 'ssl/local/cert.pem'
|
||||
|
||||
if not os.path.exists(certPath):
|
||||
# 不再自动生成证书
|
||||
# mw.createSSL()
|
||||
cert['privateKey'] = ''
|
||||
cert['is_https'] = ''
|
||||
cert['certPem'] = ''
|
||||
cert['rep'] = os.path.exists('ssl/input.pl')
|
||||
cert['info'] = {'endtime': 0, 'subject': '无',
|
||||
'notAfter': '无', 'notBefore': '无', 'issuer': '无'}
|
||||
return cert
|
||||
mw.createLocalSSL()
|
||||
|
||||
cert = {}
|
||||
cert['privateKey'] = mw.readFile(keyPath)
|
||||
cert['is_https'] = ''
|
||||
cert['certPem'] = mw.readFile(certPath)
|
||||
cert['info'] = mw.getCertName(certPath)
|
||||
rdata['local'] = cert
|
||||
|
||||
panel_ssl = mw.getServerDir() + "/web_conf/nginx/vhost/panel.conf"
|
||||
if not os.path.exists(panel_ssl):
|
||||
@@ -384,21 +388,68 @@ class config_api:
|
||||
if ssl_data.find('$server_port !~ 443') != -1:
|
||||
cert['is_https'] = 'checked'
|
||||
|
||||
keyPath = 'ssl/nginx/private.pem'
|
||||
certPath = 'ssl/nginx/cert.pem'
|
||||
|
||||
cert = {}
|
||||
cert['privateKey'] = mw.readFile(keyPath)
|
||||
cert['certPem'] = mw.readFile(certPath)
|
||||
cert['rep'] = os.path.exists('ssl/input.pl')
|
||||
cert['info'] = mw.getCertName(certPath)
|
||||
return cert
|
||||
|
||||
rdata['nginx'] = cert
|
||||
|
||||
return rdata
|
||||
|
||||
# 面板本地SSL设置
|
||||
def setPanelLocalSslApi(self):
|
||||
cert = {}
|
||||
keyPath = 'ssl/local/private.pem'
|
||||
certPath = 'ssl/local/cert.pem'
|
||||
|
||||
if not os.path.exists(certPath):
|
||||
mw.createLocalSSL()
|
||||
|
||||
choose_file = self.__file['ssl']
|
||||
mw.writeFile(choose_file, 'local')
|
||||
|
||||
mw.restartMw()
|
||||
return mw.returnJson(True, '设置成功')
|
||||
|
||||
# 关闭SSL
|
||||
def closePanelSslApi(self):
|
||||
choose_file = self.__file['ssl']
|
||||
if os.path.exists(choose_file):
|
||||
os.remove(choose_file)
|
||||
|
||||
local_ssl = 'ssl/local'
|
||||
if os.path.exists(local_ssl):
|
||||
mw.execShell('rm -rf '+ local_ssl)
|
||||
|
||||
nginx_ssl = 'ssl/nginx'
|
||||
if os.path.exists(nginx_ssl):
|
||||
mw.execShell('rm -rf '+ nginx_ssl)
|
||||
|
||||
mw.restartMw()
|
||||
return mw.returnJson(True, '关闭SSL成功')
|
||||
|
||||
# 保存面板证书
|
||||
def savePanelSslApi(self):
|
||||
keyPath = 'ssl/private.pem'
|
||||
certPath = 'ssl/cert.pem'
|
||||
checkCert = '/tmp/cert.pl'
|
||||
|
||||
choose = request.form.get('choose', '').strip()
|
||||
certPem = request.form.get('certPem', '').strip()
|
||||
privateKey = request.form.get('privateKey', '').strip()
|
||||
|
||||
if not mw.inArray(['local','nginx'], choose):
|
||||
return mw.returnJson(True, '保存错误面板SSL类型!')
|
||||
|
||||
|
||||
keyPath = 'ssl/'+choose+'/private.pem'
|
||||
certPath = 'ssl/'+choose+'/cert.pem'
|
||||
checkCert = '/tmp/cert.pl'
|
||||
|
||||
if not os.path.exists(keyPath):
|
||||
return mw.returnJson(False, '【'+choose+'】SSL类型不存在,先申请!')
|
||||
|
||||
if(privateKey.find('KEY') == -1):
|
||||
return mw.returnJson(False, '秘钥错误,请检查!')
|
||||
if(certPem.find('CERTIFICATE') == -1):
|
||||
@@ -411,258 +462,303 @@ class config_api:
|
||||
mw.writeFile(certPath, certPem)
|
||||
if not mw.checkCert(checkCert):
|
||||
return mw.returnJson(False, '证书错误,请检查!')
|
||||
mw.writeFile('ssl/input.pl', 'True')
|
||||
return mw.returnJson(True, '证书已保存!')
|
||||
|
||||
# 设置面板SSL证书设置
|
||||
def setPanelHttpToHttpsApi(self):
|
||||
# def setPanelHttpToHttpsApi(self):
|
||||
|
||||
bind_domain = self.__file['bind_domain']
|
||||
if not os.path.exists(bind_domain):
|
||||
return mw.returnJson(False, '先要绑定域名!')
|
||||
# bind_domain = self.__file['bind_domain']
|
||||
# if not os.path.exists(bind_domain):
|
||||
# return mw.returnJson(False, '先要绑定域名!')
|
||||
|
||||
keyPath = 'ssl/private.pem'
|
||||
if not os.path.exists(keyPath):
|
||||
return mw.returnJson(False, '未申请SSL证书!')
|
||||
# choose_file = self.__file['ssl']
|
||||
# choose = mw.readFile(choose_file)
|
||||
# if choose == 'local':
|
||||
# return mw.returnJson(False, '本地SSL无法使用!')
|
||||
|
||||
is_https = request.form.get('https', '').strip()
|
||||
# keyPath = 'ssl/nginx/private.pem'
|
||||
# if not os.path.exists(keyPath):
|
||||
# return mw.returnJson(False, '未申请SSL证书!')
|
||||
|
||||
panel_ssl = mw.getServerDir() + "/web_conf/nginx/vhost/panel.conf"
|
||||
if not os.path.exists(panel_ssl):
|
||||
return mw.returnJson(False, '未开启面板SSL!')
|
||||
# is_https = request.form.get('https', '').strip()
|
||||
|
||||
if is_https == 'false':
|
||||
conf = mw.readFile(panel_ssl)
|
||||
if conf:
|
||||
if conf.find('ssl_certificate') == -1:
|
||||
return mw.returnJson(False, '当前未开启SSL')
|
||||
to = "#error_page 404/404.html;\n\
|
||||
#HTTP_TO_HTTPS_START\n\
|
||||
if ($server_port !~ 443){\n\
|
||||
rewrite ^(/.*)$ https://$host$1 permanent;\n\
|
||||
}\n\
|
||||
#HTTP_TO_HTTPS_END"
|
||||
conf = conf.replace('#error_page 404/404.html;', to)
|
||||
mw.writeFile(panel_ssl, conf)
|
||||
else:
|
||||
conf = mw.readFile(panel_ssl)
|
||||
if conf:
|
||||
rep = "\n\\s*#HTTP_TO_HTTPS_START(.|\n){1,300}#HTTP_TO_HTTPS_END"
|
||||
conf = re.sub(rep, '', conf)
|
||||
rep = "\\s+if.+server_port.+\n.+\n\\s+\\s*}"
|
||||
conf = re.sub(rep, '', conf)
|
||||
mw.writeFile(panel_ssl, conf)
|
||||
# panel_ssl = mw.getServerDir() + "/web_conf/nginx/vhost/panel.conf"
|
||||
# if not os.path.exists(panel_ssl):
|
||||
# return mw.returnJson(False, '未开启面板SSL!')
|
||||
|
||||
mw.restartWeb()
|
||||
# if is_https == 'false':
|
||||
# conf = mw.readFile(panel_ssl)
|
||||
# if conf:
|
||||
# if conf.find('ssl_certificate') == -1:
|
||||
# return mw.returnJson(False, '当前未开启SSL')
|
||||
# to = "#error_page 404/404.html;\n\
|
||||
# #HTTP_TO_HTTPS_START\n\
|
||||
# if ($server_port !~ 443){\n\
|
||||
# rewrite ^(/.*)$ https://$host$1 permanent;\n\
|
||||
# }\n\
|
||||
# #HTTP_TO_HTTPS_END"
|
||||
# conf = conf.replace('#error_page 404/404.html;', to)
|
||||
# mw.writeFile(panel_ssl, conf)
|
||||
# else:
|
||||
# conf = mw.readFile(panel_ssl)
|
||||
# if conf:
|
||||
# rep = "\n\\s*#HTTP_TO_HTTPS_START(.|\n){1,300}#HTTP_TO_HTTPS_END"
|
||||
# conf = re.sub(rep, '', conf)
|
||||
# rep = "\\s+if.+server_port.+\n.+\n\\s+\\s*}"
|
||||
# conf = re.sub(rep, '', conf)
|
||||
# mw.writeFile(panel_ssl, conf)
|
||||
|
||||
action = '开启'
|
||||
if is_https == 'true':
|
||||
action = '关闭'
|
||||
return mw.returnJson(True, action + 'HTTPS跳转成功!')
|
||||
# mw.restartNginx()
|
||||
|
||||
# action = '开启'
|
||||
# if is_https == 'true':
|
||||
# action = '关闭'
|
||||
# return mw.returnJson(True, action + 'HTTPS跳转成功!')
|
||||
|
||||
# 删除面板证书
|
||||
def delPanelSslApi(self):
|
||||
bind_domain = self.__file['bind_domain']
|
||||
if not os.path.exists(bind_domain):
|
||||
return mw.returnJson(False, '未绑定域名!')
|
||||
ip = mw.getLocalIp()
|
||||
if mw.isAppleSystem():
|
||||
ip = '127.0.0.1'
|
||||
|
||||
siteName = mw.readFile(bind_domain).strip()
|
||||
port = mw.readFile('data/port.pl').strip()
|
||||
|
||||
src_letpath = mw.getServerDir() + '/web_conf/letsencrypt/' + siteName
|
||||
choose = request.form.get('choose', '').strip()
|
||||
|
||||
dst_letpath = mw.getRunDir() + '/ssl'
|
||||
dst_csrpath = dst_letpath + '/cert.pem'
|
||||
dst_keypath = dst_letpath + '/private.pem'
|
||||
if not mw.inArray(['local','nginx'], choose):
|
||||
return mw.returnJson(True, '删除错误面板SSL类型!')
|
||||
|
||||
if os.path.exists(src_letpath) or os.path.exists(dst_csrpath):
|
||||
if os.path.exists(src_letpath):
|
||||
mw.execShell('rm -rf ' + src_letpath)
|
||||
if os.path.exists(dst_csrpath):
|
||||
mw.execShell('rm -rf ' + dst_csrpath)
|
||||
if os.path.exists(dst_keypath):
|
||||
mw.execShell('rm -rf ' + dst_keypath)
|
||||
# mw.restartWeb()
|
||||
return mw.returnJson(True, '已经删除SSL!')
|
||||
to_panel_url = 'http://'+ip+":"+port+'/config'
|
||||
|
||||
# mw.restartWeb()
|
||||
return mw.returnJson(False, '已经不存在SSL!')
|
||||
if choose == 'local':
|
||||
dst_path = mw.getRunDir() + '/ssl/local'
|
||||
ssl_file = self.__file['ssl']
|
||||
if os.path.exists(dst_path):
|
||||
mw.execShell('rm -rf ' + dst_path)
|
||||
mw.execShell('rm -rf ' + ssl_file)
|
||||
mw.restartMw();
|
||||
return mw.returnJson(True, '删除本地面板SSL成功!',to_panel_url)
|
||||
else:
|
||||
return mw.returnJson(True, '已经删除本地面板SSL!',to_panel_url)
|
||||
|
||||
if choose == 'nginx':
|
||||
|
||||
bind_domain = self.__file['bind_domain']
|
||||
if not os.path.exists(bind_domain):
|
||||
return mw.returnJson(False, '未绑定域名!')
|
||||
|
||||
siteName = mw.readFile(bind_domain).strip()
|
||||
|
||||
src_path = mw.getServerDir() + '/web_conf/letsencrypt/' + siteName
|
||||
|
||||
dst_path = mw.getRunDir() + '/ssl/nginx'
|
||||
dst_csrpath = dst_path + '/cert.pem'
|
||||
dst_keypath = dst_path + '/private.pem'
|
||||
|
||||
if os.path.exists(src_path) or os.path.exists(dst_path):
|
||||
if os.path.exists(src_letpath):
|
||||
mw.execShell('rm -rf ' + src_letpath)
|
||||
if os.path.exists(dst_csrpath):
|
||||
mw.execShell('rm -rf ' + dst_csrpath)
|
||||
if os.path.exists(dst_keypath):
|
||||
mw.execShell('rm -rf ' + dst_keypath)
|
||||
mw.restartNginx()
|
||||
return mw.returnJson(True, '删除面板SSL成功!')
|
||||
|
||||
mw.restartNginx()
|
||||
mw.restartMw()
|
||||
return mw.returnJson(False, '已经删除面板SSL!')
|
||||
return mw.returnJson(False, '未知类型!')
|
||||
|
||||
# 申请面板let证书
|
||||
def applyPanelLetSslApi(self):
|
||||
# def applyPanelAcmeSslApi(self):
|
||||
|
||||
# check domain is bind?
|
||||
bind_domain = self.__file['bind_domain']
|
||||
if not os.path.exists(bind_domain):
|
||||
return mw.returnJson(False, '先要绑定域名!')
|
||||
# bind_domain = self.__file['bind_domain']
|
||||
# if not os.path.exists(bind_domain):
|
||||
# return mw.returnJson(False, '先要绑定域名!')
|
||||
|
||||
siteName = mw.readFile(bind_domain).strip()
|
||||
auth_to = mw.getRunDir() + "/tmp"
|
||||
to_args = {
|
||||
'domains': [siteName],
|
||||
'auth_type': 'http',
|
||||
'auth_to': auth_to,
|
||||
}
|
||||
# # 生成nginx配置
|
||||
# domain = mw.readFile(bind_domain)
|
||||
# panel_tpl = mw.getRunDir() + "/data/tpl/nginx_panel.conf"
|
||||
# dst_panel_path = mw.getServerDir() + "/web_conf/nginx/vhost/panel.conf"
|
||||
# if not os.path.exists(dst_panel_path):
|
||||
# reg = r"^([\w\-\*]{1,100}\.){1,4}(\w{1,10}|\w{1,10}\.\w{1,10})$"
|
||||
# if not re.match(reg, domain):
|
||||
# return mw.returnJson(False, '主域名格式不正确')
|
||||
|
||||
src_letpath = mw.getServerDir() + '/web_conf/letsencrypt/' + siteName
|
||||
src_csrpath = src_letpath + "/fullchain.pem" # 生成证书路径
|
||||
src_keypath = src_letpath + "/privkey.pem" # 密钥文件路径
|
||||
# op_dir = mw.getServerDir() + "/openresty"
|
||||
# if not os.path.exists(op_dir):
|
||||
# return mw.returnJson(False, '依赖OpenResty,先安装启动它!')
|
||||
|
||||
dst_letpath = mw.getRunDir() + '/ssl'
|
||||
dst_csrpath = dst_letpath + '/cert.pem'
|
||||
dst_keypath = dst_letpath + '/private.pem'
|
||||
# content = mw.readFile(panel_tpl)
|
||||
# content = content.replace("{$PORT}", "80")
|
||||
# content = content.replace("{$SERVER_NAME}", domain)
|
||||
# content = content.replace("{$PANAL_PORT}", mw.readFile('data/port.pl'))
|
||||
# content = content.replace("{$LOGPATH}", mw.getRunDir() + '/logs')
|
||||
# content = content.replace("{$PANAL_ADDR}", mw.getRunDir())
|
||||
# mw.writeFile(dst_panel_path, content)
|
||||
# mw.restartNginx()
|
||||
|
||||
is_already_apply = False
|
||||
# siteName = mw.readFile(bind_domain).strip()
|
||||
# auth_to = mw.getRunDir() + "/tmp"
|
||||
# to_args = {
|
||||
# 'domains': [siteName],
|
||||
# 'auth_type': 'http',
|
||||
# 'auth_to': auth_to,
|
||||
# }
|
||||
|
||||
if not os.path.exists(src_letpath):
|
||||
import cert_api
|
||||
data = cert_api.cert_api().applyCertApi(to_args)
|
||||
if not data['status']:
|
||||
msg = data['msg']
|
||||
if type(data['msg']) != str:
|
||||
msg = data['msg'][0]
|
||||
emsg = data['msg'][1]['challenges'][0]['error']
|
||||
msg = msg + '<p><span>响应状态:</span>' + str(emsg['status']) + '</p><p><span>错误类型:</span>' + emsg[
|
||||
'type'] + '</p><p><span>错误代码:</span>' + emsg['detail'] + '</p>'
|
||||
return mw.returnJson(data['status'], msg, data['msg'])
|
||||
else:
|
||||
is_already_apply = True
|
||||
# src_path = mw.getServerDir() + '/web_conf/letsencrypt/' + siteName
|
||||
# src_csrpath = src_path + "/fullchain.pem" # 生成证书路径
|
||||
# src_keypath = src_path + "/privkey.pem" # 密钥文件路径
|
||||
|
||||
mw.buildSoftLink(src_csrpath, dst_csrpath, True)
|
||||
mw.buildSoftLink(src_keypath, dst_keypath, True)
|
||||
mw.execShell('echo "lets" > "' + dst_letpath + '/README"')
|
||||
# dst_path = mw.getRunDir() + '/ssl/nginx'
|
||||
# dst_csrpath = dst_path + '/cert.pem'
|
||||
# dst_keypath = dst_path + '/private.pem'
|
||||
|
||||
data = self.getPanelSslData()
|
||||
# is_already_apply = False
|
||||
|
||||
tmp_well_know = auth_to + '/.well-known'
|
||||
if os.path.exists(tmp_well_know):
|
||||
mw.execShell('rm -rf ' + tmp_well_know)
|
||||
# if not os.path.exists(src_path):
|
||||
# import cert_api
|
||||
# data = cert_api.cert_api().applyCertApi(to_args)
|
||||
# if not data['status']:
|
||||
# msg = data['msg']
|
||||
# if type(data['msg']) != str:
|
||||
# msg = data['msg'][0]
|
||||
# emsg = data['msg'][1]['challenges'][0]['error']
|
||||
# msg = msg + '<p><span>响应状态:</span>' + str(emsg['status']) + '</p><p><span>错误类型:</span>' + emsg[
|
||||
# 'type'] + '</p><p><span>错误代码:</span>' + emsg['detail'] + '</p>'
|
||||
# return mw.returnJson(data['status'], msg, data['msg'])
|
||||
# else:
|
||||
# is_already_apply = True
|
||||
|
||||
if is_already_apply:
|
||||
return mw.returnJson(True, '重复申请!', data)
|
||||
# mw.buildSoftLink(src_csrpath, dst_csrpath, True)
|
||||
# mw.buildSoftLink(src_keypath, dst_keypath, True)
|
||||
# mw.execShell('echo "acme" > "' + dst_path + '/README"')
|
||||
|
||||
return mw.returnJson(True, '申请成功!', data)
|
||||
# tmp_well_know = auth_to + '/.well-known'
|
||||
# if os.path.exists(tmp_well_know):
|
||||
# mw.execShell('rm -rf ' + tmp_well_know)
|
||||
|
||||
# if os.path.exists(dst_path):
|
||||
# choose_file = self.__file['ssl']
|
||||
# mw.writeFile(choose_file, 'nginx')
|
||||
|
||||
# data = self.getPanelSslData()
|
||||
|
||||
# if is_already_apply:
|
||||
# return mw.returnJson(True, '重复申请!', data)
|
||||
# return mw.returnJson(True, '申请成功!', data)
|
||||
|
||||
def setPanelDomainApi(self):
|
||||
domain = request.form.get('domain', '')
|
||||
|
||||
panel_tpl = mw.getRunDir() + "/data/tpl/nginx_panel.conf"
|
||||
dst_panel_path = mw.getServerDir() + "/web_conf/nginx/vhost/panel.conf"
|
||||
|
||||
cfg_domain = self.__file['bind_domain']
|
||||
|
||||
port = mw.readFile('data/port.pl').strip()
|
||||
ip = mw.getLocalIp()
|
||||
|
||||
if domain == '':
|
||||
os.remove(cfg_domain)
|
||||
os.remove(dst_panel_path)
|
||||
mw.restartWeb()
|
||||
return mw.returnJson(True, '清空域名成功!')
|
||||
if os.path.exists(cfg_domain):
|
||||
os.remove(cfg_domain)
|
||||
|
||||
reg = r"^([\w\-\*]{1,100}\.){1,4}(\w{1,10}|\w{1,10}\.\w{1,10})$"
|
||||
if not re.match(reg, domain):
|
||||
return mw.returnJson(False, '主域名格式不正确')
|
||||
|
||||
op_dir = mw.getServerDir() + "/openresty"
|
||||
if not os.path.exists(op_dir):
|
||||
return mw.returnJson(False, '依赖OpenResty,先安装启动它!')
|
||||
|
||||
content = mw.readFile(panel_tpl)
|
||||
content = content.replace("{$PORT}", "80")
|
||||
content = content.replace("{$SERVER_NAME}", domain)
|
||||
content = content.replace("{$PANAL_PORT}", mw.readFile('data/port.pl'))
|
||||
content = content.replace("{$LOGPATH}", mw.getRunDir() + '/logs')
|
||||
content = content.replace("{$PANAL_ADDR}", mw.getRunDir())
|
||||
mw.writeFile(dst_panel_path, content)
|
||||
mw.restartWeb()
|
||||
to_panel_url = 'http://'+ip+":"+port+'/config'
|
||||
|
||||
mw.restartMw()
|
||||
return mw.returnJson(True, '清空域名成功!', to_panel_url)
|
||||
|
||||
mw.writeFile(cfg_domain, domain)
|
||||
return mw.returnJson(True, '设置域名成功!')
|
||||
to_panel_url = 'http://'+domain+":"+port+'/config'
|
||||
mw.restartMw()
|
||||
return mw.returnJson(True, '设置域名成功!',to_panel_url)
|
||||
|
||||
# 设置面板SSL
|
||||
def setPanelSslApi(self):
|
||||
sslConf = mw.getRunDir() + '/' + self.__file['ssl']
|
||||
# def setPanelSslApi(self):
|
||||
# sslConf = mw.getRunDir() + '/' + self.__file['ssl']
|
||||
|
||||
panel_tpl = mw.getRunDir() + "/data/tpl/nginx_panel.conf"
|
||||
dst_panel_path = mw.getServerDir() + "/web_conf/nginx/vhost/panel.conf"
|
||||
if os.path.exists(sslConf):
|
||||
os.system('rm -f ' + sslConf)
|
||||
# panel_tpl = mw.getRunDir() + "/data/tpl/nginx_panel.conf"
|
||||
# dst_panel_path = mw.getServerDir() + "/web_conf/nginx/vhost/panel.conf"
|
||||
# if os.path.exists(sslConf):
|
||||
# os.system('rm -f ' + sslConf)
|
||||
|
||||
conf = mw.readFile(dst_panel_path)
|
||||
if conf:
|
||||
rep = "\\s+ssl_certificate\\s+.+;\\s+ssl_certificate_key\\s+.+;"
|
||||
conf = re.sub(rep, '', conf)
|
||||
rep = "\\s+ssl_protocols\\s+.+;\n"
|
||||
conf = re.sub(rep, '', conf)
|
||||
rep = "\\s+ssl_ciphers\\s+.+;\n"
|
||||
conf = re.sub(rep, '', conf)
|
||||
rep = "\\s+ssl_prefer_server_ciphers\\s+.+;\n"
|
||||
conf = re.sub(rep, '', conf)
|
||||
rep = "\\s+ssl_session_cache\\s+.+;\n"
|
||||
conf = re.sub(rep, '', conf)
|
||||
rep = "\\s+ssl_session_timeout\\s+.+;\n"
|
||||
conf = re.sub(rep, '', conf)
|
||||
rep = "\\s+ssl_ecdh_curve\\s+.+;\n"
|
||||
conf = re.sub(rep, '', conf)
|
||||
rep = "\\s+ssl_session_tickets\\s+.+;\n"
|
||||
conf = re.sub(rep, '', conf)
|
||||
rep = "\\s+ssl_stapling\\s+.+;\n"
|
||||
conf = re.sub(rep, '', conf)
|
||||
rep = "\\s+ssl_stapling_verify\\s+.+;\n"
|
||||
conf = re.sub(rep, '', conf)
|
||||
rep = "\\s+ssl\\s+on;"
|
||||
conf = re.sub(rep, '', conf)
|
||||
rep = "\\s+error_page\\s497.+;"
|
||||
conf = re.sub(rep, '', conf)
|
||||
rep = "\\s+if.+server_port.+\n.+\n\\s+\\s*}"
|
||||
conf = re.sub(rep, '', conf)
|
||||
rep = "\\s+listen\\s+443.*;"
|
||||
conf = re.sub(rep, '', conf)
|
||||
rep = "\\s+listen\\s+\\[\\:\\:\\]\\:443.*;"
|
||||
conf = re.sub(rep, '', conf)
|
||||
mw.writeFile(dst_panel_path, conf)
|
||||
# conf = mw.readFile(dst_panel_path)
|
||||
# if conf:
|
||||
# rep = "\\s+ssl_certificate\\s+.+;\\s+ssl_certificate_key\\s+.+;"
|
||||
# conf = re.sub(rep, '', conf)
|
||||
# rep = "\\s+ssl_protocols\\s+.+;\n"
|
||||
# conf = re.sub(rep, '', conf)
|
||||
# rep = "\\s+ssl_ciphers\\s+.+;\n"
|
||||
# conf = re.sub(rep, '', conf)
|
||||
# rep = "\\s+ssl_prefer_server_ciphers\\s+.+;\n"
|
||||
# conf = re.sub(rep, '', conf)
|
||||
# rep = "\\s+ssl_session_cache\\s+.+;\n"
|
||||
# conf = re.sub(rep, '', conf)
|
||||
# rep = "\\s+ssl_session_timeout\\s+.+;\n"
|
||||
# conf = re.sub(rep, '', conf)
|
||||
# rep = "\\s+ssl_ecdh_curve\\s+.+;\n"
|
||||
# conf = re.sub(rep, '', conf)
|
||||
# rep = "\\s+ssl_session_tickets\\s+.+;\n"
|
||||
# conf = re.sub(rep, '', conf)
|
||||
# rep = "\\s+ssl_stapling\\s+.+;\n"
|
||||
# conf = re.sub(rep, '', conf)
|
||||
# rep = "\\s+ssl_stapling_verify\\s+.+;\n"
|
||||
# conf = re.sub(rep, '', conf)
|
||||
# rep = "\\s+ssl\\s+on;"
|
||||
# conf = re.sub(rep, '', conf)
|
||||
# rep = "\\s+error_page\\s497.+;"
|
||||
# conf = re.sub(rep, '', conf)
|
||||
# rep = "\\s+if.+server_port.+\n.+\n\\s+\\s*}"
|
||||
# conf = re.sub(rep, '', conf)
|
||||
# rep = "\\s+listen\\s+443.*;"
|
||||
# conf = re.sub(rep, '', conf)
|
||||
# rep = "\\s+listen\\s+\\[\\:\\:\\]\\:443.*;"
|
||||
# conf = re.sub(rep, '', conf)
|
||||
# mw.writeFile(dst_panel_path, conf)
|
||||
|
||||
mw.writeLog('面板配置', '面板SSL关闭成功!')
|
||||
mw.restartWeb()
|
||||
return mw.returnJson(True, 'SSL已关闭,请使用http协议访问面板!')
|
||||
else:
|
||||
try:
|
||||
mw.writeFile(sslConf, 'True')
|
||||
# mw.writeLog('面板配置', '面板SSL关闭成功!')
|
||||
# mw.restartWeb()
|
||||
# return mw.returnJson(True, 'SSL已关闭,请使用http协议访问面板!')
|
||||
# else:
|
||||
# try:
|
||||
# mw.writeFile(sslConf, 'True')
|
||||
|
||||
keyPath = mw.getRunDir() + '/ssl/private.pem'
|
||||
certPath = mw.getRunDir() + '/ssl/cert.pem'
|
||||
# keyPath = mw.getRunDir() + '/ssl/private.pem'
|
||||
# certPath = mw.getRunDir() + '/ssl/cert.pem'
|
||||
|
||||
conf = mw.readFile(dst_panel_path)
|
||||
if conf:
|
||||
if conf.find('ssl_certificate') == -1:
|
||||
sslStr = """#error_page 404/404.html;
|
||||
ssl_certificate %s;
|
||||
ssl_certificate_key %s;
|
||||
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
|
||||
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
|
||||
ssl_prefer_server_ciphers on;
|
||||
ssl_session_cache shared:SSL:10m;
|
||||
ssl_session_timeout 10m;
|
||||
error_page 497 https://$host$request_uri;""" % (certPath, keyPath)
|
||||
if(conf.find('ssl_certificate') != -1):
|
||||
return mw.returnJson(True, 'SSL开启成功!')
|
||||
# conf = mw.readFile(dst_panel_path)
|
||||
# if conf:
|
||||
# if conf.find('ssl_certificate') == -1:
|
||||
# sslStr = """#error_page 404/404.html;
|
||||
# ssl_certificate %s;
|
||||
# ssl_certificate_key %s;
|
||||
# ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
|
||||
# ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
|
||||
# ssl_prefer_server_ciphers on;
|
||||
# ssl_session_cache shared:SSL:10m;
|
||||
# ssl_session_timeout 10m;
|
||||
# error_page 497 https://$host$request_uri;""" % (certPath, keyPath)
|
||||
# if(conf.find('ssl_certificate') != -1):
|
||||
# return mw.returnJson(True, 'SSL开启成功!')
|
||||
|
||||
conf = conf.replace('#error_page 404/404.html;', sslStr)
|
||||
# conf = conf.replace('#error_page 404/404.html;', sslStr)
|
||||
|
||||
rep = "listen\\s+([0-9]+)\\s*[default_server]*;"
|
||||
tmp = re.findall(rep, conf)
|
||||
if not mw.inArray(tmp, '443'):
|
||||
listen = re.search(rep, conf).group()
|
||||
http_ssl = "\n\tlisten 443 ssl http2;"
|
||||
http_ssl = http_ssl + "\n\tlisten [::]:443 ssl http2;"
|
||||
conf = conf.replace(listen, listen + http_ssl)
|
||||
# rep = "listen\\s+([0-9]+)\\s*[default_server]*;"
|
||||
# tmp = re.findall(rep, conf)
|
||||
# if not mw.inArray(tmp, '443'):
|
||||
# listen = re.search(rep, conf).group()
|
||||
# http_ssl = "\n\tlisten 443 ssl http2;"
|
||||
# http_ssl = http_ssl + "\n\tlisten [::]:443 ssl http2;"
|
||||
# conf = conf.replace(listen, listen + http_ssl)
|
||||
|
||||
mw.backFile(dst_panel_path)
|
||||
mw.writeFile(dst_panel_path, conf)
|
||||
isError = mw.checkWebConfig()
|
||||
if(isError != True):
|
||||
mw.restoreFile(dst_panel_path)
|
||||
return mw.returnJson(False, '证书错误: <br><a style="color:red;">' + isError.replace("\n", '<br>') + '</a>')
|
||||
except Exception as ex:
|
||||
return mw.returnJson(False, '开启失败:' + str(ex))
|
||||
mw.restartWeb()
|
||||
return mw.returnJson(True, '开启成功,请使用https协议访问面板!')
|
||||
# mw.backFile(dst_panel_path)
|
||||
# mw.writeFile(dst_panel_path, conf)
|
||||
# isError = mw.checkWebConfig()
|
||||
# if(isError != True):
|
||||
# mw.restoreFile(dst_panel_path)
|
||||
# return mw.returnJson(False, '证书错误: <br><a style="color:red;">' + isError.replace("\n", '<br>') + '</a>')
|
||||
# except Exception as ex:
|
||||
# return mw.returnJson(False, '开启失败:' + str(ex))
|
||||
# mw.restartWeb()
|
||||
# return mw.returnJson(True, '开启成功,请使用https协议访问面板!')
|
||||
|
||||
def getApi(self):
|
||||
data = {}
|
||||
@@ -958,7 +1054,7 @@ class config_api:
|
||||
mw.writeFile(auth, crypt_data)
|
||||
|
||||
ip = mw.getHostAddr()
|
||||
url = pyotp.totp.TOTP(sec).provisioning_uri(name=ip, issuer_name='mdserver-web')
|
||||
url = pyotp.totp.TOTP(sec).provisioning_uri(name=ip, issuer_name=tag)
|
||||
|
||||
rdata = {}
|
||||
rdata['secret'] = sec
|
||||
|
||||
@@ -396,14 +396,16 @@ class crontab_api:
|
||||
if soft_name == 'postgresql':
|
||||
sqlite3_name = 'pgsql'
|
||||
|
||||
if soft_name == 'mongodb':
|
||||
sqlite3_name = 'mongodb'
|
||||
|
||||
db_list = {}
|
||||
db_list['orderOpt'] = bak_data
|
||||
|
||||
if not os.path.exists(path + '/' + sqlite3_name + '.db'):
|
||||
db_list['data'] = []
|
||||
else:
|
||||
db_list['data'] = mw.M('databases').dbPos(
|
||||
path, sqlite3_name).field('name,ps').select()
|
||||
db_list['data'] = mw.M('databases').dbPos(path, sqlite3_name).field('name,ps').select()
|
||||
return mw.getJson(db_list)
|
||||
|
||||
if stype == 'path':
|
||||
|
||||
+8
-1
@@ -42,8 +42,13 @@ class Sql():
|
||||
self.__DB_CONN = sqlite3.connect(self.__DB_FILE)
|
||||
self.__DB_CONN.text_factory = str
|
||||
except Exception as ex:
|
||||
# print(mw.getTracebackInfo())
|
||||
return "error: " + str(ex)
|
||||
|
||||
def changeTextFactoryToBytes(self):
|
||||
self.__DB_CONN.text_factory = bytes
|
||||
return True
|
||||
|
||||
def autoTextFactory(self):
|
||||
if sys.version_info[0] == 3:
|
||||
self.__DB_CONN.text_factory = lambda x: str(
|
||||
@@ -151,7 +156,9 @@ class Sql():
|
||||
try:
|
||||
sql = "SELECT " + self.__OPT_FIELD + " FROM " + self.__DB_TABLE + \
|
||||
self.__OPT_WHERE + self.__OPT_GROUP + self.__OPT_ORDER + self.__OPT_LIMIT
|
||||
# print(sql, self.__OPT_PARAM)
|
||||
|
||||
if os.path.exists('data/debug.pl'):
|
||||
print(sql, self.__OPT_PARAM)
|
||||
result = self.__DB_CONN.execute(sql, self.__OPT_PARAM)
|
||||
data = result.fetchall()
|
||||
# 构造字曲系列
|
||||
|
||||
@@ -121,6 +121,7 @@ class files_api:
|
||||
def fileAccessApi(self):
|
||||
filename = request.form.get('filename', '')
|
||||
data = self.getAccess(filename)
|
||||
data['sys_users'] = self.getSysUserList()
|
||||
return mw.getJson(data)
|
||||
|
||||
def setFileAccessApi(self):
|
||||
@@ -933,6 +934,20 @@ class files_api:
|
||||
data['chown'] = 'www'
|
||||
return data
|
||||
|
||||
def getSysUserList(self):
|
||||
pwd_file = '/etc/passwd'
|
||||
if os.path.exists(pwd_file):
|
||||
content = mw.readFile(pwd_file)
|
||||
clist = content.split('\n')
|
||||
sys_users = []
|
||||
for line in clist:
|
||||
if line.find(":")<0:
|
||||
continue
|
||||
lines = line.split(":",1)
|
||||
sys_users.append(lines[0])
|
||||
return sys_users
|
||||
return ['root','mysql','www']
|
||||
|
||||
# 计算文件数量
|
||||
def getCount(self, path, search):
|
||||
i = 0
|
||||
|
||||
+79
-24
@@ -79,10 +79,11 @@ def getRootDir():
|
||||
def getPluginDir():
|
||||
return getRunDir() + '/plugins'
|
||||
|
||||
|
||||
def getPanelDataDir():
|
||||
return getRunDir() + '/data'
|
||||
|
||||
def getMWLogs():
|
||||
return getRunDir() + '/logs'
|
||||
|
||||
def getPanelTmp():
|
||||
return getRunDir() + '/tmp'
|
||||
@@ -346,6 +347,9 @@ def restartMw():
|
||||
import system_api
|
||||
system_api.system_api().restartMw()
|
||||
|
||||
def restartNginx(self):
|
||||
writeFile('data/restart_nginx.pl', 'True')
|
||||
return True
|
||||
|
||||
def checkWebConfig():
|
||||
op_dir = getServerDir() + '/openresty/nginx'
|
||||
@@ -908,6 +912,11 @@ def aesDecrypt_Crypto(data, key, vi):
|
||||
text_decrypted = text_decrypted.decode('utf8').rstrip() # 去掉补位的右侧空格
|
||||
return text_decrypted
|
||||
|
||||
def getDefault(data,val,def_val=''):
|
||||
if val in data:
|
||||
return data[val]
|
||||
return def_val
|
||||
|
||||
def encodeImage(imgsrc, newsrc):
|
||||
# 图片加密
|
||||
import struct
|
||||
@@ -1282,25 +1291,46 @@ def checkDomainPanel():
|
||||
domain = readFile('data/bind_domain.pl')
|
||||
port = readFile('data/port.pl').strip()
|
||||
|
||||
npid = getServerDir() + "/openresty/nginx/logs/nginx.pid"
|
||||
if not os.path.exists(npid):
|
||||
scheme = 'http'
|
||||
|
||||
choose_file = getRunDir()+'/ssl/choose.pl'
|
||||
if os.path.exists(choose_file):
|
||||
choose = readFile(choose_file).strip()
|
||||
if not inArray(['local','nginx'], choose):
|
||||
return False
|
||||
else:
|
||||
return False
|
||||
|
||||
nconf = getServerDir() + "/web_conf/nginx/vhost/panel.conf"
|
||||
if os.path.exists(nconf):
|
||||
port = "80"
|
||||
local_ssl = getRunDir()+'/ssl/local'
|
||||
if choose == 'local':
|
||||
scheme = 'https'
|
||||
|
||||
if domain:
|
||||
client_ip = getClientIp()
|
||||
if client_ip in ['127.0.0.1', 'localhost', '::1']:
|
||||
if choose == 'nginx':
|
||||
# print(port)
|
||||
npid = getServerDir() + "/openresty/nginx/logs/nginx.pid"
|
||||
if not os.path.exists(npid):
|
||||
return False
|
||||
if tmp.strip().lower() != domain.strip().lower():
|
||||
from flask import Flask, redirect, request, url_for
|
||||
to = "http://" + domain + ":" + str(port)
|
||||
return redirect(to, code=302)
|
||||
|
||||
nconf = getServerDir() + "/web_conf/nginx/vhost/panel.conf"
|
||||
if os.path.exists(nconf):
|
||||
port = "80"
|
||||
if not domain:
|
||||
return False
|
||||
|
||||
client_ip = getClientIp()
|
||||
if client_ip in ['127.0.0.1', 'localhost', '::1']:
|
||||
return False
|
||||
|
||||
if tmp.strip().lower() != domain.strip().lower():
|
||||
from flask import Flask, redirect, request, url_for
|
||||
to = scheme + "://" + domain + ":" + str(port)
|
||||
# print(to)
|
||||
return redirect(to, code=302)
|
||||
|
||||
return False
|
||||
|
||||
|
||||
|
||||
def createLinuxUser(user, group):
|
||||
execShell("groupadd {}".format(group))
|
||||
execShell('useradd -s /sbin/nologin -g {} {}'.format(user, group))
|
||||
@@ -1436,7 +1466,7 @@ def makeConf():
|
||||
file = getRunDir() + '/data/json/config.json'
|
||||
if not os.path.exists(file):
|
||||
c = {}
|
||||
c['title'] = '老子面板'
|
||||
c['title'] = '后羿面板'
|
||||
c['home'] = 'http://github/midoks/mdserver-web'
|
||||
c['recycle_bin'] = True
|
||||
c['template'] = 'default'
|
||||
@@ -1611,6 +1641,12 @@ def sortFileList(path, ftype = 'mtime', sort = 'desc'):
|
||||
flist = sorted(flist, key=lambda f: os.path.getsize(os.path.join(path,f)), reverse=True)
|
||||
if sort == 'asc':
|
||||
flist = sorted(flist, key=lambda f: os.path.getsize(os.path.join(path,f)), reverse=False)
|
||||
|
||||
if ftype == 'fname':
|
||||
if sort == 'desc':
|
||||
flist = sorted(flist, key=lambda f: os.path.join(path,f), reverse=True)
|
||||
if sort == 'asc':
|
||||
flist = sorted(flist, key=lambda f: os.path.join(path,f), reverse=False)
|
||||
return flist
|
||||
|
||||
|
||||
@@ -1799,28 +1835,38 @@ def getCertName(certPath):
|
||||
return None
|
||||
|
||||
|
||||
def createSSL():
|
||||
def createLocalSSL():
|
||||
if not os.path.exists('ssl/local'):
|
||||
execShell('mkdir -p ssl/local')
|
||||
|
||||
|
||||
# 自签证书
|
||||
if os.path.exists('ssl/input.pl'):
|
||||
return True
|
||||
# if os.path.exists('ssl/local/input.pl'):
|
||||
# return True
|
||||
|
||||
client_ip = getClientIp()
|
||||
|
||||
import OpenSSL
|
||||
key = OpenSSL.crypto.PKey()
|
||||
key.generate_key(OpenSSL.crypto.TYPE_RSA, 2048)
|
||||
cert = OpenSSL.crypto.X509()
|
||||
cert.set_serial_number(0)
|
||||
cert.get_subject().CN = getLocalIp()
|
||||
|
||||
if client_ip == '127.0.0.1':
|
||||
cert.get_subject().CN = '127.0.0.1'
|
||||
else:
|
||||
cert.get_subject().CN = getLocalIp()
|
||||
|
||||
cert.set_issuer(cert.get_subject())
|
||||
cert.gmtime_adj_notBefore(0)
|
||||
cert.gmtime_adj_notAfter(86400 * 3650)
|
||||
cert.set_pubkey(key)
|
||||
cert.sign(key, 'md5')
|
||||
cert_ca = OpenSSL.crypto.dump_certificate(
|
||||
OpenSSL.crypto.FILETYPE_PEM, cert)
|
||||
private_key = OpenSSL.crypto.dump_privatekey(
|
||||
OpenSSL.crypto.FILETYPE_PEM, key)
|
||||
cert_ca = OpenSSL.crypto.dump_certificate(OpenSSL.crypto.FILETYPE_PEM, cert)
|
||||
private_key = OpenSSL.crypto.dump_privatekey(OpenSSL.crypto.FILETYPE_PEM, key)
|
||||
if len(cert_ca) > 100 and len(private_key) > 100:
|
||||
writeFile('ssl/cert.pem', cert_ca, 'wb+')
|
||||
writeFile('ssl/private.pem', private_key, 'wb+')
|
||||
writeFile('ssl/local/cert.pem', cert_ca, 'wb+')
|
||||
writeFile('ssl/local/private.pem', private_key, 'wb+')
|
||||
return True
|
||||
return False
|
||||
|
||||
@@ -2064,6 +2110,15 @@ def notifyMessage(msg, stype='common', trigger_time=300, is_write_log=True):
|
||||
##################### notify end #########################################
|
||||
|
||||
|
||||
def getGlibcVersion():
|
||||
try:
|
||||
cmd_result = execShell("ldd --version")[0]
|
||||
if not cmd_result: return ''
|
||||
glibc_version = cmd_result.split("\n")[0].split()[-1]
|
||||
except:
|
||||
return ''
|
||||
return glibc_version
|
||||
|
||||
##################### ssh start #########################################
|
||||
def getSshDir():
|
||||
if isAppleSystem():
|
||||
|
||||
@@ -148,7 +148,7 @@ class plugins_api:
|
||||
def initApi(self):
|
||||
|
||||
plugin_names = {
|
||||
'openresty': '1.21.4.3',
|
||||
'openresty': '1.25.3.1',
|
||||
'php': '56',
|
||||
'swap': '1.1',
|
||||
'mysql': '5.7',
|
||||
|
||||
+31
-12
@@ -763,6 +763,8 @@ class site_api:
|
||||
conf = re.sub(rep, '', conf)
|
||||
rep = "\s+listen\s+\[\:\:\]\:443.*;"
|
||||
conf = re.sub(rep, '', conf)
|
||||
rep = "\s+http2\s+on;"
|
||||
conf = re.sub(rep, '', conf)
|
||||
mw.writeFile(file, conf)
|
||||
|
||||
msg = mw.getInfo('网站[{1}]关闭SSL成功!', (siteName,))
|
||||
@@ -1958,6 +1960,19 @@ class site_api:
|
||||
proxy_site_path) if os.path.exists(proxy_site_path) else ""
|
||||
data = json.loads(data_content) if data_content != "" else []
|
||||
|
||||
proxy_action = 'add'
|
||||
if _id == "":
|
||||
_id = mw.md5("{}".format(_name))
|
||||
else:
|
||||
proxy_action = 'edit'
|
||||
|
||||
if proxy_action == "add":
|
||||
for item in data:
|
||||
if item["name"] == _name:
|
||||
return mw.returnJson(False, "名称重复!!")
|
||||
if item["from"] == _from:
|
||||
return mw.returnJson(False, "代理目录已存在!!")
|
||||
|
||||
tpl = "#PROXY-START\n\
|
||||
location ^~ {from} {\n\
|
||||
proxy_pass {to};\n\
|
||||
@@ -2014,15 +2029,9 @@ location ^~ {from} {\n\
|
||||
else:
|
||||
tpl = tpl.replace("{proxy_cache}", tpl_proxy_nocache, 999)
|
||||
|
||||
proxy_action = 'add'
|
||||
if _id == "":
|
||||
_id = mw.md5("{}".format(_name))
|
||||
else:
|
||||
proxy_action = 'edit'
|
||||
|
||||
conf_proxy = "{}/{}.conf".format(self.getProxyPath(_siteName), _id)
|
||||
conf_bk = "{}/{}.conf.txt".format(self.getProxyPath(_siteName), _id)
|
||||
|
||||
mw.writeFile(conf_proxy, tpl)
|
||||
|
||||
rule_test = mw.checkWebConfig()
|
||||
@@ -2653,6 +2662,10 @@ location ^~ {from} {\n\
|
||||
mw.writeFile(rewrite_file, '')
|
||||
|
||||
def add(self, webname, port, ps, path, version):
|
||||
site_root_dir = mw.getWwwDir()
|
||||
if site_root_dir == path.rstrip('/'):
|
||||
return mw.returnJson(False, '不要以网站根目录创建站点!')
|
||||
|
||||
siteMenu = json.loads(webname)
|
||||
self.siteName = self.toPunycode(
|
||||
siteMenu['domain'].strip().split(':')[0]).strip()
|
||||
@@ -2783,11 +2796,11 @@ location ^~ {from} {\n\
|
||||
certPath = self.sslDir + '/' + siteName + '/fullchain.pem'
|
||||
if conf:
|
||||
if conf.find('ssl_certificate') == -1:
|
||||
#ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
|
||||
|
||||
# ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
|
||||
# add_header Alt-Svc 'h3=":443";ma=86400,h3-29=":443";ma=86400';
|
||||
http3Header = """
|
||||
add_header Strict-Transport-Security "max-age=63072000";
|
||||
add_header Alt-Svc 'h3=":443";ma=86400,h3-29=":443";ma=86400';
|
||||
add_header Alt-Svc 'h3=":443";ma=86400';
|
||||
"""
|
||||
if version != '1.25.3.1':
|
||||
http3Header = '';
|
||||
@@ -2811,11 +2824,17 @@ location ^~ {from} {\n\
|
||||
tmp = re.findall(rep, conf)
|
||||
if not mw.inArray(tmp, '443'):
|
||||
listen = re.search(rep, conf).group()
|
||||
http_ssl = "\n\tlisten 443 ssl http2;"
|
||||
http_ssl = http_ssl + "\n\tlisten [::]:443 ssl http2;"
|
||||
|
||||
|
||||
if version == '1.25.3.1':
|
||||
http_ssl = "\n\tlisten 443 ssl;"
|
||||
http_ssl = http_ssl + "\n\tlisten [::]:443 ssl;"
|
||||
http_ssl = http_ssl + "\n\tlisten 443 quic;"
|
||||
http_ssl = http_ssl + "\n\tlisten [::]:443 quic;"
|
||||
http_ssl = http_ssl + "\n\thttp2 on;"
|
||||
else:
|
||||
http_ssl = "\n\tlisten 443 ssl http2;"
|
||||
http_ssl = http_ssl + "\n\tlisten [::]:443 ssl http2;"
|
||||
|
||||
|
||||
conf = conf.replace(listen, listen + http_ssl)
|
||||
|
||||
|
||||
@@ -0,0 +1,120 @@
|
||||
# coding: utf-8
|
||||
|
||||
# ---------------------------------------------------------------------------------
|
||||
# MW-Linux面板
|
||||
# ---------------------------------------------------------------------------------
|
||||
# copyright (c) 2018-∞(https://github.com/midoks/mdserver-web) All rights reserved.
|
||||
# ---------------------------------------------------------------------------------
|
||||
# Author: midoks <midoks@163.com>
|
||||
# ---------------------------------------------------------------------------------
|
||||
|
||||
# ---------------------------------------------------------------------------------
|
||||
# SSH终端操作
|
||||
# ---------------------------------------------------------------------------------
|
||||
|
||||
import json
|
||||
import time
|
||||
import os
|
||||
import sys
|
||||
import socket
|
||||
import threading
|
||||
import re
|
||||
|
||||
from io import BytesIO, StringIO
|
||||
|
||||
import mw
|
||||
import paramiko
|
||||
|
||||
from flask_socketio import SocketIO, emit, send
|
||||
|
||||
|
||||
class ssh_local(object):
|
||||
|
||||
__debug_file = 'logs/ssh_local.log'
|
||||
__log_type = 'SSH终端'
|
||||
|
||||
__ssh = None
|
||||
|
||||
# lock
|
||||
_instance_lock = threading.Lock()
|
||||
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
@classmethod
|
||||
def instance(cls, *args, **kwargs):
|
||||
if not hasattr(ssh_local, "_instance"):
|
||||
with ssh_local._instance_lock:
|
||||
if not hasattr(ssh_local, "_instance"):
|
||||
ssh_local._instance = ssh_local(*args, **kwargs)
|
||||
return ssh_local._instance
|
||||
|
||||
def debug(self, msg):
|
||||
msg = "{} - {}:{} => {} \n".format(mw.formatDate(),
|
||||
self.__host, self.__port, msg)
|
||||
if not mw.isDebugMode():
|
||||
return
|
||||
mw.writeFile(self.__debug_file, msg, 'a+')
|
||||
|
||||
def returnMsg(self, status, msg):
|
||||
return {'status': status, 'msg': msg}
|
||||
|
||||
|
||||
def connectSsh(self):
|
||||
import paramiko
|
||||
ssh = paramiko.SSHClient()
|
||||
mw.createSshInfo()
|
||||
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||
|
||||
port = mw.getSSHPort()
|
||||
try:
|
||||
ssh.connect('127.0.0.1', port, timeout=5)
|
||||
except Exception as e:
|
||||
ssh.connect('localhost', port, timeout=5)
|
||||
except Exception as e:
|
||||
ssh.connect(mw.getHostAddr(), port, timeout=30)
|
||||
except Exception as e:
|
||||
return False
|
||||
|
||||
shell = ssh.invoke_shell(term='xterm', width=83, height=21)
|
||||
shell.setblocking(0)
|
||||
return shell
|
||||
|
||||
def send(self):
|
||||
pass
|
||||
|
||||
def close(self):
|
||||
try:
|
||||
if self.__ssh:
|
||||
self.__ssh.close()
|
||||
except:
|
||||
pass
|
||||
|
||||
def wsSend(self, recv):
|
||||
try:
|
||||
t = recv.decode("utf-8")
|
||||
return emit('server_response', {'data': t})
|
||||
except Exception as e:
|
||||
return emit('server_response', {'data': recv})
|
||||
|
||||
def wsSendConnect(self):
|
||||
return emit('connect', {'data': 'ok'})
|
||||
|
||||
def wsSendReConnect(self):
|
||||
return emit('reconnect', {'data': 'ok'})
|
||||
|
||||
|
||||
def run(self, info):
|
||||
if not self.__ssh:
|
||||
self.__ssh = self.connectSsh()
|
||||
|
||||
if self.__ssh.exit_status_ready():
|
||||
self.__ssh = self.connectSsh()
|
||||
|
||||
self.__ssh.send(info)
|
||||
try:
|
||||
time.sleep(0.005)
|
||||
recv = self.__ssh.recv(8192)
|
||||
return self.wsSend(recv)
|
||||
except Exception as ex:
|
||||
return self.wsSend('')
|
||||
@@ -28,9 +28,9 @@ import paramiko
|
||||
from flask_socketio import SocketIO, emit, send
|
||||
|
||||
|
||||
class ssh_terminal:
|
||||
class ssh_terminal(object):
|
||||
|
||||
__debug_file = 'logs/terminal.log'
|
||||
__debug_file = 'logs/ssh_terminal.log'
|
||||
__log_type = 'SSH终端'
|
||||
|
||||
# websocketio 唯一标识
|
||||
@@ -55,10 +55,21 @@ class ssh_terminal:
|
||||
__ssh_list = {}
|
||||
__ssh_last_request_time = {}
|
||||
|
||||
# lock
|
||||
_instance_lock = threading.Lock()
|
||||
|
||||
def __init__(self):
|
||||
ht = threading.Thread(target=self.heartbeat)
|
||||
ht.start()
|
||||
|
||||
@classmethod
|
||||
def instance(cls, *args, **kwargs):
|
||||
if not hasattr(ssh_terminal, "_instance"):
|
||||
with ssh_terminal._instance_lock:
|
||||
if not hasattr(ssh_terminal, "_instance"):
|
||||
ssh_terminal._instance = ssh_terminal(*args, **kwargs)
|
||||
return ssh_terminal._instance
|
||||
|
||||
def debug(self, msg):
|
||||
msg = "{} - {}:{} => {} \n".format(mw.formatDate(),
|
||||
self.__host, self.__port, msg)
|
||||
|
||||
+168
-25
@@ -44,10 +44,11 @@ def mw_async(f):
|
||||
class system_api:
|
||||
setupPath = None
|
||||
pids = None
|
||||
|
||||
cache = {}
|
||||
def __init__(self):
|
||||
self.setupPath = mw.getServerDir()
|
||||
|
||||
|
||||
##### ----- start ----- ###
|
||||
def networkApi(self):
|
||||
data = self.getNetWork()
|
||||
@@ -254,8 +255,7 @@ class system_api:
|
||||
data['load_average'] = self.GetLoadAverage(get)
|
||||
data['title'] = self.GetTitle()
|
||||
data['network'] = self.GetNetWorkApi(get)
|
||||
data['panel_status'] = not os.path.exists(
|
||||
'/www/server/mdserver-web/data/close.pl')
|
||||
data['panel_status'] = not os.path.exists('/www/server/mdserver-web/data/close.pl')
|
||||
import firewalls
|
||||
ssh_info = firewalls.firewalls().GetSshInfo(None)
|
||||
data['enable_ssh_status'] = ssh_info['status']
|
||||
@@ -488,7 +488,7 @@ class system_api:
|
||||
shutil.rmtree(filename)
|
||||
else:
|
||||
os.remove(filename)
|
||||
print('mail clear ok')
|
||||
# print('mail clear ok')
|
||||
num += 1
|
||||
total += size
|
||||
count += num
|
||||
@@ -547,38 +547,181 @@ class system_api:
|
||||
def getNetWork(self):
|
||||
# 取网络流量信息
|
||||
try:
|
||||
# 取网络流量信息
|
||||
networkIo = self.psutilNetIoCounters()
|
||||
if not "otime" in session:
|
||||
session['up'] = networkIo[0]
|
||||
session['down'] = networkIo[1]
|
||||
session['otime'] = time.time()
|
||||
|
||||
ntime = time.time()
|
||||
networkInfo = {}
|
||||
networkInfo['upTotal'] = networkIo[0]
|
||||
networkInfo['downTotal'] = networkIo[1]
|
||||
networkInfo['up'] = round(float(
|
||||
networkIo[0] - session['up']) / (ntime - session['otime']), 2)
|
||||
networkInfo['down'] = round(
|
||||
float(networkIo[1] - session['down']) / (ntime - session['otime']), 2)
|
||||
networkInfo['downPackets'] = networkIo[3]
|
||||
networkInfo['upPackets'] = networkIo[2]
|
||||
# 取网络流量信息
|
||||
# networkIo = self.psutilNetIoCounters()
|
||||
# if not "otime" in session:
|
||||
# session['up'] = networkIo[0]
|
||||
# session['down'] = networkIo[1]
|
||||
# session['otime'] = time.time()
|
||||
|
||||
# print networkIo[1], session['down'], ntime, session['otime']
|
||||
session['up'] = networkIo[0]
|
||||
session['down'] = networkIo[1]
|
||||
session['otime'] = time.time()
|
||||
# ntime = time.time()
|
||||
# print("source",ntime - session['otime'])
|
||||
|
||||
# networkInfo['upTotal'] = networkIo[0]
|
||||
# networkInfo['downTotal'] = networkIo[1]
|
||||
# networkInfo['up'] = round(float(
|
||||
# networkIo[0] - session['up']) / (ntime - session['otime']), 2)
|
||||
# networkInfo['down'] = round(
|
||||
# float(networkIo[1] - session['down']) / (ntime - session['otime']), 2)
|
||||
# networkInfo['downPackets'] = networkIo[3]
|
||||
# networkInfo['upPackets'] = networkIo[2]
|
||||
|
||||
# # print networkIo[1], session['down'], ntime, session['otime']
|
||||
# session['up'] = networkIo[0]
|
||||
# session['down'] = networkIo[1]
|
||||
# session['otime'] = time.time()
|
||||
|
||||
networkInfo['cpu'] = self.getCpuInfo()
|
||||
networkInfo['load'] = self.getLoadAverage()
|
||||
networkInfo['mem'] = self.getMemInfo()
|
||||
networkInfo['iostat'] = self.getDiskIostat()
|
||||
networkInfo['network'] = self.getNetWorkIostat()
|
||||
|
||||
return networkInfo
|
||||
except Exception as e:
|
||||
print("getNetWork error:", e)
|
||||
print(mw.getTracebackInfo())
|
||||
return None
|
||||
|
||||
def getNetWorkIostat(self):
|
||||
netInfo = {}
|
||||
|
||||
netInfo['ALL'] = {}
|
||||
netInfo['ALL']['up'] = 0
|
||||
netInfo['ALL']['down'] = 0
|
||||
netInfo['ALL']['upTotal'] = 0
|
||||
netInfo['ALL']['downTotal'] = 0
|
||||
netInfo['ALL']['upPackets'] = 0
|
||||
netInfo['ALL']['downPackets'] = 0
|
||||
|
||||
mtime = time.time()
|
||||
iokey = 'netstat'
|
||||
netio = None
|
||||
if iokey in self.cache:
|
||||
netio = self.cache[iokey]
|
||||
|
||||
if not netio:
|
||||
netio = {}
|
||||
netio['info'] = None
|
||||
netio['all_io'] = None
|
||||
netio['time'] = mtime
|
||||
|
||||
stime = mtime - netio['time']
|
||||
if not stime: stime = 1
|
||||
|
||||
# print("new:",stime)
|
||||
netio_group = psutil.net_io_counters(pernic=True).keys()
|
||||
|
||||
netio_cache = netio['info']
|
||||
allio_cache = netio['all_io']
|
||||
if not netio_cache:
|
||||
netio_cache = {}
|
||||
|
||||
netio_group_t = {}
|
||||
for name in netio_group:
|
||||
netInfo[name] = {}
|
||||
|
||||
io_data = psutil.net_io_counters(pernic=True).get(name)
|
||||
if not name in netio_cache:
|
||||
netio_cache[name] = io_data
|
||||
|
||||
netio_group_t[name] = io_data
|
||||
|
||||
netInfo[name]['up'] = round(float((io_data[0] - netio_cache[name][0]) / stime), 2)
|
||||
netInfo[name]['down'] = round(float((io_data[1] - netio_cache[name][1])/ stime), 2)
|
||||
|
||||
netInfo[name]['upTotal'] = io_data[0]
|
||||
netInfo[name]['downTotal'] = io_data[1]
|
||||
netInfo[name]['upPackets'] = io_data[2]
|
||||
netInfo[name]['downPackets'] = io_data[3]
|
||||
|
||||
all_io = psutil.net_io_counters()[:4]
|
||||
if not allio_cache:
|
||||
allio_cache = all_io
|
||||
|
||||
netInfo['ALL']['up'] = round(float((all_io[0] - allio_cache[0]) /stime), 2)
|
||||
netInfo['ALL']['down'] = round(float((all_io[1] - allio_cache[1]) /stime), 2)
|
||||
netInfo['ALL']['upTotal'] = all_io[0]
|
||||
netInfo['ALL']['downTotal'] = all_io[1]
|
||||
netInfo['ALL']['upPackets'] = all_io[2]
|
||||
netInfo['ALL']['downPackets'] = all_io[3]
|
||||
|
||||
self.cache[iokey] = {'info':netio_group_t,'all_io':all_io,'time':mtime}
|
||||
return netInfo
|
||||
|
||||
|
||||
def getDiskIostat(self):
|
||||
iokey = 'iostat'
|
||||
|
||||
diskInfo = {}
|
||||
diskInfo['ALL'] = {}
|
||||
diskInfo['ALL']['read_count'] = 0
|
||||
diskInfo['ALL']['write_count'] = 0
|
||||
diskInfo['ALL']['read_bytes'] = 0
|
||||
diskInfo['ALL']['write_bytes'] = 0
|
||||
diskInfo['ALL']['read_time'] = 0
|
||||
diskInfo['ALL']['write_time'] = 0
|
||||
diskInfo['ALL']['read_merged_count'] = 0
|
||||
diskInfo['ALL']['write_merged_count'] = 0
|
||||
|
||||
try:
|
||||
diskio = None
|
||||
if iokey in self.cache:
|
||||
diskio = self.cache[iokey]
|
||||
|
||||
mtime = int(time.time())
|
||||
if not diskio:
|
||||
diskio = {}
|
||||
diskio['info'] = None
|
||||
diskio['time'] = mtime
|
||||
|
||||
diskio_cache = diskio['info']
|
||||
stime = mtime - diskio['time']
|
||||
if not stime: stime = 1
|
||||
|
||||
diskio_group = psutil.disk_io_counters(perdisk=True)
|
||||
if not diskio_cache:
|
||||
diskio_cache = diskio_group
|
||||
|
||||
for disk_name in diskio_group.keys():
|
||||
diskInfo[disk_name] = {}
|
||||
# print('disk_name',disk_name)
|
||||
# print(diskio_group[disk_name].write_time , diskio_cache[disk_name].write_time)
|
||||
# print(diskio_group[disk_name].write_count , diskio_cache[disk_name].write_count)
|
||||
|
||||
diskInfo[disk_name]['read_count'] = int((diskio_group[disk_name].read_count - diskio_cache[disk_name].read_count) / stime)
|
||||
diskInfo[disk_name]['write_count'] = int((diskio_group[disk_name].write_count - diskio_cache[disk_name].write_count) / stime)
|
||||
diskInfo[disk_name]['read_bytes'] = int((diskio_group[disk_name].read_bytes - diskio_cache[disk_name].read_bytes) / stime)
|
||||
diskInfo[disk_name]['write_bytes'] = int((diskio_group[disk_name].write_bytes - diskio_cache[disk_name].write_bytes) / stime)
|
||||
diskInfo[disk_name]['read_time'] = int((diskio_group[disk_name].read_time - diskio_cache[disk_name].read_time) / stime)
|
||||
diskInfo[disk_name]['write_time'] = int((diskio_group[disk_name].write_time - diskio_cache[disk_name].write_time) / stime)
|
||||
|
||||
if 'read_merged_count' in diskio_group[disk_name] and 'read_merged_count' in diskio_cache[disk_name]:
|
||||
diskInfo[disk_name]['read_merged_count'] = int((diskio_group[disk_name].read_merged_count - diskio_cache[disk_name].read_merged_count) / stime)
|
||||
if 'write_merged_count' in diskio_group[disk_name] and 'write_merged_count' in diskio_cache[disk_name]:
|
||||
diskInfo[disk_name]['write_merged_count'] = int((diskio_group[disk_name].write_merged_count - diskio_cache[disk_name].write_merged_count) / stime)
|
||||
|
||||
diskInfo['ALL']['read_count'] += diskInfo[disk_name]['read_count']
|
||||
diskInfo['ALL']['write_count'] += diskInfo[disk_name]['write_count']
|
||||
diskInfo['ALL']['read_bytes'] += diskInfo[disk_name]['read_bytes']
|
||||
diskInfo['ALL']['write_bytes'] += diskInfo[disk_name]['write_bytes']
|
||||
if diskInfo['ALL']['read_time'] < diskInfo[disk_name]['read_time']:
|
||||
diskInfo['ALL']['read_time'] = diskInfo[disk_name]['read_time']
|
||||
if diskInfo['ALL']['write_time'] < diskInfo[disk_name]['write_time']:
|
||||
diskInfo['ALL']['write_time'] = diskInfo[disk_name]['write_time']
|
||||
|
||||
if 'read_merged_count' in diskInfo[disk_name] and 'read_merged_count' in diskInfo[disk_name]:
|
||||
diskInfo['ALL']['read_merged_count'] += diskInfo[disk_name]['read_merged_count']
|
||||
if 'write_merged_count' in diskInfo[disk_name] and 'write_merged_count' in diskInfo[disk_name]:
|
||||
diskInfo['ALL']['write_merged_count'] += diskInfo[disk_name]['write_merged_count']
|
||||
|
||||
self.cache[iokey] = {'info':diskio_group,'time':mtime}
|
||||
except Exception as e:
|
||||
# print(mw.getTracebackInfo())
|
||||
pass
|
||||
|
||||
return diskInfo
|
||||
|
||||
def getNetWorkIoData(self, start, end):
|
||||
# 取指定时间段的网络Io
|
||||
data = mw.M('network').dbfile('system').where("addtime>=? AND addtime<=?", (start, end)).field(
|
||||
|
||||
+29
-5
@@ -17,37 +17,50 @@ class ORM:
|
||||
__DB_CUR = None
|
||||
__DB_ERR = None
|
||||
__DB_CNF = '/etc/my.cnf'
|
||||
__DB_TIMEOUT=1
|
||||
__DB_SOCKET = '/www/server/mysql/mysql.sock'
|
||||
|
||||
__DB_CHARSET = "utf8"
|
||||
|
||||
def __Conn(self):
|
||||
# print(self.__DB_HOST, self.__DB_USER)
|
||||
'''连接数据库'''
|
||||
try:
|
||||
|
||||
if os.path.exists(self.__DB_SOCKET):
|
||||
if self.__DB_HOST != 'localhost':
|
||||
try:
|
||||
self.__DB_CONN = pymysql.connect(host=self.__DB_HOST, user=self.__DB_USER, passwd=self.__DB_PASS,
|
||||
database=self.__DB_NAME,
|
||||
port=int(self.__DB_PORT), charset=self.__DB_CHARSET, connect_timeout=self.__DB_TIMEOUT,
|
||||
cursorclass=pymysql.cursors.DictCursor)
|
||||
except Exception as e:
|
||||
self.__DB_CONN = pymysql.connect(host=self.__DB_HOST, user=self.__DB_USER, passwd=self.__DB_PASS,
|
||||
database=self.__DB_NAME,
|
||||
port=int(self.__DB_PORT), charset=self.__DB_CHARSET, connect_timeout=self.__DB_TIMEOUT,
|
||||
cursorclass=pymysql.cursors.DictCursor)
|
||||
elif os.path.exists(self.__DB_SOCKET):
|
||||
try:
|
||||
self.__DB_CONN = pymysql.connect(host=self.__DB_HOST, user=self.__DB_USER, passwd=self.__DB_PASS,
|
||||
database=self.__DB_NAME,
|
||||
port=int(self.__DB_PORT), charset=self.__DB_CHARSET, connect_timeout=1,
|
||||
port=int(self.__DB_PORT), charset=self.__DB_CHARSET, connect_timeout=self.__DB_TIMEOUT,
|
||||
unix_socket=self.__DB_SOCKET, cursorclass=pymysql.cursors.DictCursor)
|
||||
except Exception as e:
|
||||
self.__DB_HOST = '127.0.0.1'
|
||||
self.__DB_CONN = pymysql.connect(host=self.__DB_HOST, user=self.__DB_USER, passwd=self.__DB_PASS,
|
||||
database=self.__DB_NAME,
|
||||
port=int(self.__DB_PORT), charset=self.__DB_CHARSET, connect_timeout=1,
|
||||
port=int(self.__DB_PORT), charset=self.__DB_CHARSET, connect_timeout=self.__DB_TIMEOUT,
|
||||
unix_socket=self.__DB_SOCKET, cursorclass=pymysql.cursors.DictCursor)
|
||||
else:
|
||||
try:
|
||||
self.__DB_CONN = pymysql.connect(host=self.__DB_HOST, user=self.__DB_USER, passwd=self.__DB_PASS,
|
||||
database=self.__DB_NAME,
|
||||
port=int(self.__DB_PORT), charset=self.__DB_CHARSET, connect_timeout=1,
|
||||
port=int(self.__DB_PORT), charset=self.__DB_CHARSET, connect_timeout=self.__DB_TIMEOUT,
|
||||
cursorclass=pymysql.cursors.DictCursor)
|
||||
except Exception as e:
|
||||
self.__DB_HOST = '127.0.0.1'
|
||||
self.__DB_CONN = pymysql.connect(host=self.__DB_HOST, user=self.__DB_USER, passwd=self.__DB_PASS,
|
||||
database=self.__DB_NAME,
|
||||
port=int(self.__DB_PORT), charset=self.__DB_CHARSET, connect_timeout=1,
|
||||
port=int(self.__DB_PORT), charset=self.__DB_CHARSET, connect_timeout=self.__DB_TIMEOUT,
|
||||
cursorclass=pymysql.cursors.DictCursor)
|
||||
|
||||
self.__DB_CUR = self.__DB_CONN.cursor()
|
||||
@@ -80,6 +93,10 @@ class ORM:
|
||||
def getPwd(self):
|
||||
return self.__DB_PASS
|
||||
|
||||
def setTimeout(self, timeout = 1):
|
||||
self.__DB_TIMEOUT = timeout
|
||||
return True
|
||||
|
||||
def setDbName(self, name):
|
||||
self.__DB_NAME = name
|
||||
|
||||
@@ -95,6 +112,13 @@ class ORM:
|
||||
except Exception as ex:
|
||||
return ex
|
||||
|
||||
def ping(self):
|
||||
try:
|
||||
self.__DB_CONN.ping()
|
||||
except Exception as e:
|
||||
print(e)
|
||||
return True
|
||||
|
||||
def query(self, sql):
|
||||
# 执行SQL语句返回数据集
|
||||
if not self.__Conn():
|
||||
|
||||
@@ -64,6 +64,11 @@ mw_start_debug2(){
|
||||
gunicorn -b :7200 -k geventwebsocket.gunicorn.workers.GeventWebSocketWorker -w 1 app:app
|
||||
}
|
||||
|
||||
mw_start_debug3(){
|
||||
gunicorn -c setting.py app:app
|
||||
python3 task.py
|
||||
}
|
||||
|
||||
|
||||
mw_stop()
|
||||
{
|
||||
@@ -96,4 +101,8 @@ case "$1" in
|
||||
mw_stop
|
||||
mw_start_debug2
|
||||
;;
|
||||
'debug3')
|
||||
mw_stop
|
||||
mw_start_debug3
|
||||
;;
|
||||
esac
|
||||
@@ -5,7 +5,8 @@
|
||||
|
||||
```
|
||||
/etc/init.d/mw default | 显示登录信息
|
||||
/etc/init.d/mw db | 快捷连接数据库
|
||||
/etc/init.d/mw db | 快捷连接MySQL
|
||||
/etc/init.d/mw redis | 快捷连接Redis
|
||||
----------------------------------------
|
||||
mw open | 开启面板
|
||||
mw close | 关闭面板
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
server
|
||||
{
|
||||
# reuseport 只能在一个server出现一次
|
||||
listen {$PORT};
|
||||
listen [::]:{$PORT};
|
||||
server_name {$SERVER_NAME};
|
||||
|
||||
@@ -17,7 +17,7 @@ pluginService('clean');
|
||||
|
||||
function pRead(){
|
||||
var readme = '<ul class="help-info-text c7">';
|
||||
readme += '<li>启动后,加入到计划中[2:30]执行。</li>';
|
||||
readme += '<li>启动后,加入到计划任务每隔7天[0:15]执行。</li>';
|
||||
readme += '<li>【*】代表要删除。</li>';
|
||||
readme += '<li>添加/删除清除日志,可在`配置修改`中添加/删除。</li>';
|
||||
readme += '<li>如果是目录,会寻找【.log】后缀的文件清空。</li>';
|
||||
|
||||
+21
-1
@@ -99,7 +99,27 @@ def initConf():
|
||||
"/var/log/secure",
|
||||
"/var/log/lastlog",
|
||||
"/var/log/cron",
|
||||
"/www/server/cron"
|
||||
"/www/server/rsyncd",
|
||||
"/www/server/sphinx/index",
|
||||
"/www/server/mongodb/logs",
|
||||
"/www/server/php/53/var/log",
|
||||
"/www/server/php/54/var/log",
|
||||
"/www/server/php/55/var/log",
|
||||
"/www/server/php/56/var/log",
|
||||
"/www/server/php/70/var/log",
|
||||
"/www/server/php/71/var/log",
|
||||
"/www/server/php/72/var/log",
|
||||
"/www/server/php/73/var/log",
|
||||
"/www/server/php/74/var/log",
|
||||
"/www/server/php/80/var/log",
|
||||
"/www/server/php/81/var/log",
|
||||
"/www/server/php/82/var/log",
|
||||
"/www/server/php/83/var/log",
|
||||
"/www/server/php/84/var/log",
|
||||
"/www/server/openresty/nginx/logs",
|
||||
"/www/server/phpmyadmin",
|
||||
"/www/server/redis/data",
|
||||
"/www/server/cron",
|
||||
]
|
||||
for i in clogcom:
|
||||
if os.path.exists(i):
|
||||
|
||||
+30
-57
@@ -37,57 +37,36 @@ def getConfigData():
|
||||
return json.loads(mw.readFile(getTaskConf()))
|
||||
except:
|
||||
pass
|
||||
return []
|
||||
|
||||
|
||||
def getConfigTpl():
|
||||
tpl = {
|
||||
"name": "",
|
||||
return {
|
||||
"task_id": -1,
|
||||
"period": "day-n",
|
||||
"where1": "7",
|
||||
"hour": "0",
|
||||
"minute": "15",
|
||||
}
|
||||
return tpl
|
||||
|
||||
|
||||
def createBgTask():
|
||||
removeBgTask()
|
||||
args = {
|
||||
"period": "day",
|
||||
"hour": "0",
|
||||
"minute": "15",
|
||||
}
|
||||
createBgTaskByName(getPluginName(), args)
|
||||
createBgTaskByName(getPluginName())
|
||||
|
||||
|
||||
def createBgTaskByName(name, args):
|
||||
cfg = getConfigTpl()
|
||||
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 cfg.keys() and cfg["task_id"] > 0:
|
||||
if "task_id" in args and args["task_id"] > 0:
|
||||
res = mw.M("crontab").field("id, name").where(
|
||||
"id=?", (cfg["task_id"],)).find()
|
||||
if res and res["id"] == cfg["task_id"]:
|
||||
"id=?", (args["task_id"],)).find()
|
||||
if res and res["id"] == args["task_id"]:
|
||||
print("计划任务已经存在!")
|
||||
return True
|
||||
import crontab_api
|
||||
api = crontab_api.crontab_api()
|
||||
|
||||
period = args['period']
|
||||
_hour = ''
|
||||
_minute = ''
|
||||
_where1 = ''
|
||||
_type_day = "day"
|
||||
if period == 'day':
|
||||
_type_day = 'day'
|
||||
_hour = args['hour']
|
||||
_minute = args['minute']
|
||||
elif period == 'minute-n':
|
||||
_type_day = 'minute-n'
|
||||
_where1 = args['minute-n']
|
||||
_minute = ''
|
||||
|
||||
mw_dir = mw.getRunDir()
|
||||
cmd = '''
|
||||
mw_dir=%s
|
||||
@@ -105,11 +84,11 @@ logs_file=$plugin_path/${rname}.log
|
||||
|
||||
params = {
|
||||
'name': _name,
|
||||
'type': _type_day,
|
||||
'type': args['period'],
|
||||
'week': "",
|
||||
'where1': _where1,
|
||||
'hour': _hour,
|
||||
'minute': _minute,
|
||||
'where1': args['where1'],
|
||||
'hour': args['hour'],
|
||||
'minute': args['minute'],
|
||||
'save': "",
|
||||
'backup_to': "",
|
||||
'stype': "toShell",
|
||||
@@ -120,30 +99,24 @@ logs_file=$plugin_path/${rname}.log
|
||||
|
||||
task_id = api.add(params)
|
||||
if task_id > 0:
|
||||
cfg["task_id"] = task_id
|
||||
cfg["name"] = name
|
||||
|
||||
_dd = getConfigData()
|
||||
_dd.append(cfg)
|
||||
mw.writeFile(getTaskConf(), json.dumps(_dd))
|
||||
args["task_id"] = task_id
|
||||
args["name"] = name
|
||||
mw.writeFile(getTaskConf(), json.dumps(args))
|
||||
|
||||
|
||||
def removeBgTask():
|
||||
cfg_list = getConfigData()
|
||||
for x in range(len(cfg_list)):
|
||||
cfg = cfg_list[x]
|
||||
if "task_id" in cfg.keys() 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"]:
|
||||
import crontab_api
|
||||
api = crontab_api.crontab_api()
|
||||
data = api.delete(cfg["task_id"])
|
||||
if data[0]:
|
||||
cfg["task_id"] = -1
|
||||
cfg_list[x] = cfg
|
||||
mw.writeFile(getTaskConf(), '[]')
|
||||
return True
|
||||
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"]:
|
||||
import crontab_api
|
||||
api = crontab_api.crontab_api()
|
||||
data = api.delete(cfg["task_id"])
|
||||
if data[0]:
|
||||
cfg["task_id"] = -1
|
||||
mw.writeFile(getTaskConf(), json.loads(cfg))
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
|
||||
@@ -5,6 +5,16 @@
|
||||
white-space: nowrap;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
#select_db xm-select{
|
||||
min-height: 30px;
|
||||
line-height: 30px;
|
||||
}
|
||||
|
||||
#select_db xm-select *{
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
<div class="bt-form">
|
||||
|
||||
@@ -7,6 +7,7 @@ import time
|
||||
import re
|
||||
import pymongo
|
||||
import json
|
||||
import yaml
|
||||
|
||||
from bson.objectid import ObjectId
|
||||
from bson.json_util import dumps
|
||||
@@ -23,6 +24,95 @@ def singleton(cls):
|
||||
return _instance[cls]
|
||||
return inner
|
||||
|
||||
def getPluginName():
|
||||
return 'mongodb'
|
||||
|
||||
def getPluginDir():
|
||||
return mw.getPluginDir() + '/' + getPluginName()
|
||||
|
||||
|
||||
def getServerDir():
|
||||
return mw.getServerDir() + '/' + getPluginName()
|
||||
|
||||
def getConf():
|
||||
path = getServerDir() + "/mongodb.conf"
|
||||
return path
|
||||
|
||||
|
||||
def getConfTpl():
|
||||
path = getPluginDir() + "/config/mongodb.conf"
|
||||
return path
|
||||
|
||||
def pSqliteDb(dbname='users'):
|
||||
file = getServerDir() + '/mongodb.db'
|
||||
name = 'mongodb'
|
||||
|
||||
sql_file = getPluginDir() + '/config/mongodb.sql'
|
||||
import_sql = mw.readFile(sql_file)
|
||||
# print(sql_file,import_sql)
|
||||
md5_sql = mw.md5(import_sql)
|
||||
|
||||
import_sign = False
|
||||
save_md5_file = getServerDir() + '/import_mongodb.md5'
|
||||
if os.path.exists(save_md5_file):
|
||||
save_md5_sql = mw.readFile(save_md5_file)
|
||||
if save_md5_sql != md5_sql:
|
||||
import_sign = True
|
||||
mw.writeFile(save_md5_file, md5_sql)
|
||||
else:
|
||||
mw.writeFile(save_md5_file, md5_sql)
|
||||
|
||||
if not os.path.exists(file) or import_sql:
|
||||
conn = mw.M(dbname).dbPos(getServerDir(), name)
|
||||
csql_list = import_sql.split(';')
|
||||
for index in range(len(csql_list)):
|
||||
conn.execute(csql_list[index], ())
|
||||
|
||||
conn = mw.M(dbname).dbPos(getServerDir(), name)
|
||||
return conn
|
||||
|
||||
def getConfigData():
|
||||
cfg = getConf()
|
||||
# print(cfg)
|
||||
config_data = mw.readFile(cfg)
|
||||
try:
|
||||
config = yaml.safe_load(config_data)
|
||||
except:
|
||||
config = {
|
||||
"systemLog": {
|
||||
"destination": "file",
|
||||
"logAppend": True,
|
||||
"path": mw.getServerDir()+"/mongodb/log/mongodb.log"
|
||||
},
|
||||
"storage": {
|
||||
"dbPath": mw.getServerDir()+"/mongodb/data",
|
||||
"directoryPerDB": True,
|
||||
"journal": {
|
||||
"enabled": True
|
||||
}
|
||||
},
|
||||
"processManagement": {
|
||||
"fork": True,
|
||||
"pidFilePath": mw.getServerDir()+"/mongodb/log/mongodb.pid"
|
||||
},
|
||||
"net": {
|
||||
"port": 27017,
|
||||
"bindIp": "0.0.0.0"
|
||||
},
|
||||
"security": {
|
||||
"authorization": "disabled",
|
||||
"javascriptEnabled": False
|
||||
}
|
||||
}
|
||||
return config
|
||||
|
||||
def getConfPort():
|
||||
data = getConfigData()
|
||||
return data['net']['port']
|
||||
|
||||
def getConfAuth():
|
||||
data = getConfigData()
|
||||
return data['security']['authorization']
|
||||
|
||||
@singleton
|
||||
class nosqlMongodb():
|
||||
@@ -49,15 +139,22 @@ class nosqlMongodb():
|
||||
if not self.__DB_LOCAL:
|
||||
self.__DB_PORT = int(self.__config['port'])
|
||||
|
||||
# print(self.__DB_HOST,self.__DB_PORT, self.__DB_PASS)
|
||||
auth = getConfAuth()
|
||||
port = getConfPort()
|
||||
mg_root = pSqliteDb('config').where('id=?', (1,)).getField('mg_root')
|
||||
# print(auth,self.__DB_HOST,port, self.__DB_PASS)
|
||||
try:
|
||||
self.__DB_CONN = pymongo.MongoClient(host=self.__DB_HOST, port=self.__DB_PORT, maxPoolSize=10)
|
||||
if auth == 'disabled':
|
||||
self.__DB_CONN = pymongo.MongoClient(host=self.__DB_HOST, port=port, directConnection=True)
|
||||
else:
|
||||
self.__DB_CONN = pymongo.MongoClient(host=self.__DB_HOST, port=port, directConnection=True, username='root',password=mg_root)
|
||||
self.__DB_CONN.admin.command('ping')
|
||||
return self.__DB_CONN
|
||||
except pymongo.errors.ConnectionFailure:
|
||||
return False
|
||||
except Exception:
|
||||
self.__DB_ERR = mw.get_error_info()
|
||||
except Exception as e:
|
||||
# print(e)
|
||||
self.__DB_ERR = mw.getTracebackInfo()
|
||||
return False
|
||||
|
||||
# 获取配置项
|
||||
@@ -122,7 +219,7 @@ class nosqlMongodbCtr():
|
||||
|
||||
mgdb_instance = self.getInstanceBySid(sid).mgdb_conn()
|
||||
if mgdb_instance is False:
|
||||
return mw.returnData(False,'无法链接')
|
||||
return mw.returnData(False,'无法链接.')
|
||||
|
||||
result = {}
|
||||
collections = mgdb_instance[name].list_collection_names()
|
||||
@@ -164,7 +261,7 @@ class nosqlMongodbCtr():
|
||||
where[mg_field] = re.compile(mg_value)
|
||||
|
||||
# print(where)
|
||||
result = collection_instance.find(where).skip(start_index).limit(size).sort({'_id':-1})
|
||||
result = collection_instance.find(where).skip(start_index).limit(size).sort('_id',-1)
|
||||
count = collection_instance.count_documents(where)
|
||||
d = []
|
||||
for document in result:
|
||||
|
||||
@@ -123,9 +123,16 @@
|
||||
<input name="mongodb_field_value" type="text" class="bt-input-text" placeholder="请输入查找内容">
|
||||
</div>
|
||||
|
||||
<button type="button" class="mongodb_find btn btn-success btn-sm mr5 ml5" style="float:right;">
|
||||
<span>查找</span>
|
||||
</button>
|
||||
<div style="float:right;">
|
||||
|
||||
<button type="button" class="mongodb_find btn btn-success btn-sm mr5 ml5" >
|
||||
<span>查找</span>
|
||||
</button>
|
||||
|
||||
<button type="button" class="mongodb_refresh btn btn-success btn-sm mr5 ml5">
|
||||
<span>刷新</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="pull-right" style="padding-top: 5px;">
|
||||
|
||||
@@ -738,6 +738,10 @@ function mongodbInitField(f, data){
|
||||
}
|
||||
mongodbDataList(1);
|
||||
});
|
||||
|
||||
$('#mongodb .mongodb_refresh').unbind('click').click(function(){
|
||||
mongodbDataList(1);
|
||||
});
|
||||
}
|
||||
|
||||
var mogodb_db_list;
|
||||
@@ -1252,7 +1256,7 @@ function redisBatchClear(){
|
||||
|
||||
xm_db_list = xmSelect.render({
|
||||
el: '#select_db',
|
||||
repeat: true,
|
||||
repeat: false,
|
||||
toolbar: {show: true},
|
||||
data: idx_db,
|
||||
});
|
||||
|
||||
+349
-7
@@ -1948,7 +1948,7 @@ def addMasterRepSlaveUser(version=''):
|
||||
if isError != None:
|
||||
return isError
|
||||
|
||||
sql_select = "grant select,lock tables,PROCESS on *.* to " + username + "@'%';"
|
||||
sql_select = "grant select,reload,REPLICATION CLIENT,PROCESS on *.* to " + username + "@'%';"
|
||||
pdb.execute(sql_select)
|
||||
pdb.execute('FLUSH PRIVILEGES;')
|
||||
|
||||
@@ -2583,6 +2583,293 @@ def dumpMysqlData(version=''):
|
||||
return 'ok'
|
||||
return 'fail'
|
||||
|
||||
############### --- 重要 数据补足同步 ---- ###########
|
||||
|
||||
def getSyncMysqlDB(dbname,sign = ''):
|
||||
conn = pSqliteDb('slave_sync_user')
|
||||
if sign != '':
|
||||
data = conn.field('ip,port,user,pass,mode,cmd').where('ip=?', (sign,)).find()
|
||||
else:
|
||||
data = conn.field('ip,port,user,pass,mode,cmd').find()
|
||||
user = data['user']
|
||||
apass = data['pass']
|
||||
port = data['port']
|
||||
ip = data['ip']
|
||||
# 远程数据
|
||||
sync_db = mw.getMyORM()
|
||||
# MySQLdb |
|
||||
sync_db.setPort(port)
|
||||
sync_db.setHost(ip)
|
||||
sync_db.setUser(user)
|
||||
sync_db.setPwd(apass)
|
||||
sync_db.setDbName(dbname)
|
||||
sync_db.setTimeout(60)
|
||||
return sync_db
|
||||
|
||||
def syncDatabaseRepairTempFile():
|
||||
tmp_log = mw.getMWLogs()+ '/mariadb-check.log'
|
||||
return tmp_log
|
||||
|
||||
def syncDatabaseRepairLog(version=''):
|
||||
import subprocess
|
||||
args = getArgs()
|
||||
data = checkArgs(args, ['db','sign','op'])
|
||||
if not data[0]:
|
||||
return data[1]
|
||||
|
||||
sync_args_db = args['db']
|
||||
sync_args_sign = args['sign']
|
||||
op = args['op']
|
||||
tmp_log = syncDatabaseRepairTempFile()
|
||||
cmd = 'cd '+mw.getServerDir()+'/mdserver-web && source bin/activate && python3 plugins/mariadb/index.py sync_database_repair {"db":"'+sync_args_db+'","sign":"'+sync_args_sign+'"}'
|
||||
# print(cmd)
|
||||
|
||||
if op == 'get':
|
||||
log = mw.getLastLine(tmp_log, 15)
|
||||
return mw.returnJson(True, log)
|
||||
|
||||
if op == 'cmd':
|
||||
return mw.returnJson(True, 'ok', cmd)
|
||||
|
||||
if op == 'do':
|
||||
os.system(' echo "开始执行" > '+ tmp_log)
|
||||
os.system(cmd +' >> '+ tmp_log +' &')
|
||||
# time.sleep(10)
|
||||
# mw.execShell('rm -rf '+tmp_log)
|
||||
return mw.returnJson(True, 'ok')
|
||||
|
||||
return mw.returnJson(False, '无效请求!')
|
||||
|
||||
|
||||
def syncDatabaseRepair(version=''):
|
||||
time_stats_s = time.time()
|
||||
tmp_log = syncDatabaseRepairTempFile()
|
||||
|
||||
from pymysql.converters import escape_string
|
||||
args = getArgs()
|
||||
data = checkArgs(args, ['db','sign'])
|
||||
if not data[0]:
|
||||
return data[1]
|
||||
|
||||
sync_args_db = args['db']
|
||||
sync_args_sign = args['sign']
|
||||
|
||||
# 本地数据
|
||||
local_db = pMysqlDb()
|
||||
# 远程数据
|
||||
sync_db = getSyncMysqlDB(sync_args_db,sync_args_sign)
|
||||
|
||||
tables = local_db.query('show tables from `%s`' % sync_args_db)
|
||||
table_key = "Tables_in_" + sync_args_db
|
||||
inconsistent_table = []
|
||||
|
||||
tmp_dir = '/tmp/sync_db_repair'
|
||||
mw.execShell('mkdir -p '+tmp_dir)
|
||||
|
||||
for tb in tables:
|
||||
|
||||
table_name = sync_args_db+'.'+tb[table_key]
|
||||
table_check_file = tmp_dir+'/'+table_name+'.txt'
|
||||
|
||||
if os.path.exists(table_check_file):
|
||||
# print(table_name+', 已检查OK')
|
||||
continue
|
||||
|
||||
primary_key_sql = "SHOW INDEX FROM "+table_name+" WHERE Key_name = 'PRIMARY';";
|
||||
primary_key_data = local_db.query(primary_key_sql)
|
||||
# print(primary_key_sql,primary_key_data)
|
||||
pkey_name = '*'
|
||||
if len(primary_key_data) == 1:
|
||||
pkey_name = primary_key_data[0]['Column_name']
|
||||
# print(pkey_name)
|
||||
if pkey_name != '*' :
|
||||
# 智能校验(由于服务器同步可能会慢,比较总数总是对不上)
|
||||
cmd_local_newpk_sql = 'select ' + pkey_name + ' from ' + table_name + " order by " + pkey_name + " desc limit 1"
|
||||
cmd_local_newpk_data = local_db.query(cmd_local_newpk_sql)
|
||||
# print(cmd_local_newpk_data)
|
||||
if len(cmd_local_newpk_data) == 1:
|
||||
# 比较总数
|
||||
cmd_count_sql = 'select count('+pkey_name+') as num from '+table_name + ' where '+pkey_name + ' <= '+ str(cmd_local_newpk_data[0][pkey_name])
|
||||
local_count_data = local_db.query(cmd_count_sql)
|
||||
sync_count_data = sync_db.query(cmd_count_sql)
|
||||
|
||||
if local_count_data != sync_count_data:
|
||||
print(cmd_count_sql)
|
||||
print("all data compare: ",local_count_data, sync_count_data)
|
||||
else:
|
||||
print(table_name+' smart compare check ok.')
|
||||
mw.writeFile(tmp_log, table_name+' smart compare check ok.\n','a+')
|
||||
mw.execShell("echo 'ok' > "+table_check_file)
|
||||
continue
|
||||
|
||||
|
||||
|
||||
# 比较总数
|
||||
cmd_count_sql = 'select count('+pkey_name+') as num from '+table_name
|
||||
local_count_data = local_db.query(cmd_count_sql)
|
||||
sync_count_data = sync_db.query(cmd_count_sql)
|
||||
|
||||
if local_count_data != sync_count_data:
|
||||
print("all data compare: ",local_count_data, sync_count_data)
|
||||
inconsistent_table.append(table_name)
|
||||
diff = sync_count_data[0]['num'] - local_count_data[0]['num']
|
||||
print(table_name+', need sync. diff,'+str(diff))
|
||||
mw.writeFile(tmp_log, table_name+', need sync. diff,'+str(diff)+'\n','a+')
|
||||
else:
|
||||
print(table_name+' check ok.')
|
||||
mw.writeFile(tmp_log, table_name+' check ok.\n','a+')
|
||||
mw.execShell("echo 'ok' > "+table_check_file)
|
||||
|
||||
|
||||
# inconsistent_table = ['xx.xx']
|
||||
# 数据对齐
|
||||
for table_name in inconsistent_table:
|
||||
is_break = False
|
||||
while not is_break:
|
||||
local_db.ping()
|
||||
# 远程数据
|
||||
sync_db.ping()
|
||||
|
||||
print("check table:"+table_name)
|
||||
mw.writeFile(tmp_log, "check table:"+table_name+'\n','a+')
|
||||
table_name_pos = 0
|
||||
table_name_pos_file = tmp_dir+'/'+table_name+'.pos.txt'
|
||||
primary_key_sql = "SHOW INDEX FROM "+table_name+" WHERE Key_name = 'PRIMARY';";
|
||||
primary_key_data = local_db.query(primary_key_sql)
|
||||
pkey_name = primary_key_data[0]['Column_name']
|
||||
|
||||
if os.path.exists(table_name_pos_file):
|
||||
table_name_pos = mw.readFile(table_name_pos_file)
|
||||
|
||||
|
||||
data_select_sql = 'select * from '+table_name + ' where '+pkey_name+' > '+str(table_name_pos)+' limit 10000'
|
||||
print(data_select_sql)
|
||||
local_select_data = local_db.query(data_select_sql)
|
||||
|
||||
time_s = time.time()
|
||||
sync_select_data = sync_db.query(data_select_sql)
|
||||
print(f'sync query cos:{time.time() - time_s:.4f}s')
|
||||
mw.writeFile(tmp_log, f'sync query cos:{time.time() - time_s:.4f}s\n','a+')
|
||||
|
||||
# print(local_select_data)
|
||||
# print(sync_select_data)
|
||||
|
||||
# print(len(local_select_data))
|
||||
# print(len(sync_select_data))
|
||||
print('pos:',str(table_name_pos),'local compare sync,',local_select_data == sync_select_data)
|
||||
|
||||
|
||||
cmd_count_sql = 'select count('+pkey_name+') as num from '+table_name
|
||||
local_count_data = local_db.query(cmd_count_sql)
|
||||
time_s = time.time()
|
||||
sync_count_data = sync_db.query(cmd_count_sql)
|
||||
print(f'sync count data cos:{time.time() - time_s:.4f}s')
|
||||
print(local_count_data,sync_count_data)
|
||||
# 数据同步有延迟,相等即任务数据补足完成
|
||||
if local_count_data[0]['num'] == sync_count_data[0]['num']:
|
||||
is_break = True
|
||||
break
|
||||
|
||||
diff = sync_count_data[0]['num'] - local_count_data[0]['num']
|
||||
print("diff," + str(diff)+' line data!')
|
||||
|
||||
if local_select_data == sync_select_data:
|
||||
data_count = len(local_select_data)
|
||||
if data_count == 0:
|
||||
# mw.writeFile(table_name_pos_file, '0')
|
||||
print(table_name+",data is equal ok..")
|
||||
is_break = True
|
||||
break
|
||||
|
||||
# print(table_name,data_count)
|
||||
pos = local_select_data[data_count-1][pkey_name]
|
||||
print('pos',pos)
|
||||
progress = pos/sync_count_data[0]['num']
|
||||
print('progress,%.2f' % progress+'%')
|
||||
mw.writeFile(table_name_pos_file, str(pos))
|
||||
else:
|
||||
sync_select_data_len = len(sync_select_data)
|
||||
skip_idx = 0
|
||||
# 主库PK -> 查询本地 | 保证一致
|
||||
if sync_select_data_len > 0:
|
||||
for idx in range(sync_select_data_len):
|
||||
sync_idx_data = sync_select_data[idx]
|
||||
local_idx_data = None
|
||||
if idx in local_select_data:
|
||||
local_idx_data = local_select_data[idx]
|
||||
if sync_select_data[idx] == local_idx_data:
|
||||
skip_idx = idx
|
||||
pos = local_select_data[idx][pkey_name]
|
||||
mw.writeFile(table_name_pos_file, str(pos))
|
||||
|
||||
# print(insert_data)
|
||||
local_inquery_sql = 'select * from ' + table_name+ ' where ' +pkey_name+' = '+ str(sync_idx_data[pkey_name])
|
||||
# print(local_inquery_sql)
|
||||
ldata = local_db.query(local_inquery_sql)
|
||||
# print('ldata:',ldata)
|
||||
if len(ldata) == 0:
|
||||
print("id:"+ str(sync_idx_data[pkey_name])+ " no exists, insert")
|
||||
insert_sql = 'insert into ' + table_name
|
||||
field_str = ''
|
||||
value_str = ''
|
||||
for field in sync_idx_data:
|
||||
field_str += '`'+field+'`,'
|
||||
value_str += '\''+escape_string(str(sync_idx_data[field]))+'\','
|
||||
field_str = '(' +field_str.strip(',')+')'
|
||||
value_str = '(' +value_str.strip(',')+')'
|
||||
insert_sql = insert_sql+' '+field_str+' values'+value_str+';'
|
||||
print(insert_sql)
|
||||
r = local_db.execute(insert_sql)
|
||||
print(r)
|
||||
else:
|
||||
# print('compare sync->local:',sync_idx_data == ldata[0] )
|
||||
if ldata[0] == sync_idx_data:
|
||||
continue
|
||||
|
||||
print("id:"+ str(sync_idx_data[pkey_name])+ " data is not equal, update")
|
||||
update_sql = 'update ' + table_name
|
||||
field_str = ''
|
||||
value_str = ''
|
||||
for field in sync_idx_data:
|
||||
if field == pkey_name:
|
||||
continue
|
||||
field_str += '`'+field+'`=\''+escape_string(str(sync_idx_data[field]))+'\','
|
||||
field_str = field_str.strip(',')
|
||||
update_sql = update_sql+' set '+field_str+' where '+pkey_name+'=\''+str(sync_idx_data[pkey_name])+'\';'
|
||||
print(update_sql)
|
||||
r = local_db.execute(update_sql)
|
||||
print(r)
|
||||
|
||||
# 本地PK -> 查询主库 | 保证一致
|
||||
# local_select_data_len = len(local_select_data)
|
||||
# if local_select_data_len > 0:
|
||||
# for idx in range(local_select_data_len):
|
||||
# if idx < skip_idx:
|
||||
# continue
|
||||
# local_idx_data = local_select_data[idx]
|
||||
# print('local idx check', idx, skip_idx)
|
||||
# local_inquery_sql = 'select * from ' + table_name+ ' where ' +pkey_name+' = '+ str(local_idx_data[pkey_name])
|
||||
# print(local_inquery_sql)
|
||||
# sdata = sync_db.query(local_inquery_sql)
|
||||
# sdata_len = len(sdata)
|
||||
# print('sdata:',sdata,sdata_len)
|
||||
# if sdata_len == 0:
|
||||
# delete_sql = 'delete from ' + table_name + ' where ' +pkey_name+' = '+ str(local_idx_data[pkey_name])
|
||||
# print(delete_sql)
|
||||
# r = local_db.execute(delete_sql)
|
||||
# print(r)
|
||||
# break
|
||||
|
||||
|
||||
if is_break:
|
||||
print("break all")
|
||||
break
|
||||
time.sleep(3)
|
||||
print(f'data check cos:{time.time() - time_stats_s:.4f}s')
|
||||
print("data supplementation completed")
|
||||
mw.execShell('rm -rf '+tmp_dir)
|
||||
return 'ok'
|
||||
|
||||
|
||||
############### --- 重要 同步---- ###########
|
||||
|
||||
@@ -2647,11 +2934,18 @@ def doFullSync(version=''):
|
||||
|
||||
|
||||
def doFullSyncUser(version=''):
|
||||
which_pv = mw.execShell('which pv')
|
||||
is_exist_pv = False
|
||||
if os.path.exists(which_pv[0]):
|
||||
is_exist_pv = True
|
||||
|
||||
|
||||
args = getArgs()
|
||||
data = checkArgs(args, ['db', 'sign'])
|
||||
if not data[0]:
|
||||
return data[1]
|
||||
|
||||
time_all_s = time.time()
|
||||
sync_db = args['db']
|
||||
sync_sign = args['sign']
|
||||
|
||||
@@ -2675,23 +2969,67 @@ def doFullSyncUser(version=''):
|
||||
os.system("rm -rf " + bak_file)
|
||||
|
||||
writeDbSyncStatus({'code': 0, 'msg': '开始同步...', 'progress': 0})
|
||||
|
||||
dmp_option = ''
|
||||
mode = recognizeDbMode()
|
||||
# if mode == 'gtid':
|
||||
# dmp_option = ' --set-gtid-purged=off '
|
||||
|
||||
writeDbSyncStatus({'code': 1, 'msg': '远程导出数据...', 'progress': 10})
|
||||
|
||||
find_run_dump = mw.execShell('ps -ef | grep mariadb-dump | grep -v grep')
|
||||
if find_run_dump[0] != "":
|
||||
print("正在远程导出数据中,别着急...")
|
||||
writeDbSyncStatus({'code': 3.1, 'msg': '正在远程导出数据中,别着急...', 'progress': 39})
|
||||
return False
|
||||
|
||||
time_s = time.time()
|
||||
if not os.path.exists(bak_file):
|
||||
dmp_option += " --master-data=1 --apply-slave-statements --include-master-host-port "
|
||||
|
||||
# https://mariadb.com/kb/zh-cn/mariadb-dump/
|
||||
dump_sql_data = getServerDir() + "/bin/mariadb-dump -f --opt --default-character-set=utf8 --single-transaction -h" + ip + " -P" + \
|
||||
dump_sql_data = getServerDir() + "/bin/mariadb-dump " + dmp_option + " -f --default-character-set=utf8 --single-transaction --compress -q -h" + ip + " -P" + \
|
||||
port + " -u" + user + " -p'" + apass + "' " + sync_db + ">" + bak_file
|
||||
print(dump_sql_data)
|
||||
mw.execShell(dump_sql_data)
|
||||
|
||||
writeDbSyncStatus({'code': 2, 'msg': '本地导入数据...', 'progress': 40})
|
||||
time_e = time.time()
|
||||
export_cos = time_e - time_s
|
||||
print("export cos:", export_cos)
|
||||
writeDbSyncStatus({'code': 3, 'msg': '导出耗时:'+str(int(export_cos))+'秒,正在到本地导入数据中...', 'progress': 40})
|
||||
|
||||
|
||||
find_run_import = mw.execShell('ps -ef | grep mariadb| grep '+ bak_file +' | grep -v grep')
|
||||
if find_run_import[0] != "":
|
||||
print("正在导入数据中,别着急...")
|
||||
writeDbSyncStatus({'code': 4.1, 'msg': '正在导入数据中,别着急...', 'progress': 59})
|
||||
return False
|
||||
|
||||
# if os.path.exists(bak_file):
|
||||
# db.execute('reset master')
|
||||
|
||||
time_s = time.time()
|
||||
if os.path.exists(bak_file):
|
||||
pwd = pSqliteDb('config').where('id=?', (1,)).getField('mysql_root')
|
||||
sock = getSocketFile()
|
||||
my_import_cmd = getServerDir() + '/bin/mariadb -S ' + sock + " -uroot -p'" + pwd + \
|
||||
"' " + sync_db + '<' + bak_file
|
||||
print(my_import_cmd)
|
||||
mw.execShell(my_import_cmd)
|
||||
|
||||
if is_exist_pv:
|
||||
my_import_cmd = getServerDir() + '/bin/mariadb -S ' + sock + " -uroot -p'" + pwd + "' " + sync_db
|
||||
my_import_cmd = "pv -t -p " + bak_file + '|' + my_import_cmd
|
||||
print(my_import_cmd)
|
||||
os.system(my_import_cmd)
|
||||
else:
|
||||
my_import_cmd = getServerDir() + '/bin/mariadb -S ' + sock + " -uroot -p'" + pwd + \
|
||||
"' " + sync_db + '<' + bak_file
|
||||
print(my_import_cmd)
|
||||
mw.execShell(my_import_cmd)
|
||||
|
||||
time_e = time.time()
|
||||
import_cos = time_e - time_s
|
||||
print("import cos:", import_cos)
|
||||
writeDbSyncStatus({'code': 4, 'msg': '导入耗时:'+str(int(import_cos))+'秒', 'progress': 60})
|
||||
|
||||
time.sleep(3)
|
||||
|
||||
pinfo = parseSlaveSyncCmd(data['cmd'])
|
||||
# print(pinfo)
|
||||
@@ -3026,5 +3364,9 @@ if __name__ == "__main__":
|
||||
print(doFullSync(version))
|
||||
elif func == 'dump_mysql_data':
|
||||
print(dumpMysqlData(version))
|
||||
elif func == 'sync_database_repair':
|
||||
print(syncDatabaseRepair())
|
||||
elif func == 'sync_database_repair_log':
|
||||
print(syncDatabaseRepairLog())
|
||||
else:
|
||||
print('error')
|
||||
|
||||
@@ -7,6 +7,12 @@ rootPath=$(dirname "$curPath")
|
||||
rootPath=$(dirname "$rootPath")
|
||||
serverPath=$(dirname "$rootPath")
|
||||
|
||||
# cd /www/server/mdserver-web/plugins/mariadb && bash install.sh install 8.2
|
||||
# cd /www/server/mdserver-web && source bin/activate && python3 plugins/mariadb/index.py try_slave_sync_bugfix {}
|
||||
# cd /www/server/mdserver-web && source bin/activate && python3 plugins/mariadb/index.py do_full_sync {"db":"xxx","sign":"","begin":1}
|
||||
# cd /www/server/mdserver-web && source bin/activate && python3 plugins/mariadb/index.py sync_database_repair {"db":"xxx","sign":""}
|
||||
# cd /www/server/mdserver-web && source bin/activate && python3 plugins/mariadb/index.py init_slave_status
|
||||
# cd /www/server/mdserver-web && source bin/activate && python3 plugins/mariadb/index.py install_pre_inspection
|
||||
|
||||
install_tmp=${rootPath}/tmp/mw_install.pl
|
||||
|
||||
|
||||
@@ -874,7 +874,7 @@ function openPhpmyadmin(name,username,password){
|
||||
}
|
||||
|
||||
if (rdata.data['cfg']['choose'] != 'mariadb'){
|
||||
layer.msg('当前为['+rdata.choose+']模式,若要使用请修改phpMyAdmin访问切换.',{icon:2,shade: [0.3, '#000']});
|
||||
layer.msg('当前为['+rdata.data['cfg']['choose']+']模式,若要使用请修改phpMyAdmin访问切换.',{icon:2,shade: [0.3, '#000']});
|
||||
return;
|
||||
}
|
||||
var home_page = rdata.data['home_page'];
|
||||
@@ -1153,7 +1153,7 @@ function dbList(page, search){
|
||||
list += '<td><span class="c9 input-edit" onclick="setDbPs(\''+rdata.data[i]['id']+'\',\''+rdata.data[i]['name']+'\',this)" style="display: inline-block;">'+rdata.data[i]['ps']+'</span></td>';
|
||||
list += '<td style="text-align:right">';
|
||||
|
||||
list += '<a href="javascript:;" class="btlink" class="btlink" onclick="setBackup(\''+rdata.data[i]['name']+'\')" title="数据库备份">'+(rdata.data[i]['is_backup']?'备份':'未备份') +'</a> | ';
|
||||
list += '<a href="javascript:;" class="btlink" class="btlink" onclick="setBackup(\''+rdata.data[i]['name']+'\')" title="数据库备份">'+(rdata.data[i]['is_backup']?'已备份':'未备份') +'</a> | ';
|
||||
|
||||
var rw = '';
|
||||
var rw_change = 'all';
|
||||
@@ -1978,6 +1978,84 @@ function getFullSyncStatus(db){
|
||||
|
||||
}
|
||||
|
||||
function dataSyncVerify(db){
|
||||
var reqTimer = null;
|
||||
|
||||
function requestLogs(layerIndex){
|
||||
myPostN('sync_database_repair_log', {db:db, sign:'',op:'get'}, function(rdata){
|
||||
var rdata = $.parseJSON(rdata.data);
|
||||
|
||||
if(!rdata.status) {
|
||||
layer.close(layerIndex);
|
||||
layer.msg(rdata.msg,{icon:2, time:2000});
|
||||
clearInterval(reqTimer);
|
||||
return;
|
||||
};
|
||||
|
||||
if (rdata.msg == ''){
|
||||
rdata.msg = '暂无数据!';
|
||||
}
|
||||
|
||||
$("#data_verify_log").html(rdata.msg);
|
||||
//滚动到最低
|
||||
var ob = document.getElementById('data_verify_log');
|
||||
ob.scrollTop = ob.scrollHeight;
|
||||
});
|
||||
}
|
||||
|
||||
layer.open({
|
||||
type: 1,
|
||||
title: '同步数据库['+db+']数据校验',
|
||||
area: '500px',
|
||||
btn:[ "开始","取消","手动"],
|
||||
content:"<div class='bt-form'>\
|
||||
"+'<pre id="data_verify_log" style="overflow: auto; border: 0px none; line-height:23px;padding: 5px; margin: 0px; white-space: pre-wrap; height: 395px; background-color: rgb(51,51,51);color:#f1f1f1;border-radius:0px;font-family:"></pre>'+"\
|
||||
</div>",
|
||||
cancel: function(){
|
||||
if (reqTimer){
|
||||
clearInterval(reqTimer);
|
||||
}
|
||||
},
|
||||
yes:function(index,layer_index){
|
||||
myPostN('sync_database_repair_log', {db:db, sign:'',op:'do'}, function(data){});
|
||||
layer.msg("执行成功");
|
||||
|
||||
requestLogs(layer_index);
|
||||
reqTimer = setInterval(function(){
|
||||
requestLogs(layer_index);
|
||||
},3000);
|
||||
},
|
||||
success:function(){
|
||||
},
|
||||
btn3: function(){
|
||||
myPostN('sync_database_repair_log', {db:db, sign:'',op:'cmd'}, function(rdata){
|
||||
var rdata = $.parseJSON(rdata.data);
|
||||
layer.open({
|
||||
title: "手动执行命令CMD",
|
||||
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);
|
||||
}
|
||||
});
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
function addSlaveSSH(ip=''){
|
||||
|
||||
myPost('get_slave_ssh_by_ip', {ip:ip}, function(rdata){
|
||||
@@ -2633,7 +2711,8 @@ function masterOrSlaveConf(version=''){
|
||||
list += '<td>' + rdata.data[i]['name'] +'</td>';
|
||||
list += '<td style="text-align:right">' +
|
||||
'<a href="javascript:;" class="btlink" onclick="setDbSlave(\''+rdata.data[i]['name']+'\')" title="加入|退出">'+(rdata.data[i]['slave']?'退出':'加入')+'</a> | ' +
|
||||
'<a href="javascript:;" class="btlink" onclick="getFullSyncStatus(\''+rdata.data[i]['name']+'\')" title="同步">同步</a>' +
|
||||
'<a href="javascript:;" class="btlink" onclick="getFullSyncStatus(\''+rdata.data[i]['name']+'\')" title="同步">同步</a> | ' +
|
||||
'<a href="javascript:;" class="btlink" onclick="dataSyncVerify(\''+rdata.data[i]['name']+'\')" title="数据校验">数据校验</a>' +
|
||||
'</td>';
|
||||
list += '</tr>';
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ class backupTools:
|
||||
# mw.execShell(db_path + "/bin/mysqldump --defaults-file=" + my_conf_path + " --skip-lock-tables --default-character-set=utf8 " +
|
||||
# name + " | gzip > " + filename)
|
||||
|
||||
cmd = db_path + "/bin/mysqldump --defaults-file=" + my_conf_path + " --single-transaction --quick --default-character-set=utf8 " + \
|
||||
cmd = db_path + "/bin/mariadb-dump --defaults-file=" + my_conf_path + " --single-transaction --quick --default-character-set=utf8 " + \
|
||||
name + " | gzip > " + filename
|
||||
mw.execShell(cmd)
|
||||
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
directoryperdb = true
|
||||
dbpath = {$SERVER_PATH}/mongodb/data
|
||||
logpath = {$SERVER_PATH}/mongodb/logs/mongodb.log
|
||||
logappend = true
|
||||
bind_ip = 127.0.0.1
|
||||
port = 27017
|
||||
fork = true
|
||||
auth = false
|
||||
#smallfiles = true
|
||||
|
||||
oplogSize=100
|
||||
|
||||
# Master/slave replication is no longer supported
|
||||
#master = true
|
||||
|
||||
#replSet = test
|
||||
|
||||
pidfilepath = {$SERVER_PATH}/mongodb/mongodb.pid
|
||||
@@ -1,17 +1,19 @@
|
||||
dbpath = {$SERVER_PATH}/mongodb/data
|
||||
logpath = {$SERVER_PATH}/mongodb/logs/mongodb.log
|
||||
logappend = true
|
||||
bind_ip = 127.0.0.1
|
||||
port = 27017
|
||||
fork = true
|
||||
auth = false
|
||||
#smallfiles = true
|
||||
|
||||
oplogSize=100
|
||||
|
||||
# Master/slave replication is no longer supported
|
||||
#master = true
|
||||
|
||||
#replSet = test
|
||||
|
||||
pidfilepath = {$SERVER_PATH}/mongodb/mongodb.pid
|
||||
net:
|
||||
bindIp: 127.0.0.1
|
||||
port: 27017
|
||||
processManagement:
|
||||
fork: true
|
||||
pidFilePath: {$SERVER_PATH}/mongodb/mongodb.pid
|
||||
security:
|
||||
authorization: disabled
|
||||
javascriptEnabled: false
|
||||
storage:
|
||||
dbPath: {$SERVER_PATH}/mongodb/data
|
||||
directoryPerDB: true
|
||||
systemLog:
|
||||
destination: file
|
||||
logAppend: true
|
||||
logRotate: reopen
|
||||
path: {$SERVER_PATH}/mongodb/logs/mongodb.log
|
||||
replication:
|
||||
oplogSizeMB: 2048
|
||||
@@ -0,0 +1,19 @@
|
||||
CREATE TABLE IF NOT EXISTS `config` (
|
||||
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
`mg_root` TEXT
|
||||
);
|
||||
|
||||
INSERT INTO `config` (`id`, `mg_root`) VALUES (1, 'mg_root');
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `databases` (
|
||||
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
`name` TEXT,
|
||||
`username` TEXT,
|
||||
`password` TEXT,
|
||||
`accept` TEXT,
|
||||
`rw` TEXT DEFAULT 'rw',
|
||||
`ps` TEXT,
|
||||
`addtime` TEXT
|
||||
);
|
||||
|
||||
@@ -6,7 +6,48 @@
|
||||
white-space: nowrap;
|
||||
display: inline-block;
|
||||
vertical-align: middle;
|
||||
}
|
||||
}
|
||||
|
||||
.bingfa .bt-input-text {
|
||||
width: 200px;
|
||||
}
|
||||
|
||||
.inlineBlock {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.db_list{
|
||||
padding: 0px 0 10px 0;
|
||||
font-size: 13px;
|
||||
line-height: 35px;
|
||||
height: 45px;
|
||||
}
|
||||
.db_list a{
|
||||
margin-right: 15px;
|
||||
color: #555;
|
||||
font-weight: 600;
|
||||
}
|
||||
.db_list span:nth-child(1){
|
||||
display: block;
|
||||
float: left;
|
||||
padding-left: 15px;
|
||||
background: #ececec;
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
#db_tools button {
|
||||
margin-right: 10px;
|
||||
}
|
||||
#db_tools button:last-child{
|
||||
margin-right: 0;
|
||||
}
|
||||
|
||||
.conf_p span {
|
||||
display: inline-block;
|
||||
margin-right: 10px;
|
||||
width: 115px;
|
||||
text-align: right;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div class="bt-form">
|
||||
@@ -14,20 +55,27 @@
|
||||
<div class="bt-w-menu">
|
||||
<p class="bgw" onclick="pluginService('mongodb');">服务</p>
|
||||
<p onclick="pluginInitD('mongodb');">自启动</p>
|
||||
<p onclick="pluginConfig('mongodb');">配置修改</p>
|
||||
<p onclick="mongoStatus();">负载状态</p>
|
||||
<p onclick="mongoSetConfig();">配置修改</p>
|
||||
<p onclick="pluginConfig('mongodb');">配置文件</p>
|
||||
<p onclick="pluginConfig('mongodb','','config_key');">配置[KEY]</p>
|
||||
<p onclick="dbList();">数据列表</p>
|
||||
<p onclick="mongoDocStatus();">文档状态</p>
|
||||
<p onclick="mongoStatus();">负载状态</p>
|
||||
<p onclick="mongoReplStatus();">复制状态</p>
|
||||
<p onclick="pluginLogs('mongodb','','run_log');">日志</p>
|
||||
<p onclick="mgdbReadme();">相关说明</p>
|
||||
</div>
|
||||
<div class="bt-w-con pd15">
|
||||
<div class="soft-man-con" style="height:455px;overflow: auto;"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- <script type="text/javascript" src="/plugins/file?name=mongodb&f=js/mongodb.js"></script> -->
|
||||
<script type="text/javascript">
|
||||
//mongodb start
|
||||
resetPluginWinHeight(530);
|
||||
resetPluginWinWidth(800);
|
||||
$.getScript('/plugins/file?name=mongodb&f=js/mongodb.js', function(){
|
||||
pluginService('mongodb');
|
||||
});
|
||||
|
||||
+1295
-64
File diff suppressed because it is too large
Load Diff
@@ -1,10 +1,12 @@
|
||||
{
|
||||
"sort": 7,
|
||||
"ps": "一个高性能的NOSQL数据库",
|
||||
"hook":["database"],
|
||||
"ps": "一个高性能的NOSQL数据库【社区版】",
|
||||
"name": "mongodb",
|
||||
"title": "Mongodb",
|
||||
"title": "MongoDB",
|
||||
"shell": "install.sh",
|
||||
"install_pre_inspection":true,
|
||||
"uninstall_pre_inspection":true,
|
||||
"versions":["4.4","5.0","6.0","7.0"],
|
||||
"tip": "soft",
|
||||
"checks": "server/mongodb",
|
||||
|
||||
@@ -4,7 +4,7 @@ export PATH
|
||||
|
||||
# https://www.mongodb.com/try/download/community
|
||||
|
||||
# cd /Users/midoks/Desktop/mwdev/server/mdserver-web/plugins/mongodb && /bin/bash install.sh install 5.0.4
|
||||
# cd /Users/midoks/Desktop/mwdev/server/mdserver-web/plugins/mongodb && /bin/bash install.sh install 7.0
|
||||
# cd /www/server/mdserver-web/plugins/mongodb && /bin/bash install.sh install 7.0
|
||||
# cd /www/server/mdserver-web && python3 /www/server/mdserver-web/plugins/mongodb/index.py start
|
||||
|
||||
@@ -31,6 +31,9 @@ if [ "macos" != "$OSNAME" ];then
|
||||
SYS_VERSION_ID=`cat /etc/*-release | grep VERSION_ID | awk -F = '{print $2}' | awk -F "\"" '{print $2}'`
|
||||
fi
|
||||
|
||||
if [ -f ${rootPath}/bin/activate ];then
|
||||
source ${rootPath}/bin/activate
|
||||
fi
|
||||
Install_app()
|
||||
{
|
||||
echo '正在安装脚本文件...' > $install_tmp
|
||||
|
||||
+1114
-10
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,234 @@
|
||||
# coding: utf-8
|
||||
#-----------------------------
|
||||
# 网站备份工具
|
||||
#-----------------------------
|
||||
|
||||
import sys
|
||||
import os
|
||||
import re
|
||||
|
||||
if sys.platform != 'darwin':
|
||||
os.chdir('/www/server/mdserver-web')
|
||||
|
||||
|
||||
chdir = os.getcwd()
|
||||
sys.path.append(chdir + '/class/core')
|
||||
|
||||
# reload(sys)
|
||||
# sys.setdefaultencoding('utf-8')
|
||||
|
||||
import mw
|
||||
import db
|
||||
import time
|
||||
import yaml
|
||||
|
||||
def getPluginName():
|
||||
return 'mongodb'
|
||||
|
||||
|
||||
def getPluginDir():
|
||||
return mw.getPluginDir() + '/' + getPluginName()
|
||||
|
||||
|
||||
def getServerDir():
|
||||
return mw.getServerDir() + '/' + getPluginName()
|
||||
|
||||
|
||||
def getConf():
|
||||
path = getServerDir() + "/mongodb.conf"
|
||||
return path
|
||||
|
||||
def getConfigData():
|
||||
cfg = getConf()
|
||||
config_data = mw.readFile(cfg)
|
||||
try:
|
||||
config = yaml.safe_load(config_data)
|
||||
except:
|
||||
config = {
|
||||
"systemLog": {
|
||||
"destination": "file",
|
||||
"logAppend": True,
|
||||
"path": mw.getServerDir()+"/mongodb/log/mongodb.log"
|
||||
},
|
||||
"storage": {
|
||||
"dbPath": mw.getServerDir()+"/mongodb/data",
|
||||
"directoryPerDB": True,
|
||||
"journal": {
|
||||
"enabled": True
|
||||
}
|
||||
},
|
||||
"processManagement": {
|
||||
"fork": True,
|
||||
"pidFilePath": mw.getServerDir()+"/mongodb/log/mongodb.pid"
|
||||
},
|
||||
"net": {
|
||||
"port": 27017,
|
||||
"bindIp": "0.0.0.0"
|
||||
},
|
||||
"security": {
|
||||
"authorization": "enabled",
|
||||
"javascriptEnabled": False
|
||||
}
|
||||
}
|
||||
return config
|
||||
|
||||
|
||||
def getConfIp():
|
||||
data = getConfigData()
|
||||
return data['net']['bindIp']
|
||||
|
||||
def getConfPort():
|
||||
data = getConfigData()
|
||||
return data['net']['port']
|
||||
|
||||
def getConfAuth():
|
||||
data = getConfigData()
|
||||
return data['security']['authorization']
|
||||
|
||||
def pSqliteDb(dbname='users'):
|
||||
file = getServerDir() + '/mongodb.db'
|
||||
name = 'mongodb'
|
||||
|
||||
sql_file = getPluginDir() + '/config/mongodb.sql'
|
||||
import_sql = mw.readFile(sql_file)
|
||||
# print(sql_file,import_sql)
|
||||
md5_sql = mw.md5(import_sql)
|
||||
|
||||
import_sign = False
|
||||
save_md5_file = getServerDir() + '/import_mongodb.md5'
|
||||
if os.path.exists(save_md5_file):
|
||||
save_md5_sql = mw.readFile(save_md5_file)
|
||||
if save_md5_sql != md5_sql:
|
||||
import_sign = True
|
||||
mw.writeFile(save_md5_file, md5_sql)
|
||||
else:
|
||||
mw.writeFile(save_md5_file, md5_sql)
|
||||
|
||||
if not os.path.exists(file) or import_sql:
|
||||
conn = mw.M(dbname).dbPos(getServerDir(), name)
|
||||
csql_list = import_sql.split(';')
|
||||
for index in range(len(csql_list)):
|
||||
conn.execute(csql_list[index], ())
|
||||
|
||||
conn = mw.M(dbname).dbPos(getServerDir(), name)
|
||||
return conn
|
||||
|
||||
def mongdbClient():
|
||||
import pymongo
|
||||
port = getConfPort()
|
||||
auth = getConfAuth()
|
||||
ip = getConfIp()
|
||||
mg_root = pSqliteDb('config').where('id=?', (1,)).getField('mg_root')
|
||||
# print(ip,port,auth,mg_root)
|
||||
if auth == 'disabled':
|
||||
client = pymongo.MongoClient(host=ip, port=int(port), directConnection=True)
|
||||
else:
|
||||
# uri = "mongodb://root:"+mg_root+"@127.0.0.1:"+str(port)
|
||||
# client = pymongo.MongoClient(uri)
|
||||
client = pymongo.MongoClient(host=ip, port=int(port), directConnection=True, username='root',password=mg_root)
|
||||
return client
|
||||
|
||||
class backupTools:
|
||||
|
||||
def getDbBackupList(self,dbname=''):
|
||||
bkDir = mw.getRootDir() + '/backup/database'
|
||||
blist = os.listdir(bkDir)
|
||||
r = []
|
||||
|
||||
bname = 'mongodb_' + dbname
|
||||
blen = len(bname)
|
||||
for x in blist:
|
||||
fbstr = x[0:blen]
|
||||
if fbstr == bname:
|
||||
r.append(x)
|
||||
return r
|
||||
|
||||
def backupDatabase(self, name, count):
|
||||
db_path = mw.getServerDir() + '/mongodb'
|
||||
db_name = 'mongodb'
|
||||
name = mw.M('databases').dbPos(db_path, db_name).where('name=?', (name,)).getField('name')
|
||||
|
||||
startTime = time.time()
|
||||
if not name:
|
||||
endDate = time.strftime('%Y/%m/%d %X', time.localtime())
|
||||
log = "数据库[" + name + "]不存在!"
|
||||
print("★[" + endDate + "] " + log)
|
||||
print(
|
||||
"----------------------------------------------------------------------------")
|
||||
return
|
||||
|
||||
backup_path = mw.getBackupDir() + '/database'
|
||||
if not os.path.exists(backup_path):
|
||||
mw.execShell("mkdir -p " + backup_path)
|
||||
|
||||
time_now = time.strftime('%Y%m%d_%H%M%S', time.localtime())
|
||||
backup_name = "mongodb_" + name + "_" + time_now + ".tar.gz"
|
||||
filename = backup_path + "/"+backup_name
|
||||
|
||||
port = getConfPort()
|
||||
auth = getConfAuth()
|
||||
mg_root = pSqliteDb('config').where('id=?', (1,)).getField('mg_root')
|
||||
uoption = ''
|
||||
if auth != 'disabled':
|
||||
uoption =' --authenticationDatabase admin -u root -p '+mg_root
|
||||
|
||||
cmd = db_path + "/bin/mongodump "+uoption+" --port "+str(port)+" -d test -o "+backup_path
|
||||
# print(cmd)
|
||||
mw.execShell(cmd)
|
||||
cmd_gz = "cd "+backup_path+"/"+name+" && tar -zcvf "+filename + " ./"
|
||||
mw.execShell(cmd_gz)
|
||||
mw.execShell("rm -rf "+ backup_path+"/"+name)
|
||||
|
||||
if not os.path.exists(filename):
|
||||
endDate = time.strftime('%Y/%m/%d %X', time.localtime())
|
||||
log = "数据库[" + name + "]备份失败!"
|
||||
print("★[" + endDate + "] " + log)
|
||||
print("----------------------------------------------------------------------------")
|
||||
return
|
||||
|
||||
|
||||
endDate = time.strftime('%Y/%m/%d %X', time.localtime())
|
||||
outTime = time.time() - startTime
|
||||
|
||||
# print(outTime)
|
||||
log = "数据库MongoDB[" + name + "]备份成功,用时[" + str(round(outTime, 2)) + "]秒"
|
||||
mw.writeLog('计划任务', log)
|
||||
print("★[" + endDate + "] " + log)
|
||||
print("|---保留最新的[" + count + "]份备份")
|
||||
print("|---文件名:" + filename)
|
||||
|
||||
backups = self.getDbBackupList(name)
|
||||
|
||||
# 清理多余备份
|
||||
num = len(backups) - int(count)
|
||||
if num > 0:
|
||||
for backup in backups:
|
||||
mw.execShell("rm -f " + backup_path + "/"+backup)
|
||||
num -= 1
|
||||
print("|---已清理过期备份文件:" + backup)
|
||||
if num < 1:
|
||||
break
|
||||
|
||||
def backupDatabaseAll(self, save):
|
||||
db_path = mw.getServerDir() + '/mongodb'
|
||||
db_name = 'mongodb'
|
||||
databases = mw.M('databases').dbPos(
|
||||
db_path, db_name).field('name').select()
|
||||
for db in databases:
|
||||
self.backupDatabase(db['name'], save)
|
||||
|
||||
def findPathName(self, path, filename):
|
||||
f = os.scandir(path)
|
||||
l = []
|
||||
for ff in f:
|
||||
if ff.name.find(filename) > -1:
|
||||
l.append(ff.name)
|
||||
return l
|
||||
|
||||
if __name__ == "__main__":
|
||||
backup = backupTools()
|
||||
stype = sys.argv[1]
|
||||
if stype == 'all':
|
||||
backup.backupDatabaseAll(sys.argv[2])
|
||||
if stype == 'database':
|
||||
backup.backupDatabase(sys.argv[2], sys.argv[3])
|
||||
@@ -67,3 +67,45 @@ if [ ! -d $serverPath/mongodb/bin ];then
|
||||
fi
|
||||
|
||||
cd ${MG_DIR} && rm -rf ${MG_DIR}/${FILE_NAME}
|
||||
|
||||
#--------------- mongosh tool install ------------------ #
|
||||
TOOL_VERSION=2.2.5
|
||||
TOOL_FILE_NAME=mongosh-${TOOL_VERSION}-linux-x64
|
||||
if [ "aarch64" == ${SYS_ARCH} ];then
|
||||
TOOL_FILE_NAME=mongosh-${TOOL_VERSION}-linux-arm64
|
||||
fi
|
||||
TOOL_FILE_NAME_TGZ=${TOOL_FILE_NAME}.tgz
|
||||
if [ ! -f $MG_DIR/${TOOL_FILE_NAME_TGZ} ]; then
|
||||
wget --no-check-certificate -O $MG_DIR/${TOOL_FILE_NAME_TGZ} https://downloads.mongodb.com/compass/${TOOL_FILE_NAME_TGZ}
|
||||
echo "wget --no-check-certificate -O $MG_DIR/${TOOL_FILE_NAME_TGZ} https://downloads.mongodb.com/compass/${TOOL_FILE_NAME_TGZ}"
|
||||
fi
|
||||
|
||||
if [ ! -d $MG_DIR/${TOOL_FILE_NAME_TGZ} ];then
|
||||
cd $MG_DIR && tar -zxvf ${TOOL_FILE_NAME_TGZ}
|
||||
fi
|
||||
|
||||
cd ${MG_DIR}/${TOOL_FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
||||
cd ${MG_DIR} && rm -rf ${MG_DIR}/${TOOL_FILE_NAME}
|
||||
|
||||
#--------------- mongodb database install ------------------ #
|
||||
TOOL_VERSION=100.9.4
|
||||
TOOL_FILE_NAME=mongodb-database-tools-rhel${SYS_NAME}-x86_64-${TOOL_VERSION}
|
||||
if [ "aarch64" == ${SYS_ARCH} ];then
|
||||
TOOL_FILE_NAME=mongodb-database-tools-rhel${SYS_NAME}-aarch64-${TOOL_VERSION}
|
||||
fi
|
||||
|
||||
if [ "arm64" == ${SYS_ARCH} ];then
|
||||
TOOL_FILE_NAME=mongodb-database-tools-rhel${SYS_NAME}-arm64-${TOOL_VERSION}
|
||||
fi
|
||||
|
||||
TOOL_FILE_NAME_TGZ=${TOOL_FILE_NAME}.tgz
|
||||
if [ ! -f $MG_DIR/${TOOL_FILE_NAME_TGZ} ]; then
|
||||
wget --no-check-certificate -O $MG_DIR/${TOOL_FILE_NAME_TGZ} https://fastdl.mongodb.org/tools/db/${TOOL_FILE_NAME_TGZ}
|
||||
fi
|
||||
|
||||
if [ ! -d $MG_DIR/${TOOL_FILE_NAME_TGZ} ];then
|
||||
cd $MG_DIR && tar -zxvf ${TOOL_FILE_NAME_TGZ}
|
||||
fi
|
||||
|
||||
cd ${MG_DIR}/${TOOL_FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
||||
cd ${MG_DIR} && rm -rf ${MG_DIR}/${TOOL_FILE_NAME}
|
||||
|
||||
@@ -44,3 +44,46 @@ if [ ! -d $serverPath/mongodb/bin ];then
|
||||
fi
|
||||
|
||||
cd ${MG_DIR} && rm -rf ${MG_DIR}/${FILE_NAME}
|
||||
|
||||
#--------------- mongosh tool install ------------------ #
|
||||
TOOL_VERSION=2.2.5
|
||||
TOOL_FILE_NAME=mongosh-${TOOL_VERSION}-linux-x64
|
||||
if [ "aarch64" == ${SYS_ARCH} ];then
|
||||
TOOL_FILE_NAME=mongosh-${TOOL_VERSION}-linux-arm64
|
||||
fi
|
||||
TOOL_FILE_NAME_TGZ=${TOOL_FILE_NAME}.tgz
|
||||
if [ ! -f $MG_DIR/${TOOL_FILE_NAME_TGZ} ]; then
|
||||
wget --no-check-certificate -O $MG_DIR/${TOOL_FILE_NAME_TGZ} https://downloads.mongodb.com/compass/${TOOL_FILE_NAME_TGZ}
|
||||
echo "wget --no-check-certificate -O $MG_DIR/${TOOL_FILE_NAME_TGZ} https://downloads.mongodb.com/compass/${TOOL_FILE_NAME_TGZ}"
|
||||
fi
|
||||
|
||||
if [ ! -d $MG_DIR/${TOOL_FILE_NAME_TGZ} ];then
|
||||
cd $MG_DIR && tar -zxvf ${TOOL_FILE_NAME_TGZ}
|
||||
fi
|
||||
|
||||
cd ${MG_DIR}/${TOOL_FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
||||
cd ${MG_DIR} && rm -rf ${MG_DIR}/${TOOL_FILE_NAME}
|
||||
|
||||
|
||||
#--------------- mongodb database install ------------------ #
|
||||
TOOL_VERSION=100.9.4
|
||||
TOOL_FILE_NAME=mongodb-database-tools-debian${SYS_NAME}-x86_64-${TOOL_VERSION}
|
||||
if [ "aarch64" == ${SYS_ARCH} ];then
|
||||
TOOL_FILE_NAME=mongodb-database-tools-debian${SYS_NAME}-arm64-${TOOL_VERSION}
|
||||
fi
|
||||
|
||||
if [ "arm64" == ${SYS_ARCH} ];then
|
||||
TOOL_FILE_NAME=mongodb-database-tools-debian${SYS_NAME}-arm64-${TOOL_VERSION}
|
||||
fi
|
||||
|
||||
TOOL_FILE_NAME_TGZ=${TOOL_FILE_NAME}.zip
|
||||
if [ ! -f $MG_DIR/${TOOL_FILE_NAME_TGZ} ]; then
|
||||
wget --no-check-certificate -O $MG_DIR/${TOOL_FILE_NAME_TGZ} https://fastdl.mongodb.org/tools/db/${TOOL_FILE_NAME_TGZ}
|
||||
fi
|
||||
|
||||
if [ ! -d $MG_DIR/${TOOL_FILE_NAME_TGZ} ];then
|
||||
cd $MG_DIR && tar -zxvf ${TOOL_FILE_NAME_TGZ}
|
||||
fi
|
||||
|
||||
cd ${MG_DIR}/${TOOL_FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
||||
cd ${MG_DIR} && rm -rf ${MG_DIR}/${TOOL_FILE_NAME}
|
||||
|
||||
@@ -26,4 +26,52 @@ fi
|
||||
if [ ! -d $serverPath/mongodb/bin ];then
|
||||
mkdir -p $serverPath/mongodb
|
||||
cd $MG_DIR/mongodb-macos-x86_64-${VERSION} && cp -rf ./bin $serverPath/mongodb
|
||||
fi
|
||||
fi
|
||||
|
||||
#--------------- mongosh tool install ------------------ #
|
||||
TOOL_VERSION=2.2.5
|
||||
TOOL_FILE_NAME=mongosh-${TOOL_VERSION}-darwin-x64
|
||||
if [ "aarch64" == ${SYS_ARCH} ];then
|
||||
TOOL_FILE_NAME=mongosh-${TOOL_VERSION}-darwin-arm64
|
||||
fi
|
||||
|
||||
if [ "arm64" == ${SYS_ARCH} ];then
|
||||
TOOL_FILE_NAME=mongosh-${TOOL_VERSION}-darwin-arm64
|
||||
fi
|
||||
TOOL_FILE_NAME_TGZ=${TOOL_FILE_NAME}.zip
|
||||
if [ ! -f $MG_DIR/${TOOL_FILE_NAME_TGZ} ]; then
|
||||
wget --no-check-certificate -O $MG_DIR/${TOOL_FILE_NAME_TGZ} https://downloads.mongodb.com/compass/${TOOL_FILE_NAME_TGZ}
|
||||
echo "wget --no-check-certificate -O $MG_DIR/${TOOL_FILE_NAME_TGZ} https://downloads.mongodb.com/compass/${TOOL_FILE_NAME_TGZ}"
|
||||
fi
|
||||
|
||||
if [ ! -d $MG_DIR/${TOOL_FILE_NAME_TGZ} ];then
|
||||
cd $MG_DIR && unzip ${TOOL_FILE_NAME_TGZ}
|
||||
fi
|
||||
|
||||
cd ${MG_DIR}/${TOOL_FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
||||
cd ${MG_DIR} && rm -rf ${MG_DIR}/${TOOL_FILE_NAME}
|
||||
|
||||
#--------------- mongodb-database-tools ------------------ #
|
||||
# https://fastdl.mongodb.org/tools/db/mongodb-database-tools-macos-arm64-100.9.4.zip
|
||||
TOOL_VERSION=100.9.4
|
||||
TOOL_FILE_NAME=mongodb-database-tools-macos-x86_64-${TOOL_VERSION}
|
||||
if [ "aarch64" == ${SYS_ARCH} ];then
|
||||
TOOL_FILE_NAME=mongodb-database-tools-macos-arm64-${TOOL_VERSION}
|
||||
fi
|
||||
|
||||
if [ "arm64" == ${SYS_ARCH} ];then
|
||||
TOOL_FILE_NAME=mongodb-database-tools-macos-arm64-${TOOL_VERSION}
|
||||
fi
|
||||
|
||||
TOOL_FILE_NAME_TGZ=${TOOL_FILE_NAME}.zip
|
||||
if [ ! -f $MG_DIR/${TOOL_FILE_NAME_TGZ} ]; then
|
||||
wget --no-check-certificate -O $MG_DIR/${TOOL_FILE_NAME_TGZ} https://fastdl.mongodb.org/tools/db/${TOOL_FILE_NAME_TGZ}
|
||||
echo "wget --no-check-certificate -O $MG_DIR/${TOOL_FILE_NAME_TGZ} https://fastdl.mongodb.org/tools/db/${TOOL_FILE_NAME_TGZ}"
|
||||
fi
|
||||
|
||||
if [ ! -d $MG_DIR/${TOOL_FILE_NAME_TGZ} ];then
|
||||
cd $MG_DIR && unzip ${TOOL_FILE_NAME_TGZ}
|
||||
fi
|
||||
|
||||
cd ${MG_DIR}/${TOOL_FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
||||
cd ${MG_DIR} && rm -rf ${MG_DIR}/${TOOL_FILE_NAME}
|
||||
@@ -46,4 +46,48 @@ if [ ! -d $serverPath/mongodb/bin ];then
|
||||
cd $MG_DIR/${FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
||||
fi
|
||||
|
||||
cd ${MG_DIR} && rm -rf ${MG_DIR}/${FILE_NAME}
|
||||
cd ${MG_DIR} && rm -rf ${MG_DIR}/${FILE_NAME}
|
||||
|
||||
#--------------- mongosh tool install ------------------ #
|
||||
TOOL_VERSION=2.2.5
|
||||
TOOL_FILE_NAME=mongosh-${TOOL_VERSION}-linux-x64
|
||||
if [ "aarch64" == ${SYS_ARCH} ];then
|
||||
TOOL_FILE_NAME=mongosh-${TOOL_VERSION}-linux-arm64
|
||||
fi
|
||||
TOOL_FILE_NAME_TGZ=${TOOL_FILE_NAME}.tgz
|
||||
if [ ! -f $MG_DIR/${TOOL_FILE_NAME_TGZ} ]; then
|
||||
wget --no-check-certificate -O $MG_DIR/${TOOL_FILE_NAME_TGZ} https://downloads.mongodb.com/compass/${TOOL_FILE_NAME_TGZ}
|
||||
echo "wget --no-check-certificate -O $MG_DIR/${TOOL_FILE_NAME_TGZ} https://downloads.mongodb.com/compass/${TOOL_FILE_NAME_TGZ}"
|
||||
fi
|
||||
|
||||
if [ ! -d $MG_DIR/${TOOL_FILE_NAME_TGZ} ];then
|
||||
cd $MG_DIR && tar -zxvf ${TOOL_FILE_NAME_TGZ}
|
||||
fi
|
||||
|
||||
cd ${MG_DIR}/${TOOL_FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
||||
cd ${MG_DIR} && rm -rf ${MG_DIR}/${TOOL_FILE_NAME}
|
||||
|
||||
|
||||
# https://fastdl.mongodb.org/tools/db/mongodb-database-tools-suse12-x86_64-100.9.4.tgz
|
||||
#--------------- mongodb database install ------------------ #
|
||||
TOOL_VERSION=100.9.4
|
||||
TOOL_FILE_NAME=mongodb-database-tools-suse${SYS_NAME}-x86_64-${TOOL_VERSION}
|
||||
if [ "aarch64" == ${SYS_ARCH} ];then
|
||||
TOOL_FILE_NAME=mongodb-database-tools-suse${SYS_NAME}-arm64-${TOOL_VERSION}
|
||||
fi
|
||||
|
||||
if [ "arm64" == ${SYS_ARCH} ];then
|
||||
TOOL_FILE_NAME=mongodb-database-tools-suse${SYS_NAME}-arm64-${TOOL_VERSION}
|
||||
fi
|
||||
|
||||
TOOL_FILE_NAME_TGZ=${TOOL_FILE_NAME}.tgz
|
||||
if [ ! -f $MG_DIR/${TOOL_FILE_NAME_TGZ} ]; then
|
||||
wget --no-check-certificate -O $MG_DIR/${TOOL_FILE_NAME_TGZ} https://fastdl.mongodb.org/tools/db/${TOOL_FILE_NAME_TGZ}
|
||||
fi
|
||||
|
||||
if [ ! -d $MG_DIR/${TOOL_FILE_NAME_TGZ} ];then
|
||||
cd $MG_DIR && tar -zxvf ${TOOL_FILE_NAME_TGZ}
|
||||
fi
|
||||
|
||||
cd ${MG_DIR}/${TOOL_FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
||||
cd ${MG_DIR} && rm -rf ${MG_DIR}/${TOOL_FILE_NAME}
|
||||
@@ -42,4 +42,23 @@ if [ ! -d $serverPath/mongodb/bin ];then
|
||||
cd $MG_DIR/${FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
||||
fi
|
||||
|
||||
cd ${MG_DIR} && rm -rf ${MG_DIR}/${FILE_NAME}
|
||||
cd ${MG_DIR} && rm -rf ${MG_DIR}/${FILE_NAME}
|
||||
|
||||
#--------------- mongosh tool install ------------------ #
|
||||
TOOL_VERSION=2.2.5
|
||||
TOOL_FILE_NAME=mongosh-${TOOL_VERSION}-linux-x64
|
||||
if [ "aarch64" == ${SYS_ARCH} ];then
|
||||
TOOL_FILE_NAME=mongosh-${TOOL_VERSION}-linux-arm64
|
||||
fi
|
||||
TOOL_FILE_NAME_TGZ=${TOOL_FILE_NAME}.tgz
|
||||
if [ ! -f $MG_DIR/${TOOL_FILE_NAME_TGZ} ]; then
|
||||
wget --no-check-certificate -O $MG_DIR/${TOOL_FILE_NAME_TGZ} https://downloads.mongodb.com/compass/${TOOL_FILE_NAME_TGZ}
|
||||
echo "wget --no-check-certificate -O $MG_DIR/${TOOL_FILE_NAME_TGZ} https://downloads.mongodb.com/compass/${TOOL_FILE_NAME_TGZ}"
|
||||
fi
|
||||
|
||||
if [ ! -d $MG_DIR/${TOOL_FILE_NAME_TGZ} ];then
|
||||
cd $MG_DIR && tar -zxvf ${TOOL_FILE_NAME_TGZ}
|
||||
fi
|
||||
|
||||
cd ${MG_DIR}/${TOOL_FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
||||
cd ${MG_DIR} && rm -rf ${MG_DIR}/${TOOL_FILE_NAME}
|
||||
@@ -44,4 +44,47 @@ if [ ! -d $serverPath/mongodb/bin ];then
|
||||
cd $MG_DIR/${FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
||||
fi
|
||||
|
||||
cd ${MG_DIR} && rm -rf ${MG_DIR}/${FILE_NAME}
|
||||
cd ${MG_DIR} && rm -rf ${MG_DIR}/${FILE_NAME}
|
||||
|
||||
#--------------- mongosh tool install ------------------ #
|
||||
TOOL_VERSION=2.2.5
|
||||
TOOL_FILE_NAME=mongosh-${TOOL_VERSION}-linux-x64
|
||||
if [ "aarch64" == ${SYS_ARCH} ];then
|
||||
TOOL_FILE_NAME=mongosh-${TOOL_VERSION}-linux-arm64
|
||||
fi
|
||||
TOOL_FILE_NAME_TGZ=${TOOL_FILE_NAME}.tgz
|
||||
if [ ! -f $MG_DIR/${TOOL_FILE_NAME_TGZ} ]; then
|
||||
wget --no-check-certificate -O $MG_DIR/${TOOL_FILE_NAME_TGZ} https://downloads.mongodb.com/compass/${TOOL_FILE_NAME_TGZ}
|
||||
echo "wget --no-check-certificate -O $MG_DIR/${TOOL_FILE_NAME_TGZ} https://downloads.mongodb.com/compass/${TOOL_FILE_NAME_TGZ}"
|
||||
fi
|
||||
|
||||
if [ ! -d $MG_DIR/${TOOL_FILE_NAME_TGZ} ];then
|
||||
cd $MG_DIR && tar -zxvf ${TOOL_FILE_NAME_TGZ}
|
||||
fi
|
||||
|
||||
cd ${MG_DIR}/${TOOL_FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
||||
cd ${MG_DIR} && rm -rf ${MG_DIR}/${TOOL_FILE_NAME}
|
||||
|
||||
# https://fastdl.mongodb.org/tools/db/mongodb-database-tools-ubuntu2204-x86_64-100.9.4.tgz
|
||||
#--------------- mongodb database install ------------------ #
|
||||
TOOL_VERSION=100.9.4
|
||||
TOOL_FILE_NAME=mongodb-database-tools-ubuntu${SYS_NAME}-x86_64-${TOOL_VERSION}
|
||||
if [ "aarch64" == ${SYS_ARCH} ];then
|
||||
TOOL_FILE_NAME=mongodb-database-tools-ubuntu${SYS_NAME}-arm64-${TOOL_VERSION}
|
||||
fi
|
||||
|
||||
if [ "arm64" == ${SYS_ARCH} ];then
|
||||
TOOL_FILE_NAME=mongodb-database-tools-ubuntu${SYS_NAME}-arm64-${TOOL_VERSION}
|
||||
fi
|
||||
|
||||
TOOL_FILE_NAME_TGZ=${TOOL_FILE_NAME}.tgz
|
||||
if [ ! -f $MG_DIR/${TOOL_FILE_NAME_TGZ} ]; then
|
||||
wget --no-check-certificate -O $MG_DIR/${TOOL_FILE_NAME_TGZ} https://fastdl.mongodb.org/tools/db/${TOOL_FILE_NAME_TGZ}
|
||||
fi
|
||||
|
||||
if [ ! -d $MG_DIR/${TOOL_FILE_NAME_TGZ} ];then
|
||||
cd $MG_DIR && tar -zxvf ${TOOL_FILE_NAME_TGZ}
|
||||
fi
|
||||
|
||||
cd ${MG_DIR}/${TOOL_FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
||||
cd ${MG_DIR} && rm -rf ${MG_DIR}/${TOOL_FILE_NAME}
|
||||
@@ -54,3 +54,45 @@ if [ ! -d $serverPath/mongodb/bin ];then
|
||||
fi
|
||||
|
||||
cd ${MG_DIR} && rm -rf ${MG_DIR}/${FILE_NAME}
|
||||
|
||||
#--------------- mongosh tool install ------------------ #
|
||||
TOOL_VERSION=2.2.5
|
||||
TOOL_FILE_NAME=mongosh-${TOOL_VERSION}-linux-x64
|
||||
if [ "aarch64" == ${SYS_ARCH} ];then
|
||||
TOOL_FILE_NAME=mongosh-${TOOL_VERSION}-linux-arm64
|
||||
fi
|
||||
TOOL_FILE_NAME_TGZ=${TOOL_FILE_NAME}.tgz
|
||||
if [ ! -f $MG_DIR/${TOOL_FILE_NAME_TGZ} ]; then
|
||||
wget --no-check-certificate -O $MG_DIR/${TOOL_FILE_NAME_TGZ} https://downloads.mongodb.com/compass/${TOOL_FILE_NAME_TGZ}
|
||||
echo "wget --no-check-certificate -O $MG_DIR/${TOOL_FILE_NAME_TGZ} https://downloads.mongodb.com/compass/${TOOL_FILE_NAME_TGZ}"
|
||||
fi
|
||||
|
||||
if [ ! -d $MG_DIR/${TOOL_FILE_NAME_TGZ} ];then
|
||||
cd $MG_DIR && tar -zxvf ${TOOL_FILE_NAME_TGZ}
|
||||
fi
|
||||
|
||||
cd ${MG_DIR}/${TOOL_FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
||||
cd ${MG_DIR} && rm -rf ${MG_DIR}/${TOOL_FILE_NAME}
|
||||
|
||||
#--------------- mongodb database install ------------------ #
|
||||
TOOL_VERSION=100.9.4
|
||||
TOOL_FILE_NAME=mongodb-database-tools-rhel${SYS_NAME}-x86_64-${TOOL_VERSION}
|
||||
if [ "aarch64" == ${SYS_ARCH} ];then
|
||||
TOOL_FILE_NAME=mongodb-database-tools-rhel${SYS_NAME}-aarch64-${TOOL_VERSION}
|
||||
fi
|
||||
|
||||
if [ "arm64" == ${SYS_ARCH} ];then
|
||||
TOOL_FILE_NAME=mongodb-database-tools-rhel${SYS_NAME}-arm64-${TOOL_VERSION}
|
||||
fi
|
||||
|
||||
TOOL_FILE_NAME_TGZ=${TOOL_FILE_NAME}.tgz
|
||||
if [ ! -f $MG_DIR/${TOOL_FILE_NAME_TGZ} ]; then
|
||||
wget --no-check-certificate -O $MG_DIR/${TOOL_FILE_NAME_TGZ} https://fastdl.mongodb.org/tools/db/${TOOL_FILE_NAME_TGZ}
|
||||
fi
|
||||
|
||||
if [ ! -d $MG_DIR/${TOOL_FILE_NAME_TGZ} ];then
|
||||
cd $MG_DIR && tar -zxvf ${TOOL_FILE_NAME_TGZ}
|
||||
fi
|
||||
|
||||
cd ${MG_DIR}/${TOOL_FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
||||
cd ${MG_DIR} && rm -rf ${MG_DIR}/${TOOL_FILE_NAME}
|
||||
|
||||
@@ -44,3 +44,45 @@ if [ ! -d $serverPath/mongodb/bin ];then
|
||||
fi
|
||||
|
||||
cd ${MG_DIR} && rm -rf ${MG_DIR}/${FILE_NAME}
|
||||
|
||||
#--------------- mongosh tool install ------------------ #
|
||||
TOOL_VERSION=2.2.5
|
||||
TOOL_FILE_NAME=mongosh-${TOOL_VERSION}-linux-x64
|
||||
if [ "aarch64" == ${SYS_ARCH} ];then
|
||||
TOOL_FILE_NAME=mongosh-${TOOL_VERSION}-linux-arm64
|
||||
fi
|
||||
TOOL_FILE_NAME_TGZ=${TOOL_FILE_NAME}.tgz
|
||||
if [ ! -f $MG_DIR/${TOOL_FILE_NAME_TGZ} ]; then
|
||||
wget --no-check-certificate -O $MG_DIR/${TOOL_FILE_NAME_TGZ} https://downloads.mongodb.com/compass/${TOOL_FILE_NAME_TGZ}
|
||||
echo "wget --no-check-certificate -O $MG_DIR/${TOOL_FILE_NAME_TGZ} https://downloads.mongodb.com/compass/${TOOL_FILE_NAME_TGZ}"
|
||||
fi
|
||||
|
||||
if [ ! -d $MG_DIR/${TOOL_FILE_NAME_TGZ} ];then
|
||||
cd $MG_DIR && tar -zxvf ${TOOL_FILE_NAME_TGZ}
|
||||
fi
|
||||
|
||||
cd ${MG_DIR}/${TOOL_FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
||||
cd ${MG_DIR} && rm -rf ${MG_DIR}/${TOOL_FILE_NAME}
|
||||
|
||||
#--------------- mongodb database install ------------------ #
|
||||
TOOL_VERSION=100.9.4
|
||||
TOOL_FILE_NAME=mongodb-database-tools-debian${SYS_NAME}-x86_64-${TOOL_VERSION}
|
||||
if [ "aarch64" == ${SYS_ARCH} ];then
|
||||
TOOL_FILE_NAME=mongodb-database-tools-debian${SYS_NAME}-arm64-${TOOL_VERSION}
|
||||
fi
|
||||
|
||||
if [ "arm64" == ${SYS_ARCH} ];then
|
||||
TOOL_FILE_NAME=mongodb-database-tools-debian${SYS_NAME}-arm64-${TOOL_VERSION}
|
||||
fi
|
||||
|
||||
TOOL_FILE_NAME_TGZ=${TOOL_FILE_NAME}.zip
|
||||
if [ ! -f $MG_DIR/${TOOL_FILE_NAME_TGZ} ]; then
|
||||
wget --no-check-certificate -O $MG_DIR/${TOOL_FILE_NAME_TGZ} https://fastdl.mongodb.org/tools/db/${TOOL_FILE_NAME_TGZ}
|
||||
fi
|
||||
|
||||
if [ ! -d $MG_DIR/${TOOL_FILE_NAME_TGZ} ];then
|
||||
cd $MG_DIR && tar -zxvf ${TOOL_FILE_NAME_TGZ}
|
||||
fi
|
||||
|
||||
cd ${MG_DIR}/${TOOL_FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
||||
cd ${MG_DIR} && rm -rf ${MG_DIR}/${TOOL_FILE_NAME}
|
||||
|
||||
@@ -26,4 +26,52 @@ fi
|
||||
if [ ! -d $serverPath/mongodb/bin ];then
|
||||
mkdir -p $serverPath/mongodb
|
||||
cd $MG_DIR/mongodb-macos-x86_64-${VERSION} && cp -rf ./bin $serverPath/mongodb
|
||||
fi
|
||||
fi
|
||||
|
||||
#--------------- mongosh tool install ------------------ #
|
||||
TOOL_VERSION=2.2.5
|
||||
TOOL_FILE_NAME=mongosh-${TOOL_VERSION}-darwin-x64
|
||||
if [ "aarch64" == ${SYS_ARCH} ];then
|
||||
TOOL_FILE_NAME=mongosh-${TOOL_VERSION}-darwin-arm64
|
||||
fi
|
||||
|
||||
if [ "arm64" == ${SYS_ARCH} ];then
|
||||
TOOL_FILE_NAME=mongosh-${TOOL_VERSION}-darwin-arm64
|
||||
fi
|
||||
TOOL_FILE_NAME_TGZ=${TOOL_FILE_NAME}.zip
|
||||
if [ ! -f $MG_DIR/${TOOL_FILE_NAME_TGZ} ]; then
|
||||
wget --no-check-certificate -O $MG_DIR/${TOOL_FILE_NAME_TGZ} https://downloads.mongodb.com/compass/${TOOL_FILE_NAME_TGZ}
|
||||
echo "wget --no-check-certificate -O $MG_DIR/${TOOL_FILE_NAME_TGZ} https://downloads.mongodb.com/compass/${TOOL_FILE_NAME_TGZ}"
|
||||
fi
|
||||
|
||||
if [ ! -d $MG_DIR/${TOOL_FILE_NAME_TGZ} ];then
|
||||
cd $MG_DIR && unzip ${TOOL_FILE_NAME_TGZ}
|
||||
fi
|
||||
|
||||
cd ${MG_DIR}/${TOOL_FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
||||
cd ${MG_DIR} && rm -rf ${MG_DIR}/${TOOL_FILE_NAME}
|
||||
|
||||
#--------------- mongodb-database-tools ------------------ #
|
||||
# https://fastdl.mongodb.org/tools/db/mongodb-database-tools-macos-arm64-100.9.4.zip
|
||||
TOOL_VERSION=100.9.4
|
||||
TOOL_FILE_NAME=mongodb-database-tools-macos-x86_64-${TOOL_VERSION}
|
||||
if [ "aarch64" == ${SYS_ARCH} ];then
|
||||
TOOL_FILE_NAME=mongodb-database-tools-macos-arm64-${TOOL_VERSION}
|
||||
fi
|
||||
|
||||
if [ "arm64" == ${SYS_ARCH} ];then
|
||||
TOOL_FILE_NAME=mongodb-database-tools-macos-arm64-${TOOL_VERSION}
|
||||
fi
|
||||
|
||||
TOOL_FILE_NAME_TGZ=${TOOL_FILE_NAME}.zip
|
||||
if [ ! -f $MG_DIR/${TOOL_FILE_NAME_TGZ} ]; then
|
||||
wget --no-check-certificate -O $MG_DIR/${TOOL_FILE_NAME_TGZ} https://fastdl.mongodb.org/tools/db/${TOOL_FILE_NAME_TGZ}
|
||||
echo "wget --no-check-certificate -O $MG_DIR/${TOOL_FILE_NAME_TGZ} https://fastdl.mongodb.org/tools/db/${TOOL_FILE_NAME_TGZ}"
|
||||
fi
|
||||
|
||||
if [ ! -d $MG_DIR/${TOOL_FILE_NAME_TGZ} ];then
|
||||
cd $MG_DIR && unzip ${TOOL_FILE_NAME_TGZ}
|
||||
fi
|
||||
|
||||
cd ${MG_DIR}/${TOOL_FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
||||
cd ${MG_DIR} && rm -rf ${MG_DIR}/${TOOL_FILE_NAME}
|
||||
@@ -47,3 +47,46 @@ if [ ! -d $serverPath/mongodb/bin ];then
|
||||
fi
|
||||
|
||||
cd ${MG_DIR} && rm -rf ${MG_DIR}/${FILE_NAME}
|
||||
|
||||
#--------------- mongosh tool install ------------------ #
|
||||
TOOL_VERSION=2.2.5
|
||||
TOOL_FILE_NAME=mongosh-${TOOL_VERSION}-linux-x64
|
||||
if [ "aarch64" == ${SYS_ARCH} ];then
|
||||
TOOL_FILE_NAME=mongosh-${TOOL_VERSION}-linux-arm64
|
||||
fi
|
||||
TOOL_FILE_NAME_TGZ=${TOOL_FILE_NAME}.tgz
|
||||
if [ ! -f $MG_DIR/${TOOL_FILE_NAME_TGZ} ]; then
|
||||
wget --no-check-certificate -O $MG_DIR/${TOOL_FILE_NAME_TGZ} https://downloads.mongodb.com/compass/${TOOL_FILE_NAME_TGZ}
|
||||
echo "wget --no-check-certificate -O $MG_DIR/${TOOL_FILE_NAME_TGZ} https://downloads.mongodb.com/compass/${TOOL_FILE_NAME_TGZ}"
|
||||
fi
|
||||
|
||||
if [ ! -d $MG_DIR/${TOOL_FILE_NAME_TGZ} ];then
|
||||
cd $MG_DIR && tar -zxvf ${TOOL_FILE_NAME_TGZ}
|
||||
fi
|
||||
|
||||
cd ${MG_DIR}/${TOOL_FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
||||
cd ${MG_DIR} && rm -rf ${MG_DIR}/${TOOL_FILE_NAME}
|
||||
|
||||
# https://fastdl.mongodb.org/tools/db/mongodb-database-tools-suse12-x86_64-100.9.4.tgz
|
||||
#--------------- mongodb database install ------------------ #
|
||||
TOOL_VERSION=100.9.4
|
||||
TOOL_FILE_NAME=mongodb-database-tools-suse${SYS_NAME}-x86_64-${TOOL_VERSION}
|
||||
if [ "aarch64" == ${SYS_ARCH} ];then
|
||||
TOOL_FILE_NAME=mongodb-database-tools-suse${SYS_NAME}-arm64-${TOOL_VERSION}
|
||||
fi
|
||||
|
||||
if [ "arm64" == ${SYS_ARCH} ];then
|
||||
TOOL_FILE_NAME=mongodb-database-tools-suse${SYS_NAME}-arm64-${TOOL_VERSION}
|
||||
fi
|
||||
|
||||
TOOL_FILE_NAME_TGZ=${TOOL_FILE_NAME}.tgz
|
||||
if [ ! -f $MG_DIR/${TOOL_FILE_NAME_TGZ} ]; then
|
||||
wget --no-check-certificate -O $MG_DIR/${TOOL_FILE_NAME_TGZ} https://fastdl.mongodb.org/tools/db/${TOOL_FILE_NAME_TGZ}
|
||||
fi
|
||||
|
||||
if [ ! -d $MG_DIR/${TOOL_FILE_NAME_TGZ} ];then
|
||||
cd $MG_DIR && tar -zxvf ${TOOL_FILE_NAME_TGZ}
|
||||
fi
|
||||
|
||||
cd ${MG_DIR}/${TOOL_FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
||||
cd ${MG_DIR} && rm -rf ${MG_DIR}/${TOOL_FILE_NAME}
|
||||
|
||||
@@ -46,3 +46,46 @@ fi
|
||||
|
||||
cd ${MG_DIR} && rm -rf ${MG_DIR}/${FILE_NAME}
|
||||
|
||||
#--------------- mongosh tool install ------------------ #
|
||||
TOOL_VERSION=2.2.5
|
||||
TOOL_FILE_NAME=mongosh-${TOOL_VERSION}-linux-x64
|
||||
if [ "aarch64" == ${SYS_ARCH} ];then
|
||||
TOOL_FILE_NAME=mongosh-${TOOL_VERSION}-linux-arm64
|
||||
fi
|
||||
TOOL_FILE_NAME_TGZ=${TOOL_FILE_NAME}.tgz
|
||||
if [ ! -f $MG_DIR/${TOOL_FILE_NAME_TGZ} ]; then
|
||||
wget --no-check-certificate -O $MG_DIR/${TOOL_FILE_NAME_TGZ} https://downloads.mongodb.com/compass/${TOOL_FILE_NAME_TGZ}
|
||||
echo "wget --no-check-certificate -O $MG_DIR/${TOOL_FILE_NAME_TGZ} https://downloads.mongodb.com/compass/${TOOL_FILE_NAME_TGZ}"
|
||||
fi
|
||||
|
||||
if [ ! -d $MG_DIR/${TOOL_FILE_NAME_TGZ} ];then
|
||||
cd $MG_DIR && tar -zxvf ${TOOL_FILE_NAME_TGZ}
|
||||
fi
|
||||
|
||||
cd ${MG_DIR}/${TOOL_FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
||||
cd ${MG_DIR} && rm -rf ${MG_DIR}/${TOOL_FILE_NAME}
|
||||
|
||||
# https://fastdl.mongodb.org/tools/db/mongodb-database-tools-ubuntu2204-x86_64-100.9.4.tgz
|
||||
#--------------- mongodb database install ------------------ #
|
||||
TOOL_VERSION=100.9.4
|
||||
TOOL_FILE_NAME=mongodb-database-tools-ubuntu${SYS_NAME}-x86_64-${TOOL_VERSION}
|
||||
if [ "aarch64" == ${SYS_ARCH} ];then
|
||||
TOOL_FILE_NAME=mongodb-database-tools-ubuntu${SYS_NAME}-arm64-${TOOL_VERSION}
|
||||
fi
|
||||
|
||||
if [ "arm64" == ${SYS_ARCH} ];then
|
||||
TOOL_FILE_NAME=mongodb-database-tools-ubuntu${SYS_NAME}-arm64-${TOOL_VERSION}
|
||||
fi
|
||||
|
||||
TOOL_FILE_NAME_TGZ=${TOOL_FILE_NAME}.tgz
|
||||
if [ ! -f $MG_DIR/${TOOL_FILE_NAME_TGZ} ]; then
|
||||
wget --no-check-certificate -O $MG_DIR/${TOOL_FILE_NAME_TGZ} https://fastdl.mongodb.org/tools/db/${TOOL_FILE_NAME_TGZ}
|
||||
fi
|
||||
|
||||
if [ ! -d $MG_DIR/${TOOL_FILE_NAME_TGZ} ];then
|
||||
cd $MG_DIR && tar -zxvf ${TOOL_FILE_NAME_TGZ}
|
||||
fi
|
||||
|
||||
cd ${MG_DIR}/${TOOL_FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
||||
cd ${MG_DIR} && rm -rf ${MG_DIR}/${TOOL_FILE_NAME}
|
||||
|
||||
|
||||
@@ -59,4 +59,48 @@ if [ ! -d $serverPath/mongodb/bin ];then
|
||||
cd $MG_DIR/${FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
||||
fi
|
||||
|
||||
rm -rf ${MG_DIR}/${FILE_NAME}
|
||||
rm -rf ${MG_DIR}/${FILE_NAME}
|
||||
|
||||
|
||||
#--------------- mongosh tool install ------------------ #
|
||||
TOOL_VERSION=2.2.5
|
||||
TOOL_FILE_NAME=mongosh-${TOOL_VERSION}-linux-x64
|
||||
if [ "aarch64" == ${SYS_ARCH} ];then
|
||||
TOOL_FILE_NAME=mongosh-${TOOL_VERSION}-linux-arm64
|
||||
fi
|
||||
TOOL_FILE_NAME_TGZ=${TOOL_FILE_NAME}.tgz
|
||||
if [ ! -f $MG_DIR/${TOOL_FILE_NAME_TGZ} ]; then
|
||||
wget --no-check-certificate -O $MG_DIR/${TOOL_FILE_NAME_TGZ} https://downloads.mongodb.com/compass/${TOOL_FILE_NAME_TGZ}
|
||||
echo "wget --no-check-certificate -O $MG_DIR/${TOOL_FILE_NAME_TGZ} https://downloads.mongodb.com/compass/${TOOL_FILE_NAME_TGZ}"
|
||||
fi
|
||||
|
||||
if [ ! -d $MG_DIR/${TOOL_FILE_NAME_TGZ} ];then
|
||||
cd $MG_DIR && tar -zxvf ${TOOL_FILE_NAME_TGZ}
|
||||
fi
|
||||
|
||||
cd ${MG_DIR}/${TOOL_FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
||||
cd ${MG_DIR} && rm -rf ${MG_DIR}/${TOOL_FILE_NAME}
|
||||
|
||||
|
||||
#--------------- mongodb database install ------------------ #
|
||||
TOOL_VERSION=100.9.4
|
||||
TOOL_FILE_NAME=mongodb-database-tools-rhel${SYS_NAME}-x86_64-${TOOL_VERSION}
|
||||
if [ "aarch64" == ${SYS_ARCH} ];then
|
||||
TOOL_FILE_NAME=mongodb-database-tools-rhel${SYS_NAME}-aarch64-${TOOL_VERSION}
|
||||
fi
|
||||
|
||||
if [ "arm64" == ${SYS_ARCH} ];then
|
||||
TOOL_FILE_NAME=mongodb-database-tools-rhel${SYS_NAME}-arm64-${TOOL_VERSION}
|
||||
fi
|
||||
|
||||
TOOL_FILE_NAME_TGZ=${TOOL_FILE_NAME}.tgz
|
||||
if [ ! -f $MG_DIR/${TOOL_FILE_NAME_TGZ} ]; then
|
||||
wget --no-check-certificate -O $MG_DIR/${TOOL_FILE_NAME_TGZ} https://fastdl.mongodb.org/tools/db/${TOOL_FILE_NAME_TGZ}
|
||||
fi
|
||||
|
||||
if [ ! -d $MG_DIR/${TOOL_FILE_NAME_TGZ} ];then
|
||||
cd $MG_DIR && tar -zxvf ${TOOL_FILE_NAME_TGZ}
|
||||
fi
|
||||
|
||||
cd ${MG_DIR}/${TOOL_FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
||||
cd ${MG_DIR} && rm -rf ${MG_DIR}/${TOOL_FILE_NAME}
|
||||
@@ -45,3 +45,46 @@ fi
|
||||
|
||||
cd ${MG_DIR} && rm -rf ${MG_DIR}/${FILE_NAME}
|
||||
|
||||
#--------------- mongosh tool install ------------------ #
|
||||
TOOL_VERSION=2.2.5
|
||||
TOOL_FILE_NAME=mongosh-${TOOL_VERSION}-linux-x64
|
||||
if [ "aarch64" == ${SYS_ARCH} ];then
|
||||
TOOL_FILE_NAME=mongosh-${TOOL_VERSION}-linux-arm64
|
||||
fi
|
||||
TOOL_FILE_NAME_TGZ=${TOOL_FILE_NAME}.tgz
|
||||
if [ ! -f $MG_DIR/${TOOL_FILE_NAME_TGZ} ]; then
|
||||
wget --no-check-certificate -O $MG_DIR/${TOOL_FILE_NAME_TGZ} https://downloads.mongodb.com/compass/${TOOL_FILE_NAME_TGZ}
|
||||
echo "wget --no-check-certificate -O $MG_DIR/${TOOL_FILE_NAME_TGZ} https://downloads.mongodb.com/compass/${TOOL_FILE_NAME_TGZ}"
|
||||
fi
|
||||
|
||||
if [ ! -d $MG_DIR/${TOOL_FILE_NAME_TGZ} ];then
|
||||
cd $MG_DIR && tar -zxvf ${TOOL_FILE_NAME_TGZ}
|
||||
fi
|
||||
|
||||
cd ${MG_DIR}/${TOOL_FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
||||
cd ${MG_DIR} && rm -rf ${MG_DIR}/${TOOL_FILE_NAME}
|
||||
|
||||
|
||||
#--------------- mongodb database install ------------------ #
|
||||
TOOL_VERSION=100.9.4
|
||||
TOOL_FILE_NAME=mongodb-database-tools-debian${SYS_NAME}-x86_64-${TOOL_VERSION}
|
||||
if [ "aarch64" == ${SYS_ARCH} ];then
|
||||
TOOL_FILE_NAME=mongodb-database-tools-debian${SYS_NAME}-arm64-${TOOL_VERSION}
|
||||
fi
|
||||
|
||||
if [ "arm64" == ${SYS_ARCH} ];then
|
||||
TOOL_FILE_NAME=mongodb-database-tools-debian${SYS_NAME}-arm64-${TOOL_VERSION}
|
||||
fi
|
||||
|
||||
TOOL_FILE_NAME_TGZ=${TOOL_FILE_NAME}.zip
|
||||
if [ ! -f $MG_DIR/${TOOL_FILE_NAME_TGZ} ]; then
|
||||
wget --no-check-certificate -O $MG_DIR/${TOOL_FILE_NAME_TGZ} https://fastdl.mongodb.org/tools/db/${TOOL_FILE_NAME_TGZ}
|
||||
fi
|
||||
|
||||
if [ ! -d $MG_DIR/${TOOL_FILE_NAME_TGZ} ];then
|
||||
cd $MG_DIR && tar -zxvf ${TOOL_FILE_NAME_TGZ}
|
||||
fi
|
||||
|
||||
cd ${MG_DIR}/${TOOL_FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
||||
cd ${MG_DIR} && rm -rf ${MG_DIR}/${TOOL_FILE_NAME}
|
||||
|
||||
|
||||
@@ -26,4 +26,52 @@ fi
|
||||
if [ ! -d $serverPath/mongodb/bin ];then
|
||||
mkdir -p $serverPath/mongodb
|
||||
cd $MG_DIR/mongodb-macos-x86_64-${VERSION} && cp -rf ./bin $serverPath/mongodb
|
||||
fi
|
||||
fi
|
||||
|
||||
#--------------- mongosh tool install ------------------ #
|
||||
TOOL_VERSION=2.2.5
|
||||
TOOL_FILE_NAME=mongosh-${TOOL_VERSION}-darwin-x64
|
||||
if [ "aarch64" == ${SYS_ARCH} ];then
|
||||
TOOL_FILE_NAME=mongosh-${TOOL_VERSION}-darwin-arm64
|
||||
fi
|
||||
|
||||
if [ "arm64" == ${SYS_ARCH} ];then
|
||||
TOOL_FILE_NAME=mongosh-${TOOL_VERSION}-darwin-arm64
|
||||
fi
|
||||
TOOL_FILE_NAME_TGZ=${TOOL_FILE_NAME}.zip
|
||||
if [ ! -f $MG_DIR/${TOOL_FILE_NAME_TGZ} ]; then
|
||||
wget --no-check-certificate -O $MG_DIR/${TOOL_FILE_NAME_TGZ} https://downloads.mongodb.com/compass/${TOOL_FILE_NAME_TGZ}
|
||||
echo "wget --no-check-certificate -O $MG_DIR/${TOOL_FILE_NAME_TGZ} https://downloads.mongodb.com/compass/${TOOL_FILE_NAME_TGZ}"
|
||||
fi
|
||||
|
||||
if [ ! -d $MG_DIR/${TOOL_FILE_NAME_TGZ} ];then
|
||||
cd $MG_DIR && unzip ${TOOL_FILE_NAME_TGZ}
|
||||
fi
|
||||
|
||||
cd ${MG_DIR}/${TOOL_FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
||||
cd ${MG_DIR} && rm -rf ${MG_DIR}/${TOOL_FILE_NAME}
|
||||
|
||||
#--------------- mongodb-database-tools ------------------ #
|
||||
# https://fastdl.mongodb.org/tools/db/mongodb-database-tools-macos-arm64-100.9.4.zip
|
||||
TOOL_VERSION=100.9.4
|
||||
TOOL_FILE_NAME=mongodb-database-tools-macos-x86_64-${TOOL_VERSION}
|
||||
if [ "aarch64" == ${SYS_ARCH} ];then
|
||||
TOOL_FILE_NAME=mongodb-database-tools-macos-arm64-${TOOL_VERSION}
|
||||
fi
|
||||
|
||||
if [ "arm64" == ${SYS_ARCH} ];then
|
||||
TOOL_FILE_NAME=mongodb-database-tools-macos-arm64-${TOOL_VERSION}
|
||||
fi
|
||||
|
||||
TOOL_FILE_NAME_TGZ=${TOOL_FILE_NAME}.zip
|
||||
if [ ! -f $MG_DIR/${TOOL_FILE_NAME_TGZ} ]; then
|
||||
wget --no-check-certificate -O $MG_DIR/${TOOL_FILE_NAME_TGZ} https://fastdl.mongodb.org/tools/db/${TOOL_FILE_NAME_TGZ}
|
||||
echo "wget --no-check-certificate -O $MG_DIR/${TOOL_FILE_NAME_TGZ} https://fastdl.mongodb.org/tools/db/${TOOL_FILE_NAME_TGZ}"
|
||||
fi
|
||||
|
||||
if [ ! -d $MG_DIR/${TOOL_FILE_NAME_TGZ} ];then
|
||||
cd $MG_DIR && unzip ${TOOL_FILE_NAME_TGZ}
|
||||
fi
|
||||
|
||||
cd ${MG_DIR}/${TOOL_FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
||||
cd ${MG_DIR} && rm -rf ${MG_DIR}/${TOOL_FILE_NAME}
|
||||
@@ -48,3 +48,46 @@ fi
|
||||
|
||||
cd ${MG_DIR} && rm -rf ${MG_DIR}/${FILE_NAME}
|
||||
|
||||
#--------------- mongosh tool install ------------------ #
|
||||
TOOL_VERSION=2.2.5
|
||||
TOOL_FILE_NAME=mongosh-${TOOL_VERSION}-linux-x64
|
||||
if [ "aarch64" == ${SYS_ARCH} ];then
|
||||
TOOL_FILE_NAME=mongosh-${TOOL_VERSION}-linux-arm64
|
||||
fi
|
||||
TOOL_FILE_NAME_TGZ=${TOOL_FILE_NAME}.tgz
|
||||
if [ ! -f $MG_DIR/${TOOL_FILE_NAME_TGZ} ]; then
|
||||
wget --no-check-certificate -O $MG_DIR/${TOOL_FILE_NAME_TGZ} https://downloads.mongodb.com/compass/${TOOL_FILE_NAME_TGZ}
|
||||
echo "wget --no-check-certificate -O $MG_DIR/${TOOL_FILE_NAME_TGZ} https://downloads.mongodb.com/compass/${TOOL_FILE_NAME_TGZ}"
|
||||
fi
|
||||
|
||||
if [ ! -d $MG_DIR/${TOOL_FILE_NAME_TGZ} ];then
|
||||
cd $MG_DIR && tar -zxvf ${TOOL_FILE_NAME_TGZ}
|
||||
fi
|
||||
|
||||
cd ${MG_DIR}/${TOOL_FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
||||
cd ${MG_DIR} && rm -rf ${MG_DIR}/${TOOL_FILE_NAME}
|
||||
|
||||
# https://fastdl.mongodb.org/tools/db/mongodb-database-tools-suse12-x86_64-100.9.4.tgz
|
||||
#--------------- mongodb database install ------------------ #
|
||||
TOOL_VERSION=100.9.4
|
||||
TOOL_FILE_NAME=mongodb-database-tools-suse${SYS_NAME}-x86_64-${TOOL_VERSION}
|
||||
if [ "aarch64" == ${SYS_ARCH} ];then
|
||||
TOOL_FILE_NAME=mongodb-database-tools-suse${SYS_NAME}-arm64-${TOOL_VERSION}
|
||||
fi
|
||||
|
||||
if [ "arm64" == ${SYS_ARCH} ];then
|
||||
TOOL_FILE_NAME=mongodb-database-tools-suse${SYS_NAME}-arm64-${TOOL_VERSION}
|
||||
fi
|
||||
|
||||
TOOL_FILE_NAME_TGZ=${TOOL_FILE_NAME}.tgz
|
||||
if [ ! -f $MG_DIR/${TOOL_FILE_NAME_TGZ} ]; then
|
||||
wget --no-check-certificate -O $MG_DIR/${TOOL_FILE_NAME_TGZ} https://fastdl.mongodb.org/tools/db/${TOOL_FILE_NAME_TGZ}
|
||||
fi
|
||||
|
||||
if [ ! -d $MG_DIR/${TOOL_FILE_NAME_TGZ} ];then
|
||||
cd $MG_DIR && tar -zxvf ${TOOL_FILE_NAME_TGZ}
|
||||
fi
|
||||
|
||||
cd ${MG_DIR}/${TOOL_FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
||||
cd ${MG_DIR} && rm -rf ${MG_DIR}/${TOOL_FILE_NAME}
|
||||
|
||||
|
||||
@@ -45,3 +45,46 @@ if [ ! -d $serverPath/mongodb/bin ];then
|
||||
fi
|
||||
|
||||
cd ${MG_DIR} && rm -rf ${MG_DIR}/${FILE_NAME}
|
||||
|
||||
#--------------- mongosh tool install ------------------ #
|
||||
TOOL_VERSION=2.2.5
|
||||
TOOL_FILE_NAME=mongosh-${TOOL_VERSION}-linux-x64
|
||||
if [ "aarch64" == ${SYS_ARCH} ];then
|
||||
TOOL_FILE_NAME=mongosh-${TOOL_VERSION}-linux-arm64
|
||||
fi
|
||||
TOOL_FILE_NAME_TGZ=${TOOL_FILE_NAME}.tgz
|
||||
if [ ! -f $MG_DIR/${TOOL_FILE_NAME_TGZ} ]; then
|
||||
wget --no-check-certificate -O $MG_DIR/${TOOL_FILE_NAME_TGZ} https://downloads.mongodb.com/compass/${TOOL_FILE_NAME_TGZ}
|
||||
echo "wget --no-check-certificate -O $MG_DIR/${TOOL_FILE_NAME_TGZ} https://downloads.mongodb.com/compass/${TOOL_FILE_NAME_TGZ}"
|
||||
fi
|
||||
|
||||
if [ ! -d $MG_DIR/${TOOL_FILE_NAME_TGZ} ];then
|
||||
cd $MG_DIR && tar -zxvf ${TOOL_FILE_NAME_TGZ}
|
||||
fi
|
||||
|
||||
cd ${MG_DIR}/${TOOL_FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
||||
cd ${MG_DIR} && rm -rf ${MG_DIR}/${TOOL_FILE_NAME}
|
||||
|
||||
# https://fastdl.mongodb.org/tools/db/mongodb-database-tools-ubuntu2204-x86_64-100.9.4.tgz
|
||||
#--------------- mongodb database install ------------------ #
|
||||
TOOL_VERSION=100.9.4
|
||||
TOOL_FILE_NAME=mongodb-database-tools-ubuntu${SYS_NAME}-x86_64-${TOOL_VERSION}
|
||||
if [ "aarch64" == ${SYS_ARCH} ];then
|
||||
TOOL_FILE_NAME=mongodb-database-tools-ubuntu${SYS_NAME}-arm64-${TOOL_VERSION}
|
||||
fi
|
||||
|
||||
if [ "arm64" == ${SYS_ARCH} ];then
|
||||
TOOL_FILE_NAME=mongodb-database-tools-ubuntu${SYS_NAME}-arm64-${TOOL_VERSION}
|
||||
fi
|
||||
|
||||
TOOL_FILE_NAME_TGZ=${TOOL_FILE_NAME}.tgz
|
||||
if [ ! -f $MG_DIR/${TOOL_FILE_NAME_TGZ} ]; then
|
||||
wget --no-check-certificate -O $MG_DIR/${TOOL_FILE_NAME_TGZ} https://fastdl.mongodb.org/tools/db/${TOOL_FILE_NAME_TGZ}
|
||||
fi
|
||||
|
||||
if [ ! -d $MG_DIR/${TOOL_FILE_NAME_TGZ} ];then
|
||||
cd $MG_DIR && tar -zxvf ${TOOL_FILE_NAME_TGZ}
|
||||
fi
|
||||
|
||||
cd ${MG_DIR}/${TOOL_FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
||||
cd ${MG_DIR} && rm -rf ${MG_DIR}/${TOOL_FILE_NAME}
|
||||
|
||||
@@ -9,7 +9,7 @@ rootPath=$(dirname "$rootPath")
|
||||
serverPath=$(dirname "$rootPath")
|
||||
|
||||
install_tmp=${rootPath}/tmp/mw_install.pl
|
||||
VERSION=7.0.0
|
||||
VERSION=7.0.9
|
||||
SYS_ARCH=`arch`
|
||||
|
||||
SYS_VERSION_ID=`cat /etc/*-release | grep VERSION_ID | awk -F = '{print $2}' | awk -F "\"" '{print $2}'`
|
||||
@@ -61,3 +61,48 @@ fi
|
||||
|
||||
cd ${MG_DIR} && rm -rf ${MG_DIR}/${FILE_NAME}
|
||||
|
||||
#--------------- mongosh tool install ------------------ #
|
||||
TOOL_VERSION=2.2.5
|
||||
TOOL_FILE_NAME=mongosh-${TOOL_VERSION}-linux-x64
|
||||
if [ "aarch64" == ${SYS_ARCH} ];then
|
||||
TOOL_FILE_NAME=mongosh-${TOOL_VERSION}-linux-arm64
|
||||
fi
|
||||
TOOL_FILE_NAME_TGZ=${TOOL_FILE_NAME}.tgz
|
||||
if [ ! -f $MG_DIR/${TOOL_FILE_NAME_TGZ} ]; then
|
||||
wget --no-check-certificate -O $MG_DIR/${TOOL_FILE_NAME_TGZ} https://downloads.mongodb.com/compass/${TOOL_FILE_NAME_TGZ}
|
||||
echo "wget --no-check-certificate -O $MG_DIR/${TOOL_FILE_NAME_TGZ} https://downloads.mongodb.com/compass/${TOOL_FILE_NAME_TGZ}"
|
||||
fi
|
||||
|
||||
if [ ! -d $MG_DIR/${TOOL_FILE_NAME_TGZ} ];then
|
||||
cd $MG_DIR && tar -zxvf ${TOOL_FILE_NAME_TGZ}
|
||||
fi
|
||||
|
||||
cd ${MG_DIR}/${TOOL_FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
||||
cd ${MG_DIR} && rm -rf ${MG_DIR}/${TOOL_FILE_NAME}
|
||||
|
||||
# https://fastdl.mongodb.org/tools/db/mongodb-database-tools-rhel90-aarch64-100.9.4.tgz
|
||||
# https://fastdl.mongodb.org/tools/db/mongodb-database-tools-rhel90-x86_64-100.9.4.tgz
|
||||
# https://fastdl.mongodb.org/tools/db/mongodb-database-tools-rhel83-s390x-100.9.4.tgz
|
||||
#--------------- mongodb database install ------------------ #
|
||||
TOOL_VERSION=100.9.4
|
||||
TOOL_FILE_NAME=mongodb-database-tools-rhel${SYS_NAME}-x86_64-${TOOL_VERSION}
|
||||
if [ "aarch64" == ${SYS_ARCH} ];then
|
||||
TOOL_FILE_NAME=mongodb-database-tools-rhel${SYS_NAME}-aarch64-${TOOL_VERSION}
|
||||
fi
|
||||
|
||||
if [ "arm64" == ${SYS_ARCH} ];then
|
||||
TOOL_FILE_NAME=mongodb-database-tools-rhel${SYS_NAME}-arm64-${TOOL_VERSION}
|
||||
fi
|
||||
|
||||
TOOL_FILE_NAME_TGZ=${TOOL_FILE_NAME}.tgz
|
||||
if [ ! -f $MG_DIR/${TOOL_FILE_NAME_TGZ} ]; then
|
||||
wget --no-check-certificate -O $MG_DIR/${TOOL_FILE_NAME_TGZ} https://fastdl.mongodb.org/tools/db/${TOOL_FILE_NAME_TGZ}
|
||||
fi
|
||||
|
||||
if [ ! -d $MG_DIR/${TOOL_FILE_NAME_TGZ} ];then
|
||||
cd $MG_DIR && tar -zxvf ${TOOL_FILE_NAME_TGZ}
|
||||
fi
|
||||
|
||||
cd ${MG_DIR}/${TOOL_FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
||||
cd ${MG_DIR} && rm -rf ${MG_DIR}/${TOOL_FILE_NAME}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ rootPath=$(dirname "$rootPath")
|
||||
serverPath=$(dirname "$rootPath")
|
||||
|
||||
install_tmp=${rootPath}/tmp/mw_install.pl
|
||||
VERSION=7.0.0
|
||||
VERSION=7.0.9
|
||||
SYS_ARCH=`arch`
|
||||
SYS_VERSION_ID=`cat /etc/*-release | grep VERSION_ID | awk -F = '{print $2}' | awk -F "\"" '{print $2}'`
|
||||
SYS_NAME=${SYS_VERSION_ID/./}
|
||||
@@ -45,3 +45,47 @@ fi
|
||||
|
||||
cd ${MG_DIR} && rm -rf ${MG_DIR}/${FILE_NAME}
|
||||
|
||||
|
||||
#--------------- mongosh tool install ------------------ #
|
||||
TOOL_VERSION=2.2.5
|
||||
TOOL_FILE_NAME=mongosh-${TOOL_VERSION}-linux-x64
|
||||
if [ "aarch64" == ${SYS_ARCH} ];then
|
||||
TOOL_FILE_NAME=mongosh-${TOOL_VERSION}-linux-arm64
|
||||
fi
|
||||
TOOL_FILE_NAME_TGZ=${TOOL_FILE_NAME}.tgz
|
||||
if [ ! -f $MG_DIR/${TOOL_FILE_NAME_TGZ} ]; then
|
||||
wget --no-check-certificate -O $MG_DIR/${TOOL_FILE_NAME_TGZ} https://downloads.mongodb.com/compass/${TOOL_FILE_NAME_TGZ}
|
||||
echo "wget --no-check-certificate -O $MG_DIR/${TOOL_FILE_NAME_TGZ} https://downloads.mongodb.com/compass/${TOOL_FILE_NAME_TGZ}"
|
||||
fi
|
||||
|
||||
if [ ! -d $MG_DIR/${TOOL_FILE_NAME_TGZ} ];then
|
||||
cd $MG_DIR && tar -zxvf ${TOOL_FILE_NAME_TGZ}
|
||||
fi
|
||||
|
||||
cd ${MG_DIR}/${TOOL_FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
||||
cd ${MG_DIR} && rm -rf ${MG_DIR}/${TOOL_FILE_NAME}
|
||||
|
||||
|
||||
#--------------- mongodb database install ------------------ #
|
||||
TOOL_VERSION=100.9.4
|
||||
TOOL_FILE_NAME=mongodb-database-tools-debian${SYS_NAME}-x86_64-${TOOL_VERSION}
|
||||
if [ "aarch64" == ${SYS_ARCH} ];then
|
||||
TOOL_FILE_NAME=mongodb-database-tools-debian${SYS_NAME}-arm64-${TOOL_VERSION}
|
||||
fi
|
||||
|
||||
if [ "arm64" == ${SYS_ARCH} ];then
|
||||
TOOL_FILE_NAME=mongodb-database-tools-debian${SYS_NAME}-arm64-${TOOL_VERSION}
|
||||
fi
|
||||
|
||||
TOOL_FILE_NAME_TGZ=${TOOL_FILE_NAME}.tgz
|
||||
if [ ! -f $MG_DIR/${TOOL_FILE_NAME_TGZ} ]; then
|
||||
wget --no-check-certificate -O $MG_DIR/${TOOL_FILE_NAME_TGZ} https://fastdl.mongodb.org/tools/db/${TOOL_FILE_NAME_TGZ}
|
||||
fi
|
||||
|
||||
if [ ! -d $MG_DIR/${TOOL_FILE_NAME_TGZ} ];then
|
||||
cd $MG_DIR && tar -zxvf ${TOOL_FILE_NAME_TGZ}
|
||||
fi
|
||||
|
||||
cd ${MG_DIR}/${TOOL_FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
||||
cd ${MG_DIR} && rm -rf ${MG_DIR}/${TOOL_FILE_NAME}
|
||||
|
||||
|
||||
@@ -7,9 +7,10 @@ rootPath=$(dirname "$curPath")
|
||||
rootPath=$(dirname "$rootPath")
|
||||
rootPath=$(dirname "$rootPath")
|
||||
serverPath=$(dirname "$rootPath")
|
||||
SYS_ARCH=`arch`
|
||||
|
||||
install_tmp=${rootPath}/tmp/mw_install.pl
|
||||
VERSION=7.0.0
|
||||
VERSION=7.0.9
|
||||
|
||||
MG_DIR=$serverPath/source/mongodb
|
||||
mkdir -p $MG_DIR
|
||||
@@ -26,4 +27,55 @@ fi
|
||||
if [ ! -d $serverPath/mongodb/bin ];then
|
||||
mkdir -p $serverPath/mongodb
|
||||
cd $MG_DIR/mongodb-macos-x86_64-${VERSION} && cp -rf ./bin $serverPath/mongodb
|
||||
fi
|
||||
fi
|
||||
|
||||
# https://downloads.mongodb.com/compass/mongosh-2.2.5-darwin-x64.zip
|
||||
# https://downloads.mongodb.com/compass/mongosh-2.2.5-darwin-arm64.zip
|
||||
#--------------- mongosh tool install ------------------ #
|
||||
TOOL_VERSION=2.2.5
|
||||
TOOL_FILE_NAME=mongosh-${TOOL_VERSION}-darwin-x64
|
||||
if [ "aarch64" == ${SYS_ARCH} ];then
|
||||
TOOL_FILE_NAME=mongosh-${TOOL_VERSION}-darwin-arm64
|
||||
fi
|
||||
|
||||
if [ "arm64" == ${SYS_ARCH} ];then
|
||||
TOOL_FILE_NAME=mongosh-${TOOL_VERSION}-darwin-arm64
|
||||
fi
|
||||
TOOL_FILE_NAME_TGZ=${TOOL_FILE_NAME}.zip
|
||||
if [ ! -f $MG_DIR/${TOOL_FILE_NAME_TGZ} ]; then
|
||||
wget --no-check-certificate -O $MG_DIR/${TOOL_FILE_NAME_TGZ} https://downloads.mongodb.com/compass/${TOOL_FILE_NAME_TGZ}
|
||||
echo "wget --no-check-certificate -O $MG_DIR/${TOOL_FILE_NAME_TGZ} https://downloads.mongodb.com/compass/${TOOL_FILE_NAME_TGZ}"
|
||||
fi
|
||||
|
||||
if [ ! -d $MG_DIR/${TOOL_FILE_NAME_TGZ} ];then
|
||||
cd $MG_DIR && unzip ${TOOL_FILE_NAME_TGZ}
|
||||
fi
|
||||
|
||||
cd ${MG_DIR}/${TOOL_FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
||||
cd ${MG_DIR} && rm -rf ${MG_DIR}/${TOOL_FILE_NAME}
|
||||
|
||||
|
||||
|
||||
# https://fastdl.mongodb.org/tools/db/mongodb-database-tools-macos-arm64-100.9.4.zip
|
||||
TOOL_VERSION=100.9.4
|
||||
TOOL_FILE_NAME=mongodb-database-tools-macos-x86_64-${TOOL_VERSION}
|
||||
if [ "aarch64" == ${SYS_ARCH} ];then
|
||||
TOOL_FILE_NAME=mongodb-database-tools-macos-arm64-${TOOL_VERSION}
|
||||
fi
|
||||
|
||||
if [ "arm64" == ${SYS_ARCH} ];then
|
||||
TOOL_FILE_NAME=mongodb-database-tools-macos-arm64-${TOOL_VERSION}
|
||||
fi
|
||||
|
||||
TOOL_FILE_NAME_TGZ=${TOOL_FILE_NAME}.zip
|
||||
if [ ! -f $MG_DIR/${TOOL_FILE_NAME_TGZ} ]; then
|
||||
wget --no-check-certificate -O $MG_DIR/${TOOL_FILE_NAME_TGZ} https://fastdl.mongodb.org/tools/db/${TOOL_FILE_NAME_TGZ}
|
||||
echo "wget --no-check-certificate -O $MG_DIR/${TOOL_FILE_NAME_TGZ} https://fastdl.mongodb.org/tools/db/${TOOL_FILE_NAME_TGZ}"
|
||||
fi
|
||||
|
||||
if [ ! -d $MG_DIR/${TOOL_FILE_NAME_TGZ} ];then
|
||||
cd $MG_DIR && unzip ${TOOL_FILE_NAME_TGZ}
|
||||
fi
|
||||
|
||||
cd ${MG_DIR}/${TOOL_FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
||||
cd ${MG_DIR} && rm -rf ${MG_DIR}/${TOOL_FILE_NAME}
|
||||
@@ -9,7 +9,7 @@ rootPath=$(dirname "$rootPath")
|
||||
serverPath=$(dirname "$rootPath")
|
||||
|
||||
install_tmp=${rootPath}/tmp/mw_install.pl
|
||||
VERSION=7.0.0
|
||||
VERSION=7.0.9
|
||||
SYS_ARCH=`arch`
|
||||
|
||||
SYS_VERSION_ID=`cat /etc/*-release | grep VERSION_ID | awk -F = '{print $2}' | awk -F "\"" '{print $2}' | awk -F . '{print $1}'`
|
||||
@@ -46,4 +46,50 @@ if [ ! -d $serverPath/mongodb/bin ];then
|
||||
cd $MG_DIR/${FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
||||
fi
|
||||
|
||||
cd ${MG_DIR} && rm -rf ${MG_DIR}/${FILE_NAME}
|
||||
cd ${MG_DIR} && rm -rf ${MG_DIR}/${FILE_NAME}
|
||||
|
||||
|
||||
#--------------- mongosh tool install ------------------ #
|
||||
TOOL_VERSION=2.2.5
|
||||
TOOL_FILE_NAME=mongosh-${TOOL_VERSION}-linux-x64
|
||||
if [ "aarch64" == ${SYS_ARCH} ];then
|
||||
TOOL_FILE_NAME=mongosh-${TOOL_VERSION}-linux-arm64
|
||||
fi
|
||||
TOOL_FILE_NAME_TGZ=${TOOL_FILE_NAME}.tgz
|
||||
if [ ! -f $MG_DIR/${TOOL_FILE_NAME_TGZ} ]; then
|
||||
wget --no-check-certificate -O $MG_DIR/${TOOL_FILE_NAME_TGZ} https://downloads.mongodb.com/compass/${TOOL_FILE_NAME_TGZ}
|
||||
echo "wget --no-check-certificate -O $MG_DIR/${TOOL_FILE_NAME_TGZ} https://downloads.mongodb.com/compass/${TOOL_FILE_NAME_TGZ}"
|
||||
fi
|
||||
|
||||
if [ ! -d $MG_DIR/${TOOL_FILE_NAME_TGZ} ];then
|
||||
cd $MG_DIR && tar -zxvf ${TOOL_FILE_NAME_TGZ}
|
||||
fi
|
||||
|
||||
cd ${MG_DIR}/${TOOL_FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
||||
cd ${MG_DIR} && rm -rf ${MG_DIR}/${TOOL_FILE_NAME}
|
||||
|
||||
|
||||
# https://fastdl.mongodb.org/tools/db/mongodb-database-tools-suse12-x86_64-100.9.4.tgz
|
||||
#--------------- mongodb database install ------------------ #
|
||||
TOOL_VERSION=100.9.4
|
||||
TOOL_FILE_NAME=mongodb-database-tools-suse${SYS_NAME}-x86_64-${TOOL_VERSION}
|
||||
if [ "aarch64" == ${SYS_ARCH} ];then
|
||||
TOOL_FILE_NAME=mongodb-database-tools-suse${SYS_NAME}-arm64-${TOOL_VERSION}
|
||||
fi
|
||||
|
||||
if [ "arm64" == ${SYS_ARCH} ];then
|
||||
TOOL_FILE_NAME=mongodb-database-tools-suse${SYS_NAME}-arm64-${TOOL_VERSION}
|
||||
fi
|
||||
|
||||
TOOL_FILE_NAME_TGZ=${TOOL_FILE_NAME}.tgz
|
||||
if [ ! -f $MG_DIR/${TOOL_FILE_NAME_TGZ} ]; then
|
||||
wget --no-check-certificate -O $MG_DIR/${TOOL_FILE_NAME_TGZ} https://fastdl.mongodb.org/tools/db/${TOOL_FILE_NAME_TGZ}
|
||||
fi
|
||||
|
||||
if [ ! -d $MG_DIR/${TOOL_FILE_NAME_TGZ} ];then
|
||||
cd $MG_DIR && tar -zxvf ${TOOL_FILE_NAME_TGZ}
|
||||
fi
|
||||
|
||||
cd ${MG_DIR}/${TOOL_FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
||||
cd ${MG_DIR} && rm -rf ${MG_DIR}/${TOOL_FILE_NAME}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ rootPath=$(dirname "$rootPath")
|
||||
serverPath=$(dirname "$rootPath")
|
||||
|
||||
install_tmp=${rootPath}/tmp/mw_install.pl
|
||||
VERSION=7.0.0
|
||||
VERSION=7.0.9
|
||||
SYS_ARCH=`arch`
|
||||
|
||||
SYS_VERSION_ID=`cat /etc/*-release | grep VERSION_ID | awk -F = '{print $2}' | awk -F "\"" '{print $2}'`
|
||||
@@ -44,4 +44,48 @@ if [ ! -d $serverPath/mongodb/bin ];then
|
||||
cd $MG_DIR/${FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
||||
fi
|
||||
|
||||
cd ${MG_DIR} && rm -rf ${MG_DIR}/${FILE_NAME}
|
||||
cd ${MG_DIR} && rm -rf ${MG_DIR}/${FILE_NAME}
|
||||
|
||||
|
||||
#--------------- mongosh tool install ------------------ #
|
||||
TOOL_VERSION=2.2.5
|
||||
TOOL_FILE_NAME=mongosh-${TOOL_VERSION}-linux-x64
|
||||
if [ "aarch64" == ${SYS_ARCH} ];then
|
||||
TOOL_FILE_NAME=mongosh-${TOOL_VERSION}-linux-arm64
|
||||
fi
|
||||
TOOL_FILE_NAME_TGZ=${TOOL_FILE_NAME}.tgz
|
||||
if [ ! -f $MG_DIR/${TOOL_FILE_NAME_TGZ} ]; then
|
||||
wget --no-check-certificate -O $MG_DIR/${TOOL_FILE_NAME_TGZ} https://downloads.mongodb.com/compass/${TOOL_FILE_NAME_TGZ}
|
||||
echo "wget --no-check-certificate -O $MG_DIR/${TOOL_FILE_NAME_TGZ} https://downloads.mongodb.com/compass/${TOOL_FILE_NAME_TGZ}"
|
||||
fi
|
||||
|
||||
if [ ! -d $MG_DIR/${TOOL_FILE_NAME_TGZ} ];then
|
||||
cd $MG_DIR && tar -zxvf ${TOOL_FILE_NAME_TGZ}
|
||||
fi
|
||||
|
||||
cd ${MG_DIR}/${TOOL_FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
||||
cd ${MG_DIR} && rm -rf ${MG_DIR}/${TOOL_FILE_NAME}
|
||||
|
||||
# https://fastdl.mongodb.org/tools/db/mongodb-database-tools-ubuntu2204-x86_64-100.9.4.tgz
|
||||
#--------------- mongodb database install ------------------ #
|
||||
TOOL_VERSION=100.9.4
|
||||
TOOL_FILE_NAME=mongodb-database-tools-ubuntu${SYS_NAME}-x86_64-${TOOL_VERSION}
|
||||
if [ "aarch64" == ${SYS_ARCH} ];then
|
||||
TOOL_FILE_NAME=mongodb-database-tools-ubuntu${SYS_NAME}-arm64-${TOOL_VERSION}
|
||||
fi
|
||||
|
||||
if [ "arm64" == ${SYS_ARCH} ];then
|
||||
TOOL_FILE_NAME=mongodb-database-tools-ubuntu${SYS_NAME}-arm64-${TOOL_VERSION}
|
||||
fi
|
||||
|
||||
TOOL_FILE_NAME_TGZ=${TOOL_FILE_NAME}.tgz
|
||||
if [ ! -f $MG_DIR/${TOOL_FILE_NAME_TGZ} ]; then
|
||||
wget --no-check-certificate -O $MG_DIR/${TOOL_FILE_NAME_TGZ} https://fastdl.mongodb.org/tools/db/${TOOL_FILE_NAME_TGZ}
|
||||
fi
|
||||
|
||||
if [ ! -d $MG_DIR/${TOOL_FILE_NAME_TGZ} ];then
|
||||
cd $MG_DIR && tar -zxvf ${TOOL_FILE_NAME_TGZ}
|
||||
fi
|
||||
|
||||
cd ${MG_DIR}/${TOOL_FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
||||
cd ${MG_DIR} && rm -rf ${MG_DIR}/${TOOL_FILE_NAME}
|
||||
@@ -1151,7 +1151,7 @@ function dbList(page, search){
|
||||
list += '<td><span class="c9 input-edit" onclick="setDbPs(\''+rdata.data[i]['id']+'\',\''+rdata.data[i]['name']+'\',this)" style="display: inline-block;">'+rdata.data[i]['ps']+'</span></td>';
|
||||
list += '<td style="text-align:right">';
|
||||
|
||||
list += '<a href="javascript:;" class="btlink" class="btlink" onclick="setBackup(\''+rdata.data[i]['name']+'\',this)" title="数据库备份">'+(rdata.data[i]['is_backup']?'备份':'未备份') +'</a> | ';
|
||||
list += '<a href="javascript:;" class="btlink" class="btlink" onclick="setBackup(\''+rdata.data[i]['name']+'\',this)" title="数据库备份">'+(rdata.data[i]['is_backup']?'已备份':'未备份') +'</a> | ';
|
||||
|
||||
var rw = '';
|
||||
var rw_change = 'all';
|
||||
|
||||
@@ -63,7 +63,7 @@ class backupTools:
|
||||
if len(mycnf) > 100:
|
||||
mw.writeFile(db_path + '/etc/my.cnf', mycnf)
|
||||
|
||||
cmd = db_path + "/bin/usr/bin/mysqldump --defaults-file=" + my_conf_path + " --single-transaction --quick --default-character-set=utf8 " + \
|
||||
cmd = db_path + "/bin/usr/bin/mysqldump --defaults-file=" + my_conf_path + " --single-transaction -q --default-character-set=utf8 " + \
|
||||
name + " | gzip > " + filename
|
||||
mw.execShell(cmd)
|
||||
|
||||
|
||||
@@ -112,10 +112,10 @@ Install_mysql()
|
||||
|
||||
if [ "$?" == "0" ];then
|
||||
mkdir -p $serverPath/mysql-apt
|
||||
echo '8.0' > $serverPath/mysql-apt/version.pl
|
||||
echo '8.2' > $serverPath/mysql-apt/version.pl
|
||||
echo '安装完成' > $install_tmp
|
||||
else
|
||||
echo '8.0' > $serverPath/mysql-apt/version.pl
|
||||
echo '8.2' > $serverPath/mysql-apt/version.pl
|
||||
echo "暂时不支持该系统" > $install_tmp
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -1152,7 +1152,7 @@ function dbList(page, search){
|
||||
list += '<td><span class="c9 input-edit" onclick="setDbPs(\''+rdata.data[i]['id']+'\',\''+rdata.data[i]['name']+'\',this)" style="display: inline-block;">'+rdata.data[i]['ps']+'</span></td>';
|
||||
list += '<td style="text-align:right">';
|
||||
|
||||
list += '<a href="javascript:;" class="btlink" class="btlink" onclick="setBackup(\''+rdata.data[i]['name']+'\',this)" title="数据库备份">'+(rdata.data[i]['is_backup']?'备份':'未备份') +'</a> | ';
|
||||
list += '<a href="javascript:;" class="btlink" class="btlink" onclick="setBackup(\''+rdata.data[i]['name']+'\',this)" title="数据库备份">'+(rdata.data[i]['is_backup']?'已备份':'未备份') +'</a> | ';
|
||||
|
||||
var rw = '';
|
||||
var rw_change = 'all';
|
||||
|
||||
@@ -65,7 +65,7 @@ class backupTools:
|
||||
if len(content) > 100:
|
||||
mw.writeFile(my_cnf, content)
|
||||
|
||||
cmd = db_path + "/bin/usr/bin/mysqldump --defaults-file=" + my_cnf + " --single-transaction --quick --default-character-set=utf8 " + \
|
||||
cmd = db_path + "/bin/usr/bin/mysqldump --defaults-file=" + my_cnf + " --single-transaction -q --default-character-set=utf8 " + \
|
||||
name + " | gzip > " + filename
|
||||
mw.execShell(cmd)
|
||||
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
|
||||
```
|
||||
show global variables like '%gtid%';
|
||||
show global variables like 'server_uuid';
|
||||
```
|
||||
|
||||
```
|
||||
# 不锁表,需要删除原来数据表
|
||||
# tables = db.query('show tables from `%s`' % sync_db_import)
|
||||
# table_key = "Tables_in_" + sync_db_import
|
||||
# for tname in tables:
|
||||
# drop_db_cmd = 'drop table if exists '+sync_db_import+'.'+tname[table_key]
|
||||
# # print(drop_db_cmd)
|
||||
# db.query(drop_db_cmd)
|
||||
```
|
||||
|
||||
```
|
||||
# 修改同步位置
|
||||
# master_info = sync_mdb.query('show master status')
|
||||
# slave_info = db.query('show slave status')
|
||||
# if len(master_info)>0:
|
||||
# channel_name = slave_info[0]['Channel_Name']
|
||||
# change_cmd = "CHANGE MASTER TO MASTER_LOG_FILE='"+master_info[0]['File']+"', MASTER_LOG_POS="+str(master_info[0]['Position'])+" for channel '"+channel_name+"';"
|
||||
# print(change_cmd)
|
||||
# r = db.execute(change_cmd)
|
||||
# print(r)
|
||||
```
|
||||
@@ -0,0 +1,116 @@
|
||||
[client]
|
||||
user = root
|
||||
#password = your_password
|
||||
port = 3306
|
||||
socket = {$SERVER_APP_PATH}/mysql.sock
|
||||
default-character-set = UTF8MB4
|
||||
|
||||
[mysqld]
|
||||
!include {$SERVER_APP_PATH}/etc/mode/classic.cnf
|
||||
|
||||
sha256_password_private_key_path={$SERVER_APP_PATH}/data/mysql.pem
|
||||
sha256_password_public_key_path={$SERVER_APP_PATH}/data/mysql.pub
|
||||
authentication_policy=mysql_native_password
|
||||
|
||||
pid-file = {$SERVER_APP_PATH}/data/mysql.pid
|
||||
user = mysql
|
||||
port = 3306
|
||||
socket = {$SERVER_APP_PATH}/mysql.sock
|
||||
basedir = {$SERVER_APP_PATH}
|
||||
datadir = {$SERVER_APP_PATH}/data
|
||||
log-error = {$SERVER_APP_PATH}/data/error.log
|
||||
server-id = {$SERVER_ID}
|
||||
#sql-mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
|
||||
|
||||
default_storage_engine = InnoDB
|
||||
|
||||
key_buffer_size = 8M
|
||||
table_open_cache = 32
|
||||
sort_buffer_size = 256K
|
||||
net_buffer_length = 4K
|
||||
read_buffer_size = 128K
|
||||
read_rnd_buffer_size = 256K
|
||||
myisam_sort_buffer_size = 4M
|
||||
thread_cache_size = 4
|
||||
lower_case_table_names=0
|
||||
tmp_table_size = 8M
|
||||
character-set-server = UTF8MB4
|
||||
|
||||
max_connections = 500
|
||||
max_connect_errors = 100
|
||||
open_files_limit = 2560
|
||||
max_allowed_packet = 128M
|
||||
|
||||
skip_name_resolve=1
|
||||
#skip-networking
|
||||
#skip-external-locking
|
||||
#loose-skip-innodb
|
||||
#skip-grant-tables
|
||||
|
||||
log-bin=mysql-bin
|
||||
slow_query_log=1
|
||||
slow-query-log-file={$SERVER_APP_PATH}/data/mysql-slow.log
|
||||
long_query_time=10
|
||||
#log_queries_not_using_indexes=1
|
||||
#log_slow_admin_statements=1
|
||||
#log_slow_replica_statements=1
|
||||
binlog_expire_logs_seconds=2592000
|
||||
|
||||
relay-log=mdserver
|
||||
relay-log-index=mdserver
|
||||
|
||||
#多主设置
|
||||
#auto_increment_offset=2
|
||||
#auto_increment_increment=2
|
||||
|
||||
#master
|
||||
#sync_binlog=1
|
||||
|
||||
#binlog-do-db
|
||||
binlog-ignore-db = test
|
||||
binlog-ignore-db = mysql
|
||||
binlog-ignore-db = information_schema
|
||||
binlog-ignore-db = performance_schema
|
||||
|
||||
#slave
|
||||
log_replica_updates = 1
|
||||
# Prevent replication from starting automatically with MySQL
|
||||
#skip_replica_start = 1
|
||||
#replicate-do-db
|
||||
replica_skip_errors=1062,1396
|
||||
replicate-ignore-db = information_schema
|
||||
replicate-ignore-db = performance_schema
|
||||
replicate-ignore-db = mysql
|
||||
replicate-ignore-db = test
|
||||
|
||||
|
||||
innodb_data_home_dir = {$SERVER_APP_PATH}/data
|
||||
innodb_data_file_path = ibdata1:10M:autoextend
|
||||
innodb_log_group_home_dir = {$SERVER_APP_PATH}/data
|
||||
innodb_buffer_pool_size = 16M
|
||||
#innodb_log_file_size = 5M
|
||||
innodb_redo_log_capacity=10485760
|
||||
innodb_log_buffer_size = 8M
|
||||
innodb_flush_log_at_trx_commit = 1
|
||||
innodb_lock_wait_timeout = 120
|
||||
innodb_max_dirty_pages_pct = 90
|
||||
innodb_read_io_threads = 1
|
||||
innodb_write_io_threads = 1
|
||||
innodb_file_per_table=1
|
||||
|
||||
secure-file-priv={$SERVER_APP_PATH}/tmp
|
||||
|
||||
[mysqldump]
|
||||
quick
|
||||
|
||||
[mysql]
|
||||
no-auto-rehash
|
||||
|
||||
[myisamchk]
|
||||
key_buffer_size = 20M
|
||||
sort_buffer_size = 20M
|
||||
read_buffer = 2M
|
||||
write_buffer = 2M
|
||||
|
||||
[mysqlhotcopy]
|
||||
interactive-timeout
|
||||
@@ -50,7 +50,9 @@ CREATE TABLE IF NOT EXISTS `slave_sync_user` (
|
||||
`pass` TEXT,
|
||||
`mode` TEXT,
|
||||
`cmd` TEXT,
|
||||
`db` TEXT,
|
||||
`addtime` TEXT
|
||||
);
|
||||
ALTER TABLE `slave_sync_user` ADD COLUMN `db` TEXT DEFAULT '';
|
||||
|
||||
|
||||
|
||||
+633
-56
@@ -63,12 +63,12 @@ def getArgs():
|
||||
if t.strip() == '':
|
||||
tmp = []
|
||||
else:
|
||||
t = t.split(':', 1)
|
||||
t = t.split(':',1)
|
||||
tmp[t[0]] = t[1]
|
||||
tmp[t[0]] = t[1]
|
||||
elif args_len > 1:
|
||||
for i in range(len(args)):
|
||||
t = args[i].split(':', 1)
|
||||
t = args[i].split(':',1)
|
||||
tmp[t[0]] = t[1]
|
||||
return tmp
|
||||
|
||||
@@ -622,6 +622,8 @@ def my8cmd(version, method):
|
||||
isInited = initMysql8Data()
|
||||
elif version == '8.2':
|
||||
isInited = initMysql8Data()
|
||||
elif version == '8.3':
|
||||
isInited = initMysql8Data()
|
||||
|
||||
if not isInited:
|
||||
|
||||
@@ -743,7 +745,7 @@ def getMyDbPos():
|
||||
return tmp.groups()[0].strip()
|
||||
|
||||
|
||||
def setMyDbPos():
|
||||
def setMyDbPos(version):
|
||||
args = getArgs()
|
||||
data = checkArgs(args, ['datadir'])
|
||||
if not data[0]:
|
||||
@@ -758,7 +760,7 @@ def setMyDbPos():
|
||||
mw.execShell('mkdir -p ' + t_datadir)
|
||||
|
||||
# mw.execShell('/etc/init.d/mysqld stop')
|
||||
stop()
|
||||
stop(version)
|
||||
mw.execShell('cp -rf ' + s_datadir + '/* ' + t_datadir + '/')
|
||||
mw.execShell('chown -R mysql mysql ' + t_datadir)
|
||||
mw.execShell('chmod -R 755 ' + t_datadir)
|
||||
@@ -772,7 +774,7 @@ def setMyDbPos():
|
||||
|
||||
mycnf = mycnf.replace(s_datadir, t_datadir)
|
||||
mw.writeFile(myfile, mycnf)
|
||||
start()
|
||||
start(version)
|
||||
|
||||
result = mw.execShell(
|
||||
'ps aux|grep mysqld| grep -v grep|grep -v python')
|
||||
@@ -782,7 +784,7 @@ def setMyDbPos():
|
||||
else:
|
||||
mw.execShell('pkill -9 mysqld')
|
||||
mw.writeFile(myfile, mw.readFile(path + '/etc/my_backup.cnf'))
|
||||
start()
|
||||
start(version)
|
||||
return mw.returnJson(False, '文件迁移失败!')
|
||||
|
||||
|
||||
@@ -1068,6 +1070,81 @@ def importDbExternal():
|
||||
|
||||
return mw.returnJson(True, 'ok')
|
||||
|
||||
def importDbExternalProgress():
|
||||
args = getArgs()
|
||||
data = checkArgs(args, ['file', 'name'])
|
||||
if not data[0]:
|
||||
return data[1]
|
||||
|
||||
file = args['file']
|
||||
name = args['name']
|
||||
|
||||
cmd = 'cd '+mw.getServerDir()+'/mdserver-web && source bin/activate && '
|
||||
cmd += 'python3 '+mw.getServerDir()+'/mdserver-web/plugins/mysql/index.py import_db_external_progress_bar {"file":"'+file+'","name":"'+name+'"}'
|
||||
return mw.returnJson(True, 'ok',cmd)
|
||||
|
||||
def importDbExternalProgressBar():
|
||||
args = getArgs()
|
||||
data = checkArgs(args, ['file', 'name'])
|
||||
if not data[0]:
|
||||
return data[1]
|
||||
|
||||
file = args['file']
|
||||
name = args['name']
|
||||
|
||||
import_dir = mw.getRootDir() + '/backup/import/'
|
||||
|
||||
file_path = import_dir + file
|
||||
if not os.path.exists(file_path):
|
||||
return mw.returnJson(False, '文件突然消失?')
|
||||
|
||||
exts = ['sql', 'gz', 'zip']
|
||||
ext = mw.getFileSuffix(file)
|
||||
if ext not in exts:
|
||||
return mw.returnJson(False, '导入数据库格式不对!')
|
||||
|
||||
tmp = file.split('/')
|
||||
tmpFile = tmp[len(tmp) - 1]
|
||||
tmpFile = tmpFile.replace('.sql.' + ext, '.sql')
|
||||
tmpFile = tmpFile.replace('.' + ext, '.sql')
|
||||
tmpFile = tmpFile.replace('tar.', '')
|
||||
|
||||
# print(tmpFile)
|
||||
import_sql = ""
|
||||
if file.find("sql.gz") > -1:
|
||||
cmd = 'cd ' + import_dir + ' && gzip -dc ' + \
|
||||
file + " > " + import_dir + tmpFile
|
||||
info = mw.execShell(cmd)
|
||||
if info[1] == "":
|
||||
import_sql = import_dir + tmpFile
|
||||
|
||||
if file.find(".zip") > -1:
|
||||
cmd = 'cd ' + import_dir + ' && unzip -o ' + file
|
||||
mw.execShell(cmd)
|
||||
import_sql = import_dir + tmpFile
|
||||
|
||||
if file.find("tar.gz") > -1:
|
||||
cmd = 'cd ' + import_dir + ' && tar -zxvf ' + file
|
||||
mw.execShell(cmd)
|
||||
import_sql = import_dir + tmpFile
|
||||
|
||||
if file.find(".sql") > -1 and file.find(".sql.gz") == -1:
|
||||
import_sql = import_dir + file
|
||||
|
||||
if import_sql == "":
|
||||
return mw.returnJson(False, '未找SQL文件')
|
||||
|
||||
pwd = pSqliteDb('config').where('id=?', (1,)).getField('mysql_root')
|
||||
sock = getSocketFile()
|
||||
|
||||
my_cnf = getConf()
|
||||
mysql_cmd = getServerDir() + '/bin/mysql --defaults-file=' + my_cnf + \
|
||||
' -uroot -p"' + pwd + '" -f ' + name
|
||||
mysql_cmd_progress_bar = "pv -t -p " + import_sql + '|'+ mysql_cmd
|
||||
print(mysql_cmd_progress_bar)
|
||||
rdata = os.system(mysql_cmd_progress_bar)
|
||||
return ""
|
||||
|
||||
|
||||
def importDbBackup():
|
||||
args = getArgs()
|
||||
@@ -1105,6 +1182,53 @@ def importDbBackup():
|
||||
return mw.returnJson(True, 'ok')
|
||||
|
||||
|
||||
def importDbBackupProgress():
|
||||
args = getArgs()
|
||||
data = checkArgs(args, ['file', 'name'])
|
||||
if not data[0]:
|
||||
return data[1]
|
||||
|
||||
file = args['file']
|
||||
name = args['name']
|
||||
|
||||
cmd = 'cd '+mw.getServerDir()+'/mdserver-web && source bin/activate && '
|
||||
cmd += 'python3 '+mw.getServerDir()+'/mdserver-web/plugins/mysql/index.py import_db_backup_progress_bar {"file":"'+file+'","name":"'+name+'"}'
|
||||
return mw.returnJson(True, 'ok',cmd)
|
||||
|
||||
return mw.returnJson(True, 'ok')
|
||||
|
||||
def importDbBackupProgressBar():
|
||||
args = getArgs()
|
||||
data = checkArgs(args, ['file', 'name'])
|
||||
if not data[0]:
|
||||
return data[1]
|
||||
|
||||
file = args['file']
|
||||
name = args['name']
|
||||
|
||||
file_path = mw.getRootDir() + '/backup/database/' + file
|
||||
file_path_sql = mw.getRootDir() + '/backup/database/' + file.replace('.gz', '')
|
||||
|
||||
if not os.path.exists(file_path_sql):
|
||||
cmd = 'cd ' + mw.getRootDir() + '/backup/database && gzip -d ' + file
|
||||
mw.execShell(cmd)
|
||||
|
||||
local_mode = recognizeDbMode()
|
||||
if local_mode == 'gtid':
|
||||
pdb = pMysqlDb()
|
||||
pdb.execute('reset master')
|
||||
|
||||
pwd = pSqliteDb('config').where('id=?', (1,)).getField('mysql_root')
|
||||
sock = getSocketFile()
|
||||
|
||||
mysql_cmd = getServerDir() + '/bin/mysql -S ' + sock + ' -uroot -p"' + pwd + \
|
||||
'" ' + name
|
||||
mysql_cmd_progress_bar = "pv -t -p " + file_path_sql + '|'+ mysql_cmd
|
||||
print(mysql_cmd_progress_bar)
|
||||
rdata = os.system(mysql_cmd_progress_bar)
|
||||
return ''
|
||||
|
||||
|
||||
def deleteDbBackup():
|
||||
args = getArgs()
|
||||
data = checkArgs(args, ['filename', 'path'])
|
||||
@@ -2225,7 +2349,7 @@ def addMasterRepSlaveUser(version=''):
|
||||
if isError != None:
|
||||
return isError
|
||||
|
||||
sql_select = "grant select,lock tables,PROCESS on *.* to " + username + "@'%';"
|
||||
sql_select = "grant select,reload,REPLICATION CLIENT,PROCESS on *.* to " + username + "@'%';"
|
||||
pdb.execute(sql_select)
|
||||
pdb.execute('FLUSH PRIVILEGES;')
|
||||
|
||||
@@ -2270,29 +2394,31 @@ def getMasterRepSlaveUserCmd(version):
|
||||
if sid != '':
|
||||
channel_name = " for channel 'r{}';".format(sid)
|
||||
|
||||
if mode == "gtid":
|
||||
sql = "CHANGE MASTER TO MASTER_HOST='" + ip + "', MASTER_PORT=" + port + ", MASTER_USER='" + \
|
||||
clist[0]['username'] + "', MASTER_PASSWORD='" + \
|
||||
clist[0]['password'] + "', MASTER_AUTO_POSITION=1" + channel_name
|
||||
if version == '8.0':
|
||||
sql = "CHANGE REPLICATION SOURCE TO SOURCE_HOST='" + ip + "', SOURCE_PORT=" + port + ", SOURCE_USER='" + \
|
||||
clist[0]['username'] + "', SOURCE_PASSWORD='" + \
|
||||
clist[0]['password'] + \
|
||||
"', MASTER_AUTO_POSITION=1" + channel_name
|
||||
else:
|
||||
sql = "CHANGE MASTER TO MASTER_HOST='" + ip + "', MASTER_PORT=" + port + ", MASTER_USER='" + \
|
||||
clist[0]['username'] + "', MASTER_PASSWORD='" + \
|
||||
clist[0]['password'] + \
|
||||
"', MASTER_LOG_FILE='" + mstatus[0]["File"] + \
|
||||
"',MASTER_LOG_POS=" + str(mstatus[0]["Position"]) + channel_name
|
||||
mdb8 = ['8.0','8.1','8.2','8.3','8.4']
|
||||
sql = ''
|
||||
if not mw.inArray(mdb8,version):
|
||||
base_sql = "CHANGE MASTER TO MASTER_HOST='" + ip + "', MASTER_PORT=" + port + ", MASTER_USER='" + \
|
||||
clist[0]['username'] + "', MASTER_PASSWORD='" + \
|
||||
clist[0]['password'] + "'"
|
||||
|
||||
if version == "8.0":
|
||||
sql = "CHANGE REPLICATION SOURCE TO SOURCE_HOST='" + ip + "', SOURCE_PORT=" + port + ", SOURCE_USER='" + \
|
||||
sql += base_sql +';'
|
||||
sql += "<br/><hr/>"
|
||||
# sql += base_sql + ", MASTER_AUTO_POSITION=1" + channel_name
|
||||
sql += base_sql + channel_name
|
||||
sql += "<br/><hr/>"
|
||||
|
||||
sql += base_sql + "', MASTER_LOG_FILE='" + mstatus[0]["File"] + "',MASTER_LOG_POS=" + str(mstatus[0]["Position"]) + channel_name
|
||||
else:
|
||||
base_sql = "CHANGE REPLICATION SOURCE TO SOURCE_HOST='" + ip + "', SOURCE_PORT=" + port + ", SOURCE_USER='" + \
|
||||
clist[0]['username'] + "', SOURCE_PASSWORD='" + \
|
||||
clist[0]['password'] + \
|
||||
"', SOURCE_LOG_FILE='" + mstatus[0]["File"] + \
|
||||
"',SOURCE_LOG_POS=" + \
|
||||
str(mstatus[0]["Position"]) + channel_name
|
||||
clist[0]['password']+"'"
|
||||
sql += base_sql +';'
|
||||
sql += "<br/><hr/>"
|
||||
# sql += base_sql + ", MASTER_AUTO_POSITION=1" + channel_name
|
||||
sql += base_sql + channel_name
|
||||
sql += "<br/><hr/>"
|
||||
sql += base_sql + "', SOURCE_LOG_FILE='" + mstatus[0]["File"] + "',SOURCE_LOG_POS=" + str(mstatus[0]["Position"]) + channel_name
|
||||
|
||||
|
||||
data = {}
|
||||
data['cmd'] = sql
|
||||
@@ -2645,6 +2771,7 @@ def initSlaveStatus(version=''):
|
||||
return mw.returnJson(False, 'MySQL未启动', [])
|
||||
|
||||
mode_file = getSyncModeFile()
|
||||
# print(mode_file)
|
||||
if not os.path.exists(mode_file):
|
||||
return mw.returnJson(False, '需要先设置同步配置')
|
||||
|
||||
@@ -2718,7 +2845,7 @@ def initSlaveStatusSyncUser(version=''):
|
||||
|
||||
if slave_t['mode'] == '1':
|
||||
mode_name = 'gtid'
|
||||
|
||||
# print(local_mode, mode_name)
|
||||
if local_mode != mode_name:
|
||||
msg += base_t + '->同步模式不一致'
|
||||
continue
|
||||
@@ -2732,8 +2859,9 @@ def initSlaveStatusSyncUser(version=''):
|
||||
pinfo = parseSlaveSyncCmd(cmd_sql)
|
||||
except Exception as e:
|
||||
return mw.returnJson(False, base_t + '->CMD同步命令不合规范!')
|
||||
# print(u['cmd'])
|
||||
# print(cmd_sql)
|
||||
t = pdb.query(cmd_sql)
|
||||
# print(t)
|
||||
isError = isSqlError(t)
|
||||
if isError:
|
||||
return isError
|
||||
@@ -2848,18 +2976,21 @@ def setSlaveStatus(version=''):
|
||||
|
||||
return mw.returnJson(True, '设置成功!')
|
||||
|
||||
|
||||
def deleteSlave(version=''):
|
||||
args = getArgs()
|
||||
def deleteSlaveFunc(sign = ''):
|
||||
db = pMysqlDb()
|
||||
if 'sign' in args:
|
||||
sign = args['sign']
|
||||
if sign != '':
|
||||
db.query("stop slave for channel '{}'".format(sign))
|
||||
db.query("reset slave all for channel '{}'".format(sign))
|
||||
else:
|
||||
db.query('stop slave')
|
||||
db.query('reset slave all')
|
||||
|
||||
def deleteSlave(version=''):
|
||||
args = getArgs()
|
||||
sign = ''
|
||||
if 'sign' in args:
|
||||
sign = args['sign']
|
||||
deleteSlaveFunc(sign)
|
||||
return mw.returnJson(True, '删除成功!')
|
||||
|
||||
|
||||
@@ -2894,6 +3025,291 @@ def dumpMysqlData(version=''):
|
||||
return 'fail'
|
||||
|
||||
|
||||
############### --- 重要 数据补足同步 ---- ###########
|
||||
|
||||
def getSyncMysqlDB(dbname,sign = ''):
|
||||
conn = pSqliteDb('slave_sync_user')
|
||||
if sign != '':
|
||||
data = conn.field('ip,port,user,pass,mode,cmd').where('ip=?', (sign,)).find()
|
||||
else:
|
||||
data = conn.field('ip,port,user,pass,mode,cmd').find()
|
||||
user = data['user']
|
||||
apass = data['pass']
|
||||
port = data['port']
|
||||
ip = data['ip']
|
||||
# 远程数据
|
||||
sync_db = mw.getMyORM()
|
||||
# MySQLdb |
|
||||
sync_db.setPort(port)
|
||||
sync_db.setHost(ip)
|
||||
sync_db.setUser(user)
|
||||
sync_db.setPwd(apass)
|
||||
sync_db.setDbName(dbname)
|
||||
sync_db.setTimeout(60)
|
||||
return sync_db
|
||||
|
||||
def syncDatabaseRepairTempFile():
|
||||
tmp_log = mw.getMWLogs()+ '/mysql-check.log'
|
||||
return tmp_log
|
||||
|
||||
def syncDatabaseRepairLog(version=''):
|
||||
import subprocess
|
||||
args = getArgs()
|
||||
data = checkArgs(args, ['db','sign','op'])
|
||||
if not data[0]:
|
||||
return data[1]
|
||||
|
||||
sync_args_db = args['db']
|
||||
sync_args_sign = args['sign']
|
||||
op = args['op']
|
||||
tmp_log = syncDatabaseRepairTempFile()
|
||||
cmd = 'cd '+mw.getServerDir()+'/mdserver-web && source bin/activate && python3 plugins/mysql/index.py sync_database_repair {"db":"'+sync_args_db+'","sign":"'+sync_args_sign+'"}'
|
||||
# print(cmd)
|
||||
|
||||
if op == 'get':
|
||||
log = mw.getLastLine(tmp_log, 15)
|
||||
return mw.returnJson(True, log)
|
||||
|
||||
if op == 'cmd':
|
||||
return mw.returnJson(True, 'ok', cmd)
|
||||
|
||||
if op == 'do':
|
||||
os.system(' echo "开始执行" > '+ tmp_log)
|
||||
os.system(cmd +' >> '+ tmp_log +' &')
|
||||
return mw.returnJson(True, 'ok')
|
||||
|
||||
return mw.returnJson(False, '无效请求!')
|
||||
|
||||
|
||||
def syncDatabaseRepair(version=''):
|
||||
time_stats_s = time.time()
|
||||
tmp_log = syncDatabaseRepairTempFile()
|
||||
|
||||
from pymysql.converters import escape_string
|
||||
args = getArgs()
|
||||
data = checkArgs(args, ['db','sign'])
|
||||
if not data[0]:
|
||||
return data[1]
|
||||
|
||||
sync_args_db = args['db']
|
||||
sync_args_sign = args['sign']
|
||||
|
||||
# 本地数据
|
||||
local_db = pMysqlDb()
|
||||
# 远程数据
|
||||
sync_db = getSyncMysqlDB(sync_args_db,sync_args_sign)
|
||||
|
||||
tables = local_db.query('show tables from `%s`' % sync_args_db)
|
||||
table_key = "Tables_in_" + sync_args_db
|
||||
inconsistent_table = []
|
||||
|
||||
tmp_dir = '/tmp/sync_db_repair'
|
||||
mw.execShell('mkdir -p '+tmp_dir)
|
||||
|
||||
for tb in tables:
|
||||
|
||||
table_name = sync_args_db+'.'+tb[table_key]
|
||||
table_check_file = tmp_dir+'/'+table_name+'.txt'
|
||||
|
||||
if os.path.exists(table_check_file):
|
||||
# print(table_name+', 已检查OK')
|
||||
continue
|
||||
|
||||
primary_key_sql = "SHOW INDEX FROM "+table_name+" WHERE Key_name = 'PRIMARY';";
|
||||
primary_key_data = local_db.query(primary_key_sql)
|
||||
# print(primary_key_sql,primary_key_data)
|
||||
pkey_name = '*'
|
||||
if len(primary_key_data) == 1:
|
||||
pkey_name = primary_key_data[0]['Column_name']
|
||||
# print(pkey_name)
|
||||
if pkey_name != '*' :
|
||||
# 智能校验(由于服务器同步可能会慢,比较总数总是对不上)
|
||||
cmd_local_newpk_sql = 'select ' + pkey_name + ' from ' + table_name + " order by " + pkey_name + " desc limit 1"
|
||||
cmd_local_newpk_data = local_db.query(cmd_local_newpk_sql)
|
||||
# print(cmd_local_newpk_data)
|
||||
if len(cmd_local_newpk_data) == 1:
|
||||
# 比较总数
|
||||
cmd_count_sql = 'select count('+pkey_name+') as num from '+table_name + ' where '+pkey_name + ' <= '+ str(cmd_local_newpk_data[0][pkey_name])
|
||||
local_count_data = local_db.query(cmd_count_sql)
|
||||
sync_count_data = sync_db.query(cmd_count_sql)
|
||||
|
||||
if local_count_data != sync_count_data:
|
||||
print(cmd_count_sql)
|
||||
print("all data compare: ",local_count_data, sync_count_data)
|
||||
else:
|
||||
print(table_name+' smart compare check ok.')
|
||||
mw.writeFile(tmp_log, table_name+' smart compare check ok.\n','a+')
|
||||
mw.execShell("echo 'ok' > "+table_check_file)
|
||||
continue
|
||||
|
||||
|
||||
|
||||
# 比较总数
|
||||
cmd_count_sql = 'select count('+pkey_name+') as num from '+table_name
|
||||
local_count_data = local_db.query(cmd_count_sql)
|
||||
sync_count_data = sync_db.query(cmd_count_sql)
|
||||
|
||||
if local_count_data != sync_count_data:
|
||||
print("all data compare: ",local_count_data, sync_count_data)
|
||||
inconsistent_table.append(table_name)
|
||||
diff = sync_count_data[0]['num'] - local_count_data[0]['num']
|
||||
print(table_name+', need sync. diff,'+str(diff))
|
||||
mw.writeFile(tmp_log, table_name+', need sync. diff,'+str(diff)+'\n','a+')
|
||||
else:
|
||||
print(table_name+' check ok.')
|
||||
mw.writeFile(tmp_log, table_name+' check ok.\n','a+')
|
||||
mw.execShell("echo 'ok' > "+table_check_file)
|
||||
|
||||
|
||||
# inconsistent_table = ['xx.xx']
|
||||
# 数据对齐
|
||||
for table_name in inconsistent_table:
|
||||
is_break = False
|
||||
while not is_break:
|
||||
local_db.ping()
|
||||
# 远程数据
|
||||
sync_db.ping()
|
||||
|
||||
print("check table:"+table_name)
|
||||
mw.writeFile(tmp_log, "check table:"+table_name+'\n','a+')
|
||||
table_name_pos = 0
|
||||
table_name_pos_file = tmp_dir+'/'+table_name+'.pos.txt'
|
||||
primary_key_sql = "SHOW INDEX FROM "+table_name+" WHERE Key_name = 'PRIMARY';";
|
||||
primary_key_data = local_db.query(primary_key_sql)
|
||||
pkey_name = primary_key_data[0]['Column_name']
|
||||
|
||||
if os.path.exists(table_name_pos_file):
|
||||
table_name_pos = mw.readFile(table_name_pos_file)
|
||||
|
||||
|
||||
data_select_sql = 'select * from '+table_name + ' where '+pkey_name+' > '+str(table_name_pos)+' limit 10000'
|
||||
print(data_select_sql)
|
||||
local_select_data = local_db.query(data_select_sql)
|
||||
|
||||
time_s = time.time()
|
||||
sync_select_data = sync_db.query(data_select_sql)
|
||||
print(f'sync query cos:{time.time() - time_s:.4f}s')
|
||||
mw.writeFile(tmp_log, f'sync query cos:{time.time() - time_s:.4f}s\n','a+')
|
||||
|
||||
# print(local_select_data)
|
||||
# print(sync_select_data)
|
||||
|
||||
# print(len(local_select_data))
|
||||
# print(len(sync_select_data))
|
||||
print('pos:',str(table_name_pos),'local compare sync,',local_select_data == sync_select_data)
|
||||
|
||||
|
||||
cmd_count_sql = 'select count('+pkey_name+') as num from '+table_name
|
||||
local_count_data = local_db.query(cmd_count_sql)
|
||||
time_s = time.time()
|
||||
sync_count_data = sync_db.query(cmd_count_sql)
|
||||
print(f'sync count data cos:{time.time() - time_s:.4f}s')
|
||||
print(local_count_data,sync_count_data)
|
||||
# 数据同步有延迟,相等即任务数据补足完成
|
||||
if local_count_data[0]['num'] == sync_count_data[0]['num']:
|
||||
is_break = True
|
||||
break
|
||||
|
||||
diff = sync_count_data[0]['num'] - local_count_data[0]['num']
|
||||
print("diff," + str(diff)+' line data!')
|
||||
|
||||
if local_select_data == sync_select_data:
|
||||
data_count = len(local_select_data)
|
||||
if data_count == 0:
|
||||
# mw.writeFile(table_name_pos_file, '0')
|
||||
print(table_name+",data is equal ok..")
|
||||
is_break = True
|
||||
break
|
||||
|
||||
# print(table_name,data_count)
|
||||
pos = local_select_data[data_count-1][pkey_name]
|
||||
print('pos',pos)
|
||||
progress = pos/sync_count_data[0]['num']
|
||||
print('progress,%.2f' % progress+'%')
|
||||
mw.writeFile(table_name_pos_file, str(pos))
|
||||
else:
|
||||
sync_select_data_len = len(sync_select_data)
|
||||
skip_idx = 0
|
||||
# 主库PK -> 查询本地 | 保证一致
|
||||
if sync_select_data_len > 0:
|
||||
for idx in range(sync_select_data_len):
|
||||
sync_idx_data = sync_select_data[idx]
|
||||
local_idx_data = None
|
||||
if idx in local_select_data:
|
||||
local_idx_data = local_select_data[idx]
|
||||
if sync_select_data[idx] == local_idx_data:
|
||||
skip_idx = idx
|
||||
pos = local_select_data[idx][pkey_name]
|
||||
mw.writeFile(table_name_pos_file, str(pos))
|
||||
|
||||
# print(insert_data)
|
||||
local_inquery_sql = 'select * from ' + table_name+ ' where ' +pkey_name+' = '+ str(sync_idx_data[pkey_name])
|
||||
# print(local_inquery_sql)
|
||||
ldata = local_db.query(local_inquery_sql)
|
||||
# print('ldata:',ldata)
|
||||
if len(ldata) == 0:
|
||||
print("id:"+ str(sync_idx_data[pkey_name])+ " no exists, insert")
|
||||
insert_sql = 'insert into ' + table_name
|
||||
field_str = ''
|
||||
value_str = ''
|
||||
for field in sync_idx_data:
|
||||
field_str += '`'+field+'`,'
|
||||
value_str += '\''+escape_string(str(sync_idx_data[field]))+'\','
|
||||
field_str = '(' +field_str.strip(',')+')'
|
||||
value_str = '(' +value_str.strip(',')+')'
|
||||
insert_sql = insert_sql+' '+field_str+' values'+value_str+';'
|
||||
print(insert_sql)
|
||||
r = local_db.execute(insert_sql)
|
||||
print(r)
|
||||
else:
|
||||
# print('compare sync->local:',sync_idx_data == ldata[0] )
|
||||
if ldata[0] == sync_idx_data:
|
||||
continue
|
||||
|
||||
print("id:"+ str(sync_idx_data[pkey_name])+ " data is not equal, update")
|
||||
update_sql = 'update ' + table_name
|
||||
field_str = ''
|
||||
value_str = ''
|
||||
for field in sync_idx_data:
|
||||
if field == pkey_name:
|
||||
continue
|
||||
field_str += '`'+field+'`=\''+escape_string(str(sync_idx_data[field]))+'\','
|
||||
field_str = field_str.strip(',')
|
||||
update_sql = update_sql+' set '+field_str+' where '+pkey_name+'=\''+str(sync_idx_data[pkey_name])+'\';'
|
||||
print(update_sql)
|
||||
r = local_db.execute(update_sql)
|
||||
print(r)
|
||||
|
||||
# 本地PK -> 查询主库 | 保证一致
|
||||
# local_select_data_len = len(local_select_data)
|
||||
# if local_select_data_len > 0:
|
||||
# for idx in range(local_select_data_len):
|
||||
# if idx < skip_idx:
|
||||
# continue
|
||||
# local_idx_data = local_select_data[idx]
|
||||
# print('local idx check', idx, skip_idx)
|
||||
# local_inquery_sql = 'select * from ' + table_name+ ' where ' +pkey_name+' = '+ str(local_idx_data[pkey_name])
|
||||
# print(local_inquery_sql)
|
||||
# sdata = sync_db.query(local_inquery_sql)
|
||||
# sdata_len = len(sdata)
|
||||
# print('sdata:',sdata,sdata_len)
|
||||
# if sdata_len == 0:
|
||||
# delete_sql = 'delete from ' + table_name + ' where ' +pkey_name+' = '+ str(local_idx_data[pkey_name])
|
||||
# print(delete_sql)
|
||||
# r = local_db.execute(delete_sql)
|
||||
# print(r)
|
||||
# break
|
||||
|
||||
|
||||
if is_break:
|
||||
print("break all")
|
||||
break
|
||||
time.sleep(3)
|
||||
print(f'data check cos:{time.time() - time_stats_s:.4f}s')
|
||||
print("data supplementation completed")
|
||||
mw.execShell('rm -rf '+tmp_dir)
|
||||
return 'ok'
|
||||
|
||||
############### --- 重要 同步---- ###########
|
||||
|
||||
def asyncTmpfile():
|
||||
@@ -2904,7 +3320,20 @@ def asyncTmpfile():
|
||||
def writeDbSyncStatus(data):
|
||||
path = asyncTmpfile()
|
||||
mw.writeFile(path, json.dumps(data))
|
||||
return True
|
||||
|
||||
def fullSyncCmd():
|
||||
time_all_s = time.time()
|
||||
args = getArgs()
|
||||
data = checkArgs(args, ['db', 'sign'])
|
||||
if not data[0]:
|
||||
return data[1]
|
||||
|
||||
db = args['db']
|
||||
sign = args['sign']
|
||||
|
||||
cmd = 'cd '+mw.getServerDir()+'/mdserver-web && source bin/activate && python3 plugins/mysql/index.py do_full_sync {"db":"'+db+'","sign":"'+sign+'"}'
|
||||
return mw.returnJson(True,'ok',cmd)
|
||||
|
||||
def doFullSync(version=''):
|
||||
mode_file = getSyncModeFile()
|
||||
@@ -2918,7 +3347,53 @@ def doFullSync(version=''):
|
||||
return doFullSyncUser(version)
|
||||
|
||||
|
||||
def isSimpleSyncCmd(sql):
|
||||
new_sql = sql.lower()
|
||||
if new_sql.find('master_auto_position') > 0:
|
||||
return False
|
||||
return True
|
||||
|
||||
def getChannelNameForCmd(cmd):
|
||||
cmd = cmd.lower()
|
||||
cmd_arr = cmd.split('channel')
|
||||
if len(cmd_arr) == 2:
|
||||
cmd_channel_info = cmd_arr[1]
|
||||
channel_name = cmd_channel_info.strip()
|
||||
channel_name = channel_name.strip(';')
|
||||
channel_name = channel_name.strip("'")
|
||||
return channel_name
|
||||
return ''
|
||||
|
||||
|
||||
|
||||
def doFullSyncUserImportContentForChannel(file, channel_name):
|
||||
# print(file, channel_name)
|
||||
content = mw.readFile(file)
|
||||
|
||||
content = content.replace('STOP SLAVE;', "STOP SLAVE for channel '{}';".format(channel_name))
|
||||
content = content.replace('START SLAVE;', "START SLAVE for channel '{}';".format(channel_name))
|
||||
|
||||
find_head = "CHANGE MASTER TO "
|
||||
find_re = find_head+"(.*?);"
|
||||
find_r = re.search(find_re, content, re.I|re.M)
|
||||
if find_r:
|
||||
find_rg = find_r.groups()
|
||||
if len(find_rg)>0:
|
||||
find_str = find_head+find_rg[0]
|
||||
if find_str.lower().find('channel')==-1:
|
||||
content = content.replace(find_str+';', find_str+" for channel '{}';".format(channel_name))
|
||||
|
||||
mw.writeFile(file,content)
|
||||
return True
|
||||
|
||||
|
||||
def doFullSyncUser(version=''):
|
||||
which_pv = mw.execShell('which pv')
|
||||
is_exist_pv = False
|
||||
if os.path.exists(which_pv[0]):
|
||||
is_exist_pv = True
|
||||
|
||||
time_all_s = time.time()
|
||||
args = getArgs()
|
||||
data = checkArgs(args, ['db', 'sign'])
|
||||
if not data[0]:
|
||||
@@ -2939,6 +3414,9 @@ def doFullSyncUser(version=''):
|
||||
|
||||
db = pMysqlDb()
|
||||
|
||||
# 重置
|
||||
# deleteSlaveFunc(sync_sign)
|
||||
|
||||
conn = pSqliteDb('slave_sync_user')
|
||||
if sync_sign != '':
|
||||
data = conn.field('ip,port,user,pass,mode,cmd').where(
|
||||
@@ -2946,10 +3424,15 @@ def doFullSyncUser(version=''):
|
||||
else:
|
||||
data = conn.field('ip,port,user,pass,mode,cmd').find()
|
||||
|
||||
# print(data)
|
||||
user = data['user']
|
||||
apass = data['pass']
|
||||
port = data['port']
|
||||
ip = data['ip']
|
||||
cmd = data['cmd']
|
||||
channel_name = getChannelNameForCmd(cmd)
|
||||
|
||||
sync_mdb = getSyncMysqlDB(sync_db,sync_sign)
|
||||
|
||||
bak_file = '/tmp/tmp.sql'
|
||||
if os.path.exists(bak_file):
|
||||
@@ -2963,41 +3446,111 @@ def doFullSyncUser(version=''):
|
||||
|
||||
time.sleep(1)
|
||||
writeDbSyncStatus({'code': 1, 'msg': '正在停止从库...', 'progress': 15})
|
||||
if version == '8.0':
|
||||
|
||||
mdb8 = ['8.0','8.1','8.2','8.3','8.4']
|
||||
if mw.inArray(mdb8,version):
|
||||
db.query("stop slave user='{}' password='{}';".format(user, apass))
|
||||
else:
|
||||
db.query("stop slave")
|
||||
|
||||
time.sleep(2)
|
||||
time.sleep(1)
|
||||
|
||||
writeDbSyncStatus({'code': 2, 'msg': '远程导出数据...', 'progress': 20})
|
||||
|
||||
if not os.path.exists(bak_file):
|
||||
dump_sql_data = getServerDir() + "/bin/mysqldump " + dmp_option + " --force --opt --default-character-set=utf8 --single-transaction -h" + ip + " -P" + \
|
||||
port + " -u" + user + " -p'" + apass + \
|
||||
"' --ssl-mode=DISABLED " + sync_db + " > " + bak_file
|
||||
print(dump_sql_data)
|
||||
mw.execShell(dump_sql_data)
|
||||
# --master-data=2表示在dump过程中记录主库的binlog和pos点,并在dump文件中注释掉这一行
|
||||
# --master-data=1表示在dump过程中记录主库的binlog和pos点,并在dump文件中不注释掉这一行,即恢复时会执行
|
||||
|
||||
# --dump-slave=2表示在dump过程中,在从库dump,mysqldump进程也要在从库执行,记录当时主库的binlog和pos点,并在dump文件中注释掉这一行
|
||||
# --dump-slave=1表示在dump过程中,在从库dump,mysqldump进程也要在从库执行,记录当时主库的binlog和pos点,并在dump文件中不注释掉这一行
|
||||
|
||||
# --force --opt --single-transaction
|
||||
# --skip-opt --create-options
|
||||
# --master-data=1
|
||||
|
||||
find_run_dump = mw.execShell('ps -ef | grep mysqldump | grep -v grep')
|
||||
if find_run_dump[0] != "":
|
||||
print("正在远程导出数据中,别着急...")
|
||||
writeDbSyncStatus({'code': 3.1, 'msg': '正在远程导出数据中,别着急...', 'progress': 19})
|
||||
return False
|
||||
|
||||
time_s = time.time()
|
||||
if not os.path.exists(bak_file):
|
||||
if isSimpleSyncCmd(cmd):
|
||||
dmp_option += " --master-data=1 --apply-slave-statements --include-master-host-port "
|
||||
else:
|
||||
dmp_option += ' '
|
||||
|
||||
dump_sql_data = getServerDir() + "/bin/mysqldump --single-transaction --default-character-set=utf8mb4 --compress -q " + dmp_option + " -h" + ip + " -P" + \
|
||||
port + " -u" + user + " -p'" + apass + "' --ssl-mode=DISABLED " + sync_db + " > " + bak_file
|
||||
print(dump_sql_data)
|
||||
time_s = time.time()
|
||||
r = mw.execShell(dump_sql_data)
|
||||
print(r)
|
||||
time_e = time.time()
|
||||
export_cos = time_e - time_s
|
||||
print("export cos:", export_cos)
|
||||
|
||||
writeDbSyncStatus({'code': 3, 'msg': '正在到本地导入数据中...', 'progress': 40})
|
||||
writeDbSyncStatus({'code': 3, 'msg': '导出耗时:'+str(int(export_cos))+'秒,正在到本地导入数据中...', 'progress': 40})
|
||||
|
||||
find_run_import = mw.execShell('ps -ef | grep mysql| grep '+ bak_file +' | grep -v grep')
|
||||
if find_run_import[0] != "":
|
||||
print("正在导入数据中,别着急...")
|
||||
writeDbSyncStatus({'code': 4.1, 'msg': '正在导入数据中,别着急...', 'progress': 39})
|
||||
return False
|
||||
|
||||
time_s = time.time()
|
||||
if os.path.exists(bak_file):
|
||||
# 重置
|
||||
db.execute('reset master')
|
||||
|
||||
# 加快导入 - 开始
|
||||
# db.execute('set global innodb_flush_log_at_trx_commit = 2')
|
||||
# db.execute('set global sync_binlog = 2000')
|
||||
|
||||
if channel_name != '':
|
||||
doFullSyncUserImportContentForChannel(bak_file, channel_name)
|
||||
|
||||
pwd = pSqliteDb('config').where('id=?', (1,)).getField('mysql_root')
|
||||
sock = getSocketFile()
|
||||
my_import_cmd = getServerDir() + '/bin/mysql -S ' + sock + " -uroot -p'" + pwd + \
|
||||
"' " + sync_db_import + ' < ' + bak_file
|
||||
print(my_import_cmd)
|
||||
mw.execShell(my_import_cmd)
|
||||
|
||||
if version == '8.0':
|
||||
if is_exist_pv:
|
||||
my_import_cmd = getServerDir() + '/bin/mysql -S ' + sock + " -uroot -p'" + pwd + "' " + sync_db_import
|
||||
my_import_cmd = "pv -t -p " + bak_file + '|' + my_import_cmd
|
||||
print(my_import_cmd)
|
||||
os.system(my_import_cmd)
|
||||
else:
|
||||
my_import_cmd = getServerDir() + '/bin/mysql -S ' + sock + " -uroot -p'" + pwd + "' " + sync_db_import + ' < ' + bak_file
|
||||
print(my_import_cmd)
|
||||
mw.execShell(my_import_cmd)
|
||||
|
||||
# 加快导入 - 结束
|
||||
# db.execute('set global innodb_flush_log_at_trx_commit = 1')
|
||||
# db.execute('set global sync_binlog = 1')
|
||||
|
||||
time_e = time.time()
|
||||
import_cos = time_e - time_s
|
||||
print("import cos:", import_cos)
|
||||
writeDbSyncStatus({'code': 4, 'msg': '导入耗时:'+str(int(import_cos))+'秒', 'progress': 60})
|
||||
|
||||
time.sleep(3)
|
||||
# print(cmd)
|
||||
# r = db.query(cmd)
|
||||
# print(r)
|
||||
|
||||
mdb8 = ['8.0','8.1','8.2','8.3','8.4']
|
||||
if mw.inArray(mdb8,version):
|
||||
db.query("start slave user='{}' password='{}';".format(user, apass))
|
||||
else:
|
||||
db.query("start slave")
|
||||
|
||||
writeDbSyncStatus({'code': 6, 'msg': '从库重启完成...', 'progress': 100})
|
||||
db.query("start all slaves")
|
||||
time_all_e = time.time()
|
||||
cos = time_all_e - time_all_s
|
||||
writeDbSyncStatus({'code': 6, 'msg': '总耗时:'+str(int(cos))+'秒,从库重启完成...', 'progress': 100})
|
||||
|
||||
if os.path.exists(bak_file):
|
||||
os.system("rm -rf " + bak_file)
|
||||
|
||||
return True
|
||||
|
||||
|
||||
@@ -3128,10 +3681,13 @@ def doFullSyncSSH(version=''):
|
||||
print(import_data[0])
|
||||
writeDbSyncStatus({'code': 5, 'msg': '导入数据失败...', 'progress': 100})
|
||||
return 'fail'
|
||||
|
||||
# "start slave user='{}' password='{}';".format(uinfo['username'], uinfo['password'])
|
||||
|
||||
db.query("start slave")
|
||||
|
||||
mdb8 = ['8.0','8.1','8.2','8.3','8.4']
|
||||
if mw.inArray(mdb8,version):
|
||||
db.query("start slave user='{}' password='{}';".format(uinfo['username'], uinfo['password']))
|
||||
else:
|
||||
db.query("start slave")
|
||||
|
||||
writeDbSyncStatus({'code': 6, 'msg': '从库重启完成...', 'progress': 100})
|
||||
|
||||
os.system("rm -rf " + SSH_PRIVATE_KEY)
|
||||
@@ -3176,9 +3732,16 @@ def fullSync(version=''):
|
||||
|
||||
|
||||
def installPreInspection(version):
|
||||
import psutil
|
||||
mem = psutil.virtual_memory()
|
||||
memTotal = mem.total
|
||||
memG = memTotal/1024/1024/1024
|
||||
if memG > 2:
|
||||
return 'ok'
|
||||
|
||||
swap_path = mw.getServerDir() + "/swap"
|
||||
if not os.path.exists(swap_path):
|
||||
return "为了稳定安装MySQL,先安装swap插件!"
|
||||
return "内存小,为了稳定安装MySQL,先安装swap插件!"
|
||||
return 'ok'
|
||||
|
||||
|
||||
@@ -3241,7 +3804,7 @@ if __name__ == "__main__":
|
||||
elif func == 'my_db_pos':
|
||||
print(getMyDbPos())
|
||||
elif func == 'set_db_pos':
|
||||
print(setMyDbPos())
|
||||
print(setMyDbPos(version))
|
||||
elif func == 'my_port':
|
||||
print(getMyPort())
|
||||
elif func == 'set_my_port':
|
||||
@@ -3256,8 +3819,16 @@ if __name__ == "__main__":
|
||||
print(setDbBackup())
|
||||
elif func == 'import_db_backup':
|
||||
print(importDbBackup())
|
||||
elif func == 'import_db_backup_progress':
|
||||
print(importDbBackupProgress())
|
||||
elif func == 'import_db_backup_progress_bar':
|
||||
print(importDbBackupProgressBar())
|
||||
elif func == 'import_db_external':
|
||||
print(importDbExternal())
|
||||
elif func == 'import_db_external_progress':
|
||||
print(importDbExternalProgress())
|
||||
elif func == 'import_db_external_progress_bar':
|
||||
print(importDbExternalProgressBar())
|
||||
elif func == 'delete_db_backup':
|
||||
print(deleteDbBackup())
|
||||
elif func == 'get_db_backup_list':
|
||||
@@ -3362,7 +3933,13 @@ if __name__ == "__main__":
|
||||
print(fullSync(version))
|
||||
elif func == 'do_full_sync':
|
||||
print(doFullSync(version))
|
||||
elif func == 'full_sync_cmd':
|
||||
print(fullSyncCmd())
|
||||
elif func == 'dump_mysql_data':
|
||||
print(dumpMysqlData(version))
|
||||
elif func == 'sync_database_repair':
|
||||
print(syncDatabaseRepair())
|
||||
elif func == 'sync_database_repair_log':
|
||||
print(syncDatabaseRepairLog())
|
||||
else:
|
||||
print('error')
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
"checks": "server/mysql/VERSION/bin/mysql",
|
||||
"path": "server/mysql/VERSION",
|
||||
"todo_versions":["5.6","5.7","8.0","8.2"],
|
||||
"versions":["5.5", "5.6", "5.7","8.0","8.2"],
|
||||
"updates":["5.5.62","5.6.50", "5.7.32","8.0.34","8.2.0"],
|
||||
"versions":["5.5", "5.6", "5.7","8.0","8.2","8.3"],
|
||||
"updates":["5.5.62","5.6.50", "5.7.32","8.0.34","8.2.0","8.3.0"],
|
||||
"shell":"install.sh",
|
||||
"checks":"server/mysql",
|
||||
"path":"server/mysql",
|
||||
|
||||
@@ -6,8 +6,11 @@ export PATH
|
||||
# https://www.cnblogs.com/whiteY/p/17331882.html
|
||||
|
||||
# cd /www/server/mdserver-web/plugins/mysql && bash install.sh install 8.2
|
||||
# cd /www/server/mdserver-web && source bin/activate && python3 /www/server/mdserver-web/plugins/mysql/index.py try_slave_sync_bugfix {}
|
||||
|
||||
# cd /www/server/mdserver-web && source bin/activate && python3 plugins/mysql/index.py try_slave_sync_bugfix {}
|
||||
# cd /www/server/mdserver-web && source bin/activate && python3 plugins/mysql/index.py do_full_sync {"db":"xxx","sign":"","begin":1}
|
||||
# cd /www/server/mdserver-web && source bin/activate && python3 plugins/mysql/index.py sync_database_repair {"db":"xxx","sign":""}
|
||||
# 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
|
||||
curPath=`pwd`
|
||||
rootPath=$(dirname "$curPath")
|
||||
rootPath=$(dirname "$rootPath")
|
||||
|
||||
+178
-14
@@ -795,7 +795,7 @@ function addDatabase(type){
|
||||
|
||||
function delDb(id, name){
|
||||
safeMessage('删除['+name+']','您真的要删除['+name+']吗?',function(){
|
||||
var data='id='+id+'&name='+name
|
||||
var data='id='+id+'&name='+name;
|
||||
myPost('del_db', data, function(data){
|
||||
var rdata = $.parseJSON(data.data);
|
||||
showMsg(rdata.msg,function(){
|
||||
@@ -871,7 +871,7 @@ function openPhpmyadmin(name,username,password){
|
||||
}
|
||||
|
||||
if (rdata.data['cfg']['choose'] != 'mysql'){
|
||||
layer.msg('当前为['+rdata.choose+']模式,若要使用请修改phpMyAdmin访问切换.',{icon:2,shade: [0.3, '#000']});
|
||||
layer.msg('当前为['+rdata.data['cfg']['choose'] + ']模式,若要使用请修改phpMyAdmin访问切换.',{icon:2,shade: [0.3, '#000']});
|
||||
return;
|
||||
}
|
||||
var home_page = rdata.data['home_page'];
|
||||
@@ -929,6 +929,31 @@ function importBackup(file,name){
|
||||
});
|
||||
}
|
||||
|
||||
function importBackupProgress(file,name){
|
||||
myPost('import_db_backup_progress',{file:file,name:name}, function(data){
|
||||
var rdata = $.parseJSON(data.data);
|
||||
layer.open({
|
||||
title: "手动导入命令CMD【显示进度】",
|
||||
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 importDbExternal(file,name){
|
||||
myPost('import_db_external',{file:file,name:name}, function(data){
|
||||
@@ -936,6 +961,31 @@ function importDbExternal(file,name){
|
||||
});
|
||||
}
|
||||
|
||||
function importDbExternalProgress(file,name){
|
||||
myPost('import_db_external_progress',{file:file,name:name}, function(data){
|
||||
var rdata = $.parseJSON(data.data);
|
||||
layer.open({
|
||||
title: "手动导入命令CMD【显示进度】",
|
||||
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 setLocalImport(db_name){
|
||||
|
||||
//上传文件
|
||||
@@ -991,6 +1041,7 @@ function setLocalImport(db_name){
|
||||
<td><span> ' + file_list[i]['time'] + '</span></td>\
|
||||
<td style="text-align: right;">\
|
||||
<a class="btlink" onclick="importDbExternal(\'' + file_list[i]['name'] + '\',\'' +db_name+ '\')">导入</a> | \
|
||||
<a class="btlink" onclick="importDbExternalProgress(\'' + file_list[i]['name'] + '\',\'' +db_name+ '\')">导入进度</a> | \
|
||||
<a class="btlink del" index="'+i+'">删除</a>\
|
||||
</td>\
|
||||
</tr>';
|
||||
@@ -1014,7 +1065,7 @@ function setLocalImport(db_name){
|
||||
var layerIndex = layer.open({
|
||||
type: 1,
|
||||
title: "从文件导入数据",
|
||||
area: ['600px', '380px'],
|
||||
area: ['700px', '380px'],
|
||||
closeBtn: 1,
|
||||
shadeClose: false,
|
||||
content: '<div class="pd15">\
|
||||
@@ -1060,7 +1111,7 @@ function setBackup(db_name){
|
||||
var layerIndex = layer.open({
|
||||
type: 1,
|
||||
title: "数据库备份详情",
|
||||
area: ['600px', '280px'],
|
||||
area: ['700px', '280px'],
|
||||
closeBtn: 1,
|
||||
shadeClose: false,
|
||||
content: '<div class="pd15">\
|
||||
@@ -1114,6 +1165,7 @@ function setBackupReq(db_name, obj){
|
||||
<td><span> ' + rdata.data[i]['time'] + '</span></td>\
|
||||
<td style="text-align: right;">\
|
||||
<a class="btlink" onclick="importBackup(\'' + rdata.data[i]['name'] + '\',\'' +db_name+ '\')">导入</a> | \
|
||||
<a class="btlink" onclick="importBackupProgress(\'' + rdata.data[i]['name'] + '\',\'' +db_name+ '\')">导入进度</a> | \
|
||||
<a class="btlink" onclick="downloadBackup(\'' + rdata.data[i]['file'] + '\')">下载</a> | \
|
||||
<a class="btlink" onclick="delBackup(\'' + rdata.data[i]['name'] + '\',\'' +db_name+ '\')">删除</a>\
|
||||
</td>\
|
||||
@@ -1152,7 +1204,7 @@ function dbList(page, search){
|
||||
list += '<td><span class="c9 input-edit" onclick="setDbPs(\''+rdata.data[i]['id']+'\',\''+rdata.data[i]['name']+'\',this)" style="display: inline-block;">'+rdata.data[i]['ps']+'</span></td>';
|
||||
list += '<td style="text-align:right">';
|
||||
|
||||
list += '<a href="javascript:;" class="btlink" class="btlink" onclick="setBackup(\''+rdata.data[i]['name']+'\',this)" title="数据库备份">'+(rdata.data[i]['is_backup']?'备份':'未备份') +'</a> | ';
|
||||
list += '<a href="javascript:;" class="btlink" class="btlink" onclick="setBackup(\''+rdata.data[i]['name']+'\',this)" title="数据库备份">'+(rdata.data[i]['is_backup']?'已备份':'未备份') +'</a> | ';
|
||||
|
||||
var rw = '';
|
||||
var rw_change = 'all';
|
||||
@@ -1933,6 +1985,7 @@ function getFullSyncStatus(db){
|
||||
</div>\
|
||||
<div class='table_toolbar' style='left:0px;'>\
|
||||
<span data-status='init' class='sync btn btn-default btn-sm' id='begin_full_sync'>开始</span>\
|
||||
<span data-status='init' class='btn btn-default btn-sm' id='full_sync_cmd'>手动命令</span>\
|
||||
</div>\
|
||||
</div>",
|
||||
cancel: function(){
|
||||
@@ -1951,10 +2004,36 @@ function getFullSyncStatus(db){
|
||||
fullSync(db,sign,0);
|
||||
}, 1000);
|
||||
$(this).data('status','starting');
|
||||
$('#begin_full_sync').text("同步中");
|
||||
} else {
|
||||
layer.msg("正在同步中..",{icon:0});
|
||||
}
|
||||
});
|
||||
|
||||
$('#full_sync_cmd').click(function(){
|
||||
myPostN('full_sync_cmd', {'db':db,'sign':''}, function(rdata){
|
||||
var rdata = $.parseJSON(rdata.data);
|
||||
layer.open({
|
||||
title: "手动执行命令CMD",
|
||||
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);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -1970,12 +2049,91 @@ function getFullSyncStatus(db){
|
||||
if (rdata['code']==6 ||rdata['code']<0){
|
||||
layer.msg(rdata['msg']);
|
||||
clearInterval(timeId);
|
||||
$('#begin_full_sync').text("同步结束,再次同步?");
|
||||
$("#begin_full_sync").attr('data-status','init');
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function dataSyncVerify(db){
|
||||
var reqTimer = null;
|
||||
|
||||
function requestLogs(layerIndex){
|
||||
myPostN('sync_database_repair_log', {db:db, sign:'',op:'get'}, function(rdata){
|
||||
var rdata = $.parseJSON(rdata.data);
|
||||
|
||||
if(!rdata.status) {
|
||||
layer.close(layerIndex);
|
||||
layer.msg(rdata.msg,{icon:2, time:2000});
|
||||
clearInterval(reqTimer);
|
||||
return;
|
||||
};
|
||||
|
||||
if (rdata.msg == ''){
|
||||
rdata.msg = '暂无数据!';
|
||||
}
|
||||
|
||||
$("#data_verify_log").html(rdata.msg);
|
||||
//滚动到最低
|
||||
var ob = document.getElementById('data_verify_log');
|
||||
ob.scrollTop = ob.scrollHeight;
|
||||
});
|
||||
}
|
||||
|
||||
layer.open({
|
||||
type: 1,
|
||||
title: '同步数据库['+db+']数据校验',
|
||||
area: '500px',
|
||||
btn:[ "开始","取消","手动"],
|
||||
content:"<div class='bt-form'>\
|
||||
"+'<pre id="data_verify_log" style="overflow: auto; border: 0px none; line-height:23px;padding: 5px; margin: 0px; white-space: pre-wrap; height: 395px; background-color: rgb(51,51,51);color:#f1f1f1;border-radius:0px;font-family:"></pre>'+"\
|
||||
</div>",
|
||||
cancel: function(){
|
||||
if (reqTimer){
|
||||
clearInterval(reqTimer);
|
||||
}
|
||||
},
|
||||
yes:function(index,layer_index){
|
||||
myPostN('sync_database_repair_log', {db:db, sign:'',op:'do'}, function(data){});
|
||||
layer.msg("执行成功");
|
||||
|
||||
requestLogs(layer_index);
|
||||
reqTimer = setInterval(function(){
|
||||
requestLogs(layer_index);
|
||||
},3000);
|
||||
},
|
||||
success:function(){
|
||||
},
|
||||
btn3: function(){
|
||||
myPostN('sync_database_repair_log', {db:db, sign:'',op:'cmd'}, function(rdata){
|
||||
var rdata = $.parseJSON(rdata.data);
|
||||
layer.open({
|
||||
title: "手动执行命令CMD",
|
||||
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);
|
||||
}
|
||||
});
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
function addSlaveSSH(ip=''){
|
||||
|
||||
myPost('get_slave_ssh_by_ip', {ip:ip}, function(rdata){
|
||||
@@ -2131,7 +2289,7 @@ function addSlaveSyncUser(ip=''){
|
||||
|
||||
var index = layer.open({
|
||||
type: 1,
|
||||
area: ['500px','470px'],
|
||||
area: ['500px','510px'],
|
||||
title: '同步账户',
|
||||
closeBtn: 1,
|
||||
shift: 5,
|
||||
@@ -2142,6 +2300,15 @@ function addSlaveSyncUser(ip=''){
|
||||
<div class='line'><span class='tname'>端口</span><div class='info-r'><input name='port' class='bt-input-text mr5' type='number' style='width:330px;' value='"+port+"'></div></div>\
|
||||
<div class='line'><span class='tname'>同步账户</span><div class='info-r'><input name='user' class='bt-input-text mr5' type='text' style='width:330px;' value='"+user+"'></div></div>\
|
||||
<div class='line'><span class='tname'>同步密码</span><div class='info-r'><input name='pass' class='bt-input-text mr5' type='text' style='width:330px;' value='"+pass+"'></div></div>\
|
||||
<div class='line'>\
|
||||
<span class='tname'>同步模式</span>\
|
||||
<div class='info-r'>\
|
||||
<select class='bt-input-text mr5' name='mode'>\
|
||||
<option value='0' "+( mode == '0' ? 'selected="selected"' : '')+">经典</option>\
|
||||
<option value='1' "+( mode == '1' ? 'selected="selected"' : '')+">GTID</option>\
|
||||
</select>\
|
||||
</div>\
|
||||
</div>\
|
||||
<div class='line'>\
|
||||
<span class='tname'>CMD[必须填写]</span>\
|
||||
<div class='info-r'><textarea class='bt-input-text mr5' row='20' cols='30' name='cmd' style='width:330px;height:150px;'></textarea></div>\
|
||||
@@ -2152,6 +2319,7 @@ function addSlaveSyncUser(ip=''){
|
||||
$('textarea[name="cmd"]').html(cmd);
|
||||
$('textarea[name="cmd"]').change(function(){
|
||||
var val = $(this).val();
|
||||
val = val.replace(';','');
|
||||
var a = {};
|
||||
if (val.toLowerCase().indexOf('for')>0){
|
||||
cmd_tmp = val.split('for');
|
||||
@@ -2178,11 +2346,6 @@ function addSlaveSyncUser(ip=''){
|
||||
$('input[name="port"]').val(a['MASTER_PORT']);
|
||||
$('input[name="user"]').val(a['MASTER_USER']);
|
||||
$('input[name="pass"]').val(a['MASTER_PASSWORD']);
|
||||
|
||||
console.log(a['MASTER_AUTO_POSITION'],typeof(a['MASTER_AUTO_POSITION']));
|
||||
if (typeof(a['MASTER_AUTO_POSITION']) != 'undefined' ){
|
||||
$('input[name="mode"]').val('1');
|
||||
}
|
||||
});
|
||||
},
|
||||
yes:function(index){
|
||||
@@ -2191,7 +2354,7 @@ function addSlaveSyncUser(ip=''){
|
||||
var user = $('input[name="user"]').val();
|
||||
var pass = $('input[name="pass"]').val();
|
||||
var cmd = $('textarea[name="cmd"]').val();
|
||||
var mode = $('input[name="mode"]').val();
|
||||
var mode = $('select[name="mode"]').val();
|
||||
|
||||
var data = {ip:ip,port:port,cmd:cmd,user:user,pass:pass,mode:mode};
|
||||
myPost('add_slave_sync_user', data, function(ret_data){
|
||||
@@ -2469,7 +2632,7 @@ function masterOrSlaveConf(version=''){
|
||||
for(i in rdata.data){
|
||||
|
||||
var v = rdata.data[i];
|
||||
if ('Channel_Name' in v){
|
||||
if ('Channel_Name' in v && v['Channel_Name'] !=''){
|
||||
isHasSign = true;
|
||||
}
|
||||
|
||||
@@ -2640,7 +2803,8 @@ function masterOrSlaveConf(version=''){
|
||||
list += '<td>' + rdata.data[i]['name'] +'</td>';
|
||||
list += '<td style="text-align:right">' +
|
||||
'<a href="javascript:;" class="btlink" onclick="setDbSlave(\''+rdata.data[i]['name']+'\')" title="加入|退出">'+(rdata.data[i]['slave']?'退出':'加入')+'</a> | ' +
|
||||
'<a href="javascript:;" class="btlink" onclick="getFullSyncStatus(\''+rdata.data[i]['name']+'\')" title="同步">同步</a>' +
|
||||
'<a href="javascript:;" class="btlink" onclick="getFullSyncStatus(\''+rdata.data[i]['name']+'\')" title="同步">同步</a> | ' +
|
||||
'<a href="javascript:;" class="btlink" onclick="dataSyncVerify(\''+rdata.data[i]['name']+'\')" title="数据校验">数据校验</a>' +
|
||||
'</td>';
|
||||
list += '</tr>';
|
||||
}
|
||||
|
||||
@@ -117,11 +117,11 @@ Install_mysql()
|
||||
if [ -f ${mysqlDir}/mysql-boost-${VERSION}.tar.gz ];then
|
||||
md5_mysql=`md5sum ${mysqlDir}/mysql-boost-${VERSION}.tar.gz | awk '{print $1}'`
|
||||
if [ "${md5_mysql_ok}" == "${md5_mysql}" ]; then
|
||||
echo "mysql8.0 file check ok"
|
||||
echo "mysql8.2 file check ok"
|
||||
else
|
||||
# 重新下载
|
||||
rm -rf ${mysqlDir}/mysql-${VERSION}
|
||||
wget --no-check-certificate -O ${mysqlDir}/mysql-boost-${VERSION}.tar.gz --tries=3 https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-boost-${VERSION}.tar.gz
|
||||
wget --no-check-certificate -O ${mysqlDir}/mysql-boost-${VERSION}.tar.gz --tries=3 https://dev.mysql.com/get/Downloads/MySQL-8.2/mysql-boost-${VERSION}.tar.gz
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
Executable
+235
@@ -0,0 +1,235 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/bin/bash
|
||||
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin:/opt/homebrew/bin
|
||||
export PATH
|
||||
|
||||
#https://dev.mysql.com/downloads/mysql/5.7.html
|
||||
#https://dev.mysql.com/downloads/file/?id=489855
|
||||
|
||||
curPath=`pwd`
|
||||
rootPath=$(dirname "$curPath")
|
||||
rootPath=$(dirname "$rootPath")
|
||||
serverPath=$(dirname "$rootPath")
|
||||
sysName=`uname`
|
||||
|
||||
|
||||
install_tmp=${rootPath}/tmp/mw_install.pl
|
||||
mysqlDir=${serverPath}/source/mysql
|
||||
|
||||
_os=`uname`
|
||||
echo "use system: ${_os}"
|
||||
if [ ${_os} == "Darwin" ]; then
|
||||
OSNAME='macos'
|
||||
elif grep -Eq "openSUSE" /etc/*-release; then
|
||||
OSNAME='opensuse'
|
||||
zypper refresh
|
||||
elif grep -Eq "FreeBSD" /etc/*-release; then
|
||||
OSNAME='freebsd'
|
||||
pkg install -y wget unzip
|
||||
elif grep -Eqi "Arch" /etc/issue || grep -Eq "Arch" /etc/*-release; then
|
||||
OSNAME='arch'
|
||||
echo y | pacman -Sy unzip
|
||||
elif grep -Eqi "CentOS" /etc/issue || grep -Eq "CentOS" /etc/*-release; then
|
||||
OSNAME='centos'
|
||||
yum install -y wget zip unzip
|
||||
elif grep -Eqi "Fedora" /etc/issue || grep -Eq "Fedora" /etc/*-release; then
|
||||
OSNAME='fedora'
|
||||
yum install -y wget zip unzip
|
||||
elif grep -Eqi "Rocky" /etc/issue || grep -Eq "Rocky" /etc/*-release; then
|
||||
OSNAME='rocky'
|
||||
yum install -y wget zip unzip
|
||||
elif grep -Eqi "AlmaLinux" /etc/issue || grep -Eq "AlmaLinux" /etc/*-release; then
|
||||
OSNAME='alma'
|
||||
yum install -y wget zip unzip
|
||||
elif grep -Eqi "Debian" /etc/issue || grep -Eq "Debian" /etc/*-release; then
|
||||
OSNAME='debian'
|
||||
apt update -y
|
||||
apt install -y devscripts
|
||||
apt install -y wget zip unzip
|
||||
elif grep -Eqi "Ubuntu" /etc/issue || grep -Eq "Ubuntu" /etc/*-release; then
|
||||
OSNAME='ubuntu'
|
||||
apt install -y wget zip unzip
|
||||
else
|
||||
OSNAME='unknow'
|
||||
fi
|
||||
|
||||
VERSION_ID=`cat /etc/*-release | grep VERSION_ID | awk -F = '{print $2}' | awk -F "\"" '{print $2}'`
|
||||
|
||||
|
||||
VERSION=8.3.0
|
||||
Install_mysql()
|
||||
{
|
||||
mkdir -p ${mysqlDir}
|
||||
echo '正在安装脚本文件...' > $install_tmp
|
||||
|
||||
|
||||
if id mysql &> /dev/null ;then
|
||||
echo "mysql UID is `id -u www`"
|
||||
echo "mysql Shell is `grep "^www:" /etc/passwd |cut -d':' -f7 `"
|
||||
else
|
||||
groupadd mysql
|
||||
useradd -g mysql mysql
|
||||
fi
|
||||
|
||||
# ----- cpu start ------
|
||||
if [ -z "${cpuCore}" ]; then
|
||||
cpuCore="1"
|
||||
fi
|
||||
|
||||
if [ -f /proc/cpuinfo ];then
|
||||
cpuCore=`cat /proc/cpuinfo | grep "processor" | wc -l`
|
||||
fi
|
||||
|
||||
MEM_INFO=$(free -m|grep Mem|awk '{printf("%.f",($2)/1024)}')
|
||||
if [ "${cpuCore}" != "1" ] && [ "${MEM_INFO}" != "0" ];then
|
||||
if [ "${cpuCore}" -gt "${MEM_INFO}" ];then
|
||||
cpuCore="${MEM_INFO}"
|
||||
fi
|
||||
else
|
||||
cpuCore="1"
|
||||
fi
|
||||
|
||||
if [ "$cpuCore" -gt "2" ];then
|
||||
cpuCore=`echo "$cpuCore" | awk '{printf("%.f",($1)*0.8)}'`
|
||||
else
|
||||
cpuCore="1"
|
||||
fi
|
||||
# ----- cpu end ------
|
||||
|
||||
cd ${rootPath}/plugins/mysql/lib && /bin/bash rpcgen.sh
|
||||
|
||||
INSTALL_CMD=cmake
|
||||
# check cmake version
|
||||
CMAKE_VERSION=`cmake -version | grep version | awk '{print $3}' | awk -F '.' '{print $1}'`
|
||||
if [ "$CMAKE_VERSION" -eq "2" ];then
|
||||
mkdir -p /var/log/mariadb
|
||||
touch /var/log/mariadb/mariadb.log
|
||||
INSTALL_CMD=cmake3
|
||||
fi
|
||||
|
||||
if [ ! -f ${mysqlDir}/mysql-boost-${VERSION}.tar.gz ];then
|
||||
wget --no-check-certificate -O ${mysqlDir}/mysql-boost-${VERSION}.tar.gz --tries=3 https://cdn.mysql.com//Downloads/MySQL-8.3/mysql-boost-${VERSION}.tar.gz
|
||||
fi
|
||||
|
||||
#检测文件是否损坏.
|
||||
md5_mysql_ok=8c2399782217f5391322751c66ea261b
|
||||
if [ -f ${mysqlDir}/mysql-boost-${VERSION}.tar.gz ];then
|
||||
md5_mysql=`md5sum ${mysqlDir}/mysql-boost-${VERSION}.tar.gz | awk '{print $1}'`
|
||||
if [ "${md5_mysql_ok}" == "${md5_mysql}" ]; then
|
||||
echo "mysql8.3 file check ok"
|
||||
else
|
||||
# 重新下载
|
||||
rm -rf ${mysqlDir}/mysql-${VERSION}
|
||||
wget --no-check-certificate -O ${mysqlDir}/mysql-boost-${VERSION}.tar.gz --tries=3 https://dev.mysql.com/get/Downloads/MySQL-8.3/mysql-boost-${VERSION}.tar.gz
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ ! -d ${mysqlDir}/mysql-${VERSION} ];then
|
||||
cd ${mysqlDir} && tar -zxvf ${mysqlDir}/mysql-boost-${VERSION}.tar.gz
|
||||
fi
|
||||
|
||||
OPTIONS=''
|
||||
##check openssl version
|
||||
OPENSSL_VERSION=`openssl version|awk '{print $2}'|awk -F '.' '{print $1}'`
|
||||
if [ "${OPENSSL_VERSION}" -ge "3" ];then
|
||||
#openssl version to high
|
||||
cd ${rootPath}/plugins/php/lib && /bin/bash openssl.sh
|
||||
export PKG_CONFIG_PATH=$serverPath/lib/openssl/lib/pkgconfig
|
||||
OPTIONS="-DWITH_SSL=${serverPath}/lib/openssl"
|
||||
fi
|
||||
|
||||
WHERE_DIR_GCC=/usr/bin/gcc
|
||||
WHERE_DIR_GPP=/usr/bin/g++
|
||||
if [ "$OSNAME" == "centos" ] && [ "$VERSION_ID" == "7" ];then
|
||||
yum install -y libudev-devel
|
||||
yum install -y centos-release-scl
|
||||
yum install -y devtoolset-11-gcc devtoolset-11-gcc-c++ devtoolset-11-binutils
|
||||
|
||||
gcc --version
|
||||
WHERE_DIR_GCC=/opt/rh/devtoolset-11/root/usr/bin/gcc
|
||||
WHERE_DIR_GPP=/opt/rh/devtoolset-11/root/usr/bin/g++
|
||||
echo $WHERE_DIR_GCC
|
||||
echo $WHERE_DIR_GPP
|
||||
fi
|
||||
|
||||
if [ "$OSNAME" == "ubuntu" ];then
|
||||
apt install -y libudev-dev
|
||||
apt install -y libtirpc-dev
|
||||
apt install -y libssl-dev
|
||||
apt install -y libgssglue-dev
|
||||
apt install -y software-properties-common
|
||||
add-apt-repository -y ppa:ubuntu-toolchain-r/test
|
||||
|
||||
LIBTIRPC_VER=`pkg-config libtirpc --modversion`
|
||||
if [ ! -f ${mysqlDir}/libtirpc_1.3.3.orig.tar.bz2 ];then
|
||||
wget --no-check-certificate -O ${mysqlDir}/libtirpc_1.3.3.orig.tar.bz2 https://downloads.sourceforge.net/libtirpc/libtirpc-1.3.3.tar.bz2
|
||||
cd ${mysqlDir} && tar -jxvf libtirpc_1.3.3.orig.tar.bz2
|
||||
cd libtirpc-1.3.3 && ./configure
|
||||
fi
|
||||
|
||||
export PKG_CONFIG_PATH=/usr/lib/pkgconfig
|
||||
apt install -y gcc-11 g++-11
|
||||
WHERE_DIR_GCC=/usr/bin/gcc-11
|
||||
WHERE_DIR_GPP=/usr/bin/g++-11
|
||||
fi
|
||||
|
||||
|
||||
if [ "$OSNAME" == "opensuse" ];then
|
||||
zypper install -y gcc11
|
||||
zypper install -y gcc11-c++
|
||||
|
||||
|
||||
WHERE_DIR_GCC=/usr/bin/gcc-11
|
||||
WHERE_DIR_GPP=/usr/bin/g++-11
|
||||
fi
|
||||
|
||||
if [ ! -d $serverPath/mysql ];then
|
||||
# -DCMAKE_CXX_STANDARD=17 \
|
||||
cd ${mysqlDir}/mysql-${VERSION} && ${INSTALL_CMD} \
|
||||
-DCMAKE_INSTALL_PREFIX=$serverPath/mysql \
|
||||
-DMYSQL_USER=mysql \
|
||||
-DMYSQL_TCP_PORT=3306 \
|
||||
-DMYSQL_UNIX_ADDR=/var/tmp/mysql.sock \
|
||||
-DWITH_MYISAM_STORAGE_ENGINE=1 \
|
||||
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
|
||||
-DWITH_MEMORY_STORAGE_ENGINE=1 \
|
||||
-DENABLED_LOCAL_INFILE=1 \
|
||||
-DWITH_PARTITION_STORAGE_ENGINE=1 \
|
||||
-DWITH_READLINE=1 \
|
||||
-DEXTRA_CHARSETS=all \
|
||||
-DDEFAULT_CHARSET=utf8mb4 \
|
||||
-DDEFAULT_COLLATION=utf8mb4_general_ci \
|
||||
-DDOWNLOAD_BOOST=1 \
|
||||
-DFORCE_INSOURCE_BUILD=1 \
|
||||
$OPTIONS \
|
||||
-DCMAKE_C_COMPILER=$WHERE_DIR_GCC \
|
||||
-DCMAKE_CXX_COMPILER=$WHERE_DIR_GPP \
|
||||
-DDOWNLOAD_BOOST=0 \
|
||||
-DWITH_BOOST=${mysqlDir}/mysql-${VERSION}/boost/
|
||||
make -j${cpuCore} && make install && make clean
|
||||
|
||||
if [ -d $serverPath/mysql ];then
|
||||
rm -rf ${mysqlDir}/mysql-${VERSION}
|
||||
echo '8.3' > $serverPath/mysql/version.pl
|
||||
echo "${VERSION}安装完成"
|
||||
else
|
||||
# rm -rf ${mysqlDir}/mysql-${VERSION}
|
||||
echo "${VERSION}安装失败"
|
||||
echo 'install fail'>&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
Uninstall_mysql()
|
||||
{
|
||||
rm -rf $serverPath/mysql
|
||||
echo '卸载完成' > $install_tmp
|
||||
}
|
||||
|
||||
action=$1
|
||||
if [ "${1}" == "install" ];then
|
||||
Install_mysql
|
||||
else
|
||||
Uninstall_mysql
|
||||
fi
|
||||
+10
-5
@@ -40,11 +40,11 @@ def getArgs():
|
||||
|
||||
if args_len == 1:
|
||||
t = args[0].strip('{').strip('}')
|
||||
t = t.split(':')
|
||||
t = t.split(':', 1)
|
||||
tmp[t[0]] = t[1]
|
||||
elif args_len > 1:
|
||||
for i in range(len(args)):
|
||||
t = args[i].split(':')
|
||||
t = args[i].split(':', 1)
|
||||
tmp[t[0]] = t[1]
|
||||
|
||||
return tmp
|
||||
@@ -971,9 +971,14 @@ def setRetry():
|
||||
conf = getJsonPath('config')
|
||||
content = mw.readFile(conf)
|
||||
cobj = json.loads(content)
|
||||
|
||||
cobj['retry'] = args
|
||||
|
||||
|
||||
## 修复数据类型错误
|
||||
tmp = args
|
||||
tmp['retry'] = int(tmp['retry'])
|
||||
tmp['retry_time'] = int(tmp['retry_time'])
|
||||
tmp['retry_cycle'] = int(tmp['retry_cycle'])
|
||||
|
||||
cobj['retry'] = tmp
|
||||
cjson = mw.getJson(cobj)
|
||||
mw.writeFile(conf, cjson)
|
||||
|
||||
|
||||
@@ -2,5 +2,7 @@
|
||||
[1,"(HTTrack|Apache-HttpClient|harvest|audit|dirbuster|pangolin|nmap|sqln|hydra|Parser|libwww|BBBike|sqlmap|w3af|owasp|Nikto|fimap|havij|zmeu|BabyKrokodil|netsparker|httperf| SF/)","关键词过滤1",0],
|
||||
[1,"(ApacheBench)","AB测试",0],
|
||||
[1,"(Amazonbot)","Amazon爬虫",0],
|
||||
[1,"(SemrushBot)","Semrush爬虫",0]
|
||||
]
|
||||
[1,"(SemrushBot)","Semrush爬虫",0],
|
||||
[1,"(^$|Apache-HttpClient|colly|curl|okhttp|Go-http-client|python-requests|Python-urllib|python-httpx|Scrapy|aiohttp|Nmap Scripting Engine|Java|fasthttp|Wget)","非法脚本",0],
|
||||
[1,"(CensysInspect|intelx\\.io_bot|InternetMeasurement|ips-agent|MJ12Bot|NetcraftSurveyAgent|SemrushBot|l9scan|SEOlyt|kirkland-signature|ZoominfoBot|Expanse|CheckMarkNetwork|dotbot|Pandalytics|Screaming Frog SEO Spider|W3C_CSS_Validator_JFouffa)","非法扫描器",0]
|
||||
]
|
||||
|
||||
@@ -51,7 +51,7 @@ http
|
||||
gzip_min_length 1k;
|
||||
gzip_buffers 4 16k;
|
||||
gzip_http_version 1.1;
|
||||
gzip_comp_level 2;
|
||||
gzip_comp_level 9;
|
||||
gzip_types text/plain application/javascript application/x-javascript text/javascript text/css application/xml;
|
||||
gzip_vary on;
|
||||
gzip_proxied expired no-cache no-store private auth;
|
||||
|
||||
@@ -121,11 +121,18 @@ Install_openresty()
|
||||
# OPENSSL_LIB_DEPEND_DIR=`brew info openssl@1.1 | grep ${BREW_DIR}/Cellar/openssl@1.1 | cut -d \ -f 1 | awk 'END {print}'`
|
||||
# OPTIONS="${OPTIONS} --with-openssl=${OPENSSL_LIB_DEPEND_DIR}"
|
||||
else
|
||||
if [ ! -f ${openrestyDir}/openssl-${opensslVersion}.tar.gz ];then
|
||||
wget --no-check-certificate -O ${openrestyDir}/openssl-${opensslVersion}.tar.gz https://www.openssl.org/source/openssl-${opensslVersion}.tar.gz
|
||||
fi
|
||||
|
||||
if [ ! -d ${openrestyDir}/openssl-${opensslVersion} ];then
|
||||
cd ${openrestyDir} && tar -zxvf openssl-${opensslVersion}.tar.gz
|
||||
fi
|
||||
OPTIONS="${OPTIONS} --with-openssl=${openrestyDir}/openssl-${opensslVersion}"
|
||||
|
||||
if [ "$VERSION" == "1.25.3.1" ]; then
|
||||
OPTIONS="${OPTIONS} --with-http_v3_module"
|
||||
|
||||
|
||||
|
||||
if [ ! -f ${openrestyDir}/libressl-${libresslVersion}.tar.gz ];then
|
||||
wget --no-check-certificate -O ${openrestyDir}/libressl-${libresslVersion}.tar.gz https://ftp.openbsd.org/pub/OpenBSD/LibreSSL/libressl-${libresslVersion}.tar.gz
|
||||
fi
|
||||
@@ -133,16 +140,7 @@ Install_openresty()
|
||||
if [ ! -d ${openrestyDir}/libressl-${libresslVersion} ];then
|
||||
cd ${openrestyDir} && tar -zxvf libressl-${libresslVersion}.tar.gz
|
||||
fi
|
||||
|
||||
if [ ! -f ${openrestyDir}/openssl-${opensslVersion}.tar.gz ];then
|
||||
wget --no-check-certificate -O ${openrestyDir}/openssl-${opensslVersion}.tar.gz https://www.openssl.org/source/openssl-${opensslVersion}.tar.gz
|
||||
fi
|
||||
|
||||
if [ ! -d ${openrestyDir}/openssl-${opensslVersion} ];then
|
||||
cd ${openrestyDir} && tar -zxvf openssl-${opensslVersion}.tar.gz
|
||||
fi
|
||||
|
||||
OPTIONS="${OPTIONS} --with-openssl=${openrestyDir}/openssl-${opensslVersion}"
|
||||
|
||||
OPTIONS="${OPTIONS} --with-cc-opt=-I${openrestyDir}/libressl-${libresslVersion}/libressl/build/include"
|
||||
OPTIONS="${OPTIONS} --with-cc-opt=-I${openrestyDir}/libressl-${libresslVersion}/libressl/build/lib"
|
||||
|
||||
|
||||
@@ -223,6 +223,25 @@
|
||||
"shell": "exif.sh",
|
||||
"check": "exif"
|
||||
},
|
||||
{
|
||||
"name": "igbinary",
|
||||
"versions": [
|
||||
"56",
|
||||
"70",
|
||||
"71",
|
||||
"72",
|
||||
"73",
|
||||
"74",
|
||||
"80",
|
||||
"81",
|
||||
"82",
|
||||
"83"
|
||||
],
|
||||
"type": "通用扩展",
|
||||
"msg": "序列化扩展!",
|
||||
"shell": "igbinary.sh",
|
||||
"check": "igbinary.so"
|
||||
},
|
||||
{
|
||||
"name": "xml",
|
||||
"versions": [
|
||||
|
||||
@@ -63,7 +63,7 @@ if [ "${action}" == "install" ] && [ -d ${serverPath}/php/${type} ];then
|
||||
# cd /www/server/mdserver-web/plugins/php/versions/common && bash intl.sh install 73
|
||||
# cd /www/server/mdserver-web/plugins/php/versions/common && bash gd.sh install 56
|
||||
# cd /www/server/mdserver-web/plugins/php/versions/common && bash openssl.sh install 56
|
||||
# cd /www/server/mdserver-web/plugins/php/versions/common && bash sodium.sh install 81
|
||||
# cd /www/server/mdserver-web/plugins/php/versions/common && bash fileinfo.sh install 81
|
||||
cd ${rootPath}/plugins/php/versions/common && bash gd.sh install ${type}
|
||||
cd ${rootPath}/plugins/php/versions/common && bash iconv.sh install ${type}
|
||||
cd ${rootPath}/plugins/php/versions/common && bash exif.sh install ${type}
|
||||
|
||||
@@ -26,7 +26,7 @@ function phpPost(method, version, args,callback){
|
||||
},'json');
|
||||
}
|
||||
|
||||
function phpPostCallbak(method, version, args,callback){
|
||||
function phpPostCallback(method, version, args,callback){
|
||||
var loadT = layer.msg('正在获取...', { icon: 16, time: 0, shade: 0.3 });
|
||||
|
||||
var req_data = {};
|
||||
@@ -79,7 +79,7 @@ function phpSetConfig(version) {
|
||||
ibody = '<select class="bt-input-text mr5" name="' + rdata[i].name + '" style="width: ' + w + 'px;"><option value="On" ' + selected_1 + '>开启</option><option value="Off" ' + selected_0 + '>关闭</option></select>'
|
||||
break;
|
||||
}
|
||||
mlist += '<p><span>' + rdata[i].name + '</span>' + ibody + ', <font>' + rdata[i].ps + '</font></p>'
|
||||
mlist += '<p><span>' + rdata[i].name + '</span>' + ibody + ', <font>' + rdata[i].ps + '</font></p>';
|
||||
}
|
||||
var phpCon = '<style>.conf_p p{margin-bottom: 2px}</style><div class="conf_p" style="margin-bottom:0">\
|
||||
' + mlist + '\
|
||||
@@ -715,7 +715,7 @@ function getPHPInfo_old(version) {
|
||||
}
|
||||
|
||||
function getPHPInfo(version) {
|
||||
phpPostCallbak('get_php_info', version, {}, function(data){
|
||||
phpPostCallback('get_php_info', version, {}, function(data){
|
||||
if (!data.status){
|
||||
layer.msg(rdata.msg, { icon: 2 });
|
||||
return;
|
||||
@@ -739,7 +739,7 @@ function phpLibConfig(version){
|
||||
// var rdata = $.parseJSON(rdata.data);
|
||||
// });
|
||||
|
||||
phpPostCallbak('get_lib_conf', version, {}, function(rdata){
|
||||
phpPostCallback('get_lib_conf', version, {}, function(rdata){
|
||||
var rdata = rdata.data;
|
||||
|
||||
if (!rdata.status){
|
||||
|
||||
@@ -16,7 +16,7 @@ function version_lt() { test "$(echo "$@" | tr " " "\n" | sort -rV | head -n 1)"
|
||||
function version_ge() { test "$(echo "$@" | tr " " "\n" | sort -rV | head -n 1)" == "$1"; }
|
||||
|
||||
|
||||
version=8.1.27
|
||||
version=8.1.28
|
||||
PHP_VER=81
|
||||
Install_php()
|
||||
{
|
||||
@@ -56,7 +56,7 @@ if [ ! -d $sourcePath/php/php${PHP_VER} ];then
|
||||
fi
|
||||
|
||||
#检测文件是否损坏.
|
||||
md5_file_ok=479e65c3f05714d4aace1370e617d78e49e996ec7a7579a5be47535be61f0658
|
||||
md5_file_ok=95d0b2e9466108fd750dab5c30a09e5c67f5ad2cb3b1ffb3625a038a755ad080
|
||||
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
|
||||
|
||||
@@ -16,7 +16,7 @@ function version_lt() { test "$(echo "$@" | tr " " "\n" | sort -rV | head -n 1)"
|
||||
function version_ge() { test "$(echo "$@" | tr " " "\n" | sort -rV | head -n 1)" == "$1"; }
|
||||
|
||||
|
||||
version=8.2.17
|
||||
version=8.2.18
|
||||
PHP_VER=82
|
||||
Install_php()
|
||||
{
|
||||
@@ -57,7 +57,7 @@ if [ ! -d $sourcePath/php/php${PHP_VER} ];then
|
||||
fi
|
||||
|
||||
#检测文件是否损坏.
|
||||
md5_file_ok=1cc4ef733ba58f6557db648012471f1916e5bac316303aa165535bedab08ee35
|
||||
md5_file_ok=44b306fc021e56441f691da6c3108788bd9e450f293b3bc70fcd64b08dd41a50
|
||||
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
|
||||
|
||||
@@ -15,7 +15,7 @@ function version_le() { test "$(echo "$@" | tr " " "\n" | sort -V | head -n 1)"
|
||||
function version_lt() { test "$(echo "$@" | tr " " "\n" | sort -rV | head -n 1)" != "$1"; }
|
||||
function version_ge() { test "$(echo "$@" | tr " " "\n" | sort -rV | head -n 1)" == "$1"; }
|
||||
|
||||
version=8.3.4
|
||||
version=8.3.6
|
||||
PHP_VER=83
|
||||
Install_php()
|
||||
{
|
||||
@@ -56,7 +56,7 @@ if [ ! -d $sourcePath/php/php${PHP_VER} ];then
|
||||
fi
|
||||
|
||||
#检测文件是否损坏.
|
||||
md5_file_ok=39a337036a546e5c28aea76cf424ac172db5156bd8a8fd85252e389409a5ba63
|
||||
md5_file_ok=53c8386b2123af97626d3438b3e4058e0c5914cb74b048a6676c57ac647f5eae
|
||||
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
|
||||
|
||||
@@ -39,7 +39,7 @@ 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)
|
||||
PHP_VER_LIST=(53 54 55 56 70 71 72 73 74 80 81 82 83)
|
||||
# yar
|
||||
PHP_EXT_LIST=(ZendGuardLoader pdo mysqlnd sqlite3 openssl opcache mcrypt fileinfo \
|
||||
exif gd intl pcntl memcache memcached redis imagemagick xdebug \
|
||||
|
||||
@@ -15,7 +15,13 @@ actionType=$1
|
||||
version=$2
|
||||
|
||||
LIBNAME=event
|
||||
LIBV=3.1.0RC1
|
||||
LIBV=3.1.3
|
||||
|
||||
|
||||
if [ "$version" -lt "55" ];then
|
||||
echo 'not need'
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "$version" -lt "83" ];then
|
||||
LIBV=3.0.8
|
||||
|
||||
@@ -37,6 +37,8 @@ else
|
||||
BAK=''
|
||||
fi
|
||||
|
||||
OSNAME=`cat ${rootPath}/data/osname.pl`
|
||||
|
||||
Install_lib()
|
||||
{
|
||||
|
||||
@@ -59,6 +61,7 @@ Install_lib()
|
||||
OPTIONS="$OPTIONS --build=aarch64-unknown-linux-gnu --host=aarch64-unknown-linux-gnu"
|
||||
fi
|
||||
|
||||
|
||||
$serverPath/php/$version/bin/phpize
|
||||
./configure --with-php-config=$serverPath/php/$version/bin/php-config $OPTIONS
|
||||
|
||||
@@ -66,7 +69,6 @@ Install_lib()
|
||||
# It is considered as a temporary bug
|
||||
if [ "$version" == "81" ] || [ "$version" == "82" ];then
|
||||
bash ${rootPath}/scripts/getos.sh
|
||||
OSNAME=`cat ${rootPath}/data/osname.pl`
|
||||
if [ "$OSNAME" == 'centos' ];then
|
||||
FILE_softmagic=$sourcePath/php${version}/ext/${LIBNAME}/libmagic/softmagic.c
|
||||
FIND_UNDEF_STRNDUP=`cat $FILE_softmagic|grep '#undef strndup'`
|
||||
@@ -81,6 +83,11 @@ Install_lib()
|
||||
sed -i $BAK 's/CFLAGS \=/CFLAGS \= -std=gnu99/g' Makefile
|
||||
fi
|
||||
|
||||
if [ "$version" -gt "80" ] && [ "$OSNAME" == 'centos' ];then
|
||||
sed -i $BAK "s#CFLAGS = -g -O2#CFLAGS = -std=c99 -g#g" $sourcePath/php${version}/ext/${LIBNAME}/Makefile
|
||||
fi
|
||||
|
||||
|
||||
make clean && make && make install && make clean
|
||||
|
||||
if [ -d $sourcePath/php${version} ];then
|
||||
|
||||
@@ -73,6 +73,12 @@ Install_lib()
|
||||
OPTIONS="$OPTIONS --build=aarch64-unknown-linux-gnu --host=aarch64-unknown-linux-gnu"
|
||||
fi
|
||||
|
||||
if [ "$version" -lt "55" ];then
|
||||
echo "not need xmp"
|
||||
else
|
||||
OPTIONS="$OPTIONS --with-xpm-dir"
|
||||
fi
|
||||
|
||||
#--with-xpm
|
||||
# =${serverPath}/lib/freetype_old
|
||||
# =/usr/lib
|
||||
@@ -80,9 +86,7 @@ Install_lib()
|
||||
$OPTIONS \
|
||||
--with-gd \
|
||||
--with-jpeg-dir \
|
||||
--with-webp-dir \
|
||||
--with-png-dir \
|
||||
--with-xpm-dir \
|
||||
--with-freetype-dir=${serverPath}/lib/freetype_old
|
||||
# --enable-gd-jis-conv
|
||||
# --enable-gd-native-ttf
|
||||
|
||||
@@ -17,6 +17,10 @@ sysName=`uname`
|
||||
actionType=$1
|
||||
version=$2
|
||||
|
||||
if [ "$version" -ge '74' ];then
|
||||
LIBV=1.19.0
|
||||
fi
|
||||
|
||||
if [ "$version" == '71' ];then
|
||||
LIBV=1.11.1
|
||||
fi
|
||||
|
||||
@@ -23,10 +23,13 @@ elif [ "$version" == "70" ];then
|
||||
LIBV=4.3.0
|
||||
elif [ "$version" == "71" ];then
|
||||
LIBV=4.5.2
|
||||
elif [ "$version" == "72" ] || [ "$version" == "73" ] || [ "$version" == "74" ];then
|
||||
LIBV=4.8.10
|
||||
elif [ "$version" -gt "74" ];then
|
||||
LIBV=5.0.3
|
||||
LIBV=5.1.1
|
||||
else
|
||||
echo 'other?'
|
||||
exit 0
|
||||
fi
|
||||
|
||||
LIB_PATH_NAME=lib/php
|
||||
|
||||
@@ -25,8 +25,8 @@ if [ "$version" -eq "70" ] || [ "$version" -eq "71" ];then
|
||||
LIBV=2.7.0
|
||||
fi
|
||||
|
||||
if [ "$version" -eq "82" ];then
|
||||
LIBV=3.2.2
|
||||
if [ "$version" -gt "80" ];then
|
||||
LIBV=3.3.2
|
||||
fi
|
||||
|
||||
LIB_PATH_NAME=lib/php
|
||||
|
||||
@@ -254,7 +254,6 @@
|
||||
{
|
||||
"name": "event",
|
||||
"versions": [
|
||||
"54",
|
||||
"55",
|
||||
"56",
|
||||
"70",
|
||||
|
||||
@@ -210,13 +210,17 @@ def __delete_port(port):
|
||||
|
||||
|
||||
def openPort():
|
||||
for i in ["888"]:
|
||||
conf = getCfg()
|
||||
port = conf['port']
|
||||
for i in [port]:
|
||||
__release_port(i)
|
||||
return True
|
||||
|
||||
|
||||
def delPort():
|
||||
for i in ["888"]:
|
||||
conf = getCfg()
|
||||
port = conf['port']
|
||||
for i in [port]:
|
||||
__delete_port(i)
|
||||
return True
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
daemonize yes
|
||||
pidfile {$SERVER_PATH}/redis/redis_6379.pid
|
||||
pidfile {$SERVER_PATH}/redis/redis.pid
|
||||
|
||||
bind 127.0.0.1
|
||||
port 6379
|
||||
@@ -40,15 +40,20 @@ maxclients 10000
|
||||
#maxmemory-samples 3
|
||||
maxmemory 218mb
|
||||
maxmemory-policy volatile-ttl
|
||||
#maxmemory-policy allkeys-lru
|
||||
|
||||
############################## APPEND ONLY MODE ###############################
|
||||
|
||||
|
||||
#appendonly no
|
||||
# appendonly no
|
||||
|
||||
# appendfsync always
|
||||
#appendfsync everysec
|
||||
# appendfsync everysec
|
||||
# appendfsync no
|
||||
#no-appendfsync-on-rewrite no
|
||||
|
||||
# appendfilename "appendonly.aof"
|
||||
|
||||
# no-appendfsync-on-rewrite no
|
||||
|
||||
auto-aof-rewrite-percentage 100
|
||||
auto-aof-rewrite-min-size 64mb
|
||||
|
||||
@@ -23,7 +23,7 @@ if [ "$REDISPASS" != "" ];then
|
||||
fi
|
||||
EXEC={$SERVER_PATH}/redis/bin/redis-server
|
||||
CLIEXEC="{$SERVER_PATH}/redis/bin/redis-cli -p $REDISPORT$REDISPASS"
|
||||
PIDFILE={$SERVER_PATH}/redis/redis_6379.pid
|
||||
PIDFILE={$SERVER_PATH}/redis/redis.pid
|
||||
|
||||
echo $REDISPASS
|
||||
echo $REDISPORT
|
||||
|
||||
@@ -25,14 +25,16 @@ Install_App()
|
||||
{
|
||||
echo '正在安装脚本文件...' > $install_tmp
|
||||
mkdir -p $serverPath/source
|
||||
mkdir -p $serverPath/source/redis
|
||||
|
||||
if [ ! -f $serverPath/source/redis-${VERSION}.tar.gz ];then
|
||||
wget -O $serverPath/source/redis-${VERSION}.tar.gz http://download.redis.io/releases/redis-${VERSION}.tar.gz
|
||||
FILE_TGZ=redis-${VERSION}.tar.gz
|
||||
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}
|
||||
fi
|
||||
|
||||
cd $serverPath/source && tar -zxvf redis-${VERSION}.tar.gz
|
||||
|
||||
|
||||
cd $REDIS_DIR && tar -zxvf ${FILE_TGZ}
|
||||
|
||||
CMD_MAKE=`which gmake`
|
||||
if [ "$?" == "0" ];then
|
||||
@@ -55,8 +57,8 @@ Install_App()
|
||||
echo '安装失败!'
|
||||
fi
|
||||
|
||||
if [ -d $serverPath/source/redis-${VERSION} ];then
|
||||
rm -rf $serverPath/source/redis-${VERSION}
|
||||
if [ -d ${REDIS_DIR}/redis-${VERSION} ];then
|
||||
rm -rf ${REDIS_DIR}/redis-${VERSION}
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -80,8 +82,11 @@ Uninstall_App()
|
||||
$serverPath/redis/initd/redis stop
|
||||
fi
|
||||
|
||||
rm -rf $serverPath/redis
|
||||
echo "Uninstall_redis" > $install_tmp
|
||||
if [ -d $serverPath/redis ];then
|
||||
rm -rf $serverPath/redis
|
||||
fi
|
||||
|
||||
echo "卸载redis成功"
|
||||
}
|
||||
|
||||
action=$1
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
daemonize yes
|
||||
pidfile {$SERVER_PATH}/redis/redis_6379.pid
|
||||
pidfile {$SERVER_PATH}/redis/redis.pid
|
||||
|
||||
loglevel notice
|
||||
logfile {$SERVER_PATH}/redis/data/redis.log
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
daemonize yes
|
||||
pidfile {$SERVER_PATH}/redis/redis_6379.pid
|
||||
pidfile {$SERVER_PATH}/redis/redis.pid
|
||||
|
||||
bind 127.0.0.1
|
||||
port 6379
|
||||
|
||||
@@ -1,17 +1,18 @@
|
||||
daemonize yes
|
||||
pidfile {$SERVER_PATH}/redis/redis_6379.pid
|
||||
|
||||
loglevel notice
|
||||
logfile {$SERVER_PATH}/redis/data/redis.log
|
||||
databases 16
|
||||
|
||||
timeout 0
|
||||
tcp-keepalive 0
|
||||
pidfile {$SERVER_PATH}/redis/redis.pid
|
||||
|
||||
bind 127.0.0.1
|
||||
port 6379
|
||||
requirepass {$REDIS_PASS}
|
||||
|
||||
timeout 0
|
||||
tcp-keepalive 0
|
||||
|
||||
loglevel notice
|
||||
|
||||
logfile {$SERVER_PATH}/redis/data/redis.log
|
||||
databases 16
|
||||
|
||||
################################ SNAPSHOTTING #################################
|
||||
|
||||
save 900 1
|
||||
@@ -33,7 +34,7 @@ slave-priority 100
|
||||
|
||||
# 填写主库信息
|
||||
#slaveof 127.0.0.1 6379
|
||||
#masterauth master_pwd
|
||||
#masterauth 123123
|
||||
|
||||
################################## SECURITY ###################################
|
||||
|
||||
@@ -41,7 +42,7 @@ slave-priority 100
|
||||
################################### LIMITS ####################################
|
||||
maxclients 10000
|
||||
#maxmemory-samples 3
|
||||
maxmemory 218mb
|
||||
maxmemory 0mb
|
||||
maxmemory-policy volatile-ttl
|
||||
|
||||
############################## APPEND ONLY MODE ###############################
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
daemonize yes
|
||||
pidfile {$SERVER_PATH}/redis/redis.pid
|
||||
|
||||
loglevel notice
|
||||
logfile {$SERVER_PATH}/redis/data/redis.log
|
||||
databases 16
|
||||
|
||||
timeout 0
|
||||
tcp-keepalive 0
|
||||
|
||||
bind 127.0.0.1
|
||||
port 6379
|
||||
requirepass {$REDIS_PASS}
|
||||
|
||||
################################ SNAPSHOTTING #################################
|
||||
|
||||
save ""
|
||||
stop-writes-on-bgsave-error no
|
||||
|
||||
################################# REPLICATION #################################
|
||||
|
||||
slave-serve-stale-data yes
|
||||
slave-read-only yes
|
||||
|
||||
repl-disable-tcp-nodelay no
|
||||
slave-priority 100
|
||||
|
||||
# 填写主库信息
|
||||
#slaveof 127.0.0.1 6379
|
||||
#masterauth 123123
|
||||
|
||||
################################## SECURITY ###################################
|
||||
|
||||
|
||||
################################### LIMITS ####################################
|
||||
maxclients 10000
|
||||
#maxmemory-samples 3
|
||||
maxmemory 218mb
|
||||
maxmemory-policy allkeys-lru
|
||||
|
||||
############################## APPEND ONLY MODE ###############################
|
||||
|
||||
|
||||
################################ LUA SCRIPTING ###############################
|
||||
|
||||
lua-time-limit 5000
|
||||
|
||||
################################## SLOW LOG ###################################
|
||||
|
||||
|
||||
slowlog-log-slower-than 10000
|
||||
slowlog-max-len 128
|
||||
|
||||
############################### ADVANCED CONFIG ###############################
|
||||
|
||||
hash-max-ziplist-entries 512
|
||||
hash-max-ziplist-value 64
|
||||
|
||||
list-max-ziplist-entries 512
|
||||
list-max-ziplist-value 64
|
||||
|
||||
set-max-intset-entries 512
|
||||
|
||||
zset-max-ziplist-entries 128
|
||||
zset-max-ziplist-value 64
|
||||
|
||||
activerehashing no
|
||||
|
||||
client-output-buffer-limit normal 0 0 0
|
||||
client-output-buffer-limit slave 256mb 64mb 60
|
||||
client-output-buffer-limit pubsub 32mb 8mb 60
|
||||
|
||||
hz 10
|
||||
|
||||
aof-rewrite-incremental-fsync yes
|
||||
@@ -0,0 +1,486 @@
|
||||
# coding:utf-8
|
||||
|
||||
import sys
|
||||
import io
|
||||
import os
|
||||
import time
|
||||
import subprocess
|
||||
import re
|
||||
import json
|
||||
|
||||
|
||||
sys.path.append(os.getcwd() + "/class/core")
|
||||
import 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 = '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*(.*)'
|
||||
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):
|
||||
ver = self.ver.replace(".1",'')
|
||||
if float(ver) >= 3.6:
|
||||
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'
|
||||
|
||||
if float(ver) >= 3.3:
|
||||
if field == 'sql_attr_timestamp':
|
||||
return 'sql_attr_bigint'
|
||||
|
||||
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 = 128M
|
||||
}
|
||||
|
||||
searchd
|
||||
{
|
||||
listen = 9312
|
||||
listen = 9306:mysql41
|
||||
log = {$server_dir}/sphinx/index/searchd.log
|
||||
query_log = {$server_dir}/sphinx/index/query.log
|
||||
read_timeout = 5
|
||||
max_children = 0
|
||||
pid_file = {$server_dir}/sphinx/index/searchd.pid
|
||||
seamless_rotate = 1
|
||||
preopen_indexes = 1
|
||||
unlink_old = 1
|
||||
#workers = threads # for RT to work
|
||||
binlog_path = {$server_dir}/sphinx/index/binlog
|
||||
}
|
||||
'''
|
||||
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}/sphinx/index/db/{$DB_NAME}.{$TABLE_NAME}/delta
|
||||
|
||||
html_strip = 1
|
||||
ngram_len = 1
|
||||
ngram_chars = U+3000..U+2FA1F
|
||||
|
||||
{$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}/sphinx/index/db/{$DB_NAME}.{$TABLE_NAME}/index
|
||||
|
||||
ngram_len = 1
|
||||
ngram_chars = U+3000..U+2FA1F
|
||||
|
||||
{$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):
|
||||
ver = self.ver.replace(".1",'')
|
||||
ver = float(ver)
|
||||
if ver >= 3.6:
|
||||
content = content.replace("{$SPH_FIELD}", '')
|
||||
content = content.replace("{$SPH_FIELD_INDEX}", '')
|
||||
else:
|
||||
content = content.replace("{$SPH_FIELD}", 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
|
||||
|
||||
|
||||
@@ -1,21 +1,35 @@
|
||||
|
||||
<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('sphinx');">服务</p>
|
||||
<p onclick="pluginInitD('sphinx');">自启动</p>
|
||||
<p onclick="pluginConfigTpl('sphinx');">配置修改</p>
|
||||
<p onclick="pluginConfigTpl('sphinx','', 'conf','config_tpl','read_config_tpl',tryRebuildIndex);">配置修改</p>
|
||||
<p onclick="pluginLogs('sphinx','','run_log',30);">运行日志</p>
|
||||
<p onclick="pluginLogs('sphinx','','query_log', 30);">查询日志</p>
|
||||
<p onclick="runStatus();">运行状态</p>
|
||||
<p onclick="rebuild();">重建索引</p>
|
||||
<p onclick="commonFunc();">常用功能</p>
|
||||
<p onclick="readme();">说明</p>
|
||||
</div>
|
||||
<div class="bt-w-con pd15">
|
||||
<div class="soft-man-con"></div>
|
||||
<div class="soft-man-con" style="height:425px;overflow: auto;"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
resetPluginWinHeight(500);
|
||||
$.getScript( "/plugins/file?name=sphinx&f=js/sphinx.js", function(){
|
||||
pluginService('sphinx');
|
||||
});
|
||||
|
||||
+84
-16
@@ -15,14 +15,13 @@ app_debug = False
|
||||
if mw.isAppleSystem():
|
||||
app_debug = True
|
||||
|
||||
|
||||
def getPluginName():
|
||||
return 'sphinx'
|
||||
|
||||
|
||||
def getPluginDir():
|
||||
return mw.getPluginDir() + '/' + getPluginName()
|
||||
|
||||
sys.path.append(getPluginDir() +"/class")
|
||||
|
||||
def getServerDir():
|
||||
return mw.getServerDir() + '/' + getPluginName()
|
||||
@@ -210,9 +209,10 @@ def reload():
|
||||
|
||||
def rebuild():
|
||||
file = initDreplace()
|
||||
subprocess.Popen(file + ' rebuild &',
|
||||
stdout=subprocess.PIPE, shell=True)
|
||||
# data = mw.execShell(file + ' rebuild')
|
||||
cmd = file + ' rebuild'
|
||||
data = mw.execShell(cmd)
|
||||
if data[0].find('successfully')<0:
|
||||
return data[0].replace("\n","<br/>")
|
||||
return 'ok'
|
||||
|
||||
|
||||
@@ -295,18 +295,35 @@ def sphinxConfParse():
|
||||
sindex = re.findall(rep, content)
|
||||
indexlen = len(sindex)
|
||||
cmd = {}
|
||||
if indexlen > 0:
|
||||
cmd_index = []
|
||||
cmd_delta = []
|
||||
for x in range(indexlen):
|
||||
if sindex[x].find(':') != -1:
|
||||
cmd_delta.append(sindex[x])
|
||||
else:
|
||||
cmd_index.append(sindex[x])
|
||||
cmd['cmd'] = bin_dir + '/bin/bin/indexer -c ' + bin_dir + '/sphinx.conf'
|
||||
|
||||
cmd['index'] = cmd_index
|
||||
cmd['delta'] = cmd_delta
|
||||
cmd['cmd'] = bin_dir + '/bin/bin/indexer -c ' + bin_dir + '/sphinx.conf'
|
||||
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
|
||||
|
||||
|
||||
@@ -317,6 +334,55 @@ def sphinxCmd():
|
||||
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)
|
||||
return mw.returnJson(True,'设置成功!')
|
||||
|
||||
return mw.returnJson(True,'测试中')
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
func = sys.argv[1]
|
||||
@@ -352,5 +418,7 @@ if __name__ == "__main__":
|
||||
print(runStatus())
|
||||
elif func == 'sphinx_cmd':
|
||||
print(sphinxCmd())
|
||||
elif func == 'db_to_sphinx':
|
||||
print(makeDbToSphinx())
|
||||
else:
|
||||
print('error')
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user