mirror of
https://github.com/midoks/mdserver-web.git
synced 2026-10-10 01:39:25 +08:00
Compare commits
306
Commits
2fe17aefd9
...
b679ea035d
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b679ea035d | ||
|
|
49bbca8faa | ||
|
|
8b86cd5e63 | ||
|
|
698e3ffd81 | ||
|
|
c2284dcee5 | ||
|
|
b68c9edc3e | ||
|
|
650365997a | ||
|
|
3279404595 | ||
|
|
d32a94dccf | ||
|
|
80d846f247 | ||
|
|
eadcbe336d | ||
|
|
474d0f075f | ||
|
|
2d6a41e19f | ||
|
|
1f24944417 | ||
|
|
4ab3409e54 | ||
|
|
c3ad146303 | ||
|
|
745cd304fb | ||
|
|
e6efefd1fd | ||
|
|
1350404c58 | ||
|
|
9cdd2274fa | ||
|
|
cc204ad721 | ||
|
|
8eb1614b31 | ||
|
|
9c2e9627ec | ||
|
|
87123c526a | ||
|
|
7c3ebc6e35 | ||
|
|
6c5bf63424 | ||
|
|
13fd47e7d4 | ||
|
|
fc1321584a | ||
|
|
bab3ae16d3 | ||
|
|
ab8498e519 | ||
|
|
0e480c7ad8 | ||
|
|
7ed8558ff0 | ||
|
|
4ed2f0caa9 | ||
|
|
f275eabe1b | ||
|
|
fe13ab1e5f | ||
|
|
6ed045cf94 | ||
|
|
ef333ff142 | ||
|
|
dac2f5240f | ||
|
|
cebfc2fc91 | ||
|
|
1da865c1b2 | ||
|
|
2abdaaa7ce | ||
|
|
c62142cf6b | ||
|
|
7c1820b6cd | ||
|
|
a24af95d24 | ||
|
|
1326c282c8 | ||
|
|
b7e84749f1 | ||
|
|
8a65158540 | ||
|
|
a576c521a2 | ||
|
|
736a387a71 | ||
|
|
090205c372 | ||
|
|
fda0bddc8f | ||
|
|
292b18468d | ||
|
|
47aab245fc | ||
|
|
39bd601825 | ||
|
|
b744adeb13 | ||
|
|
7b70f9fc99 | ||
|
|
0723f751b3 | ||
|
|
1fd8617a12 | ||
|
|
2fec8fcef4 | ||
|
|
51a48afa71 | ||
|
|
76919faca7 | ||
|
|
9bcbeaf1a5 | ||
|
|
d0de121721 | ||
|
|
957e2db3d0 | ||
|
|
fb0be5549d | ||
|
|
8a9132d557 | ||
|
|
04d10435c2 | ||
|
|
92543e10fa | ||
|
|
cd427dcbf3 | ||
|
|
ddb5e0285b | ||
|
|
75610a4559 | ||
|
|
b8f7a45f61 | ||
|
|
37d5ce719e | ||
|
|
ef9053aa7e | ||
|
|
018fcb7afb | ||
|
|
5cc9a67152 | ||
|
|
54895f1d0a | ||
|
|
91dfecf882 | ||
|
|
2f09e227d1 | ||
|
|
5d0463836e | ||
|
|
fb6499cb35 | ||
|
|
0bbfb58e67 | ||
|
|
fcd780a7d3 | ||
|
|
4f4d1e7580 | ||
|
|
6e2a8e0a12 | ||
|
|
817b4b36c7 | ||
|
|
0ba89cbb9e | ||
|
|
4e3e7864be | ||
|
|
6f51eaa298 | ||
|
|
39bd87e868 | ||
|
|
18443aab60 | ||
|
|
b88ea7aa3c | ||
|
|
6a6f6e6062 | ||
|
|
5839dbcd6b | ||
|
|
b46f45569e | ||
|
|
5cdc5af8cd | ||
|
|
4f38a9f3ff | ||
|
|
9c83695187 | ||
|
|
f9be534101 | ||
|
|
58ab48ac15 | ||
|
|
f34e93192d | ||
|
|
31106f2b13 | ||
|
|
468cc54cf5 | ||
|
|
728a38c55c | ||
|
|
b2b23b0e3b | ||
|
|
167dd11548 | ||
|
|
03fdbf2604 | ||
|
|
edbdec8370 | ||
|
|
8f1c9f9471 | ||
|
|
d35d16943d | ||
|
|
3ac4270dee | ||
|
|
90777e08ff | ||
|
|
b47d1262ac | ||
|
|
e28081a7c5 | ||
|
|
5f7d6c1488 | ||
|
|
59385e11be | ||
|
|
a668d88791 | ||
|
|
e62bd7c5a6 | ||
|
|
1ad3d2f187 | ||
|
|
bf06af14ed | ||
|
|
805c96f260 | ||
|
|
8ccba2f6d5 | ||
|
|
2e9f01d3ee | ||
|
|
d1dcdd4f25 | ||
|
|
60958d1403 | ||
|
|
5530b14f36 | ||
|
|
64c9942ee1 | ||
|
|
bc1437dac4 | ||
|
|
1d9576e838 | ||
|
|
8b275a5df4 | ||
|
|
40d9334dcf | ||
|
|
98c0242819 | ||
|
|
a2fb03f9b8 | ||
|
|
98815ac5c3 | ||
|
|
073dd20c96 | ||
|
|
23af9085a9 | ||
|
|
bcaec6b6ee | ||
|
|
4063bea922 | ||
|
|
9f864b3407 | ||
|
|
01ac598e39 | ||
|
|
77a0d3af36 | ||
|
|
8d34bbea47 | ||
|
|
be18e98001 | ||
|
|
754e0f98f9 | ||
|
|
07f893b6a1 | ||
|
|
c1497ec44e | ||
|
|
55d4784fe2 | ||
|
|
f26e8bc520 | ||
|
|
7b5f1a4253 | ||
|
|
1058fb7e1f | ||
|
|
0f1b95cdfc | ||
|
|
8ea16fcd85 | ||
|
|
b4b9496980 | ||
|
|
8dfd26361f | ||
|
|
cb5bd32b86 | ||
|
|
2584330d40 | ||
|
|
ebe6333ac9 | ||
|
|
534892280e | ||
|
|
df05cf69cf | ||
|
|
2f782cf6a2 | ||
|
|
6f483c17e6 | ||
|
|
e64610a2dc | ||
|
|
7673a16779 | ||
|
|
d73fe4b29c | ||
|
|
2c61be084b | ||
|
|
fe5f8d1997 | ||
|
|
2653291ded | ||
|
|
417f91a2e8 | ||
|
|
08625e85bb | ||
|
|
c554c19a12 | ||
|
|
d7d08f2f12 | ||
|
|
bafe45a2f9 | ||
|
|
a11d24723d | ||
|
|
3b858476f1 | ||
|
|
5560b68ac1 | ||
|
|
8bfd381363 | ||
|
|
c6cfe2a22c | ||
|
|
4ed274dedc | ||
|
|
283c815de7 | ||
|
|
c72c1bc889 | ||
|
|
6e61a535ca | ||
|
|
c1f69ea1c7 | ||
|
|
984599c56f | ||
|
|
038bb31ec3 | ||
|
|
1ac541d16e | ||
|
|
ecaa0e99c5 | ||
|
|
666ebeef0d | ||
|
|
b39a936fa4 | ||
|
|
d434dce568 | ||
|
|
6acb390133 | ||
|
|
3c6f3c50c4 | ||
|
|
c52e707421 | ||
|
|
5fb998c221 | ||
|
|
a0989ea833 | ||
|
|
5e565c06a0 | ||
|
|
69b96aa5fa | ||
|
|
bce9de1494 | ||
|
|
3de7928be7 | ||
|
|
41630ef01a | ||
|
|
bf29cb1a4d | ||
|
|
8f79a4ab86 | ||
|
|
0ad933c5ad | ||
|
|
5ed9470d83 | ||
|
|
cac468f454 | ||
|
|
f0f9dcf4de | ||
|
|
3e0e84a4f6 | ||
|
|
ef8080b420 | ||
|
|
b5fab1fb10 | ||
|
|
c3f019d4ff | ||
|
|
701f172276 | ||
|
|
9e8c736cb4 | ||
|
|
c8589d750c | ||
|
|
5bb20a01de | ||
|
|
6e4bf9da3e | ||
|
|
c21ddb5c63 | ||
|
|
431295cec9 | ||
|
|
180cb84b2c | ||
|
|
66b5f322d9 | ||
|
|
f00dc248bd | ||
|
|
dbba5db9f7 | ||
|
|
3a8b799df6 | ||
|
|
0b99a4ae74 | ||
|
|
99b77d347a | ||
|
|
8235a88ecc | ||
|
|
564ba30f91 | ||
|
|
aa8535d513 | ||
|
|
a02ef2575b | ||
|
|
a0be16c0fa | ||
|
|
548d87e339 | ||
|
|
c704aa0817 | ||
|
|
c6a060fde5 | ||
|
|
762e88cc44 | ||
|
|
b7f671d1d5 | ||
|
|
48706d01f9 | ||
|
|
fb53354956 | ||
|
|
5995147054 | ||
|
|
fed9f458d1 | ||
|
|
7987564401 | ||
|
|
90ae21fb8b | ||
|
|
56a78d174d | ||
|
|
37da947b90 | ||
|
|
f23e272027 | ||
|
|
10afc0a2d5 | ||
|
|
f59c8ea533 | ||
|
|
4153ea7431 | ||
|
|
2c73577798 | ||
|
|
0b5c53ef7e | ||
|
|
0fca0d54f8 | ||
|
|
3da0c5b2b6 | ||
|
|
d8519bc1c3 | ||
|
|
33a4a799c5 | ||
|
|
358a021ba6 | ||
|
|
6dba9c25b6 | ||
|
|
1f724c802b | ||
|
|
67e3dd0035 | ||
|
|
de657829fd | ||
|
|
a2c27134a8 | ||
|
|
66c60ec10e | ||
|
|
867b39d8e1 | ||
|
|
1c8997d44a | ||
|
|
88b5112e30 | ||
|
|
3874b6a25a | ||
|
|
8ba6587c57 | ||
|
|
3ebe36f785 | ||
|
|
34ed0b96d3 | ||
|
|
ab353d2268 | ||
|
|
fd6f013480 | ||
|
|
4d0b7bc127 | ||
|
|
ce917b227f | ||
|
|
dec1bb04e8 | ||
|
|
a1093c17bc | ||
|
|
8110fbf701 | ||
|
|
cf502ebf05 | ||
|
|
7c7837b967 | ||
|
|
3bfc1cacb0 | ||
|
|
cd2ea26608 | ||
|
|
dcf8159d1c | ||
|
|
1bdab80b5d | ||
|
|
241c4dc600 | ||
|
|
18e93d2b24 | ||
|
|
084cf6b761 | ||
|
|
47ddf5f4e6 | ||
|
|
325321f5d4 | ||
|
|
ecbeca3d35 | ||
|
|
862b434c72 | ||
|
|
6376ed3b7b | ||
|
|
42e40d1718 | ||
|
|
1c1cc12058 | ||
|
|
e648b88a74 | ||
|
|
6fea46f7c8 | ||
|
|
a06e5a6e55 | ||
|
|
85bf429a08 | ||
|
|
dd6ba45cdd | ||
|
|
ab967efa64 | ||
|
|
369505e1a0 | ||
|
|
86d858a0fb | ||
|
|
d1f5158276 | ||
|
|
db83b0f78c | ||
|
|
24fcc5a0c6 | ||
|
|
9cb3d474aa | ||
|
|
0adfebfad6 | ||
|
|
66c4225aa3 | ||
|
|
6ddef9ffda | ||
|
|
27a1b22e6f | ||
|
|
f9c18cb225 | ||
|
|
b97733328a |
@@ -108,7 +108,7 @@ docker run -itd --name mw-server --privileged=true -p 7200:7200 -p 80:80 -p 443:
|
|||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
### 版本更新 0.18.5
|
### 版本更新 0.18.6
|
||||||
|
|
||||||
- 常规优化。
|
- 常规优化。
|
||||||
|
|
||||||
|
|||||||
@@ -80,6 +80,7 @@ def runPanelTask():
|
|||||||
# 站点过期检查
|
# 站点过期检查
|
||||||
siteEdateCheck()
|
siteEdateCheck()
|
||||||
|
|
||||||
|
# echo "True" > /www/server/mdserver-web/logs/panel_task.lock
|
||||||
lock_file = mw.getTriggerTaskLockFile()
|
lock_file = mw.getTriggerTaskLockFile()
|
||||||
try:
|
try:
|
||||||
if os.path.exists(lock_file):
|
if os.path.exists(lock_file):
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ sysName=`uname`
|
|||||||
action=$1
|
action=$1
|
||||||
type=$2
|
type=$2
|
||||||
|
|
||||||
VERSION=2.4.66
|
VERSION=2.4.68
|
||||||
apacheDir=${serverPath}/source/apache
|
apacheDir=${serverPath}/source/apache
|
||||||
|
|
||||||
Install_App()
|
Install_App()
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ def initDreplace():
|
|||||||
caddy_file = getConf()
|
caddy_file = getConf()
|
||||||
if not os.path.exists(caddy_file):
|
if not os.path.exists(caddy_file):
|
||||||
caddy_file_tpl = getConfTpl()
|
caddy_file_tpl = getConfTpl()
|
||||||
content = mw.readFile(systemServiceTpl)
|
content = mw.readFile(caddy_file_tpl)
|
||||||
content = content.replace('{$SERVER_PATH}', service_path)
|
content = content.replace('{$SERVER_PATH}', service_path)
|
||||||
mw.writeFile(caddy_file, content)
|
mw.writeFile(caddy_file, content)
|
||||||
|
|
||||||
|
|||||||
@@ -20,9 +20,9 @@ After=network.target network-online.target
|
|||||||
Requires=network-online.target
|
Requires=network-online.target
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=notify
|
Type=simple
|
||||||
User=caddy
|
User=www
|
||||||
Group=caddy
|
Group=www
|
||||||
ExecStart={$SERVER_PATH}/caddy/bin/caddy run --environ --config {$SERVER_PATH}/caddy/Caddyfile
|
ExecStart={$SERVER_PATH}/caddy/bin/caddy run --environ --config {$SERVER_PATH}/caddy/Caddyfile
|
||||||
ExecReload={$SERVER_PATH}/caddy/bin/caddy reload --config {$SERVER_PATH}/caddy/Caddyfile --force
|
ExecReload={$SERVER_PATH}/caddy/bin/caddy reload --config {$SERVER_PATH}/caddy/Caddyfile --force
|
||||||
TimeoutStopSec=5s
|
TimeoutStopSec=5s
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin:/opt/hom
|
|||||||
export PATH
|
export PATH
|
||||||
|
|
||||||
# cd /Users/midoks/Desktop/mwdev/server/mdserver-web/plugins/caddy && bash install.sh install 1.21.4
|
# cd /Users/midoks/Desktop/mwdev/server/mdserver-web/plugins/caddy && bash install.sh install 1.21.4
|
||||||
# cd /www/server/mdserver-web/plugins/caddy && bash install.sh install 1.21.4
|
# cd /www/server/mdserver-web/plugins/caddy && bash install.sh install 2.11
|
||||||
# cd /www/server/mdserver-web/plugins/caddy && bash install.sh install 1.29.2
|
# cd /www/server/mdserver-web/plugins/caddy && bash install.sh install 1.29.2
|
||||||
# cd /www/server/mdserver-web/plugins/caddy && bash install.sh upgrade 1.29.2
|
# cd /www/server/mdserver-web/plugins/caddy && bash install.sh upgrade 1.29.2
|
||||||
|
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ case $(uname -m) in
|
|||||||
x86_64) ARCH_NAME="amd64" ;;
|
x86_64) ARCH_NAME="amd64" ;;
|
||||||
arm) ARCH_NAME="arm64" ;;
|
arm) ARCH_NAME="arm64" ;;
|
||||||
arm64) ARCH_NAME="arm64" ;;
|
arm64) ARCH_NAME="arm64" ;;
|
||||||
|
aarch64) ARCH_NAME="arm64" ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
VERSION=2.11.2
|
VERSION=2.11.2
|
||||||
|
|||||||
@@ -328,7 +328,7 @@ def setBlackIp():
|
|||||||
mw.execShell('fail2ban-client -vvv set {jail} unbanip {ip}'.format(jail=d, ip=ip))
|
mw.execShell('fail2ban-client -vvv set {jail} unbanip {ip}'.format(jail=d, ip=ip))
|
||||||
|
|
||||||
mw.writeFile(getBlackFile(), json.dumps([]))
|
mw.writeFile(getBlackFile(), json.dumps([]))
|
||||||
return nw.returnJson(True, "禁止IP成功")
|
return mw.returnJson(True, "禁止IP成功")
|
||||||
|
|
||||||
# 检查IP格式
|
# 检查IP格式
|
||||||
for ip in add_ip_list:
|
for ip in add_ip_list:
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ rootPath=$(dirname "$rootPath")
|
|||||||
serverPath=$(dirname "$rootPath")
|
serverPath=$(dirname "$rootPath")
|
||||||
|
|
||||||
sys_os=`uname`
|
sys_os=`uname`
|
||||||
VERSION=1.6.39
|
VERSION=1.6.42
|
||||||
|
|
||||||
echo $sys_os
|
echo $sys_os
|
||||||
|
|
||||||
|
|||||||
@@ -154,8 +154,8 @@ def checkArgs(data, ck=[]):
|
|||||||
return (True, mw.returnJson(True, 'ok'))
|
return (True, mw.returnJson(True, 'ok'))
|
||||||
|
|
||||||
def status():
|
def status():
|
||||||
data = mw.execShell(
|
cmd = "ps -ef|grep mongod |grep -v mongosh|grep -v grep | grep -v /Applications | grep -v python | grep -v mdserver-web | awk '{print $2}'"
|
||||||
"ps -ef|grep mongod |grep -v mongosh|grep -v grep | grep -v /Applications | grep -v python | grep -v mdserver-web | awk '{print $2}'")
|
data = mw.execShell(cmd)
|
||||||
if data[0] == '':
|
if data[0] == '':
|
||||||
return 'stop'
|
return 'stop'
|
||||||
return 'start'
|
return 'start'
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ export PATH
|
|||||||
|
|
||||||
# cd /Users/midoks/Desktop/mwdev/server/mdserver-web/plugins/mongodb && /bin/bash install.sh install 7.0
|
# 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/plugins/mongodb && /bin/bash install.sh install 7.0
|
||||||
|
# cd /www/server/mdserver-web/plugins/mongodb && /bin/bash install.sh install 8.0
|
||||||
# cd /www/server/mdserver-web/plugins/mongodb && /bin/bash install.sh install 3.0
|
# cd /www/server/mdserver-web/plugins/mongodb && /bin/bash install.sh install 3.0
|
||||||
# cd /www/server/mdserver-web && python3 /www/server/mdserver-web/plugins/mongodb/index.py start
|
# cd /www/server/mdserver-web && python3 /www/server/mdserver-web/plugins/mongodb/index.py start
|
||||||
|
|
||||||
@@ -75,6 +76,11 @@ Install_app()
|
|||||||
|
|
||||||
if [ -f $shell_file ];then
|
if [ -f $shell_file ];then
|
||||||
bash -x $shell_file
|
bash -x $shell_file
|
||||||
|
|
||||||
|
if [ "$?" != "0" ];then
|
||||||
|
echo '不支持...'
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
echo '不支持...'
|
echo '不支持...'
|
||||||
exit 1
|
exit 1
|
||||||
|
|||||||
@@ -11,6 +11,11 @@ serverPath=$(dirname "$rootPath")
|
|||||||
VERSION=3.0.15
|
VERSION=3.0.15
|
||||||
SYS_ARCH=`arch`
|
SYS_ARCH=`arch`
|
||||||
|
|
||||||
|
if [ "$SYS_ARCH" != "x86_64" ];then
|
||||||
|
echo "no support"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
SYS_VERSION_ID=`cat /etc/*-release | grep VERSION_ID | awk -F = '{print $2}' | awk -F "\"" '{print $2}'`
|
SYS_VERSION_ID=`cat /etc/*-release | grep VERSION_ID | awk -F = '{print $2}' | awk -F "\"" '{print $2}'`
|
||||||
SYS_NAME=${SYS_VERSION_ID/./}
|
SYS_NAME=${SYS_VERSION_ID/./}
|
||||||
SYS_NAME_LEN=`echo "$SYS_NAME" | wc -L`
|
SYS_NAME_LEN=`echo "$SYS_NAME" | wc -L`
|
||||||
@@ -60,7 +65,7 @@ if [ ! -d $MG_DIR/${FILE_NAME} ];then
|
|||||||
cd $MG_DIR && tar -zxvf ${FILE_NAME_TGZ}
|
cd $MG_DIR && tar -zxvf ${FILE_NAME_TGZ}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -d $serverPath/mongodb/bin ];then
|
if [ ! -f $serverPath/mongodb/bin/mongod ];then
|
||||||
mkdir -p $serverPath/mongodb
|
mkdir -p $serverPath/mongodb
|
||||||
cd $MG_DIR/${FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
cd $MG_DIR/${FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -11,6 +11,12 @@ serverPath=$(dirname "$rootPath")
|
|||||||
# https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-3.0.15.tgz
|
# https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-3.0.15.tgz
|
||||||
VERSION=3.0.15
|
VERSION=3.0.15
|
||||||
SYS_ARCH=`arch`
|
SYS_ARCH=`arch`
|
||||||
|
|
||||||
|
if [ "$SYS_ARCH" != "x86_64" ];then
|
||||||
|
echo "no support"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
SYS_VERSION_ID=`cat /etc/*-release | grep VERSION_ID | awk -F = '{print $2}' | awk -F "\"" '{print $2}'`
|
SYS_VERSION_ID=`cat /etc/*-release | grep VERSION_ID | awk -F = '{print $2}' | awk -F "\"" '{print $2}'`
|
||||||
SYS_NAME=${SYS_VERSION_ID/./}
|
SYS_NAME=${SYS_VERSION_ID/./}
|
||||||
|
|
||||||
@@ -39,7 +45,7 @@ if [ ! -d $MG_DIR/${FILE_NAME_TGZ} ];then
|
|||||||
cd $MG_DIR && tar -zxvf ${FILE_NAME_TGZ}
|
cd $MG_DIR && tar -zxvf ${FILE_NAME_TGZ}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -d $serverPath/mongodb/bin ];then
|
if [ ! -f $serverPath/mongodb/bin/mongod ];then
|
||||||
mkdir -p $serverPath/mongodb
|
mkdir -p $serverPath/mongodb
|
||||||
cd $MG_DIR/${FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
cd $MG_DIR/${FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ if [ ! -d $MG_DIR/mongodb-macos-x86_64-${VERSION} ];then
|
|||||||
cd $MG_DIR && tar -zxvf mongodb-macos-x86_64-${VERSION}.tgz
|
cd $MG_DIR && tar -zxvf mongodb-macos-x86_64-${VERSION}.tgz
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -d $serverPath/mongodb/bin ];then
|
if [ ! -f $serverPath/mongodb/bin/mongod ];then
|
||||||
mkdir -p $serverPath/mongodb
|
mkdir -p $serverPath/mongodb
|
||||||
cd $MG_DIR/mongodb-macos-x86_64-${VERSION} && cp -rf ./bin $serverPath/mongodb
|
cd $MG_DIR/mongodb-macos-x86_64-${VERSION} && cp -rf ./bin $serverPath/mongodb
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -11,6 +11,11 @@ serverPath=$(dirname "$rootPath")
|
|||||||
VERSION=3.0.15
|
VERSION=3.0.15
|
||||||
SYS_ARCH=`arch`
|
SYS_ARCH=`arch`
|
||||||
|
|
||||||
|
if [ "$SYS_ARCH" != "x86_64" ];then
|
||||||
|
echo "no support"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
SYS_VERSION_ID=`cat /etc/*-release | grep VERSION_ID | awk -F = '{print $2}' | awk -F "\"" '{print $2}' | awk -F . '{print $1}'`
|
SYS_VERSION_ID=`cat /etc/*-release | grep VERSION_ID | awk -F = '{print $2}' | awk -F "\"" '{print $2}' | awk -F . '{print $1}'`
|
||||||
|
|
||||||
SYS_NAME="15"
|
SYS_NAME="15"
|
||||||
@@ -40,7 +45,7 @@ if [ ! -d $MG_DIR/${FILE_NAME} ];then
|
|||||||
cd $MG_DIR && tar -zxvf ${FILE_NAME_TGZ}
|
cd $MG_DIR && tar -zxvf ${FILE_NAME_TGZ}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -d $serverPath/mongodb/bin ];then
|
if [ ! -f $serverPath/mongodb/bin/mongod ];then
|
||||||
mkdir -p $serverPath/mongodb
|
mkdir -p $serverPath/mongodb
|
||||||
cd $MG_DIR/${FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
cd $MG_DIR/${FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ if [ ! -d $MG_DIR/${FILE_NAME} ];then
|
|||||||
cd $MG_DIR && tar -zxvf ${FILE_NAME_TGZ}
|
cd $MG_DIR && tar -zxvf ${FILE_NAME_TGZ}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -d $serverPath/mongodb/bin ];then
|
if [ ! -f $serverPath/mongodb/bin/mongod ];then
|
||||||
mkdir -p $serverPath/mongodb
|
mkdir -p $serverPath/mongodb
|
||||||
cd $MG_DIR/${FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
cd $MG_DIR/${FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -11,6 +11,11 @@ serverPath=$(dirname "$rootPath")
|
|||||||
VERSION=3.0.15
|
VERSION=3.0.15
|
||||||
SYS_ARCH=`arch`
|
SYS_ARCH=`arch`
|
||||||
|
|
||||||
|
if [ "$SYS_ARCH" != "x86_64" ];then
|
||||||
|
echo "no support"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
SYS_VERSION_ID=`cat /etc/*-release | grep VERSION_ID | awk -F = '{print $2}' | awk -F "\"" '{print $2}'`
|
SYS_VERSION_ID=`cat /etc/*-release | grep VERSION_ID | awk -F = '{print $2}' | awk -F "\"" '{print $2}'`
|
||||||
SYS_NAME=${SYS_VERSION_ID/./}
|
SYS_NAME=${SYS_VERSION_ID/./}
|
||||||
# https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu2004-4.4.23.tgz
|
# https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu2004-4.4.23.tgz
|
||||||
@@ -38,7 +43,7 @@ if [ ! -d $MG_DIR/${FILE_NAME} ];then
|
|||||||
cd $MG_DIR && tar -zxvf ${FILE_NAME_TGZ}
|
cd $MG_DIR && tar -zxvf ${FILE_NAME_TGZ}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -d $serverPath/mongodb/bin ];then
|
if [ ! -f $serverPath/mongodb/bin/mongod ];then
|
||||||
mkdir -p $serverPath/mongodb
|
mkdir -p $serverPath/mongodb
|
||||||
cd $MG_DIR/${FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
cd $MG_DIR/${FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ if [ ! -d $MG_DIR/${FILE_NAME} ];then
|
|||||||
cd $MG_DIR && tar -zxvf ${FILE_NAME_TGZ}
|
cd $MG_DIR && tar -zxvf ${FILE_NAME_TGZ}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -d $serverPath/mongodb/bin ];then
|
if [ ! -f $serverPath/mongodb/bin/mongod ];then
|
||||||
mkdir -p $serverPath/mongodb
|
mkdir -p $serverPath/mongodb
|
||||||
cd $MG_DIR/${FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
cd $MG_DIR/${FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ if [ ! -d $MG_DIR/${FILE_NAME_TGZ} ];then
|
|||||||
cd $MG_DIR && tar -zxvf ${FILE_NAME_TGZ}
|
cd $MG_DIR && tar -zxvf ${FILE_NAME_TGZ}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -d $serverPath/mongodb/bin ];then
|
if [ ! -f $serverPath/mongodb/bin/mongod ];then
|
||||||
mkdir -p $serverPath/mongodb
|
mkdir -p $serverPath/mongodb
|
||||||
cd $MG_DIR/${FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
cd $MG_DIR/${FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ if [ ! -d $MG_DIR/mongodb-macos-x86_64-${VERSION} ];then
|
|||||||
cd $MG_DIR && tar -zxvf mongodb-macos-x86_64-${VERSION}.tgz
|
cd $MG_DIR && tar -zxvf mongodb-macos-x86_64-${VERSION}.tgz
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -d $serverPath/mongodb/bin ];then
|
if [ ! -f $serverPath/mongodb/bin/mongod ];then
|
||||||
mkdir -p $serverPath/mongodb
|
mkdir -p $serverPath/mongodb
|
||||||
cd $MG_DIR/mongodb-macos-x86_64-${VERSION} && cp -rf ./bin $serverPath/mongodb
|
cd $MG_DIR/mongodb-macos-x86_64-${VERSION} && cp -rf ./bin $serverPath/mongodb
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ if [ ! -d $MG_DIR/${FILE_NAME} ];then
|
|||||||
cd $MG_DIR && tar -zxvf ${FILE_NAME_TGZ}
|
cd $MG_DIR && tar -zxvf ${FILE_NAME_TGZ}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -d $serverPath/mongodb/bin ];then
|
if [ ! -f $serverPath/mongodb/bin/mongod ];then
|
||||||
mkdir -p $serverPath/mongodb
|
mkdir -p $serverPath/mongodb
|
||||||
cd $MG_DIR/${FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
cd $MG_DIR/${FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ if [ ! -d $MG_DIR/${FILE_NAME} ];then
|
|||||||
cd $MG_DIR && tar -zxvf ${FILE_NAME_TGZ}
|
cd $MG_DIR && tar -zxvf ${FILE_NAME_TGZ}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -d $serverPath/mongodb/bin ];then
|
if [ ! -f $serverPath/mongodb/bin/mongod ];then
|
||||||
mkdir -p $serverPath/mongodb
|
mkdir -p $serverPath/mongodb
|
||||||
cd $MG_DIR/${FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
cd $MG_DIR/${FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ if [ ! -d $MG_DIR/${FILE_NAME} ];then
|
|||||||
cd $MG_DIR && tar -zxvf ${FILE_NAME_TGZ}
|
cd $MG_DIR && tar -zxvf ${FILE_NAME_TGZ}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -d $serverPath/mongodb/bin ];then
|
if [ ! -f $serverPath/mongodb/bin/mongod ];then
|
||||||
mkdir -p $serverPath/mongodb
|
mkdir -p $serverPath/mongodb
|
||||||
cd $MG_DIR/${FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
cd $MG_DIR/${FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ if [ ! -d $MG_DIR/${FILE_NAME} ];then
|
|||||||
cd $MG_DIR && tar -zxvf ${FILE_NAME_TGZ}
|
cd $MG_DIR && tar -zxvf ${FILE_NAME_TGZ}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -d $serverPath/mongodb/bin ];then
|
if [ ! -f $serverPath/mongodb/bin/mongod ];then
|
||||||
mkdir -p $serverPath/mongodb
|
mkdir -p $serverPath/mongodb
|
||||||
cd $MG_DIR/${FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
cd $MG_DIR/${FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ if [ ! -d $MG_DIR/${FILE_NAME_TGZ} ];then
|
|||||||
cd $MG_DIR && tar -zxvf ${FILE_NAME_TGZ}
|
cd $MG_DIR && tar -zxvf ${FILE_NAME_TGZ}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -d $serverPath/mongodb/bin ];then
|
if [ ! -f $serverPath/mongodb/bin/mongod ];then
|
||||||
mkdir -p $serverPath/mongodb
|
mkdir -p $serverPath/mongodb
|
||||||
cd $MG_DIR/${FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
cd $MG_DIR/${FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ if [ ! -d $MG_DIR/mongodb-macos-x86_64-${VERSION} ];then
|
|||||||
cd $MG_DIR && tar -zxvf mongodb-macos-x86_64-${VERSION}.tgz
|
cd $MG_DIR && tar -zxvf mongodb-macos-x86_64-${VERSION}.tgz
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -d $serverPath/mongodb/bin ];then
|
if [ ! -f $serverPath/mongodb/bin/mongod ];then
|
||||||
mkdir -p $serverPath/mongodb
|
mkdir -p $serverPath/mongodb
|
||||||
cd $MG_DIR/mongodb-macos-x86_64-${VERSION} && cp -rf ./bin $serverPath/mongodb
|
cd $MG_DIR/mongodb-macos-x86_64-${VERSION} && cp -rf ./bin $serverPath/mongodb
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ if [ ! -d $MG_DIR/${FILE_NAME} ];then
|
|||||||
cd $MG_DIR && tar -zxvf ${FILE_NAME_TGZ}
|
cd $MG_DIR && tar -zxvf ${FILE_NAME_TGZ}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -d $serverPath/mongodb/bin ];then
|
if [ ! -f $serverPath/mongodb/bin/mongod ];then
|
||||||
mkdir -p $serverPath/mongodb
|
mkdir -p $serverPath/mongodb
|
||||||
cd $MG_DIR/${FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
cd $MG_DIR/${FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ if [ ! -d $MG_DIR/${FILE_NAME} ];then
|
|||||||
cd $MG_DIR && tar -zxvf ${FILE_NAME_TGZ}
|
cd $MG_DIR && tar -zxvf ${FILE_NAME_TGZ}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -d $serverPath/mongodb/bin ];then
|
if [ ! -f $serverPath/mongodb/bin/mongod ];then
|
||||||
mkdir -p $serverPath/mongodb
|
mkdir -p $serverPath/mongodb
|
||||||
cd $MG_DIR/${FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
cd $MG_DIR/${FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ if [ ! -d $MG_DIR/${FILE_NAME} ];then
|
|||||||
cd $MG_DIR && tar -zxvf ${FILE_NAME_TGZ}
|
cd $MG_DIR && tar -zxvf ${FILE_NAME_TGZ}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -d $serverPath/mongodb/bin ];then
|
if [ ! -f $serverPath/mongodb/bin/mongod ];then
|
||||||
mkdir -p $serverPath/mongodb
|
mkdir -p $serverPath/mongodb
|
||||||
cd $MG_DIR/${FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
cd $MG_DIR/${FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ if [ ! -d $MG_DIR/${FILE_NAME_TGZ} ];then
|
|||||||
cd $MG_DIR && tar -zxvf ${FILE_NAME_TGZ}
|
cd $MG_DIR && tar -zxvf ${FILE_NAME_TGZ}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -d $serverPath/mongodb/bin ];then
|
if [ ! -f $serverPath/mongodb/bin/mongod ];then
|
||||||
mkdir -p $serverPath/mongodb
|
mkdir -p $serverPath/mongodb
|
||||||
cd $MG_DIR/${FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
cd $MG_DIR/${FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ if [ ! -d $MG_DIR/mongodb-macos-x86_64-${VERSION} ];then
|
|||||||
cd $MG_DIR && tar -zxvf mongodb-macos-x86_64-${VERSION}.tgz
|
cd $MG_DIR && tar -zxvf mongodb-macos-x86_64-${VERSION}.tgz
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -d $serverPath/mongodb/bin ];then
|
if [ ! -f $serverPath/mongodb/bin/mongod ];then
|
||||||
mkdir -p $serverPath/mongodb
|
mkdir -p $serverPath/mongodb
|
||||||
cd $MG_DIR/mongodb-macos-x86_64-${VERSION} && cp -rf ./bin $serverPath/mongodb
|
cd $MG_DIR/mongodb-macos-x86_64-${VERSION} && cp -rf ./bin $serverPath/mongodb
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ if [ ! -d $MG_DIR/${FILE_NAME} ];then
|
|||||||
cd $MG_DIR && tar -zxvf ${FILE_NAME_TGZ}
|
cd $MG_DIR && tar -zxvf ${FILE_NAME_TGZ}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -d $serverPath/mongodb/bin ];then
|
if [ ! -f $serverPath/mongodb/bin/mongod ];then
|
||||||
mkdir -p $serverPath/mongodb
|
mkdir -p $serverPath/mongodb
|
||||||
cd $MG_DIR/${FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
cd $MG_DIR/${FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ if [ ! -d $MG_DIR/${FILE_NAME} ];then
|
|||||||
cd $MG_DIR && tar -zxvf ${FILE_NAME_TGZ}
|
cd $MG_DIR && tar -zxvf ${FILE_NAME_TGZ}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -d $serverPath/mongodb/bin ];then
|
if [ ! -f $serverPath/mongodb/bin/mongod ];then
|
||||||
mkdir -p $serverPath/mongodb
|
mkdir -p $serverPath/mongodb
|
||||||
cd $MG_DIR/${FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
cd $MG_DIR/${FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ if [ ! -d $MG_DIR/${FILE_NAME} ];then
|
|||||||
cd $MG_DIR && tar -zxvf ${FILE_NAME_TGZ}
|
cd $MG_DIR && tar -zxvf ${FILE_NAME_TGZ}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -d $serverPath/mongodb/bin ];then
|
if [ ! -f $serverPath/mongodb/bin/mongod ];then
|
||||||
mkdir -p $serverPath/mongodb
|
mkdir -p $serverPath/mongodb
|
||||||
cd $MG_DIR/${FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
cd $MG_DIR/${FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ if [ ! -d $MG_DIR/${FILE_NAME_TGZ} ];then
|
|||||||
cd $MG_DIR && tar -zxvf ${FILE_NAME_TGZ}
|
cd $MG_DIR && tar -zxvf ${FILE_NAME_TGZ}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -d $serverPath/mongodb/bin ];then
|
if [ ! -f $serverPath/mongodb/bin/mongod ];then
|
||||||
mkdir -p $serverPath/mongodb
|
mkdir -p $serverPath/mongodb
|
||||||
cd $MG_DIR/${FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
cd $MG_DIR/${FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ if [ ! -d $MG_DIR/${FILE_NAME} ];then
|
|||||||
cd $MG_DIR && tar -zxvf ${FILE_NAME_TGZ}
|
cd $MG_DIR && tar -zxvf ${FILE_NAME_TGZ}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -d $serverPath/mongodb/bin ];then
|
if [ ! -f $serverPath/mongodb/bin/mongod ];then
|
||||||
mkdir -p $serverPath/mongodb
|
mkdir -p $serverPath/mongodb
|
||||||
cd $MG_DIR/${FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
cd $MG_DIR/${FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ if [ ! -d $MG_DIR/mongodb-macos-x86_64-${VERSION} ];then
|
|||||||
cd $MG_DIR && tar -zxvf mongodb-macos-x86_64-${VERSION}.tgz
|
cd $MG_DIR && tar -zxvf mongodb-macos-x86_64-${VERSION}.tgz
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -d $serverPath/mongodb/bin ];then
|
if [ ! -f $serverPath/mongodb/bin/mongod ];then
|
||||||
mkdir -p $serverPath/mongodb
|
mkdir -p $serverPath/mongodb
|
||||||
cd $MG_DIR/mongodb-macos-x86_64-${VERSION} && cp -rf ./bin $serverPath/mongodb
|
cd $MG_DIR/mongodb-macos-x86_64-${VERSION} && cp -rf ./bin $serverPath/mongodb
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ if [ ! -d $MG_DIR/${FILE_NAME} ];then
|
|||||||
cd $MG_DIR && tar -zxvf ${FILE_NAME_TGZ}
|
cd $MG_DIR && tar -zxvf ${FILE_NAME_TGZ}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -d $serverPath/mongodb/bin ];then
|
if [ ! -f $serverPath/mongodb/bin/mongod ];then
|
||||||
mkdir -p $serverPath/mongodb
|
mkdir -p $serverPath/mongodb
|
||||||
cd $MG_DIR/${FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
cd $MG_DIR/${FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ SYS_ARCH=`arch`
|
|||||||
SYS_VERSION_ID=`cat /etc/*-release | grep VERSION_ID | awk -F = '{print $2}' | awk -F "\"" '{print $2}'`
|
SYS_VERSION_ID=`cat /etc/*-release | grep VERSION_ID | awk -F = '{print $2}' | awk -F "\"" '{print $2}'`
|
||||||
SYS_NAME=${SYS_VERSION_ID/./}
|
SYS_NAME=${SYS_VERSION_ID/./}
|
||||||
# https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu2004-4.4.23.tgz
|
# https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu2004-4.4.23.tgz
|
||||||
|
# https://fastdl.mongodb.org/linux/mongodb-linux-aarch64-ubuntu2204-7.0.37.tgz
|
||||||
|
|
||||||
if [ "$SYS_NAME" -gt "2204" ];then
|
if [ "$SYS_NAME" -gt "2204" ];then
|
||||||
SYS_NAME="2204"
|
SYS_NAME="2204"
|
||||||
@@ -38,7 +39,7 @@ if [ ! -d $MG_DIR/${FILE_NAME} ];then
|
|||||||
cd $MG_DIR && tar -zxvf ${FILE_NAME_TGZ}
|
cd $MG_DIR && tar -zxvf ${FILE_NAME_TGZ}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -d $serverPath/mongodb/bin ];then
|
if [ ! -f $serverPath/mongodb/bin/mongod ];then
|
||||||
mkdir -p $serverPath/mongodb
|
mkdir -p $serverPath/mongodb
|
||||||
cd $MG_DIR/${FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
cd $MG_DIR/${FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ if [ ! -d $MG_DIR/${FILE_NAME} ];then
|
|||||||
cd $MG_DIR && tar -zxvf ${FILE_NAME_TGZ}
|
cd $MG_DIR && tar -zxvf ${FILE_NAME_TGZ}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -d $serverPath/mongodb/bin ];then
|
if [ ! -f $serverPath/mongodb/bin/mongod ];then
|
||||||
mkdir -p $serverPath/mongodb
|
mkdir -p $serverPath/mongodb
|
||||||
cd $MG_DIR/${FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
cd $MG_DIR/${FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ if [ ! -d $MG_DIR/${FILE_NAME_TGZ} ];then
|
|||||||
cd $MG_DIR && tar -zxvf ${FILE_NAME_TGZ}
|
cd $MG_DIR && tar -zxvf ${FILE_NAME_TGZ}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -d $serverPath/mongodb/bin ];then
|
if [ ! -f $serverPath/mongodb/bin/mongod ];then
|
||||||
mkdir -p $serverPath/mongodb
|
mkdir -p $serverPath/mongodb
|
||||||
cd $MG_DIR/${FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
cd $MG_DIR/${FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ if [ ! -d $MG_DIR/${FILE_NAME} ];then
|
|||||||
cd $MG_DIR && tar -zxvf ${FILE_NAME_TGZ}
|
cd $MG_DIR && tar -zxvf ${FILE_NAME_TGZ}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -d $serverPath/mongodb/bin ];then
|
if [ ! -f $serverPath/mongodb/bin/mongod ];then
|
||||||
mkdir -p $serverPath/mongodb
|
mkdir -p $serverPath/mongodb
|
||||||
cd $MG_DIR/${FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
cd $MG_DIR/${FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ if [ ! -d $MG_DIR/${FILE_NAME} ];then
|
|||||||
cd $MG_DIR && tar -zxvf ${FILE_NAME_TGZ}
|
cd $MG_DIR && tar -zxvf ${FILE_NAME_TGZ}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -d $serverPath/mongodb/bin ];then
|
if [ ! -f $serverPath/mongodb/bin/mongod ];then
|
||||||
mkdir -p $serverPath/mongodb
|
mkdir -p $serverPath/mongodb
|
||||||
cd $MG_DIR/${FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
cd $MG_DIR/${FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ if [ ! -d $MG_DIR/${FILE_NAME} ];then
|
|||||||
cd $MG_DIR && tar -zxvf ${FILE_NAME_TGZ}
|
cd $MG_DIR && tar -zxvf ${FILE_NAME_TGZ}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -d $serverPath/mongodb/bin ];then
|
if [ ! -f $serverPath/mongodb/bin/mongod ];then
|
||||||
mkdir -p $serverPath/mongodb
|
mkdir -p $serverPath/mongodb
|
||||||
cd $MG_DIR/${FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
cd $MG_DIR/${FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -15,6 +15,10 @@ SYS_VERSION_ID=`cat /etc/*-release | grep VERSION_ID | awk -F = '{print $2}' | a
|
|||||||
SYS_NAME=${SYS_VERSION_ID/./}
|
SYS_NAME=${SYS_VERSION_ID/./}
|
||||||
# https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu2004-4.4.23.tgz
|
# https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu2004-4.4.23.tgz
|
||||||
|
|
||||||
|
if [ "$SYS_NAME" -gt "2404" ];then
|
||||||
|
SYS_NAME="2404"
|
||||||
|
fi
|
||||||
|
|
||||||
if [ "$SYS_NAME" -lt "2004" ];then
|
if [ "$SYS_NAME" -lt "2004" ];then
|
||||||
SYS_NAME="2004"
|
SYS_NAME="2004"
|
||||||
fi
|
fi
|
||||||
@@ -42,7 +46,7 @@ if [ ! -d $MG_DIR/${FILE_NAME} ];then
|
|||||||
cd $MG_DIR && tar -zxvf ${FILE_NAME_TGZ}
|
cd $MG_DIR && tar -zxvf ${FILE_NAME_TGZ}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -d $serverPath/mongodb/bin ];then
|
if [ ! -f $serverPath/mongodb/bin/mongod ];then
|
||||||
mkdir -p $serverPath/mongodb
|
mkdir -p $serverPath/mongodb
|
||||||
cd $MG_DIR/${FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
cd $MG_DIR/${FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
||||||
fi
|
fi
|
||||||
@@ -72,6 +76,7 @@ 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
|
# https://fastdl.mongodb.org/tools/db/mongodb-database-tools-ubuntu2204-x86_64-100.9.4.tgz
|
||||||
#--------------- mongodb database install ------------------ #
|
#--------------- mongodb database install ------------------ #
|
||||||
TOOL_VERSION=100.9.4
|
TOOL_VERSION=100.9.4
|
||||||
|
SYS_NAME=2204
|
||||||
TOOL_FILE_NAME=mongodb-database-tools-ubuntu${SYS_NAME}-x86_64-${TOOL_VERSION}
|
TOOL_FILE_NAME=mongodb-database-tools-ubuntu${SYS_NAME}-x86_64-${TOOL_VERSION}
|
||||||
if [ "aarch64" == ${SYS_ARCH} ];then
|
if [ "aarch64" == ${SYS_ARCH} ];then
|
||||||
TOOL_FILE_NAME=mongodb-database-tools-ubuntu${SYS_NAME}-arm64-${TOOL_VERSION}
|
TOOL_FILE_NAME=mongodb-database-tools-ubuntu${SYS_NAME}-arm64-${TOOL_VERSION}
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ if [ ! -d $MG_DIR/${FILE_NAME} ];then
|
|||||||
cd $MG_DIR && tar -zxvf ${FILE_NAME_TGZ}
|
cd $MG_DIR && tar -zxvf ${FILE_NAME_TGZ}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -d $serverPath/mongodb/bin ];then
|
if [ ! -f $serverPath/mongodb/bin/mongod ];then
|
||||||
mkdir -p $serverPath/mongodb
|
mkdir -p $serverPath/mongodb
|
||||||
cd $MG_DIR/${FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
cd $MG_DIR/${FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ if [ ! -d $MG_DIR/${FILE_NAME_TGZ} ];then
|
|||||||
cd $MG_DIR && tar -zxvf ${FILE_NAME_TGZ}
|
cd $MG_DIR && tar -zxvf ${FILE_NAME_TGZ}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -d $serverPath/mongodb/bin ];then
|
if [ ! -f $serverPath/mongodb/bin/mongod ];then
|
||||||
mkdir -p $serverPath/mongodb
|
mkdir -p $serverPath/mongodb
|
||||||
cd $MG_DIR/${FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
cd $MG_DIR/${FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ if [ ! -d $MG_DIR/${FILE_NAME} ];then
|
|||||||
cd $MG_DIR && tar -zxvf ${FILE_NAME_TGZ}
|
cd $MG_DIR && tar -zxvf ${FILE_NAME_TGZ}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -d $serverPath/mongodb/bin ];then
|
if [ ! -f $serverPath/mongodb/bin/mongod ];then
|
||||||
mkdir -p $serverPath/mongodb
|
mkdir -p $serverPath/mongodb
|
||||||
cd $MG_DIR/${FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
cd $MG_DIR/${FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ if [ ! -d $MG_DIR/${FILE_NAME} ];then
|
|||||||
cd $MG_DIR && tar -zxvf ${FILE_NAME_TGZ}
|
cd $MG_DIR && tar -zxvf ${FILE_NAME_TGZ}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -d $serverPath/mongodb/bin ];then
|
if [ ! -f $serverPath/mongodb/bin/mongod ];then
|
||||||
mkdir -p $serverPath/mongodb
|
mkdir -p $serverPath/mongodb
|
||||||
cd $MG_DIR/${FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
cd $MG_DIR/${FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ if [ ! -d $MG_DIR/${FILE_NAME} ];then
|
|||||||
cd $MG_DIR && tar -zxvf ${FILE_NAME_TGZ}
|
cd $MG_DIR && tar -zxvf ${FILE_NAME_TGZ}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -d $serverPath/mongodb/bin ];then
|
if [ ! -f $serverPath/mongodb/bin/mongod ];then
|
||||||
mkdir -p $serverPath/mongodb
|
mkdir -p $serverPath/mongodb
|
||||||
cd $MG_DIR/${FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
cd $MG_DIR/${FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -15,6 +15,10 @@ SYS_VERSION_ID=`cat /etc/*-release | grep VERSION_ID | awk -F = '{print $2}' | a
|
|||||||
SYS_NAME=${SYS_VERSION_ID/./}
|
SYS_NAME=${SYS_VERSION_ID/./}
|
||||||
# https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu2004-4.4.23.tgz
|
# https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu2004-4.4.23.tgz
|
||||||
|
|
||||||
|
if [ "$SYS_NAME" -gt "2404" ];then
|
||||||
|
SYS_NAME="2404"
|
||||||
|
fi
|
||||||
|
|
||||||
if [ "$SYS_NAME" -lt "2004" ];then
|
if [ "$SYS_NAME" -lt "2004" ];then
|
||||||
SYS_NAME="2004"
|
SYS_NAME="2004"
|
||||||
fi
|
fi
|
||||||
@@ -42,7 +46,7 @@ if [ ! -d $MG_DIR/${FILE_NAME} ];then
|
|||||||
cd $MG_DIR && tar -zxvf ${FILE_NAME_TGZ}
|
cd $MG_DIR && tar -zxvf ${FILE_NAME_TGZ}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -d $serverPath/mongodb/bin ];then
|
if [ ! -f $serverPath/mongodb/bin/mongod ];then
|
||||||
mkdir -p $serverPath/mongodb
|
mkdir -p $serverPath/mongodb
|
||||||
cd $MG_DIR/${FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
cd $MG_DIR/${FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
||||||
fi
|
fi
|
||||||
@@ -72,6 +76,7 @@ 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
|
# https://fastdl.mongodb.org/tools/db/mongodb-database-tools-ubuntu2204-x86_64-100.9.4.tgz
|
||||||
#--------------- mongodb database install ------------------ #
|
#--------------- mongodb database install ------------------ #
|
||||||
TOOL_VERSION=100.9.4
|
TOOL_VERSION=100.9.4
|
||||||
|
SYS_NAME=2204
|
||||||
TOOL_FILE_NAME=mongodb-database-tools-ubuntu${SYS_NAME}-x86_64-${TOOL_VERSION}
|
TOOL_FILE_NAME=mongodb-database-tools-ubuntu${SYS_NAME}-x86_64-${TOOL_VERSION}
|
||||||
if [ "aarch64" == ${SYS_ARCH} ];then
|
if [ "aarch64" == ${SYS_ARCH} ];then
|
||||||
TOOL_FILE_NAME=mongodb-database-tools-ubuntu${SYS_NAME}-arm64-${TOOL_VERSION}
|
TOOL_FILE_NAME=mongodb-database-tools-ubuntu${SYS_NAME}-arm64-${TOOL_VERSION}
|
||||||
|
|||||||
@@ -4,8 +4,8 @@
|
|||||||
"name": "mosquitto",
|
"name": "mosquitto",
|
||||||
"title": "mosquitto",
|
"title": "mosquitto",
|
||||||
"shell": "install.sh",
|
"shell": "install.sh",
|
||||||
"versions":["2.0.18"],
|
"versions":["2.0.18", "2.1.2"],
|
||||||
"updates":["2.0.18"],
|
"updates":["2.0.18", "2.1.2"],
|
||||||
"tip": "soft",
|
"tip": "soft",
|
||||||
"checks": "server/mosquitto",
|
"checks": "server/mosquitto",
|
||||||
"path": "server/mosquitto",
|
"path": "server/mosquitto",
|
||||||
|
|||||||
@@ -48,7 +48,9 @@ Install_App()
|
|||||||
|
|
||||||
mkdir -p $serverPath/mosquitto
|
mkdir -p $serverPath/mosquitto
|
||||||
if [ ! -d $serverPath/mosquitto/bin ];then
|
if [ ! -d $serverPath/mosquitto/bin ];then
|
||||||
cd mosquitto-${VERSION} && ${INSTALL_CMD} CMakeLists.txt -DCMAKE_INSTALL_PREFIX=$serverPath/mosquitto && make install
|
cd mosquitto-${VERSION} && ${INSTALL_CMD} CMakeLists.txt \
|
||||||
|
-DCMAKE_POLICY_VERSION_MINIMUM=3.5 \
|
||||||
|
-DCMAKE_INSTALL_PREFIX=$serverPath/mosquitto && make install
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -d $serverPath/mosquitto ];then
|
if [ -d $serverPath/mosquitto ];then
|
||||||
|
|||||||
@@ -69,25 +69,44 @@ fi
|
|||||||
|
|
||||||
VERSION_ID=`cat /etc/*-release | grep 'VERSION_ID' | awk -F = '{print $2}' | awk -F "\"" '{print $2}'`
|
VERSION_ID=`cat /etc/*-release | grep 'VERSION_ID' | awk -F = '{print $2}' | awk -F "\"" '{print $2}'`
|
||||||
|
|
||||||
# 针对ubuntu24进行优化
|
# 针对ubuntu24,26进行优化
|
||||||
if [[ "$OSNAME" == "ubuntu" ]] && [[ "$VERSION_ID" =~ "24" ]]; then
|
if [[ "$OSNAME" == "ubuntu" ]] && [[ "$VERSION_ID" =~ ^(24|26)$ ]]; then
|
||||||
cur_dir=`pwd`
|
cur_dir=`pwd`
|
||||||
cd /usr/lib/x86_64-linux-gnu
|
if [ -d /usr/lib/x86_64-linux-gnu ];then
|
||||||
if [ ! -f libaio.so.1 ];then
|
cd /usr/lib/x86_64-linux-gnu
|
||||||
ln -s libaio.so.1t64.0.2 libaio.so.1
|
if [ ! -f libaio.so.1 ];then
|
||||||
|
ln -s libaio.so.1t64.0.2 libaio.so.1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -f libncurses.so.6 ];then
|
||||||
|
ln -s libncursesw.so.6.4 libncurses.so.6
|
||||||
|
fi
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -f libncurses.so.6 ];then
|
if [ -d /usr/lib/aarch64-linux-gnu ];then
|
||||||
ln -s libncursesw.so.6.4 libncurses.so.6
|
cd /usr/lib/aarch64-linux-gnu
|
||||||
|
if [ ! -f libaio.so.1 ];then
|
||||||
|
ln -s libaio.so.1t64.0.2 libaio.so.1
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
cd $cur_dir
|
cd $cur_dir
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$OSNAME" == "debian" ]] && [[ "$VERSION_ID" =~ "13" ]]; then
|
if [[ "$OSNAME" == "debian" ]] && [[ "$VERSION_ID" =~ "13" ]]; then
|
||||||
cur_dir=`pwd`
|
cur_dir=`pwd`
|
||||||
cd /usr/lib/x86_64-linux-gnu
|
if [ -d /usr/lib/x86_64-linux-gnu ];then
|
||||||
if [ ! -f libaio.so.1 ];then
|
cd /usr/lib/x86_64-linux-gnu
|
||||||
ln -s libaio.so.1t64.0.2 libaio.so.1
|
if [ ! -f libaio.so.1 ];then
|
||||||
|
ln -s libaio.so.1t64.0.2 libaio.so.1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -d /usr/lib/aarch64-linux-gnu ];then
|
||||||
|
cd /usr/lib/aarch64-linux-gnu
|
||||||
|
if [ ! -f libaio.so.1 ];then
|
||||||
|
ln -s libaio.so.1t64.0.2 libaio.so.1
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
cd $cur_dir
|
cd $cur_dir
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
"path": "server/mysql/VERSION",
|
"path": "server/mysql/VERSION",
|
||||||
"todo_versions":["5.6","5.7","8.0","8.2"],
|
"todo_versions":["5.6","5.7","8.0","8.2"],
|
||||||
"versions":["5.5", "5.6", "5.7","8.0","8.2","8.3","8.4","9.0","9.1","9.2","9.3","9.4","9.7"],
|
"versions":["5.5", "5.6", "5.7","8.0","8.2","8.3","8.4","9.0","9.1","9.2","9.3","9.4","9.7"],
|
||||||
"updates":["5.5.62","5.6.50", "5.7.32","8.0.34","8.2.0","8.3.0","9.0.1","9.1.0","9.2.0","9.3.0","9.4.0","9.7.0"],
|
"updates":["5.5.62","5.6.50", "5.7.32","8.0.46","8.2.0","8.3.0","9.0.1","9.1.0","9.2.0","9.3.0","9.4.0","9.7.0"],
|
||||||
"shell":"install.sh",
|
"shell":"install.sh",
|
||||||
"checks":"server/mysql",
|
"checks":"server/mysql",
|
||||||
"path":"server/mysql",
|
"path":"server/mysql",
|
||||||
|
|||||||
@@ -131,6 +131,16 @@ Install_mysql()
|
|||||||
|
|
||||||
cd ${rootPath}/plugins/mysql/lib && /bin/bash rpcgen.sh
|
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
|
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/archives/mysql-5.7/mysql-boost-${VERSION}.tar.gz
|
wget --no-check-certificate -O ${mysqlDir}/mysql-boost-${VERSION}.tar.gz --tries=3 https://cdn.mysql.com/archives/mysql-5.7/mysql-boost-${VERSION}.tar.gz
|
||||||
fi
|
fi
|
||||||
@@ -180,8 +190,12 @@ Install_mysql()
|
|||||||
OPTIONS="-DWITH_SSL=${serverPath}/lib/openssl11"
|
OPTIONS="-DWITH_SSL=${serverPath}/lib/openssl11"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# -DCMAKE_EXE_LINKER_FLAGS="-ltirpc" \
|
||||||
|
# -DCMAKE_C_FLAGS="-I/usr/include/tirpc" \
|
||||||
|
# -DCMAKE_CXX_FLAGS="-I/usr/include/tirpc" \
|
||||||
|
|
||||||
if [ ! -d $serverPath/mysql ];then
|
if [ ! -d $serverPath/mysql ];then
|
||||||
cd ${mysqlDir}/mysql-${VERSION} && cmake \
|
cd ${mysqlDir}/mysql-${VERSION} && ${INSTALL_CMD} \
|
||||||
-DCMAKE_INSTALL_PREFIX=$serverPath/mysql \
|
-DCMAKE_INSTALL_PREFIX=$serverPath/mysql \
|
||||||
-DMYSQL_USER=mysql \
|
-DMYSQL_USER=mysql \
|
||||||
-DMYSQL_TCP_PORT=3306 \
|
-DMYSQL_TCP_PORT=3306 \
|
||||||
@@ -195,10 +209,19 @@ Install_mysql()
|
|||||||
-DDEFAULT_CHARSET=utf8mb4 \
|
-DDEFAULT_CHARSET=utf8mb4 \
|
||||||
-DDEFAULT_COLLATION=utf8mb4_general_ci \
|
-DDEFAULT_COLLATION=utf8mb4_general_ci \
|
||||||
-DDOWNLOAD_BOOST=1 \
|
-DDOWNLOAD_BOOST=1 \
|
||||||
|
-DCMAKE_POLICY_VERSION_MINIMUM=3.5 \
|
||||||
|
-DWITH_CRYPT=system \
|
||||||
|
-DWITH_SSL=system \
|
||||||
|
-DWITH_ZLIB=system \
|
||||||
|
-DWITH_EMBEDDED_SERVER=OFF \
|
||||||
|
-DHAVE_GETHOSTBYNAME_R_6_ARG=1 \
|
||||||
|
-DHAVE_GETHOSTBYNAME_R=1 \
|
||||||
|
-DWITHOUT_TOKUDB=1 \
|
||||||
|
-DWITHOUT_ROCKSDB=1 \
|
||||||
$OPTIONS \
|
$OPTIONS \
|
||||||
-DCMAKE_C_COMPILER=${WHERE_DIR_GCC} \
|
-DCMAKE_C_COMPILER=${WHERE_DIR_GCC} \
|
||||||
-DCMAKE_CXX_COMPILER=${WHERE_DIR_GPP} \
|
-DCMAKE_CXX_COMPILER=${WHERE_DIR_GPP} \
|
||||||
-DWITH_BOOST=${mysqlDir}/mysql-${VERSION}/boost/
|
-DWITH_BOOST=${mysqlDir}/mysql-${VERSION}/boost/boost_1_59_0
|
||||||
make -j${cpuCore} && make install && make clean
|
make -j${cpuCore} && make install && make clean
|
||||||
|
|
||||||
if [ -d $serverPath/mysql ];then
|
if [ -d $serverPath/mysql ];then
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ fi
|
|||||||
VERSION_ID=`cat /etc/*-release | grep VERSION_ID | awk -F = '{print $2}' | awk -F "\"" '{print $2}'`
|
VERSION_ID=`cat /etc/*-release | grep VERSION_ID | awk -F = '{print $2}' | awk -F "\"" '{print $2}'`
|
||||||
|
|
||||||
|
|
||||||
VERSION=8.0.37
|
VERSION=8.0.46
|
||||||
Install_mysql()
|
Install_mysql()
|
||||||
{
|
{
|
||||||
mkdir -p ${mysqlDir}
|
mkdir -p ${mysqlDir}
|
||||||
@@ -102,7 +102,7 @@ Install_mysql()
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
#检测文件是否损坏.
|
#检测文件是否损坏.
|
||||||
md5_mysql_ok=e0cb61cbf6e1144c452368c4535ae931
|
md5_mysql_ok=6707beb0d46a9e08a19aa596329ca79d
|
||||||
if [ -f ${mysqlDir}/mysql-boost-${VERSION}.tar.gz ];then
|
if [ -f ${mysqlDir}/mysql-boost-${VERSION}.tar.gz ];then
|
||||||
md5_mysql=`md5sum ${mysqlDir}/mysql-boost-${VERSION}.tar.gz | awk '{print $1}'`
|
md5_mysql=`md5sum ${mysqlDir}/mysql-boost-${VERSION}.tar.gz | awk '{print $1}'`
|
||||||
if [ "${md5_mysql_ok}" == "${md5_mysql}" ]; then
|
if [ "${md5_mysql_ok}" == "${md5_mysql}" ]; then
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ fi
|
|||||||
VERSION_ID=`cat /etc/*-release | grep VERSION_ID | awk -F = '{print $2}' | awk -F "\"" '{print $2}'`
|
VERSION_ID=`cat /etc/*-release | grep VERSION_ID | awk -F = '{print $2}' | awk -F "\"" '{print $2}'`
|
||||||
|
|
||||||
|
|
||||||
VERSION=8.4.2
|
VERSION=8.4.10
|
||||||
# https://dev.mysql.com/get/Downloads/MySQL-8.4/mysql-${VERSION}.tar.gz
|
# https://dev.mysql.com/get/Downloads/MySQL-8.4/mysql-${VERSION}.tar.gz
|
||||||
# https://cdn.mysql.com//Downloads/MySQL-8.4/mysql-boost-${VERSION}.tar.gz
|
# https://cdn.mysql.com//Downloads/MySQL-8.4/mysql-boost-${VERSION}.tar.gz
|
||||||
Install_mysql()
|
Install_mysql()
|
||||||
@@ -104,7 +104,7 @@ Install_mysql()
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
#检测文件是否损坏.
|
#检测文件是否损坏.
|
||||||
md5_mysql_ok=a632063fdb1c7de2c5db47e1f66191cd
|
md5_mysql_ok=db1e11216dd83423a9374999367d77e4
|
||||||
if [ -f ${mysqlDir}/mysql-${VERSION}.tar.gz ];then
|
if [ -f ${mysqlDir}/mysql-${VERSION}.tar.gz ];then
|
||||||
md5_mysql=`md5sum ${mysqlDir}/mysql-${VERSION}.tar.gz | awk '{print $1}'`
|
md5_mysql=`md5sum ${mysqlDir}/mysql-${VERSION}.tar.gz | awk '{print $1}'`
|
||||||
if [ "${md5_mysql_ok}" == "${md5_mysql}" ]; then
|
if [ "${md5_mysql_ok}" == "${md5_mysql}" ]; then
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ fi
|
|||||||
VERSION_ID=`cat /etc/*-release | grep VERSION_ID | awk -F = '{print $2}' | awk -F "\"" '{print $2}'`
|
VERSION_ID=`cat /etc/*-release | grep VERSION_ID | awk -F = '{print $2}' | awk -F "\"" '{print $2}'`
|
||||||
|
|
||||||
|
|
||||||
VERSION=9.7.0
|
VERSION=9.7.1
|
||||||
# https://dev.mysql.com/get/Downloads/MySQL-9.4/mysql-${VERSION}.tar.gz
|
# https://dev.mysql.com/get/Downloads/MySQL-9.4/mysql-${VERSION}.tar.gz
|
||||||
# https://cdn.mysql.com/archives/mysql-9.4/mysql-9.4.0.tar.gz
|
# https://cdn.mysql.com/archives/mysql-9.4/mysql-9.4.0.tar.gz
|
||||||
Install_mysql()
|
Install_mysql()
|
||||||
@@ -104,7 +104,7 @@ Install_mysql()
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
#检测文件是否损坏.
|
#检测文件是否损坏.
|
||||||
md5_mysql_ok=c770f276fb84019be6fbe0a57b32efbc
|
md5_mysql_ok=5d2f4c9568a0e01d20dc5442c772de9f
|
||||||
if [ -f ${mysqlDir}/mysql-${VERSION}.tar.gz ];then
|
if [ -f ${mysqlDir}/mysql-${VERSION}.tar.gz ];then
|
||||||
md5_mysql=`md5sum ${mysqlDir}/mysql-${VERSION}.tar.gz | awk '{print $1}'`
|
md5_mysql=`md5sum ${mysqlDir}/mysql-${VERSION}.tar.gz | awk '{print $1}'`
|
||||||
if [ "${md5_mysql_ok}" == "${md5_mysql}" ]; then
|
if [ "${md5_mysql_ok}" == "${md5_mysql}" ]; then
|
||||||
|
|||||||
@@ -4,11 +4,8 @@
|
|||||||
<div class="bt-w-menu">
|
<div class="bt-w-menu">
|
||||||
<p class="bgw" onclick="pluginService('nezha',$('.plugin_version').attr('version'));">面板服务</p>
|
<p class="bgw" onclick="pluginService('nezha',$('.plugin_version').attr('version'));">面板服务</p>
|
||||||
<p onclick="pluginInitD('nezha',$('.plugin_version').attr('version'));">面板自启动</p>
|
<p onclick="pluginInitD('nezha',$('.plugin_version').attr('version'));">面板自启动</p>
|
||||||
<p onclick="nezha.cfg($('.plugin_version').attr('version'));">面板配置</p>
|
<p onclick="pluginConfig('nezha', $('.plugin_version').attr('version'), 'conf');">配置文件</p>
|
||||||
<p onclick="pluginConfig('nezha', $('.plugin_version').attr('version'), 'conf');">面板配置文件</p>
|
<p onclick="nezha.otherFunc();">维护功能</p>
|
||||||
<p onclick="pluginService('nezha', $('.plugin_version').attr('version'), 'agent');">AGENT服务</p>
|
|
||||||
<p onclick="pluginInitD('nezha', $('.plugin_version').attr('version'), 'agent');">AGENT自启动</p>
|
|
||||||
<p onclick="nezha.agent_cfg($('.plugin_version').attr('version'));">AGENT配置</p>
|
|
||||||
<p onclick="nezha.readme();">说明</p>
|
<p onclick="nezha.readme();">说明</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="bt-w-con pd15">
|
<div class="bt-w-con pd15">
|
||||||
|
|||||||
+46
-159
@@ -1,4 +1,5 @@
|
|||||||
# coding:utf-8
|
#!/usr/bin/env python
|
||||||
|
# coding=utf-8
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import io
|
import io
|
||||||
@@ -64,7 +65,7 @@ class App:
|
|||||||
return "Release failed {}".format(e)
|
return "Release failed {}".format(e)
|
||||||
|
|
||||||
def openPort(self):
|
def openPort(self):
|
||||||
for i in ["9527", "5555"]:
|
for i in ["8008"]:
|
||||||
self.__release_port(i)
|
self.__release_port(i)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@@ -81,49 +82,36 @@ class App:
|
|||||||
path = self.getPluginDir() + "/init.d/nezha.tpl"
|
path = self.getPluginDir() + "/init.d/nezha.tpl"
|
||||||
return path
|
return path
|
||||||
|
|
||||||
def getInitdAgentConfTpl(self):
|
def getDataDir(self):
|
||||||
path = self.getPluginDir() + "/init.d/nezha-agent.tpl"
|
data = self.getServerDir()+"/dashboard/data/sqlite.db"
|
||||||
return path
|
return data
|
||||||
|
|
||||||
def getHomeDir(self):
|
def getHomeDir(self):
|
||||||
if mw.isAppleSystem():
|
if mw.isAppleSystem():
|
||||||
user = mw.execShell(
|
user = mw.execShell("who | sed -n '2, 1p' |awk '{print $1}'")[0].strip()
|
||||||
"who | sed -n '2, 1p' |awk '{print $1}'")[0].strip()
|
|
||||||
return '/Users/' + user
|
return '/Users/' + user
|
||||||
else:
|
else:
|
||||||
return '/root'
|
return '/root'
|
||||||
|
|
||||||
def getRunUser(self):
|
def getRunUser(self):
|
||||||
if mw.isAppleSystem():
|
if mw.isAppleSystem():
|
||||||
user = mw.execShell(
|
user = mw.execShell("who | sed -n '2, 1p' |awk '{print $1}'")[0].strip()
|
||||||
"who | sed -n '2, 1p' |awk '{print $1}'")[0].strip()
|
|
||||||
return user
|
return user
|
||||||
else:
|
else:
|
||||||
return 'root'
|
return 'root'
|
||||||
|
|
||||||
def status(self):
|
def status(self):
|
||||||
cmd = "ps -ef|grep " + self.getPluginName() + \
|
cmd = "ps -ef|grep nezha/dashboard |grep -v grep | grep -v python | awk '{print $2}'"
|
||||||
" |grep -v grep | grep -v nezha-agent | grep -v python | awk '{print $2}'"
|
|
||||||
data = mw.execShell(cmd)
|
data = mw.execShell(cmd)
|
||||||
|
# mw.writeFileLog("data[0]:"+data[0])
|
||||||
if data[0] == '':
|
if data[0] == '':
|
||||||
return "stop"
|
return "stop"
|
||||||
return 'start'
|
return 'start'
|
||||||
|
|
||||||
def status_agent(self):
|
|
||||||
cmd = "ps -ef | grep nezha-agent | grep -v grep | grep -v python | awk '{print $2}'"
|
|
||||||
data = mw.execShell(cmd)
|
|
||||||
if data[0] == '':
|
|
||||||
return 'stop'
|
|
||||||
return 'start'
|
|
||||||
|
|
||||||
def contentReplace(self, content):
|
def contentReplace(self, content):
|
||||||
|
|
||||||
service_path = mw.getServerDir()
|
service_path = mw.getServerDir()
|
||||||
content = content.replace('{$ROOT_PATH}', mw.getFatherDir())
|
content = content.replace('{$ROOT_PATH}', mw.getFatherDir())
|
||||||
content = content.replace('{$SERVER_PATH}', service_path)
|
content = content.replace('{$SERVER_PATH}', service_path)
|
||||||
content = content.replace('{$RUN_USER}', self.getRunUser())
|
|
||||||
content = content.replace('{$HOME_DIR}', self.getHomeDir())
|
|
||||||
|
|
||||||
return content
|
return content
|
||||||
|
|
||||||
def initDreplace(self):
|
def initDreplace(self):
|
||||||
@@ -146,8 +134,8 @@ class App:
|
|||||||
|
|
||||||
# systemd
|
# systemd
|
||||||
systemDir = mw.systemdCfgDir()
|
systemDir = mw.systemdCfgDir()
|
||||||
systemService = systemDir + '/nezha.service'
|
systemService = systemDir + '/nezha-dashboard.service'
|
||||||
systemServiceTpl = self.getPluginDir() + '/init.d/nezha.service.tpl'
|
systemServiceTpl = self.getPluginDir() + '/init.d/nezha-dashboard.service.tpl'
|
||||||
if os.path.exists(systemDir) and not os.path.exists(systemService):
|
if os.path.exists(systemDir) and not os.path.exists(systemService):
|
||||||
service_path = mw.getServerDir()
|
service_path = mw.getServerDir()
|
||||||
se_content = mw.readFile(systemServiceTpl)
|
se_content = mw.readFile(systemServiceTpl)
|
||||||
@@ -157,53 +145,11 @@ class App:
|
|||||||
|
|
||||||
return file_bin
|
return file_bin
|
||||||
|
|
||||||
def contentAgentReplace(self, content):
|
|
||||||
path = self.__agent_cfg
|
|
||||||
if os.path.exists(path):
|
|
||||||
data = self.get_agent_cfg()
|
|
||||||
content = content.replace('{$APP_HOST}', data['host'])
|
|
||||||
content = content.replace('{$APP_SECRET}', data['secret'])
|
|
||||||
|
|
||||||
return content
|
|
||||||
|
|
||||||
def initDAgent(self):
|
|
||||||
file_tpl = self.getInitdAgentConfTpl()
|
|
||||||
|
|
||||||
initD_path = self.getServerDir() + '/init.d'
|
|
||||||
if not os.path.exists(initD_path):
|
|
||||||
os.mkdir(initD_path)
|
|
||||||
|
|
||||||
file_agent_bin = initD_path + '/nezha-agent'
|
|
||||||
|
|
||||||
content = mw.readFile(file_tpl)
|
|
||||||
content = self.contentReplace(content)
|
|
||||||
content = self.contentAgentReplace(content)
|
|
||||||
mw.writeFile(file_agent_bin, content)
|
|
||||||
mw.execShell('chmod +x ' + file_agent_bin)
|
|
||||||
|
|
||||||
# systemd
|
|
||||||
sysDir = mw.systemdCfgDir()
|
|
||||||
sysService = sysDir + '/nezha-agent.service'
|
|
||||||
sysServiceTpl = self.getPluginDir() + '/init.d/nezha-agent.service.tpl'
|
|
||||||
service_path = mw.getServerDir()
|
|
||||||
content = mw.readFile(sysServiceTpl)
|
|
||||||
content = self.contentReplace(content)
|
|
||||||
content = self.contentAgentReplace(content)
|
|
||||||
mw.writeFile(sysService, content)
|
|
||||||
mw.execShell('systemctl daemon-reload')
|
|
||||||
|
|
||||||
return file_agent_bin
|
|
||||||
|
|
||||||
def init_cfg(self):
|
|
||||||
self.initDreplace()
|
|
||||||
self.initDAgent()
|
|
||||||
|
|
||||||
def imOp(self, method):
|
def imOp(self, method):
|
||||||
|
|
||||||
file = self.initDreplace()
|
file = self.initDreplace()
|
||||||
|
|
||||||
if not mw.isAppleSystem():
|
if not mw.isAppleSystem():
|
||||||
cmd = 'systemctl {} {}'.format(method, self.getPluginName())
|
cmd = 'systemctl {} {}'.format(method, "nezha-dashboard")
|
||||||
data = mw.execShell(cmd)
|
data = mw.execShell(cmd)
|
||||||
if data[1] == '':
|
if data[1] == '':
|
||||||
return 'ok'
|
return 'ok'
|
||||||
@@ -227,19 +173,6 @@ class App:
|
|||||||
return self.imOp('reload')
|
return self.imOp('reload')
|
||||||
|
|
||||||
def agOp(self, method):
|
def agOp(self, method):
|
||||||
file = self.initDAgent()
|
|
||||||
|
|
||||||
path = self.__agent_cfg
|
|
||||||
if not os.path.exists(path):
|
|
||||||
return '请先设置Agent配置!'
|
|
||||||
|
|
||||||
if not mw.isAppleSystem():
|
|
||||||
cmd = 'systemctl {} {}'.format(method, 'nezha-agent')
|
|
||||||
data = mw.execShell(cmd)
|
|
||||||
if data[1] == '':
|
|
||||||
return 'ok'
|
|
||||||
return 'fail'
|
|
||||||
|
|
||||||
data = mw.execShell(file + ' ' + method)
|
data = mw.execShell(file + ' ' + method)
|
||||||
if data[1] == '':
|
if data[1] == '':
|
||||||
return 'ok'
|
return 'ok'
|
||||||
@@ -258,105 +191,59 @@ class App:
|
|||||||
return self.agentOp('reload')
|
return self.agentOp('reload')
|
||||||
|
|
||||||
def initd_status(self):
|
def initd_status(self):
|
||||||
cmd = 'systemctl status nezha | grep loaded | grep "enabled;"'
|
cmd = 'systemctl status nezha-dashboard | grep loaded | grep "enabled;"'
|
||||||
data = mw.execShell(cmd)
|
data = mw.execShell(cmd)
|
||||||
if data[0] == '':
|
if data[0] == '':
|
||||||
return 'fail'
|
return 'fail'
|
||||||
return 'ok'
|
return 'ok'
|
||||||
|
|
||||||
def initd_install(self):
|
def initd_install(self):
|
||||||
mw.execShell('systemctl enable nezha')
|
mw.execShell('systemctl enable nezha-dashboard')
|
||||||
return 'ok'
|
return 'ok'
|
||||||
|
|
||||||
def initd_uninstall(self):
|
def initd_uninstall(self):
|
||||||
mw.execShell('systemctl disable nezha')
|
mw.execShell('systemctl disable nezha-dashboard')
|
||||||
return 'ok'
|
return 'ok'
|
||||||
|
|
||||||
def initd_status_agent(self):
|
def getVersion(self):
|
||||||
cmd = 'systemctl status nezha-agent | grep loaded | grep "enabled;"'
|
ver_file = self.getServerDir()+"/version.pl"
|
||||||
data = mw.execShell(cmd)
|
return mw.readFile(ver_file).strip()
|
||||||
if data[0] == '':
|
|
||||||
return 'fail'
|
|
||||||
return 'ok'
|
|
||||||
|
|
||||||
def initd_install_agent(self):
|
def uninstall_pre_inspection(self):
|
||||||
mw.execShell('systemctl enable nezha-agent')
|
version = self.getVersion()
|
||||||
return 'ok'
|
data_dir = self.getDataDir()
|
||||||
|
if os.path.exists(data_dir):
|
||||||
|
self.stop()
|
||||||
|
if mw.isDebugMode():
|
||||||
|
return 'ok'
|
||||||
|
|
||||||
def initd_uninstall_agent(self):
|
from utils.plugin import plugin as MwPlugin
|
||||||
mw.execShell('systemctl disable nezha-agent')
|
MwPlugin.instance().removeIndex(self.getPluginName(), version)
|
||||||
return 'ok'
|
|
||||||
|
return "请手动删除NEZHA[{}]<br/> rm -rf {}".format(version, self.getServerDir())
|
||||||
|
|
||||||
def conf(self):
|
def conf(self):
|
||||||
return self.getServerDir() + '/dashboard/data/config.yaml'
|
return self.getServerDir() + '/dashboard/data/config.yaml'
|
||||||
|
|
||||||
def nezha_cfg(self):
|
|
||||||
path = self.__cfg
|
|
||||||
if not os.path.exists(path):
|
|
||||||
d = {}
|
|
||||||
cmd_un = 'cd ' + self.getServerDir() + '/dashboard && ./nezha conf -u ""'
|
|
||||||
mw.execShell(cmd_un)
|
|
||||||
td = mw.execShell(cmd_un)
|
|
||||||
d['username'] = td[0].strip()
|
|
||||||
|
|
||||||
pwd = mw.getRandomString(16)
|
|
||||||
cmd_pwd = 'cd ' + self.getServerDir() + '/dashboard && ./nezha conf -u "" -p ' + pwd
|
|
||||||
td = mw.execShell(cmd_pwd)
|
|
||||||
d['password'] = pwd
|
|
||||||
|
|
||||||
mw.writeFile(path, mw.enDoubleCrypt('nezha', mw.getJson(d)))
|
|
||||||
|
|
||||||
info = mw.readFile(path)
|
|
||||||
info = mw.deDoubleCrypt('nezha', info)
|
|
||||||
|
|
||||||
info = json.loads(info)
|
|
||||||
return mw.returnJson(True, 'ok', info)
|
|
||||||
|
|
||||||
def nezha_save_cfg(self):
|
|
||||||
args = self.getArgs()
|
|
||||||
data = self.checkArgs(args, ['username', 'password'])
|
|
||||||
if not data[0]:
|
|
||||||
return data[1]
|
|
||||||
path = self.__cfg
|
|
||||||
|
|
||||||
cmd = 'cd ' + self.getServerDir() + '/dashboard && ./nezha conf -su "' + \
|
|
||||||
args['username'] + '" -p ' + args['password']
|
|
||||||
# print(cmd)
|
|
||||||
t = mw.execShell(cmd)
|
|
||||||
# print(t)
|
|
||||||
mw.writeFile(path, mw.enDoubleCrypt('nezha', mw.getJson(args)))
|
|
||||||
return mw.returnJson(True, '修改成功!')
|
|
||||||
|
|
||||||
def get_agent_cfg(self):
|
|
||||||
path = self.__agent_cfg
|
|
||||||
info = mw.readFile(path)
|
|
||||||
info = mw.deDoubleCrypt('agent', info)
|
|
||||||
info = json.loads(info)
|
|
||||||
return info
|
|
||||||
|
|
||||||
def agent_cfg(self):
|
|
||||||
path = self.__agent_cfg
|
|
||||||
if not os.path.exists(path):
|
|
||||||
d = {}
|
|
||||||
d['host'] = '127.0.0.1:5555'
|
|
||||||
d['secret'] = 'secret'
|
|
||||||
mw.writeFile(path, mw.enDoubleCrypt('agent', mw.getJson(d)))
|
|
||||||
|
|
||||||
info = self.get_agent_cfg()
|
|
||||||
return mw.returnJson(True, 'ok', info)
|
|
||||||
|
|
||||||
def agent_save_cfg(self):
|
|
||||||
args = self.getArgs()
|
|
||||||
data = self.checkArgs(args, ['host', 'secret'])
|
|
||||||
if not data[0]:
|
|
||||||
return data[1]
|
|
||||||
path = self.__agent_cfg
|
|
||||||
mw.writeFile(path, mw.enDoubleCrypt('agent', mw.getJson(args)))
|
|
||||||
return mw.returnJson(True, '修改成功!')
|
|
||||||
|
|
||||||
def run_log(self):
|
def run_log(self):
|
||||||
return self.getServerDir() + '/logs/nezha.log'
|
return self.getServerDir() + '/logs/nezha.log'
|
||||||
|
|
||||||
|
def cron_add_check(self):
|
||||||
|
try:
|
||||||
|
import tool_task
|
||||||
|
tool_task.createBgTask()
|
||||||
|
return mw.returnJson(True, '添加检查任务成功')
|
||||||
|
except Exception as e:
|
||||||
|
return mw.returnJson(False, '添加检查任务失败:'+str(e))
|
||||||
|
|
||||||
|
def cron_del_check(self):
|
||||||
|
try:
|
||||||
|
import tool_task
|
||||||
|
tool_task.removeBgTask()
|
||||||
|
return mw.returnJson(True, '删除检查任务成功')
|
||||||
|
except Exception as e:
|
||||||
|
return mw.returnJson(False, '删除检查任务失败:'+str(e))
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
func = sys.argv[1]
|
func = sys.argv[1]
|
||||||
|
|||||||
@@ -1,17 +1,19 @@
|
|||||||
{
|
{
|
||||||
"sort": 7,
|
"sort": 7,
|
||||||
"ps": "哪吒监控面板/改造版",
|
"ps": "哪吒监控面板",
|
||||||
"name": "nezha",
|
"name": "nezha",
|
||||||
"title": "哪吒监控",
|
"title": "哪吒监控",
|
||||||
"shell": "install.sh",
|
"shell": "install.sh",
|
||||||
"versions":["0.15.2"],
|
"versions":["2.2.5","2.2.6","latest"],
|
||||||
"tip": "soft",
|
"tip": "soft",
|
||||||
"checks": "server/nezha",
|
"checks": "server/nezha",
|
||||||
"path": "server/nezha",
|
"path": "server/nezha",
|
||||||
|
"coexist": false,
|
||||||
|
"uninstall_pre_inspection":true,
|
||||||
"display": 1,
|
"display": 1,
|
||||||
"author": "midoks",
|
"author": "midoks",
|
||||||
"date": "2023-06-26",
|
"date": "2023-06-26",
|
||||||
"home": "https://github.com/midoks/nezha",
|
"home": "https://github.com/nezhahq/nezha",
|
||||||
"doc1": "https://nezha.wiki/",
|
"doc1": "https://nezha.wiki/",
|
||||||
"type": 0,
|
"type": 0,
|
||||||
"pid": "5"
|
"pid": "5"
|
||||||
|
|||||||
@@ -1,30 +0,0 @@
|
|||||||
[Unit]
|
|
||||||
Description=Nezha Agent
|
|
||||||
After=syslog.target
|
|
||||||
#After=network.target
|
|
||||||
#After=nezha-dashboard.service
|
|
||||||
|
|
||||||
[Service]
|
|
||||||
# Modify these two values and uncomment them if you have
|
|
||||||
# repos with lots of files and get an HTTP error 500 because
|
|
||||||
# of that
|
|
||||||
###
|
|
||||||
#LimitMEMLOCK=infinity
|
|
||||||
#LimitNOFILE=65535
|
|
||||||
Type=simple
|
|
||||||
User=root
|
|
||||||
Group=root
|
|
||||||
WorkingDirectory={$SERVER_PATH}/nezha/agent/
|
|
||||||
ExecStart={$SERVER_PATH}/nezha/agent/nezha-agent -s {$APP_HOST} -p {$APP_SECRET}
|
|
||||||
Restart=always
|
|
||||||
#Environment=DEBUG=true
|
|
||||||
|
|
||||||
# Some distributions may not support these hardening directives. If you cannot start the service due
|
|
||||||
# to an unknown option, comment out the ones not supported by your version of systemd.
|
|
||||||
#ProtectSystem=full
|
|
||||||
#PrivateDevices=yes
|
|
||||||
#PrivateTmp=yes
|
|
||||||
#NoNewPrivileges=true
|
|
||||||
|
|
||||||
[Install]
|
|
||||||
WantedBy=multi-user.target
|
|
||||||
@@ -1,90 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
# chkconfig: 2345 55 25
|
|
||||||
# description: Nezha Agent Service
|
|
||||||
|
|
||||||
### BEGIN INIT INFO
|
|
||||||
# Provides: Nezha Agent
|
|
||||||
# Required-Start: $all
|
|
||||||
# Required-Stop: $all
|
|
||||||
# Default-Start: 2 3 4 5
|
|
||||||
# Default-Stop: 0 1 6
|
|
||||||
# Short-Description: starts Nezha Agent
|
|
||||||
# Description: starts the Nezha Agent
|
|
||||||
### END INIT INFO
|
|
||||||
|
|
||||||
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
|
|
||||||
|
|
||||||
if [ -f /etc/init.d/functions ];then
|
|
||||||
. /etc/init.d/functions
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -f /etc/rc.d/init.d/functions ];then
|
|
||||||
. /etc/rc.d/init.d/functions
|
|
||||||
fi
|
|
||||||
|
|
||||||
SERVICENAME=nezha-agent
|
|
||||||
LOG_PATH={$SERVER_PATH}/nezha/logs
|
|
||||||
APP_PATH={$SERVER_PATH}/nezha/agent
|
|
||||||
APP_HOST={$APP_HOST}
|
|
||||||
APP_SECRET={$APP_SECRET}
|
|
||||||
|
|
||||||
|
|
||||||
app_start(){
|
|
||||||
isStart=`ps -ef|grep "${SERVICENAME}" | grep -v grep | grep -v python | grep -v "/bin/bash" | awk '{print $2}'`
|
|
||||||
if [ "$isStart" == '' ];then
|
|
||||||
echo -e "Starting ${SERVICENAME}... \c"
|
|
||||||
cd $APP_PATH
|
|
||||||
exec nohup ${APP_PATH}/${SERVICENAME} -d -s ${APP_HOST} -p ${APP_SECRET} >> ${LOG_PATH}/${SERVICENAME}.log 2>&1 &
|
|
||||||
isStart=""
|
|
||||||
while [[ "$isStart" == "" ]];
|
|
||||||
do
|
|
||||||
echo -e ".\c"
|
|
||||||
sleep 0.5
|
|
||||||
isStart=$(ps -ef|grep "${SERVICENAME}" |grep -v grep | grep -v python | grep -v "/bin/bash" | awk '{print $2}')
|
|
||||||
let n+=1
|
|
||||||
if [ $n -gt 15 ];then
|
|
||||||
break;
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
if [ "$isStart" == '' ];then
|
|
||||||
echo -e "\033[31mError: ${SERVICENAME} service startup failed.\033[0m"
|
|
||||||
return;
|
|
||||||
fi
|
|
||||||
echo -e "\033[32mdone\033[0m"
|
|
||||||
else
|
|
||||||
echo "Starting ${SERVICENAME}(pid $(echo $isStart)) already running"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
app_stop(){
|
|
||||||
pids=`ps -ef | grep "${SERVICENAME}" | grep -v grep | grep -v python | grep -v "/bin/bash" |awk '{print $2}'`
|
|
||||||
arr=($pids)
|
|
||||||
echo -e "Stopping ${SERVICENAME}... \c"
|
|
||||||
for p in ${arr[@]}
|
|
||||||
do
|
|
||||||
# echo "$p"
|
|
||||||
kill -9 $p
|
|
||||||
done
|
|
||||||
echo -e "\033[32mdone\033[0m"
|
|
||||||
}
|
|
||||||
|
|
||||||
app_status(){
|
|
||||||
isStart=`ps -ef | grep "${SERVICENAME}" | grep -v grep | grep -v python | grep -v "/bin/bash" | awk '{print $2}'`
|
|
||||||
if [ "$isStart" == '' ];then
|
|
||||||
echo -e "${SERVICENAME} not running"
|
|
||||||
else
|
|
||||||
echo -e "${SERVICENAME}(pid $(echo $isStart)) already running"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
case "$1" in
|
|
||||||
'start') app_start;;
|
|
||||||
'stop') app_stop;;
|
|
||||||
'status') app_status;;
|
|
||||||
'reload')
|
|
||||||
app_stop
|
|
||||||
app_start;;
|
|
||||||
'restart')
|
|
||||||
app_stop
|
|
||||||
app_start;;
|
|
||||||
esac
|
|
||||||
+1
-1
@@ -15,7 +15,7 @@ Type=simple
|
|||||||
#User=root
|
#User=root
|
||||||
#Group=root
|
#Group=root
|
||||||
WorkingDirectory={$SERVER_PATH}/nezha/dashboard/
|
WorkingDirectory={$SERVER_PATH}/nezha/dashboard/
|
||||||
ExecStart={$SERVER_PATH}/nezha/dashboard/nezha web
|
ExecStart={$SERVER_PATH}/nezha/dashboard/app
|
||||||
Restart=always
|
Restart=always
|
||||||
#Environment=DEBUG=true
|
#Environment=DEBUG=true
|
||||||
|
|
||||||
@@ -2,6 +2,16 @@
|
|||||||
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
|
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
|
||||||
export PATH
|
export PATH
|
||||||
|
|
||||||
|
# systemctl start nezha-dashboard
|
||||||
|
# systemctl status nezha-dashboard
|
||||||
|
|
||||||
|
# cd /www/server/mdserver-web/plugins/nezha && bash install.sh install 2.2.6
|
||||||
|
# sqlite3 /www/server/nezha/dashboard/data/sqlite.db "DELETE FROM users;"
|
||||||
|
|
||||||
|
# cd /www/server/mdserver-web && source bin/activate && python3 plugins/nezha/index.py start
|
||||||
|
# cd /www/server/mdserver-web && source bin/activate && python3 plugins/nezha/index.py status
|
||||||
|
# python3 plugins/nezha/index.py cron_add_check
|
||||||
|
|
||||||
curPath=`pwd`
|
curPath=`pwd`
|
||||||
rootPath=$(dirname "$curPath")
|
rootPath=$(dirname "$curPath")
|
||||||
rootPath=$(dirname "$rootPath")
|
rootPath=$(dirname "$rootPath")
|
||||||
@@ -30,12 +40,4 @@ if [ "${action}" == "uninstall" ];then
|
|||||||
rm -rf /lib/systemd/system/nezha.service
|
rm -rf /lib/systemd/system/nezha.service
|
||||||
systemctl daemon-reload
|
systemctl daemon-reload
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -f /usr/lib/systemd/system/nezha-agent.service ] || [ -f /lib/systemd/system/nezha-agent.service ] ;then
|
|
||||||
systemctl stop nezha-agent
|
|
||||||
systemctl disable nezha-agent
|
|
||||||
rm -rf /usr/lib/systemd/system/nezha-agent.service
|
|
||||||
rm -rf /lib/systemd/system/nezha-agent.service
|
|
||||||
systemctl daemon-reload
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|||||||
+17
-88
@@ -31,14 +31,6 @@ var nezha = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var ret_data = $.parseJSON(res.data);
|
var ret_data = $.parseJSON(res.data);
|
||||||
console.log("send:",ret_data);
|
|
||||||
// if (!ret_data.status){
|
|
||||||
// layer.msg(ret_data.msg,{icon:2,time:2000});
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// console.log("send2:",ret_data);
|
|
||||||
|
|
||||||
if(typeof(callback) == 'function'){
|
if(typeof(callback) == 'function'){
|
||||||
callback(ret_data);
|
callback(ret_data);
|
||||||
}
|
}
|
||||||
@@ -82,102 +74,39 @@ var nezha = {
|
|||||||
}
|
}
|
||||||
},'json');
|
},'json');
|
||||||
},
|
},
|
||||||
|
|
||||||
repeatPwd:function (a, id) {
|
repeatPwd:function (a, id) {
|
||||||
$("#"+id).val(randomStrPwd(a))
|
$("#"+id).val(randomStrPwd(a))
|
||||||
},
|
},
|
||||||
|
|
||||||
save_cfg:function(version){
|
otherFunc:function(){
|
||||||
var username = $("input[name='username']").val();
|
var con = '<p class="conf_p" style="text-align:center;">\
|
||||||
var password = $("input[name='password']").val();
|
<button class="btn btn-default btn-sm" onclick="nezha.cronAddCheck()">添加更新任务</button>\
|
||||||
|
<button class="btn btn-default btn-sm" onclick="nezha.cronDelCheck()">删除更新任务</button>\
|
||||||
this.send({
|
</p>';
|
||||||
tips:'正在设置中...',
|
$(".soft-man-con").html(con);
|
||||||
data:{'username':username,'password':password},
|
},
|
||||||
method:'nezha_save_cfg',
|
cronAddCheck: function(){
|
||||||
|
nezha.send({
|
||||||
|
tips:"请求中...",
|
||||||
|
method: "cron_add_check",
|
||||||
success:function(rdata){
|
success:function(rdata){
|
||||||
layer.msg(rdata.msg, { icon: rdata.status ? 1 : 2 });
|
layer.msg(rdata.msg, { icon: rdata.status ? 1 : 2 });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
cronDelCheck:function(){
|
||||||
cfg:function(version){
|
nezha.send({
|
||||||
this.send({
|
tips:"请求中...",
|
||||||
tips:'正在获取中...',
|
method: "cron_del_check",
|
||||||
method:'nezha_cfg',
|
|
||||||
success:function(data){
|
|
||||||
var d = data.data;
|
|
||||||
var value = '<p>\
|
|
||||||
<span>用户名</span>\
|
|
||||||
<input id="nz_username" style="width: 160px;" class="bt-input-text mr5" name="username" value="'+d['username']+'" type="text">\
|
|
||||||
,<span title="随机用户名" class="glyphicon glyphicon-repeat cursor" onclick="nezha.repeatPwd(8,\'nz_username\')"></span>\
|
|
||||||
</p>';
|
|
||||||
|
|
||||||
value += '<p>\
|
|
||||||
<span>密码</span>\
|
|
||||||
<input id="nz_password" style="width: 160px;" class="bt-input-text mr5" name="password" value="'+d['password']+'" type="text">\
|
|
||||||
,<span title="随机密码" class="glyphicon glyphicon-repeat cursor" onclick="nezha.repeatPwd(16,\'nz_password\')"></span>\
|
|
||||||
</p>';
|
|
||||||
var conf = '<style>.conf_p p{margin-bottom: 2px;} .conf_p span {width: 50px;}</style><div class="conf_p" style="margin-bottom:0">\
|
|
||||||
' + value + '\
|
|
||||||
<div style="margin-top:10px; padding-right:15px" class="text-right">\
|
|
||||||
<button class="btn btn-success btn-sm mr5" onclick="nezha.cfg(\'' + version + '\')">刷新</button>\
|
|
||||||
<button class="btn btn-success btn-sm" onclick="nezha.save_cfg(\'' + version + '\')">保存</button>\
|
|
||||||
</div>\
|
|
||||||
</div>'
|
|
||||||
$(".soft-man-con").html(conf);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
agent_save_cfg:function(version){
|
|
||||||
var host = $("input[name='host']").val();
|
|
||||||
var secret = $("input[name='secret']").val();
|
|
||||||
|
|
||||||
this.send({
|
|
||||||
tips:'正在设置中...',
|
|
||||||
data:{'host':host,'secret':secret},
|
|
||||||
method:'agent_save_cfg',
|
|
||||||
success:function(rdata){
|
success:function(rdata){
|
||||||
layer.msg(rdata.msg, { icon: rdata.status ? 1 : 2 });
|
layer.msg(rdata.msg, { icon: rdata.status ? 1 : 2 });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
agent_cfg:function(version){
|
|
||||||
this.send({
|
|
||||||
tips:'正在获取中...',
|
|
||||||
method:'agent_cfg',
|
|
||||||
success:function(data){
|
|
||||||
var d = data.data;
|
|
||||||
var value = '<p>\
|
|
||||||
<span>地址</span>\
|
|
||||||
<input id="nz_username" style="width: 160px;" class="bt-input-text mr5" name="host" value="'+d['host']+'" type="text">\
|
|
||||||
,<font>如1.1.1.1:5444</font>\
|
|
||||||
</p>';
|
|
||||||
|
|
||||||
value += '<p>\
|
|
||||||
<span>密钥</span>\
|
|
||||||
<input id="nz_password" style="width: 160px;" class="bt-input-text mr5" name="secret" value="'+d['secret']+'" type="text">\
|
|
||||||
,<font>密钥</font>\
|
|
||||||
</p>';
|
|
||||||
var conf = '<style>.conf_p p{margin-bottom: 2px;} .conf_p span {width: 50px;}</style><div class="conf_p" style="margin-bottom:0">\
|
|
||||||
' + value + '\
|
|
||||||
<div style="margin-top:10px; padding-right:15px" class="text-right">\
|
|
||||||
<button class="btn btn-success btn-sm mr5" onclick="nezha.agent_cfg(\'' + version + '\')">刷新</button>\
|
|
||||||
<button class="btn btn-success btn-sm" onclick="nezha.agent_save_cfg(\'' + version + '\')">保存</button>\
|
|
||||||
</div>\
|
|
||||||
</div>'
|
|
||||||
$(".soft-man-con").html(conf);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
readme:function (){
|
readme:function (){
|
||||||
var readme = '<ul class="help-info-text c7">';
|
var readme = '<ul class="help-info-text c7">';
|
||||||
readme += '<li>安装时不会自动启动。</li>';
|
readme += '<li>默认用户和密码(admin:admin),务必在第一时间修改</li>';
|
||||||
readme += '<li>哪吒面板是改造版,用户名和密码登录【面板配置】,不依赖github/gitee/gitlab。</li>';
|
readme += '<li>经测试,修改(admin)密码后,需清空cookie,才能正常登录</li>';
|
||||||
readme += '<li>Agent需要先手动填写正确信息。</li>';
|
|
||||||
readme += '</ul>';
|
readme += '</ul>';
|
||||||
$('.soft-man-con').html(readme);
|
$('.soft-man-con').html(readme);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,124 @@
|
|||||||
|
# coding:utf-8
|
||||||
|
|
||||||
|
import sys
|
||||||
|
import io
|
||||||
|
import os
|
||||||
|
import time
|
||||||
|
import json
|
||||||
|
|
||||||
|
web_dir = os.getcwd() + "/web"
|
||||||
|
if os.path.exists(web_dir):
|
||||||
|
sys.path.append(web_dir)
|
||||||
|
os.chdir(web_dir)
|
||||||
|
|
||||||
|
import core.mw as mw
|
||||||
|
from utils.crontab import crontab as MwCrontab
|
||||||
|
|
||||||
|
|
||||||
|
app_debug = False
|
||||||
|
if mw.isAppleSystem():
|
||||||
|
app_debug = True
|
||||||
|
|
||||||
|
|
||||||
|
def getPluginName():
|
||||||
|
return 'nezha'
|
||||||
|
|
||||||
|
|
||||||
|
def getPluginDir():
|
||||||
|
return mw.getPluginDir() + '/' + getPluginName()
|
||||||
|
|
||||||
|
|
||||||
|
def getServerDir():
|
||||||
|
return mw.getServerDir() + '/' + getPluginName()
|
||||||
|
|
||||||
|
|
||||||
|
def getTaskConf():
|
||||||
|
conf = getServerDir() + "/task_config.json"
|
||||||
|
return conf
|
||||||
|
|
||||||
|
|
||||||
|
def getConfigData():
|
||||||
|
conf = getTaskConf()
|
||||||
|
if os.path.exists(conf):
|
||||||
|
return json.loads(mw.readFile(getTaskConf()))
|
||||||
|
return {
|
||||||
|
"task_id": -1,
|
||||||
|
"period": "day-n",
|
||||||
|
"where1": "7",
|
||||||
|
"hour": "0",
|
||||||
|
"minute": "0",
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def createBgTask():
|
||||||
|
removeBgTask()
|
||||||
|
createBgTaskByName(getPluginName())
|
||||||
|
|
||||||
|
|
||||||
|
def createBgTaskByName(name):
|
||||||
|
args = getConfigData()
|
||||||
|
_name = "[NEZHA]自动更新任务"
|
||||||
|
res = mw.M("crontab").field("id, name").where("name=?", (_name,)).find()
|
||||||
|
if res:
|
||||||
|
return True
|
||||||
|
|
||||||
|
if "task_id" in args and args["task_id"] > 0:
|
||||||
|
res = mw.M("crontab").field("id, name").where(
|
||||||
|
"id=?", (args["task_id"],)).find()
|
||||||
|
if res and res["id"] == args["task_id"]:
|
||||||
|
print("计划任务已经存在!")
|
||||||
|
return True
|
||||||
|
|
||||||
|
mw_dir = mw.getPanelDir()
|
||||||
|
cmd = '''
|
||||||
|
mw_dir=%s
|
||||||
|
rname=%s
|
||||||
|
plugin_path=%s
|
||||||
|
script_path=%s
|
||||||
|
''' % (mw_dir, name, getServerDir(), getPluginDir())
|
||||||
|
cmd += 'echo "bash $script_path/update.sh"' + "\n"
|
||||||
|
cmd += 'cd $mw_dir && bash $script_path/update.sh' + "\n"
|
||||||
|
|
||||||
|
params = {
|
||||||
|
'name': _name,
|
||||||
|
'type': args['period'],
|
||||||
|
'week': "",
|
||||||
|
'where1': args['where1'],
|
||||||
|
'hour': args['hour'],
|
||||||
|
'minute': args['minute'],
|
||||||
|
'save': "",
|
||||||
|
'backup_to': "",
|
||||||
|
'stype': "toShell",
|
||||||
|
'sname': '',
|
||||||
|
'sbody': cmd,
|
||||||
|
'url_address': '',
|
||||||
|
}
|
||||||
|
|
||||||
|
task_id = MwCrontab.instance().add(params)
|
||||||
|
if task_id > 0:
|
||||||
|
args["task_id"] = task_id
|
||||||
|
args["name"] = name
|
||||||
|
mw.writeFile(getTaskConf(), json.dumps(args))
|
||||||
|
|
||||||
|
|
||||||
|
def removeBgTask():
|
||||||
|
cfg = getConfigData()
|
||||||
|
if "task_id" in cfg and cfg["task_id"] > 0:
|
||||||
|
res = mw.M("crontab").field("id, name").where(
|
||||||
|
"id=?", (cfg["task_id"],)).find()
|
||||||
|
if res and res["id"] == cfg["task_id"]:
|
||||||
|
data = MwCrontab.instance().delete(cfg["task_id"])
|
||||||
|
if data["status"]:
|
||||||
|
cfg["task_id"] = -1
|
||||||
|
mw.writeFile(getTaskConf(), json.dumps(cfg))
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
if len(sys.argv) > 1:
|
||||||
|
action = sys.argv[1]
|
||||||
|
if action == "remove":
|
||||||
|
removeBgTask()
|
||||||
|
elif action == "add":
|
||||||
|
createBgTask()
|
||||||
@@ -0,0 +1,113 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
|
||||||
|
export PATH
|
||||||
|
|
||||||
|
# cd /www/server/mdserver-web && bash plugins/nezha/update.sh
|
||||||
|
curPath=`pwd`
|
||||||
|
serverPath=$(dirname "$curPath")
|
||||||
|
echo $curPath
|
||||||
|
|
||||||
|
nezhaDir=${serverPath}/source/nezha
|
||||||
|
|
||||||
|
REPO="nezhahq/nezha"
|
||||||
|
LATEST_VERSION=$(curl -sL "https://api.github.com/repos/$REPO/releases/latest" | jq -r '.tag_name')
|
||||||
|
echo "最新版本是: $LATEST_VERSION"
|
||||||
|
NUMBER_LATEST_VERSION=${LATEST_VERSION:1}
|
||||||
|
echo "最新[NUMBER]是: $NUMBER_LATEST_VERSION"
|
||||||
|
|
||||||
|
# INSTALL_VERSION=`cat /www/server/nezha/version.pl`
|
||||||
|
# echo "安装的版本: $INSTALL_VERSION"
|
||||||
|
|
||||||
|
INSTALL_VERSION=`/www/server/nezha/dashboard/app -v`
|
||||||
|
echo "安装的版本: $INSTALL_VERSION"
|
||||||
|
|
||||||
|
if [ -d /www/server/nezha ];then
|
||||||
|
echo "$INSTALL_VERSION" > /www/server/nezha/version.pl
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$INSTALL_VERSION" == "$NUMBER_LATEST_VERSION" ];then
|
||||||
|
echo "已经是最新!!!"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
get_arch() {
|
||||||
|
uname=$(uname -m)
|
||||||
|
case "$uname" in
|
||||||
|
amd64|x86_64)
|
||||||
|
ARCH="amd64"
|
||||||
|
;;
|
||||||
|
i386|i686)
|
||||||
|
ARCH="386"
|
||||||
|
;;
|
||||||
|
aarch64|arm64)
|
||||||
|
ARCH="arm64"
|
||||||
|
;;
|
||||||
|
*arm*)
|
||||||
|
ARCH="arm"
|
||||||
|
;;
|
||||||
|
s390x)
|
||||||
|
ARCH="s390x"
|
||||||
|
;;
|
||||||
|
riscv64)
|
||||||
|
ARCH="riscv64"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
err "未知架构:$ARCH"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
get_arch
|
||||||
|
|
||||||
|
download_file() {
|
||||||
|
url="${1}"
|
||||||
|
destination="${2}"
|
||||||
|
|
||||||
|
printf "Fetching ${url} \n\n"
|
||||||
|
|
||||||
|
if test -x "$(command -v curl)"; then
|
||||||
|
code=$(curl --connect-timeout 15 -w '%{http_code}' -L "${url}" -o "${destination}")
|
||||||
|
elif test -x "$(command -v wget)"; then
|
||||||
|
code=$(wget -t2 -T15 -O "${destination}" --server-response "${url}" 2>&1 | awk '/^ HTTP/{print $2}' | tail -1)
|
||||||
|
else
|
||||||
|
printf "\e[1;31mNeither curl nor wget was available to perform http requests.\e[0m\n"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "${code}" != 200 ]; then
|
||||||
|
printf "\e[1;31mRequest failed with code %s\e[0m\n" $code
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
printf "\n\e[1;33mDownload succeeded\e[0m\n"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
TARGET_DIR="$serverPath/nezha/dashboard"
|
||||||
|
filename="dashboard-linux-${ARCH}.zip"
|
||||||
|
DOWNLOAD_URL="https://github.com/nezhahq/nezha/releases/download/v${NUMBER_LATEST_VERSION}/${filename}"
|
||||||
|
|
||||||
|
|
||||||
|
DOWNLOAD_FILE="$nezhaDir/$filename"
|
||||||
|
if [ ! -f $DOWNLOAD_FILE ];then
|
||||||
|
download_file $DOWNLOAD_URL $DOWNLOAD_FILE
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -d $TARGET_DIR ]; then
|
||||||
|
mkdir -p $TARGET_DIR
|
||||||
|
fi
|
||||||
|
|
||||||
|
cd $TARGET_DIR && rm -rf app.bak
|
||||||
|
cd $TARGET_DIR && mv app app.bak
|
||||||
|
unzip $DOWNLOAD_FILE -d $TARGET_DIR
|
||||||
|
echo "TARGET_DIR:"$TARGET_DIR
|
||||||
|
if [ ! -f $TARGET_DIR/app ];then
|
||||||
|
cd $TARGET_DIR && mv dashboard-linux-${ARCH} app && chmod +x app
|
||||||
|
fi
|
||||||
|
|
||||||
|
systemctl restart nezha-dashboard
|
||||||
|
echo $DOWNLOAD_URL
|
||||||
|
|
||||||
|
if [ -d /www/server/nezha ];then
|
||||||
|
echo "$INSTALL_VERSION" > /www/server/nezha/version.pl
|
||||||
|
fi
|
||||||
|
echo "ok"
|
||||||
+84
-62
@@ -7,52 +7,90 @@ rootPath=$(dirname "$curPath")
|
|||||||
rootPath=$(dirname "$rootPath")
|
rootPath=$(dirname "$rootPath")
|
||||||
serverPath=$(dirname "$rootPath")
|
serverPath=$(dirname "$rootPath")
|
||||||
|
|
||||||
VERSION=0.15.2
|
nezhaDir=${serverPath}/source/nezha
|
||||||
|
VERSION=2.2.5
|
||||||
|
|
||||||
# bash install.sh install 0.15.2
|
# cd /www/server/mdserver-web/plugins/nezha && bash install.sh install 2.2.5
|
||||||
# cd /www/server/mdserver-web/plugins/nezha && bash install.sh install 0.15.2
|
# cd /Users/midoks/Desktop/mwdev/server/mdserver-web/plugins/nezha && bash install.sh install 2.2.5
|
||||||
# cd /Users/midoks/Desktop/mwdev/server/mdserver-web/plugins/nezha && bash install.sh install 0.15.2
|
|
||||||
|
|
||||||
bash ${rootPath}/scripts/getos.sh
|
bash ${rootPath}/scripts/getos.sh
|
||||||
OSNAME=`cat ${rootPath}/data/osname.pl`
|
OSNAME=`cat ${rootPath}/data/osname.pl`
|
||||||
OSNAME_ID=`cat /etc/*-release | grep VERSION_ID | awk -F = '{print $2}' | awk -F "\"" '{print $2}'`
|
OSNAME_ID=`cat /etc/*-release | grep VERSION_ID | awk -F = '{print $2}' | awk -F "\"" '{print $2}'`
|
||||||
|
|
||||||
|
|
||||||
ARCH="amd64"
|
ARCH="amd64"
|
||||||
|
|
||||||
|
geo_check() {
|
||||||
|
api_list="https://blog.cloudflare.com/cdn-cgi/trace https://developers.cloudflare.com/cdn-cgi/trace"
|
||||||
|
ua="Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/81.0"
|
||||||
|
set -- "$api_list"
|
||||||
|
for url in $api_list; do
|
||||||
|
text="$(curl -A "$ua" -m 10 -s "$url")"
|
||||||
|
endpoint="$(echo "$text" | sed -n 's/.*h=\([^ ]*\).*/\1/p')"
|
||||||
|
if echo "$text" | grep -qw 'CN'; then
|
||||||
|
isCN=true
|
||||||
|
break
|
||||||
|
elif echo "$url" | grep -q "$endpoint"; then
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
get_arch() {
|
get_arch() {
|
||||||
TMP_ARCH=`arch`
|
uname=$(uname -m)
|
||||||
if [ "$TMP_ARCH" == "x86_64" ];then
|
case "$uname" in
|
||||||
ARCH="amd64"
|
amd64|x86_64)
|
||||||
elif [ "$TMP_ARCH" == "aarch64" ];then
|
ARCH="amd64"
|
||||||
ARCH="arm64"
|
;;
|
||||||
else
|
i386|i686)
|
||||||
echo $ARCH
|
ARCH="386"
|
||||||
fi
|
;;
|
||||||
|
aarch64|arm64)
|
||||||
|
ARCH="arm64"
|
||||||
|
;;
|
||||||
|
*arm*)
|
||||||
|
ARCH="arm"
|
||||||
|
;;
|
||||||
|
s390x)
|
||||||
|
ARCH="s390x"
|
||||||
|
;;
|
||||||
|
riscv64)
|
||||||
|
ARCH="riscv64"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
err "未知架构:$ARCH"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
check_init() {
|
||||||
|
init=$(readlink /sbin/init)
|
||||||
|
case "$init" in
|
||||||
|
*systemd*)
|
||||||
|
INIT=systemd
|
||||||
|
;;
|
||||||
|
*openrc-init*|*busybox*)
|
||||||
|
INIT=openrc
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
err "Unknown init"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
load_vars() {
|
load_vars() {
|
||||||
OS=$(uname | tr '[:upper:]' '[:lower:]')
|
OS=$(uname | tr '[:upper:]' '[:lower:]')
|
||||||
TARGET_DIR="$serverPath/nezha/dashboard"
|
TARGET_DIR="$serverPath/nezha/dashboard"
|
||||||
|
|
||||||
|
# China_IP
|
||||||
## China_IP
|
# if [[ -z "${CN}" ]]; then
|
||||||
if [[ -z "${CN}" ]]; then
|
# if [[ $(curl -m 10 -s https://ipapi.co/json | grep 'China') != "" ]]; then
|
||||||
if [[ $(curl -m 10 -s https://ipapi.co/json | grep 'China') != "" ]]; then
|
# CN=true
|
||||||
CN=true
|
# fi
|
||||||
fi
|
# fi
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ -z "${CN}" ]]; then
|
GITHUB_RAW_URL="raw.githubusercontent.com/nezhahq/nezha/main"
|
||||||
GITHUB_RAW_URL="raw.githubusercontent.com/midoks/nezha/main"
|
GITHUB_URL="github.com"
|
||||||
GITHUB_URL="github.com"
|
|
||||||
else
|
|
||||||
GITHUB_RAW_URL="cdn.jsdelivr.net/gh/midoks/nezha@main"
|
|
||||||
GITHUB_URL="dn-dao-github-mirror.daocloud.io"
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo $GITHUB_RAW_URL
|
|
||||||
echo $GITHUB_URL
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# download file
|
# download file
|
||||||
@@ -82,44 +120,29 @@ download_file() {
|
|||||||
|
|
||||||
Install_dashborad(){
|
Install_dashborad(){
|
||||||
echo '正在安装哪吒监控...'
|
echo '正在安装哪吒监控...'
|
||||||
mkdir -p $serverPath/source
|
mkdir -p $nezhaDir
|
||||||
|
filename="dashboard-${OS}-${ARCH}.zip"
|
||||||
|
|
||||||
if [ ! -f $TARGET_DIR/nezha ];then
|
if [ ! -f $TARGET_DIR/nezha ];then
|
||||||
|
DOWNLOAD_URL="https://${GITHUB_URL}/nezhahq/nezha/releases/download/v${VERSION}/${filename}"
|
||||||
|
|
||||||
DOWNLOAD_URL="https://${GITHUB_URL}/midoks/nezha/releases/download/v${VERSION}/nezha-${OS}-${ARCH}.zip"
|
DOWNLOAD_FILE="$nezhaDir/$filename"
|
||||||
|
|
||||||
DOWNLOAD_FILE="$(mktemp).zip"
|
if [ ! -f $DOWNLOAD_FILE ];then
|
||||||
download_file $DOWNLOAD_URL $DOWNLOAD_FILE
|
download_file $DOWNLOAD_URL $DOWNLOAD_FILE
|
||||||
|
fi
|
||||||
|
|
||||||
if [ ! -d $TARGET_DIR ]; then
|
if [ ! -d $TARGET_DIR ]; then
|
||||||
mkdir -p $TARGET_DIR
|
mkdir -p $TARGET_DIR
|
||||||
fi
|
fi
|
||||||
|
|
||||||
unzip $DOWNLOAD_FILE -d $TARGET_DIR
|
unzip $DOWNLOAD_FILE -d $TARGET_DIR
|
||||||
rm -rf $DOWNLOAD_FILE
|
echo "TARGET_DIR:"$TARGET_DIR
|
||||||
fi
|
|
||||||
|
|
||||||
}
|
if [ ! -f $TARGET_DIR/app ];then
|
||||||
|
cd $TARGET_DIR && mv dashboard-linux-${ARCH} app && chmod +x app
|
||||||
Install_agent(){
|
|
||||||
echo -e "正在下载监控端"
|
|
||||||
mkdir -p $serverPath/source
|
|
||||||
|
|
||||||
version=v0.15.1
|
|
||||||
|
|
||||||
AGENT_TARGET_DIR="$serverPath/nezha/agent"
|
|
||||||
|
|
||||||
DOWNLOAD_URL="https://${GITHUB_URL}/nezhahq/agent/releases/download/${version}/nezha-agent_${OS}_${ARCH}.zip"
|
|
||||||
DOWNLOAD_FILE="$(mktemp).zip"
|
|
||||||
|
|
||||||
if [ ! -f $AGENT_TARGET_DIR/nezha-agent ];then
|
|
||||||
download_file $DOWNLOAD_URL $DOWNLOAD_FILE
|
|
||||||
|
|
||||||
if [ ! -d $AGENT_TARGET_DIR ]; then
|
|
||||||
mkdir -p $AGENT_TARGET_DIR
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
unzip $DOWNLOAD_FILE -d $AGENT_TARGET_DIR
|
|
||||||
rm -rf $DOWNLOAD_FILE
|
rm -rf $DOWNLOAD_FILE
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@@ -128,25 +151,24 @@ Install_App()
|
|||||||
{
|
{
|
||||||
load_vars
|
load_vars
|
||||||
get_arch
|
get_arch
|
||||||
|
check_init
|
||||||
|
|
||||||
Install_dashborad
|
Install_dashborad
|
||||||
Install_agent
|
|
||||||
|
|
||||||
if [ -d $serverPath/nezha ];then
|
if [ -d $serverPath/nezha ];then
|
||||||
echo "$VERSION" > $serverPath/nezha/version.pl
|
echo "$VERSION" > $serverPath/nezha/version.pl
|
||||||
cd ${rootPath} && python3 ${rootPath}/plugins/nezha/index.py init_cfg
|
|
||||||
fi
|
fi
|
||||||
|
cd ${rootPath} && python3 ${rootPath}/plugins/nezha/index.py start
|
||||||
|
cd ${rootPath} && python3 ${rootPath}/plugins/nezha/index.py initd_install
|
||||||
echo 'install successful'
|
echo 'install successful'
|
||||||
}
|
}
|
||||||
|
|
||||||
Uninstall_App()
|
Uninstall_App()
|
||||||
{
|
{
|
||||||
cd ${rootPath} && python3 ${rootPath}/plugins/nezha/index.py initd_uninstall
|
cd ${rootPath} && python3 ${rootPath}/plugins/nezha/index.py initd_uninstall
|
||||||
cd ${rootPath} && python3 ${rootPath}/plugins/nezha/index.py initd_uninstall_agent
|
|
||||||
cd ${rootPath} && python3 ${rootPath}/plugins/nezha/index.py stop
|
cd ${rootPath} && python3 ${rootPath}/plugins/nezha/index.py stop
|
||||||
cd ${rootPath} && python3 ${rootPath}/plugins/nezha/index.py stop_agent
|
|
||||||
rm -rf $serverPath/nezha
|
rm -rf $serverPath/nezha
|
||||||
echo "install fail"
|
echo "uninstall successful"
|
||||||
}
|
}
|
||||||
|
|
||||||
action=$1
|
action=$1
|
||||||
Executable
+180
@@ -0,0 +1,180 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
|
||||||
|
export PATH
|
||||||
|
|
||||||
|
curPath=`pwd`
|
||||||
|
rootPath=$(dirname "$curPath")
|
||||||
|
rootPath=$(dirname "$rootPath")
|
||||||
|
serverPath=$(dirname "$rootPath")
|
||||||
|
|
||||||
|
nezhaDir=${serverPath}/source/nezha
|
||||||
|
VERSION=2.2.6
|
||||||
|
|
||||||
|
# bash install.sh install 2.2.6
|
||||||
|
# cd /www/server/mdserver-web/plugins/nezha && bash install.sh install 2.2.6
|
||||||
|
# cd /Users/midoks/Desktop/mwdev/server/mdserver-web/plugins/nezha && bash install.sh install 2.2.6
|
||||||
|
|
||||||
|
bash ${rootPath}/scripts/getos.sh
|
||||||
|
OSNAME=`cat ${rootPath}/data/osname.pl`
|
||||||
|
OSNAME_ID=`cat /etc/*-release | grep VERSION_ID | awk -F = '{print $2}' | awk -F "\"" '{print $2}'`
|
||||||
|
ARCH="amd64"
|
||||||
|
|
||||||
|
geo_check() {
|
||||||
|
api_list="https://blog.cloudflare.com/cdn-cgi/trace https://developers.cloudflare.com/cdn-cgi/trace"
|
||||||
|
ua="Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/81.0"
|
||||||
|
set -- "$api_list"
|
||||||
|
for url in $api_list; do
|
||||||
|
text="$(curl -A "$ua" -m 10 -s "$url")"
|
||||||
|
endpoint="$(echo "$text" | sed -n 's/.*h=\([^ ]*\).*/\1/p')"
|
||||||
|
if echo "$text" | grep -qw 'CN'; then
|
||||||
|
isCN=true
|
||||||
|
break
|
||||||
|
elif echo "$url" | grep -q "$endpoint"; then
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
get_arch() {
|
||||||
|
uname=$(uname -m)
|
||||||
|
case "$uname" in
|
||||||
|
amd64|x86_64)
|
||||||
|
ARCH="amd64"
|
||||||
|
;;
|
||||||
|
i386|i686)
|
||||||
|
ARCH="386"
|
||||||
|
;;
|
||||||
|
aarch64|arm64)
|
||||||
|
ARCH="arm64"
|
||||||
|
;;
|
||||||
|
*arm*)
|
||||||
|
ARCH="arm"
|
||||||
|
;;
|
||||||
|
s390x)
|
||||||
|
ARCH="s390x"
|
||||||
|
;;
|
||||||
|
riscv64)
|
||||||
|
ARCH="riscv64"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
err "未知架构:$ARCH"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
check_init() {
|
||||||
|
init=$(readlink /sbin/init)
|
||||||
|
case "$init" in
|
||||||
|
*systemd*)
|
||||||
|
INIT=systemd
|
||||||
|
;;
|
||||||
|
*openrc-init*|*busybox*)
|
||||||
|
INIT=openrc
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
err "Unknown init"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
load_vars() {
|
||||||
|
OS=$(uname | tr '[:upper:]' '[:lower:]')
|
||||||
|
TARGET_DIR="$serverPath/nezha/dashboard"
|
||||||
|
|
||||||
|
# China_IP
|
||||||
|
# if [[ -z "${CN}" ]]; then
|
||||||
|
# if [[ $(curl -m 10 -s https://ipapi.co/json | grep 'China') != "" ]]; then
|
||||||
|
# CN=true
|
||||||
|
# fi
|
||||||
|
# fi
|
||||||
|
|
||||||
|
GITHUB_RAW_URL="raw.githubusercontent.com/nezhahq/nezha/main"
|
||||||
|
GITHUB_URL="github.com"
|
||||||
|
}
|
||||||
|
|
||||||
|
# download file
|
||||||
|
download_file() {
|
||||||
|
url="${1}"
|
||||||
|
destination="${2}"
|
||||||
|
|
||||||
|
printf "Fetching ${url} \n\n"
|
||||||
|
|
||||||
|
if test -x "$(command -v curl)"; then
|
||||||
|
code=$(curl --connect-timeout 15 -w '%{http_code}' -L "${url}" -o "${destination}")
|
||||||
|
elif test -x "$(command -v wget)"; then
|
||||||
|
code=$(wget -t2 -T15 -O "${destination}" --server-response "${url}" 2>&1 | awk '/^ HTTP/{print $2}' | tail -1)
|
||||||
|
else
|
||||||
|
printf "\e[1;31mNeither curl nor wget was available to perform http requests.\e[0m\n"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "${code}" != 200 ]; then
|
||||||
|
printf "\e[1;31mRequest failed with code %s\e[0m\n" $code
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
printf "\n\e[1;33mDownload succeeded\e[0m\n"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Install_dashborad(){
|
||||||
|
echo '正在安装哪吒监控...'
|
||||||
|
mkdir -p $nezhaDir
|
||||||
|
filename="dashboard-${OS}-${ARCH}.zip"
|
||||||
|
|
||||||
|
if [ ! -f $TARGET_DIR/nezha ];then
|
||||||
|
DOWNLOAD_URL="https://${GITHUB_URL}/nezhahq/nezha/releases/download/v${VERSION}/${filename}"
|
||||||
|
|
||||||
|
DOWNLOAD_FILE="$nezhaDir/$filename"
|
||||||
|
|
||||||
|
if [ ! -f $DOWNLOAD_FILE ];then
|
||||||
|
download_file $DOWNLOAD_URL $DOWNLOAD_FILE
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -d $TARGET_DIR ]; then
|
||||||
|
mkdir -p $TARGET_DIR
|
||||||
|
fi
|
||||||
|
|
||||||
|
unzip $DOWNLOAD_FILE -d $TARGET_DIR
|
||||||
|
echo "TARGET_DIR:"$TARGET_DIR
|
||||||
|
|
||||||
|
if [ ! -f $TARGET_DIR/app ];then
|
||||||
|
cd $TARGET_DIR && mv dashboard-linux-${ARCH} app && chmod +x app
|
||||||
|
fi
|
||||||
|
|
||||||
|
rm -rf $DOWNLOAD_FILE
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
Install_App()
|
||||||
|
{
|
||||||
|
load_vars
|
||||||
|
get_arch
|
||||||
|
check_init
|
||||||
|
|
||||||
|
Install_dashborad
|
||||||
|
|
||||||
|
if [ -d $serverPath/nezha ];then
|
||||||
|
echo "$VERSION" > $serverPath/nezha/version.pl
|
||||||
|
fi
|
||||||
|
cd ${rootPath} && python3 ${rootPath}/plugins/nezha/index.py start
|
||||||
|
cd ${rootPath} && python3 ${rootPath}/plugins/nezha/index.py initd_install
|
||||||
|
echo 'install successful'
|
||||||
|
}
|
||||||
|
|
||||||
|
Uninstall_App()
|
||||||
|
{
|
||||||
|
cd ${rootPath} && python3 ${rootPath}/plugins/nezha/index.py initd_uninstall
|
||||||
|
cd ${rootPath} && python3 ${rootPath}/plugins/nezha/index.py stop
|
||||||
|
rm -rf $serverPath/nezha
|
||||||
|
echo "uninstall successful"
|
||||||
|
}
|
||||||
|
|
||||||
|
action=$1
|
||||||
|
if [ "${1}" == 'install' ];then
|
||||||
|
Install_App
|
||||||
|
else
|
||||||
|
Uninstall_App
|
||||||
|
fi
|
||||||
Executable
+180
@@ -0,0 +1,180 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
|
||||||
|
export PATH
|
||||||
|
|
||||||
|
curPath=`pwd`
|
||||||
|
rootPath=$(dirname "$curPath")
|
||||||
|
rootPath=$(dirname "$rootPath")
|
||||||
|
serverPath=$(dirname "$rootPath")
|
||||||
|
|
||||||
|
nezhaDir=${serverPath}/source/nezha
|
||||||
|
VERSION=2.2.6
|
||||||
|
|
||||||
|
# bash install.sh install 2.2.6
|
||||||
|
# cd /www/server/mdserver-web/plugins/nezha && bash install.sh install 2.2.6
|
||||||
|
# cd /Users/midoks/Desktop/mwdev/server/mdserver-web/plugins/nezha && bash install.sh install 2.2.6
|
||||||
|
|
||||||
|
bash ${rootPath}/scripts/getos.sh
|
||||||
|
OSNAME=`cat ${rootPath}/data/osname.pl`
|
||||||
|
OSNAME_ID=`cat /etc/*-release | grep VERSION_ID | awk -F = '{print $2}' | awk -F "\"" '{print $2}'`
|
||||||
|
ARCH="amd64"
|
||||||
|
|
||||||
|
geo_check() {
|
||||||
|
api_list="https://blog.cloudflare.com/cdn-cgi/trace https://developers.cloudflare.com/cdn-cgi/trace"
|
||||||
|
ua="Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/81.0"
|
||||||
|
set -- "$api_list"
|
||||||
|
for url in $api_list; do
|
||||||
|
text="$(curl -A "$ua" -m 10 -s "$url")"
|
||||||
|
endpoint="$(echo "$text" | sed -n 's/.*h=\([^ ]*\).*/\1/p')"
|
||||||
|
if echo "$text" | grep -qw 'CN'; then
|
||||||
|
isCN=true
|
||||||
|
break
|
||||||
|
elif echo "$url" | grep -q "$endpoint"; then
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
get_arch() {
|
||||||
|
uname=$(uname -m)
|
||||||
|
case "$uname" in
|
||||||
|
amd64|x86_64)
|
||||||
|
ARCH="amd64"
|
||||||
|
;;
|
||||||
|
i386|i686)
|
||||||
|
ARCH="386"
|
||||||
|
;;
|
||||||
|
aarch64|arm64)
|
||||||
|
ARCH="arm64"
|
||||||
|
;;
|
||||||
|
*arm*)
|
||||||
|
ARCH="arm"
|
||||||
|
;;
|
||||||
|
s390x)
|
||||||
|
ARCH="s390x"
|
||||||
|
;;
|
||||||
|
riscv64)
|
||||||
|
ARCH="riscv64"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
err "未知架构:$ARCH"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
check_init() {
|
||||||
|
init=$(readlink /sbin/init)
|
||||||
|
case "$init" in
|
||||||
|
*systemd*)
|
||||||
|
INIT=systemd
|
||||||
|
;;
|
||||||
|
*openrc-init*|*busybox*)
|
||||||
|
INIT=openrc
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
err "Unknown init"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
load_vars() {
|
||||||
|
OS=$(uname | tr '[:upper:]' '[:lower:]')
|
||||||
|
TARGET_DIR="$serverPath/nezha/dashboard"
|
||||||
|
|
||||||
|
# China_IP
|
||||||
|
# if [[ -z "${CN}" ]]; then
|
||||||
|
# if [[ $(curl -m 10 -s https://ipapi.co/json | grep 'China') != "" ]]; then
|
||||||
|
# CN=true
|
||||||
|
# fi
|
||||||
|
# fi
|
||||||
|
|
||||||
|
GITHUB_RAW_URL="raw.githubusercontent.com/nezhahq/nezha/main"
|
||||||
|
GITHUB_URL="github.com"
|
||||||
|
}
|
||||||
|
|
||||||
|
# download file
|
||||||
|
download_file() {
|
||||||
|
url="${1}"
|
||||||
|
destination="${2}"
|
||||||
|
|
||||||
|
printf "Fetching ${url} \n\n"
|
||||||
|
|
||||||
|
if test -x "$(command -v curl)"; then
|
||||||
|
code=$(curl --connect-timeout 15 -w '%{http_code}' -L "${url}" -o "${destination}")
|
||||||
|
elif test -x "$(command -v wget)"; then
|
||||||
|
code=$(wget -t2 -T15 -O "${destination}" --server-response "${url}" 2>&1 | awk '/^ HTTP/{print $2}' | tail -1)
|
||||||
|
else
|
||||||
|
printf "\e[1;31mNeither curl nor wget was available to perform http requests.\e[0m\n"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "${code}" != 200 ]; then
|
||||||
|
printf "\e[1;31mRequest failed with code %s\e[0m\n" $code
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
printf "\n\e[1;33mDownload succeeded\e[0m\n"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Install_dashborad(){
|
||||||
|
echo '正在安装哪吒监控...'
|
||||||
|
mkdir -p $nezhaDir
|
||||||
|
filename="dashboard-${OS}-${ARCH}.zip"
|
||||||
|
|
||||||
|
if [ ! -f $TARGET_DIR/nezha ];then
|
||||||
|
DOWNLOAD_URL="https://${GITHUB_URL}/nezhahq/nezha/releases/download/v${VERSION}/${filename}"
|
||||||
|
|
||||||
|
DOWNLOAD_FILE="$nezhaDir/$filename"
|
||||||
|
|
||||||
|
if [ ! -f $DOWNLOAD_FILE ];then
|
||||||
|
download_file $DOWNLOAD_URL $DOWNLOAD_FILE
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -d $TARGET_DIR ]; then
|
||||||
|
mkdir -p $TARGET_DIR
|
||||||
|
fi
|
||||||
|
|
||||||
|
unzip $DOWNLOAD_FILE -d $TARGET_DIR
|
||||||
|
echo "TARGET_DIR:"$TARGET_DIR
|
||||||
|
|
||||||
|
if [ ! -f $TARGET_DIR/app ];then
|
||||||
|
cd $TARGET_DIR && mv dashboard-linux-${ARCH} app && chmod +x app
|
||||||
|
fi
|
||||||
|
|
||||||
|
rm -rf $DOWNLOAD_FILE
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
Install_App()
|
||||||
|
{
|
||||||
|
load_vars
|
||||||
|
get_arch
|
||||||
|
check_init
|
||||||
|
|
||||||
|
Install_dashborad
|
||||||
|
|
||||||
|
if [ -d $serverPath/nezha ];then
|
||||||
|
echo "$VERSION" > $serverPath/nezha/version.pl
|
||||||
|
fi
|
||||||
|
cd ${rootPath} && python3 ${rootPath}/plugins/nezha/index.py start
|
||||||
|
cd ${rootPath} && python3 ${rootPath}/plugins/nezha/index.py initd_install
|
||||||
|
echo 'install successful'
|
||||||
|
}
|
||||||
|
|
||||||
|
Uninstall_App()
|
||||||
|
{
|
||||||
|
cd ${rootPath} && python3 ${rootPath}/plugins/nezha/index.py initd_uninstall
|
||||||
|
cd ${rootPath} && python3 ${rootPath}/plugins/nezha/index.py stop
|
||||||
|
rm -rf $serverPath/nezha
|
||||||
|
echo "uninstall successful"
|
||||||
|
}
|
||||||
|
|
||||||
|
action=$1
|
||||||
|
if [ "${1}" == 'install' ];then
|
||||||
|
Install_App
|
||||||
|
else
|
||||||
|
Uninstall_App
|
||||||
|
fi
|
||||||
@@ -3,6 +3,7 @@
|
|||||||
<div class='plugin_version'></div>
|
<div class='plugin_version'></div>
|
||||||
<div class="bt-w-menu">
|
<div class="bt-w-menu">
|
||||||
<p class="bgw" onclick="pluginService('ollama',$('.plugin_version').attr('version'));">服务</p>
|
<p class="bgw" onclick="pluginService('ollama',$('.plugin_version').attr('version'));">服务</p>
|
||||||
|
<p onclick="ollama.ai_model_list();">模型列表</p>
|
||||||
<p onclick="pluginInitD('ollama',$('.plugin_version').attr('version'));">自启动</p>
|
<p onclick="pluginInitD('ollama',$('.plugin_version').attr('version'));">自启动</p>
|
||||||
<p onclick="ollama.readme();">说明</p>
|
<p onclick="ollama.readme();">说明</p>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -208,6 +208,35 @@ class App:
|
|||||||
mw.execShell('systemctl disable '+self.getPluginName())
|
mw.execShell('systemctl disable '+self.getPluginName())
|
||||||
return 'ok'
|
return 'ok'
|
||||||
|
|
||||||
|
def get_ai_model_list(self):
|
||||||
|
cmd = 'ollama list'
|
||||||
|
data = mw.execShell(cmd)
|
||||||
|
result = []
|
||||||
|
|
||||||
|
if data and data[0]:
|
||||||
|
lines = data[0].strip().split('\n')
|
||||||
|
for i, line in enumerate(lines):
|
||||||
|
if i < 1:
|
||||||
|
continue
|
||||||
|
line = line.strip()
|
||||||
|
if not line:
|
||||||
|
continue
|
||||||
|
parts = line.split()
|
||||||
|
if len(parts) >= 4:
|
||||||
|
name = parts[0]
|
||||||
|
model_id = parts[1]
|
||||||
|
size = parts[2] + ' ' + parts[3]
|
||||||
|
modified = ' '.join(parts[4:])
|
||||||
|
result.append({
|
||||||
|
'name': name,
|
||||||
|
'id': model_id,
|
||||||
|
'size': size,
|
||||||
|
'modified': modified
|
||||||
|
})
|
||||||
|
|
||||||
|
import json
|
||||||
|
return json.dumps(result)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ rootPath=$(dirname "$curPath")
|
|||||||
rootPath=$(dirname "$rootPath")
|
rootPath=$(dirname "$rootPath")
|
||||||
serverPath=$(dirname "$rootPath")
|
serverPath=$(dirname "$rootPath")
|
||||||
|
|
||||||
|
# cd /www/server/mdserver-web && source /www/server/mdserver-web/bin/activate && python3 /www/server/mdserver-web/plugins/ollama/index.py get_ai_model_list 1.0
|
||||||
|
|
||||||
action=$1
|
action=$1
|
||||||
type=$2
|
type=$2
|
||||||
|
|
||||||
|
|||||||
@@ -31,14 +31,6 @@ var ollama = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var ret_data = $.parseJSON(res.data);
|
var ret_data = $.parseJSON(res.data);
|
||||||
console.log("send:",ret_data);
|
|
||||||
// if (!ret_data.status){
|
|
||||||
// layer.msg(ret_data.msg,{icon:2,time:2000});
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// console.log("send2:",ret_data);
|
|
||||||
|
|
||||||
if(typeof(callback) == 'function'){
|
if(typeof(callback) == 'function'){
|
||||||
callback(ret_data);
|
callback(ret_data);
|
||||||
}
|
}
|
||||||
@@ -83,6 +75,36 @@ var ollama = {
|
|||||||
},'json');
|
},'json');
|
||||||
},
|
},
|
||||||
|
|
||||||
|
ai_model_list:function(){
|
||||||
|
this.send({
|
||||||
|
"tips":"加载中...",
|
||||||
|
"method": 'get_ai_model_list',
|
||||||
|
"success": function(data){
|
||||||
|
var html = '<div class="divtable mtb15">';
|
||||||
|
html += '<table class="table table-hover">';
|
||||||
|
html += '<thead><tr><th>NAME</th><th>ID</th><th>SIZE</th><th>MODIFIED</th></tr></thead>';
|
||||||
|
html += '<tbody>';
|
||||||
|
|
||||||
|
if (data && data.length > 0) {
|
||||||
|
for (var i = 0; i < data.length; i++) {
|
||||||
|
var item = data[i];
|
||||||
|
html += '<tr>';
|
||||||
|
html += '<td>' + (item.name || '') + '</td>';
|
||||||
|
html += '<td>' + (item.id || '') + '</td>';
|
||||||
|
html += '<td>' + (item.size || '') + '</td>';
|
||||||
|
html += '<td>' + (item.modified || '') + '</td>';
|
||||||
|
html += '</tr>';
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
html += '<tr><td colspan="4" class="text-center c7">暂无模型</td></tr>';
|
||||||
|
}
|
||||||
|
|
||||||
|
html += '</tbody></table></div>';
|
||||||
|
$('.soft-man-con').html(html);
|
||||||
|
},
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
readme:function (){
|
readme:function (){
|
||||||
var readme = '<ul class="help-info-text c7">';
|
var readme = '<ul class="help-info-text c7">';
|
||||||
readme += '<li>常用命令说明:</li>';
|
readme += '<li>常用命令说明:</li>';
|
||||||
|
|||||||
@@ -281,6 +281,7 @@ def status():
|
|||||||
return 'start'
|
return 'start'
|
||||||
|
|
||||||
|
|
||||||
|
# ps -ef|grep nginx|awk '{print $2}'|xargs kill
|
||||||
def restyOp(method):
|
def restyOp(method):
|
||||||
file = initDreplace()
|
file = initDreplace()
|
||||||
|
|
||||||
@@ -292,6 +293,7 @@ def restyOp(method):
|
|||||||
|
|
||||||
current_os = mw.getOs()
|
current_os = mw.getOs()
|
||||||
if current_os == "darwin":
|
if current_os == "darwin":
|
||||||
|
# print(file + ' ' + method)
|
||||||
data = mw.execShell(file + ' ' + method)
|
data = mw.execShell(file + ' ' + method)
|
||||||
if data[1] == '':
|
if data[1] == '':
|
||||||
return 'ok'
|
return 'ok'
|
||||||
@@ -439,6 +441,7 @@ def runInfo():
|
|||||||
data['Reading'] = tmp[11]
|
data['Reading'] = tmp[11]
|
||||||
data['Writing'] = tmp[13]
|
data['Writing'] = tmp[13]
|
||||||
data['Waiting'] = tmp[15]
|
data['Waiting'] = tmp[15]
|
||||||
|
data["time"] = time.time()
|
||||||
return mw.getJson(data)
|
return mw.getJson(data)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
try:
|
try:
|
||||||
@@ -453,6 +456,7 @@ def runInfo():
|
|||||||
data['Reading'] = tmp[11]
|
data['Reading'] = tmp[11]
|
||||||
data['Writing'] = tmp[13]
|
data['Writing'] = tmp[13]
|
||||||
data['Waiting'] = tmp[15]
|
data['Waiting'] = tmp[15]
|
||||||
|
data["time"] = time.time()
|
||||||
return mw.getJson(data)
|
return mw.getJson(data)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return mw.returnJson(False, "oprenresty异常!")
|
return mw.returnJson(False, "oprenresty异常!")
|
||||||
|
|||||||
@@ -13,6 +13,6 @@
|
|||||||
"home":"http://openresty.org",
|
"home":"http://openresty.org",
|
||||||
"date":"2017-11-24",
|
"date":"2017-11-24",
|
||||||
"pid": "1",
|
"pid": "1",
|
||||||
"versions": ["1.17.8","1.19.3","1.21.4","1.25.3","1.27.1","1.29.2","rtmp"],
|
"versions": ["1.17.8","1.19.3","1.21.4","1.25.3","1.27.1","1.29.2","1.31.1","rtmp"],
|
||||||
"updates": ["1.17.8.2","1.19.3.1","1.21.4.2","1.25.3.2"]
|
"updates": ["1.17.8.2","1.19.3.1","1.21.4.2","1.25.3.2"]
|
||||||
}
|
}
|
||||||
@@ -49,10 +49,12 @@ case "$1" in
|
|||||||
mPID=`cat $PIDFILE`
|
mPID=`cat $PIDFILE`
|
||||||
isStart=`ps ax | awk '{ print $1 }' | grep -e "^${mPID}$"`
|
isStart=`ps ax | awk '{ print $1 }' | grep -e "^${mPID}$"`
|
||||||
if [ "$isStart" = '' ];then
|
if [ "$isStart" = '' ];then
|
||||||
|
ps -ef|grep nginx|grep -v grep |awk '{print $2}'| xargs kill
|
||||||
echo "$NAME is not running."
|
echo "$NAME is not running."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
|
ps -ef|grep nginx|grep -v grep |awk '{print $2}'| xargs kill
|
||||||
echo "$NAME is not running."
|
echo "$NAME is not running."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -2,10 +2,10 @@
|
|||||||
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin:/opt/homebrew/bin
|
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin:/opt/homebrew/bin
|
||||||
export PATH
|
export PATH
|
||||||
|
|
||||||
# cd /Users/midoks/Desktop/mwdev/server/mdserver-web/plugins/openresty && bash install.sh upgrade 1.29.2
|
# cd /Users/midoks/Desktop/mwdev/server/mdserver-web/plugins/openresty && bash install.sh upgrade 1.31.1
|
||||||
# cd /www/server/mdserver-web/plugins/openresty && bash install.sh install 1.21.4
|
# cd /www/server/mdserver-web/plugins/openresty && bash install.sh install 1.21.4
|
||||||
# cd /www/server/mdserver-web/plugins/openresty && bash install.sh install 1.29.2
|
# cd /www/server/mdserver-web/plugins/openresty && bash install.sh install 1.29.2
|
||||||
# cd /www/server/mdserver-web/plugins/openresty && bash install.sh upgrade 1.29.2
|
# cd /www/server/mdserver-web/plugins/openresty && bash install.sh upgrade 1.31.1
|
||||||
|
|
||||||
# curl -I -H "Accept-Encoding: br" http://localhost
|
# curl -I -H "Accept-Encoding: br" http://localhost
|
||||||
# curl -I -H "Accept-Encoding: zstd" http://localhost
|
# curl -I -H "Accept-Encoding: zstd" http://localhost
|
||||||
|
|||||||
@@ -109,36 +109,119 @@ function orPluginOpServiceOp(a,b,c,d,a,v,request_callback){
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var optmp_status = null;
|
||||||
|
var optmp_timer = null;
|
||||||
|
|
||||||
//查看Nginx负载状态
|
//查看Nginx负载状态
|
||||||
function getOpStatus() {
|
function getOpStatus(){
|
||||||
|
var con = "<div><table class='table table-hover table-bordered op_status'>\
|
||||||
|
<tr><th>活动连接(Active connections)</th><td class='op_active'>0</td></tr>\
|
||||||
|
<tr><th>总连接次数(accepts)</th><td class='op_accepts'>0</td></tr>\
|
||||||
|
<tr><th>总握手次数(handled)</th><td class='op_handled'>0</td></tr>\
|
||||||
|
<tr><th>总请求数(requests)</th><td class='op_requests'>0</td></tr>\
|
||||||
|
<tr><th>请求数(Reading)</th><td class='op_reading'>0</td></tr>\
|
||||||
|
<tr><th>响应数(Writing)</th><td class='op_writing'>0</td></tr>\
|
||||||
|
<tr><th>驻留进程(Waiting)</th><td class='op_waiting'>0</td></tr>\
|
||||||
|
<tr><th>请求时间(time)</th><td class='op_waiting'>0</td></tr>\
|
||||||
|
</table></div>";
|
||||||
|
$(".soft-man-con").html(con);
|
||||||
|
|
||||||
|
getOpStatusOne();
|
||||||
|
clearInterval(optmp_timer);
|
||||||
|
optmp_timer = setInterval(function(){
|
||||||
|
if ($(".soft-man-con").length == 0){
|
||||||
|
clearInterval(optmp_timer);
|
||||||
|
}
|
||||||
|
getOpStatusInterval();
|
||||||
|
}, 5000);
|
||||||
|
}
|
||||||
|
|
||||||
|
function getOpStatusOne(){
|
||||||
var loadT = layer.msg('正在处理,请稍后...', { icon: 16, time: 0, shade: 0.3 });
|
var loadT = layer.msg('正在处理,请稍后...', { icon: 16, time: 0, shade: 0.3 });
|
||||||
$.post('/plugins/run', {name:'openresty', func:'run_info'}, function(data) {
|
$.post('/plugins/run', {name:'openresty', func:'run_info'}, function(data) {
|
||||||
layer.close(loadT);
|
layer.close(loadT);
|
||||||
try {
|
try {
|
||||||
var rdata = $.parseJSON(data.data);
|
var rdata = $.parseJSON(data.data);
|
||||||
if ('status' in rdata && !rdata.status){
|
if ('status' in rdata && !rdata.status){
|
||||||
showMsg(rdata.msg, function(){}, null,3000);
|
showMsg(rdata.msg, function(){
|
||||||
|
var con = "<tr><th>Error</th><td>" + rdata.msg + "</td></tr>";
|
||||||
|
$(".soft-man-con .op_status").html(con);
|
||||||
|
}, null,3000);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var con = "<div><table class='table table-hover table-bordered'>\
|
optmp_status = rdata;
|
||||||
<tr><th>活动连接(Active connections)</th><td>" + rdata.active + "</td></tr>\
|
var con = "<tr><th>活动连接(Active connections)</th><td>" + rdata.active + "</td></tr>\
|
||||||
<tr><th>总连接次数(accepts)</th><td>" + rdata.accepts + "</td></tr>\
|
<tr><th>总连接次数(accepts)</th><td>" + rdata.accepts + "</td></tr>\
|
||||||
<tr><th>总握手次数(handled)</th><td>" + rdata.handled + "</td></tr>\
|
<tr><th>总握手次数(handled)</th><td>" + rdata.handled + "</td></tr>\
|
||||||
<tr><th>总请求数(requests)</th><td>" + rdata.requests + "</td></tr>\
|
<tr><th>总请求数(requests)</th><td>" + rdata.requests + "</td></tr>\
|
||||||
<tr><th>请求数(Reading)</th><td>" + rdata.Reading + "</td></tr>\
|
<tr><th>请求数(Reading)</th><td>" + rdata.Reading + "</td></tr>\
|
||||||
<tr><th>响应数(Writing)</th><td>" + rdata.Writing + "</td></tr>\
|
<tr><th>响应数(Writing)</th><td>" + rdata.Writing + "</td></tr>\
|
||||||
<tr><th>驻留进程(Waiting)</th><td>" + rdata.Waiting + "</td></tr>\
|
<tr><th>驻留进程(Waiting)</th><td>" + rdata.Waiting + "</td></tr>\
|
||||||
</table></div>";
|
<tr><th>请求时间(time)</th><td class='op_waiting'>"+formatTimestamp(rdata.time)+"</td></tr>";
|
||||||
$(".soft-man-con").html(con);
|
$(".soft-man-con .op_status").html(con);
|
||||||
}catch(err){
|
} catch(err) {
|
||||||
showMsg(data.data, function(){}, null,3000);
|
showMsg(data.data, function(){
|
||||||
|
var con = "<tr><th>Error</th><td>" + err + "</td></tr>";
|
||||||
|
$(".soft-man-con .op_status").html(con);
|
||||||
|
}, null,3000);
|
||||||
}
|
}
|
||||||
},'json');
|
},'json');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function getOpStatusInterval(){
|
||||||
|
$.post('/plugins/run', {name:'openresty', func:'run_info'}, function(data) {
|
||||||
|
try {
|
||||||
|
var rdata = $.parseJSON(data.data);
|
||||||
|
if ('status' in rdata && !rdata.status){
|
||||||
|
showMsg(rdata.msg, function(){
|
||||||
|
var con = "<tr><th>Error</th><td>" + rdata.msg + "</td></tr>";
|
||||||
|
$(".soft-man-con .op_status").html(con);
|
||||||
|
}, null,3000);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var qbs = "";
|
||||||
|
if (optmp_status){
|
||||||
|
var time_diff = rdata.time - optmp_status.time;
|
||||||
|
var requests_diff = rdata.accepts - optmp_status.accepts;
|
||||||
|
|
||||||
|
// 检查除数是否有效
|
||||||
|
if (time_diff > 0) {
|
||||||
|
var qbs_nums = requests_diff / time_diff;
|
||||||
|
// 保留两位小数,并处理 NaN 和 Infinity
|
||||||
|
qbs_nums = isFinite(qbs_nums) ? qbs_nums.toFixed(2) : '0.00';
|
||||||
|
} else {
|
||||||
|
qbs_nums = '0.00';
|
||||||
|
}
|
||||||
|
console.log('QPS:', qbs_nums);
|
||||||
|
qbs = "<tr><th>计算(QPS)</th><td>"+qbs_nums+"</td></tr>";
|
||||||
|
}
|
||||||
|
|
||||||
|
optmp_status = rdata;
|
||||||
|
|
||||||
|
var con = "<tr><th>活动连接(Active connections)</th><td>" + rdata.active + "</td></tr>\
|
||||||
|
<tr><th>总连接次数(accepts)</th><td>" + rdata.accepts + "</td></tr>\
|
||||||
|
<tr><th>总握手次数(handled)</th><td>" + rdata.handled + "</td></tr>\
|
||||||
|
<tr><th>总请求数(requests)</th><td>" + rdata.requests + "</td></tr>\
|
||||||
|
<tr><th>请求数(Reading)</th><td>" + rdata.Reading + "</td></tr>\
|
||||||
|
<tr><th>响应数(Writing)</th><td>" + rdata.Writing + "</td></tr>\
|
||||||
|
<tr><th>驻留进程(Waiting)</th><td>" + rdata.Waiting + "</td></tr>" + qbs +
|
||||||
|
"<tr><th>请求时间(time)</th><td class='op_waiting'>"+formatTimestamp(rdata.time)+"</td></tr>";;
|
||||||
|
$(".soft-man-con .op_status").html(con);
|
||||||
|
} catch(err) {
|
||||||
|
showMsg(data.data, function(){
|
||||||
|
var con = "<tr><th>Error</th><td>" + err + "</td></tr>";
|
||||||
|
$(".soft-man-con .op_status").html(con);
|
||||||
|
}, null,3000);
|
||||||
|
}
|
||||||
|
},'json');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function setOpCfg(){
|
function setOpCfg(){
|
||||||
orPost('get_cfg', {}, function(data){
|
orPost('get_cfg', {}, function(data){
|
||||||
var rdata = $.parseJSON(data.data);
|
var rdata = $.parseJSON(data.data);
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ sysName=`uname`
|
|||||||
action=$1
|
action=$1
|
||||||
type=$2
|
type=$2
|
||||||
|
|
||||||
VERSION=1.29.2.4
|
VERSION=1.29.2.5
|
||||||
|
|
||||||
openrestyDir=${serverPath}/source/openresty
|
openrestyDir=${serverPath}/source/openresty
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,228 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin:/opt/homebrew/bin
|
||||||
|
export PATH
|
||||||
|
|
||||||
|
# cd /Users/midoks/Desktop/mwdev/server/mdserver-web/plugins/openresty && bash install.sh install 1.31.1
|
||||||
|
# cd /www/server/mdserver-web/plugins/openresty && bash install.sh install 1.31.1
|
||||||
|
|
||||||
|
curPath=`pwd`
|
||||||
|
rootPath=$(dirname "$curPath")
|
||||||
|
rootPath=$(dirname "$rootPath")
|
||||||
|
serverPath=$(dirname "$rootPath")
|
||||||
|
|
||||||
|
sysName=`uname`
|
||||||
|
action=$1
|
||||||
|
type=$2
|
||||||
|
|
||||||
|
VERSION=1.31.1.1
|
||||||
|
|
||||||
|
openrestyDir=${serverPath}/source/openresty
|
||||||
|
|
||||||
|
Install_openresty()
|
||||||
|
{
|
||||||
|
if [ "${action}" == "install" ];then
|
||||||
|
if [ -d $serverPath/openresty ];then
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
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 ------
|
||||||
|
|
||||||
|
mkdir -p ${openrestyDir}
|
||||||
|
echo '正在安装脚本文件...'
|
||||||
|
|
||||||
|
# wget -O openresty-1.21.4.1.tar.gz https://openresty.org/download/openresty-1.21.4.1.tar.gz
|
||||||
|
if [ ! -f ${openrestyDir}/openresty-${VERSION}.tar.gz ];then
|
||||||
|
wget --no-check-certificate -O ${openrestyDir}/openresty-${VERSION}.tar.gz https://openresty.org/download/openresty-${VERSION}.tar.gz -T 3
|
||||||
|
fi
|
||||||
|
|
||||||
|
DOWNLOAD_SIZE=`wc -c ${openrestyDir}/openresty-${VERSION}.tar.gz | awk '{print $1}'`
|
||||||
|
if [ "$DOWNLOAD_SIZE" == "0" ];then
|
||||||
|
echo 'download failed, download again'
|
||||||
|
rm -rf ${openrestyDir}/openresty-${VERSION}.tar.gz
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Last Download Method
|
||||||
|
if [ ! -f ${openrestyDir}/openresty-${VERSION}.tar.gz ];then
|
||||||
|
wget --no-check-certificate -O ${openrestyDir}/openresty-${VERSION}.tar.gz http://dl.midoks.icu/soft/openresty/openresty-${VERSION}.tar.gz -T 3
|
||||||
|
fi
|
||||||
|
|
||||||
|
cd ${openrestyDir} && tar -zxvf openresty-${VERSION}.tar.gz
|
||||||
|
|
||||||
|
OPTIONS=''
|
||||||
|
|
||||||
|
opensslVersion="3.5.5"
|
||||||
|
libresslVersion="3.9.1"
|
||||||
|
pcreVersion='8.45'
|
||||||
|
if [ "$sysName" == "Darwin" ];then
|
||||||
|
|
||||||
|
if [ ! -f ${openrestyDir}/pcre-${pcreVersion}.tar.gz ];then
|
||||||
|
wget --no-check-certificate -O ${openrestyDir}/pcre-${pcreVersion}.tar.gz https://netix.dl.sourceforge.net/project/pcre/pcre/${pcreVersion}/pcre-${pcreVersion}.tar.gz
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -d ${openrestyDir}/pcre-${pcreVersion} ];then
|
||||||
|
cd ${openrestyDir} && tar -zxvf pcre-${pcreVersion}.tar.gz
|
||||||
|
fi
|
||||||
|
OPTIONS="${OPTIONS} --with-pcre=${openrestyDir}/pcre-${pcreVersion}"
|
||||||
|
|
||||||
|
|
||||||
|
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}"
|
||||||
|
|
||||||
|
# BREW_DIR=`which brew`
|
||||||
|
# BREW_DIR=${BREW_DIR/\/bin\/brew/}
|
||||||
|
|
||||||
|
# brew info openssl@1.1 | grep /opt/homebrew/Cellar/openssl@1.1 | cut -d \ -f 1 | awk 'END {print}'
|
||||||
|
# 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}"
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "$VERSION" =~ "1.31.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
|
||||||
|
|
||||||
|
# if [ ! -d ${openrestyDir}/libressl-${libresslVersion} ];then
|
||||||
|
# cd ${openrestyDir} && tar -zxvf libressl-${libresslVersion}.tar.gz
|
||||||
|
# fi
|
||||||
|
|
||||||
|
# OPTIONS="${OPTIONS} --with-cc-opt=-I${openrestyDir}/libressl-${libresslVersion}/libressl/build/include"
|
||||||
|
# OPTIONS="${OPTIONS} --with-cc-opt=-I${openrestyDir}/libressl-${libresslVersion}/libressl/build/lib"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# br
|
||||||
|
if [ ! -d ${openrestyDir}/ngx_brotli ];then
|
||||||
|
cd ${openrestyDir} && git clone https://github.com/wxx9248/ngx_brotli.git
|
||||||
|
cd ${openrestyDir}/ngx_brotli && git submodule update --init
|
||||||
|
|
||||||
|
OPTIONS="${OPTIONS} --add-module=${openrestyDir}/ngx_brotli"
|
||||||
|
fi
|
||||||
|
|
||||||
|
OPTIONS="${OPTIONS} --with-threads"
|
||||||
|
OPTIONS="${OPTIONS} --with-pcre-jit"
|
||||||
|
OPTIONS="${OPTIONS} --with-http_gzip_static_module"
|
||||||
|
|
||||||
|
if [ "$sysName" != "Darwin" ];then
|
||||||
|
OPTIONS="${OPTIONS} --with-file-aio"
|
||||||
|
fi
|
||||||
|
|
||||||
|
#zstd
|
||||||
|
if [ ! -d ${openrestyDir}/zstd-nginx-module-master ];then
|
||||||
|
cd ${openrestyDir} && wget -O $openrestyDir/zstd-nginx-module.tar.gz https://github.com/tokers/zstd-nginx-module/archive/refs/heads/master.tar.gz
|
||||||
|
cd ${openrestyDir} && tar -zxvf zstd-nginx-module.tar.gz
|
||||||
|
|
||||||
|
if [ "$sysName" == "Darwin" ];then
|
||||||
|
export ZSTD_INC=/opt/homebrew/include
|
||||||
|
export ZSTD_LIB=/opt/homebrew/lib
|
||||||
|
fi
|
||||||
|
|
||||||
|
pkg-config --exists --print-errors libzstd
|
||||||
|
if [ "$?" == "0" ];then
|
||||||
|
OPTIONS="${OPTIONS} --add-module=${openrestyDir}/zstd-nginx-module-master"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
cd ${openrestyDir}/openresty-${VERSION} && ./configure \
|
||||||
|
--prefix=$serverPath/openresty \
|
||||||
|
$OPTIONS \
|
||||||
|
--with-stream \
|
||||||
|
--with-http_v2_module \
|
||||||
|
--with-http_ssl_module \
|
||||||
|
--with-http_slice_module \
|
||||||
|
--with-http_stub_status_module \
|
||||||
|
--with-http_sub_module \
|
||||||
|
--with-http_realip_module
|
||||||
|
# --without-luajit-gc64
|
||||||
|
# --with-debug
|
||||||
|
# 用于调式
|
||||||
|
|
||||||
|
CMD_MAKE=`which gmake`
|
||||||
|
if [ "$?" == "0" ];then
|
||||||
|
gmake -j${cpuCore} && gmake install && gmake clean
|
||||||
|
else
|
||||||
|
make -j${cpuCore} && make install && make clean
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
if [ -d ${openrestyDir}/pcre-${pcreVersion} ];then
|
||||||
|
rm -rf ${openrestyDir}/pcre-${pcreVersion}
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -d ${openrestyDir}/openssl-${opensslVersion} ];then
|
||||||
|
rm -rf ${openrestyDir}/openssl-${opensslVersion}
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -d ${openrestyDir}/libressl-${libresslVersion} ];then
|
||||||
|
rm -rf ${openrestyDir}/libressl-${libresslVersion}
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -d $openrestyDir/openresty-${VERSION} ];then
|
||||||
|
rm -rf $openrestyDir/openresty-${VERSION}
|
||||||
|
fi
|
||||||
|
|
||||||
|
# if [ -d $openrestyDir/zstd-nginx-module-master ];then
|
||||||
|
# rm -rf $openrestyDir/zstd-nginx-module-master
|
||||||
|
# fi
|
||||||
|
|
||||||
|
# if [ -d $openrestyDir/ngx_brotli ];then
|
||||||
|
# rm -rf $openrestyDir/ngx_brotli
|
||||||
|
# fi
|
||||||
|
echo 'Installation of Openresty completed'
|
||||||
|
}
|
||||||
|
|
||||||
|
Uninstall_openresty()
|
||||||
|
{
|
||||||
|
echo 'Uninstalling Openresty completed'
|
||||||
|
}
|
||||||
|
|
||||||
|
action=$1
|
||||||
|
if [ "${1}" == "install" ];then
|
||||||
|
Install_openresty
|
||||||
|
elif [ "${1}" == "upgrade" ];then
|
||||||
|
Install_openresty
|
||||||
|
else
|
||||||
|
Uninstall_openresty
|
||||||
|
fi
|
||||||
@@ -2,8 +2,8 @@
|
|||||||
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin:/opt/homebrew/bin
|
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin:/opt/homebrew/bin
|
||||||
export PATH
|
export PATH
|
||||||
|
|
||||||
# cd /Users/midoks/Desktop/mwdev/server/mdserver-web/plugins/openresty && bash install.sh install 1.27.1.1
|
# cd /Users/midoks/Desktop/mwdev/server/mdserver-web/plugins/openresty && bash install.sh install rtmp
|
||||||
# cd /www/server/mdserver-web/plugins/openresty && bash install.sh install 1.27.1.1
|
# cd /www/server/mdserver-web/plugins/openresty && bash install.sh install rtmp
|
||||||
|
|
||||||
curPath=`pwd`
|
curPath=`pwd`
|
||||||
rootPath=$(dirname "$curPath")
|
rootPath=$(dirname "$curPath")
|
||||||
@@ -14,7 +14,7 @@ sysName=`uname`
|
|||||||
action=$1
|
action=$1
|
||||||
type=$2
|
type=$2
|
||||||
|
|
||||||
VERSION=1.27.1.2
|
VERSION=1.29.2.5
|
||||||
|
|
||||||
openrestyDir=${serverPath}/source/openresty
|
openrestyDir=${serverPath}/source/openresty
|
||||||
|
|
||||||
|
|||||||
@@ -16,19 +16,19 @@ SOURCE_ROOT=$rootPath/source/lib
|
|||||||
if [ ! -d ${SERVER_ROOT}/freetype_old ];then
|
if [ ! -d ${SERVER_ROOT}/freetype_old ];then
|
||||||
cd $SOURCE_ROOT
|
cd $SOURCE_ROOT
|
||||||
|
|
||||||
if [ ! -f $SOURCE_ROOT/freetype-2.7.1.tar.gz ];then
|
if [ ! -f $SOURCE_ROOT/freetype-2.8.1.tar.gz ];then
|
||||||
wget -O freetype-2.7.1.tar.gz --no-check-certificate https://download.savannah.gnu.org/releases/freetype/freetype-2.7.1.tar.gz -T 5
|
wget -O freetype-2.8.1.tar.gz --no-check-certificate https://download.savannah.gnu.org/releases/freetype/freetype-2.8.1.tar.gz -T 5
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -d $SOURCE_ROOT/freetype-2.7.1 ];then
|
if [ ! -d $SOURCE_ROOT/freetype-2.8.1 ];then
|
||||||
tar zxvf freetype-2.7.1.tar.gz
|
tar zxvf freetype-2.8.1.tar.gz
|
||||||
cd freetype-2.7.1
|
cd freetype-2.8.1
|
||||||
else
|
else
|
||||||
cd freetype-2.7.1
|
cd freetype-2.8.1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
./configure --prefix=${SERVER_ROOT}/freetype_old && make && make install
|
./configure --prefix=${SERVER_ROOT}/freetype_old && make && make install
|
||||||
cd $SOURCE_ROOT && rm -rf freetype-2.7.1
|
cd $SOURCE_ROOT && rm -rf freetype-2.8.1
|
||||||
cd $SOURCE_ROOT && rm -rf $SOURCE_ROOT/freetype-2.7.1
|
cd $SOURCE_ROOT && rm -rf $SOURCE_ROOT/freetype-2.8.1
|
||||||
#rm -rf freetype-2.7.1.tar.gz
|
#rm -rf freetype-2.7.1.tar.gz
|
||||||
fi
|
fi
|
||||||
@@ -11,7 +11,7 @@ sysName=`uname`
|
|||||||
|
|
||||||
version=8.3.31
|
version=8.3.31
|
||||||
PHP_VER=83
|
PHP_VER=83
|
||||||
md5_file_ok=95eae411d594fe6f6e5678b76645dc13ae47d3c0a5325c1d969b58dea56ee45a
|
md5_file_ok=66410cee07f4b2baeb0843140bb2a2b52ef930b5cf9b3d6e6d158b33aae8fa37
|
||||||
Install_php()
|
Install_php()
|
||||||
{
|
{
|
||||||
#------------------------ install start ------------------------------------#
|
#------------------------ install start ------------------------------------#
|
||||||
|
|||||||
@@ -9,9 +9,9 @@ serverPath=$(dirname "$rootPath")
|
|||||||
sourcePath=${serverPath}/source
|
sourcePath=${serverPath}/source
|
||||||
sysName=`uname`
|
sysName=`uname`
|
||||||
|
|
||||||
version=8.4.21
|
version=8.4.22
|
||||||
PHP_VER=84
|
PHP_VER=84
|
||||||
md5_file_ok=7cf5d8ab12c3b2016875bcfaec71bef1ef0b07bed6148f2c447577074431f984
|
md5_file_ok=696c0f6ad92e94c59059c1eb6e300842b8d050934226efcdf00f2a413cb083cf
|
||||||
Install_php()
|
Install_php()
|
||||||
{
|
{
|
||||||
#------------------------ install start ------------------------------------#
|
#------------------------ install start ------------------------------------#
|
||||||
|
|||||||
@@ -9,9 +9,9 @@ serverPath=$(dirname "$rootPath")
|
|||||||
sourcePath=${serverPath}/source
|
sourcePath=${serverPath}/source
|
||||||
sysName=`uname`
|
sysName=`uname`
|
||||||
|
|
||||||
version=8.5.6
|
version=8.5.7
|
||||||
PHP_VER=85
|
PHP_VER=85
|
||||||
md5_file_ok=826c600b7c6f956bd335558ca3bdbcab23b22126c1cc8d9348be2280a2204bb7
|
md5_file_ok=01ba2ed1c2658dacf91bebc8be6a4885f69b811c7993831fc48e26107ab29985
|
||||||
Install_php()
|
Install_php()
|
||||||
{
|
{
|
||||||
#------------------------ install start ------------------------------------#
|
#------------------------ install start ------------------------------------#
|
||||||
|
|||||||
@@ -17,6 +17,9 @@ version=$2
|
|||||||
LIBNAME=gd
|
LIBNAME=gd
|
||||||
LIBV=0
|
LIBV=0
|
||||||
|
|
||||||
|
bash ${rootPath}/scripts/getos.sh
|
||||||
|
OSNAME=`cat ${rootPath}/data/osname.pl`
|
||||||
|
OSNAME_ID=`cat /etc/*-release | grep VERSION_ID | awk -F = '{print $2}' | awk -F "\"" '{print $2}'`
|
||||||
|
|
||||||
|
|
||||||
# if [ "$version" -lt "74" ];then
|
# if [ "$version" -lt "74" ];then
|
||||||
@@ -79,11 +82,24 @@ Install_lib()
|
|||||||
OPTIONS="$OPTIONS --with-xpm-dir"
|
OPTIONS="$OPTIONS --with-xpm-dir"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# if [ "debian" == "$OSNAME" ]; then
|
||||||
|
# OPTIONS="$OPTIONS --with-freetype"
|
||||||
|
# else
|
||||||
|
# find_ft2=`pkg-config --list-all | grep freetype2`
|
||||||
|
# if [ "$find_ft2" != "" ];then
|
||||||
|
# OPTIONS="$OPTIONS --with-freetype-dir=${serverPath}/lib/freetype_old"
|
||||||
|
# fi
|
||||||
|
# fi
|
||||||
|
|
||||||
|
if [ ! -d ${serverPath}/lib/freetype_old ];then
|
||||||
|
echo "freetype_old not install , check!!"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
find_ft2=`pkg-config --list-all | grep freetype2`
|
find_ft2=`pkg-config --list-all | grep freetype2`
|
||||||
if [ "$find_ft2" == "" ];then
|
if [ "$find_ft2" != "" ];then
|
||||||
OPTIONS="$OPTIONS --with-freetype-dir=${serverPath}/lib/freetype_old"
|
OPTIONS="$OPTIONS --with-freetype-dir=${serverPath}/lib/freetype_old"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
#--with-xpm
|
#--with-xpm
|
||||||
# =${serverPath}/lib/freetype_old
|
# =${serverPath}/lib/freetype_old
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ rootPath=$(dirname "$curPath")
|
|||||||
rootPath=$(dirname "$rootPath")
|
rootPath=$(dirname "$rootPath")
|
||||||
serverPath=$(dirname "$rootPath")
|
serverPath=$(dirname "$rootPath")
|
||||||
|
|
||||||
|
# cd /www/server/mdserver-web/plugins/pureftp && bash install.sh install 1.0.49
|
||||||
|
|
||||||
if [ -f ${rootPath}/bin/activate ];then
|
if [ -f ${rootPath}/bin/activate ];then
|
||||||
source ${rootPath}/bin/activate
|
source ${rootPath}/bin/activate
|
||||||
|
|||||||
@@ -4,14 +4,14 @@
|
|||||||
"name": "redis",
|
"name": "redis",
|
||||||
"title": "Redis",
|
"title": "Redis",
|
||||||
"shell": "install.sh",
|
"shell": "install.sh",
|
||||||
"versions":["4.0.14","5.0.14","6.0.20","6.2.22","7.0.15","7.2.14", "7.4.9", "8.0.6", "8.2.6", "8.4.3","8.6.3"],
|
"versions":["4.0.14","5.0.14","6.0.20","6.2.22","7.0.15","7.2.14", "7.4.9", "8.0.6", "8.2.7", "8.4.4","8.6.4","8.8.0"],
|
||||||
"tip": "soft",
|
"tip": "soft",
|
||||||
"checks": "server/redis",
|
"checks": "server/redis",
|
||||||
"path": "server/redis",
|
"path": "server/redis",
|
||||||
"display": 1,
|
"display": 1,
|
||||||
"author": "redis",
|
"author": "redis",
|
||||||
"date": "2017-04-01",
|
"date": "2017-04-01",
|
||||||
"home": "https://redis.io",
|
"home": "https://download.redis.io/releases",
|
||||||
"type": 0,
|
"type": 0,
|
||||||
"pid": "2"
|
"pid": "2"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,21 +44,47 @@ VERSION=$2
|
|||||||
# echo $VERSION
|
# echo $VERSION
|
||||||
|
|
||||||
if [ "$VERSION" == "3.1.1" ];then
|
if [ "$VERSION" == "3.1.1" ];then
|
||||||
|
if [ "$sysArch" != "x86_64" ];then
|
||||||
|
echo "no support"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
VERSION_NUM=${VERSION}-612d99f
|
VERSION_NUM=${VERSION}-612d99f
|
||||||
elif [ "$VERSION" == "3.2.1" ]; then
|
elif [ "$VERSION" == "3.2.1" ]; then
|
||||||
|
if [ "$sysArch" != "x86_64" ];then
|
||||||
|
echo "no support"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
VERSION_NUM=${VERSION}-f152e0b
|
VERSION_NUM=${VERSION}-f152e0b
|
||||||
elif [ "$VERSION" == "3.3.1" ]; then
|
elif [ "$VERSION" == "3.3.1" ]; then
|
||||||
|
if [ "$sysArch" != "x86_64" ];then
|
||||||
|
echo "no support"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
VERSION_NUM=${VERSION}-b72d67b
|
VERSION_NUM=${VERSION}-b72d67b
|
||||||
elif [ "$VERSION" == "3.4.1" ]; then
|
elif [ "$VERSION" == "3.4.1" ]; then
|
||||||
|
if [ "$sysArch" != "x86_64" ];then
|
||||||
|
echo "no support"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
VERSION_NUM=${VERSION}-efbcc65
|
VERSION_NUM=${VERSION}-efbcc65
|
||||||
elif [ "$VERSION" == "3.5.1" ]; then
|
elif [ "$VERSION" == "3.5.1" ]; then
|
||||||
|
if [ "$sysArch" != "x86_64" ];then
|
||||||
|
echo "no support"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
VERSION_NUM=${VERSION}-82c60cb
|
VERSION_NUM=${VERSION}-82c60cb
|
||||||
elif [ "$VERSION" == "3.6.1" ]; then
|
elif [ "$VERSION" == "3.6.1" ]; then
|
||||||
|
if [ "$sysArch" != "x86_64" ];then
|
||||||
|
echo "no support"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
VERSION_NUM=${VERSION}-c9dbeda
|
VERSION_NUM=${VERSION}-c9dbeda
|
||||||
elif [ "$VERSION" == "3.7.1" ]; then
|
elif [ "$VERSION" == "3.7.1" ]; then
|
||||||
VERSION_NUM=${VERSION}-da9f8a4
|
VERSION_NUM=${VERSION}-da9f8a4
|
||||||
elif [ "$VERSION" == "3.8.1" ]; then
|
elif [ "$VERSION" == "3.8.1" ]; then
|
||||||
VERSION_NUM=${VERSION}-d25e0bb
|
VERSION_NUM=${VERSION}-d25e0bb
|
||||||
|
elif [ "$VERSION" == "3.9.1" ]; then
|
||||||
|
VERSION_NUM=${VERSION}-141d2ea
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# echo $VERSION_NUM
|
# echo $VERSION_NUM
|
||||||
@@ -116,8 +142,8 @@ Install_sphinx()
|
|||||||
cd ${SPHINX_DIR} && tar -zxvf ${FILE_TGZ}
|
cd ${SPHINX_DIR} && tar -zxvf ${FILE_TGZ}
|
||||||
|
|
||||||
if [ "$?" == "0" ];then
|
if [ "$?" == "0" ];then
|
||||||
mkdir -p $SPHINX_DIR
|
mkdir -p $serverPath/sphinx/bin
|
||||||
cp -rf ${SPHINX_DIR}/sphinx-${VERSION}/ $serverPath/sphinx/bin
|
cp -rf ${SPHINX_DIR}/sphinx-${VERSION}/* $serverPath/sphinx/bin
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -d $serverPath/sphinx ];then
|
if [ -d $serverPath/sphinx ];then
|
||||||
|
|||||||
@@ -54,27 +54,17 @@ def send_msg(bot, tag='ad', trigger_time=300):
|
|||||||
mw.writeFile(lock_file, json.dumps(lock_data))
|
mw.writeFile(lock_file, json.dumps(lock_data))
|
||||||
# 信号只在一个周期内执行一次|end
|
# 信号只在一个周期内执行一次|end
|
||||||
|
|
||||||
# 实名认证/过人脸🕵️♀️各种账号处理✅ | 30/m| next,6/30 | @nngzs
|
# 实名认证/过人脸🕵️♀️各种账号处理✅ | 30/m| next,12/30 | @nngzs
|
||||||
# 18+资源采集| 4/m | next,7/14 | @liuxingyu123
|
|
||||||
# 海内外实名KYC-执照代付✅域名| 17/m | next,6/17 | @kdgzs
|
|
||||||
# 98影视采集| 21/m | next,11/21 | @liuxingyu123
|
# 98影视采集| 21/m | next,11/21 | @liuxingyu123
|
||||||
|
|
||||||
keyboard = [
|
keyboard = [
|
||||||
[
|
|
||||||
types.InlineKeyboardButton(
|
|
||||||
text="海内外实名KYC-执照代付✅域名", url='https://t.me/kuadugongzuoshi')
|
|
||||||
],
|
|
||||||
[
|
[
|
||||||
types.InlineKeyboardButton(
|
types.InlineKeyboardButton(
|
||||||
text="高价收一切流量 @caifutong555", url='https://t.me/caifutong555')
|
text="高价收一切流量 @caifutong555", url='https://t.me/caifutong555')
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
types.InlineKeyboardButton(
|
types.InlineKeyboardButton(
|
||||||
text="18+资源采集", url='https://ckzy1.com')
|
text="实名认证/过人脸🕵️♀️各种账号处理✅", url='https://t.me/zhanzhangyewu')
|
||||||
],
|
|
||||||
[
|
|
||||||
types.InlineKeyboardButton(
|
|
||||||
text="实名认证/过人脸🕵️♀️各种账号处理✅", url='https://t.me/niuniu234')
|
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
types.InlineKeyboardButton(
|
types.InlineKeyboardButton(
|
||||||
|
|||||||
@@ -0,0 +1,259 @@
|
|||||||
|
# coding:utf-8
|
||||||
|
|
||||||
|
import sys
|
||||||
|
import io
|
||||||
|
import os
|
||||||
|
import time
|
||||||
|
import json
|
||||||
|
import fcntl
|
||||||
|
|
||||||
|
web_dir = os.getcwd() + "/web"
|
||||||
|
if os.path.exists(web_dir):
|
||||||
|
sys.path.append(web_dir)
|
||||||
|
os.chdir(web_dir)
|
||||||
|
|
||||||
|
import core.mw as mw
|
||||||
|
from utils.crontab import crontab as MwCrontab
|
||||||
|
|
||||||
|
app_debug = False
|
||||||
|
if mw.isAppleSystem():
|
||||||
|
app_debug = True
|
||||||
|
|
||||||
|
|
||||||
|
def getPluginName():
|
||||||
|
return 'webstats'
|
||||||
|
|
||||||
|
|
||||||
|
def getPluginDir():
|
||||||
|
return mw.getPluginDir() + '/' + getPluginName()
|
||||||
|
|
||||||
|
|
||||||
|
def getServerDir():
|
||||||
|
return mw.getServerDir() + '/' + getPluginName()
|
||||||
|
|
||||||
|
|
||||||
|
def getConf():
|
||||||
|
conf = getServerDir() + "/lua/config.json"
|
||||||
|
return conf
|
||||||
|
|
||||||
|
|
||||||
|
def getGlobalConf():
|
||||||
|
conf = getConf()
|
||||||
|
content = mw.readFile(conf)
|
||||||
|
result = json.loads(content)
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
def pSqliteDb(dbname='web_logs', site_name='unset', fn="logs"):
|
||||||
|
db_dir = getServerDir() + '/logs/' + site_name
|
||||||
|
if not os.path.exists(db_dir):
|
||||||
|
mw.execShell('mkdir -p ' + db_dir)
|
||||||
|
|
||||||
|
name = fn
|
||||||
|
file = db_dir + '/' + name + '.db'
|
||||||
|
|
||||||
|
if not os.path.exists(file):
|
||||||
|
conn = mw.M(dbname).dbPos(db_dir, name)
|
||||||
|
sql = mw.readFile(getPluginDir() + '/conf/init.sql')
|
||||||
|
sql_list = sql.split(';')
|
||||||
|
for index in range(len(sql_list)):
|
||||||
|
conn.execute(sql_list[index], ())
|
||||||
|
else:
|
||||||
|
conn = mw.M(dbname).dbPos(db_dir, name)
|
||||||
|
|
||||||
|
conn.execute("PRAGMA synchronous = 0", ())
|
||||||
|
conn.execute("PRAGMA page_size = 4096", ())
|
||||||
|
conn.execute("PRAGMA journal_mode = wal", ())
|
||||||
|
|
||||||
|
conn.autoTextFactory()
|
||||||
|
|
||||||
|
return conn
|
||||||
|
|
||||||
|
|
||||||
|
def migrateSiteHotLogs(site_name, query_date):
|
||||||
|
start_time = time.time()
|
||||||
|
print(f"[{site_name}] 开始迁移日志...")
|
||||||
|
|
||||||
|
migrating_flag = getServerDir() + "/logs/%s/migrating" % site_name
|
||||||
|
hot_db = getServerDir() + "/logs/%s/logs.db" % site_name
|
||||||
|
hot_db_tmp = getServerDir() + "/logs/%s/logs_tmp.db" % site_name
|
||||||
|
history_logs_db = getServerDir() + "/logs/%s/history_logs.db" % site_name
|
||||||
|
|
||||||
|
if not os.path.exists(hot_db):
|
||||||
|
print(f"[{site_name}] 热日志数据库不存在,跳过")
|
||||||
|
return mw.returnMsg(True, f"{site_name} logs not exist, skip")
|
||||||
|
|
||||||
|
# 检查是否正在迁移
|
||||||
|
if os.path.exists(migrating_flag):
|
||||||
|
print(f"[{site_name}] 正在迁移中,跳过")
|
||||||
|
return mw.returnMsg(True, f"{site_name} is migrating, skip")
|
||||||
|
|
||||||
|
todayTime = time.strftime('%Y-%m-%d 00:00:00', time.localtime())
|
||||||
|
todayUt = int(time.mktime(time.strptime(
|
||||||
|
todayTime, "%Y-%m-%d %H:%M:%S")))
|
||||||
|
|
||||||
|
# 1. 备份到临时文件(copy 期间短暂互斥,完成后立即解除)
|
||||||
|
try:
|
||||||
|
import shutil
|
||||||
|
print(f"[{site_name}] 备份 {hot_db} -> {hot_db_tmp} ...")
|
||||||
|
mw.writeFile(migrating_flag, "yes")
|
||||||
|
time.sleep(0.5)
|
||||||
|
shutil.copy(hot_db, hot_db_tmp)
|
||||||
|
if not os.path.exists(hot_db_tmp):
|
||||||
|
return mw.returnMsg(False, f"{site_name} migrating fail, copy tmp file!")
|
||||||
|
except Exception as e:
|
||||||
|
return mw.returnMsg(False, f"{site_name} migrating fail: {e}")
|
||||||
|
finally:
|
||||||
|
if os.path.exists(migrating_flag):
|
||||||
|
os.remove(migrating_flag)
|
||||||
|
|
||||||
|
# 2. 从临时备份中迁移热日志数据到历史日志(读 logs_tmp,不阻塞 live 写入)
|
||||||
|
try:
|
||||||
|
logs_conn = pSqliteDb('web_log', site_name, 'logs_tmp')
|
||||||
|
history_logs_conn = pSqliteDb('web_log', site_name, 'history_logs')
|
||||||
|
|
||||||
|
hot_db_columns = logs_conn.originExecute(
|
||||||
|
"PRAGMA table_info([web_logs])")
|
||||||
|
_columns = [c[1] for c in hot_db_columns if c[1] != "id"]
|
||||||
|
columns_str = ",".join(_columns)
|
||||||
|
placeholders = ",".join(["?"] * len(_columns))
|
||||||
|
|
||||||
|
logs_sql = f"select {columns_str} from web_logs where time<{todayUt}"
|
||||||
|
selector = logs_conn.originExecute(logs_sql)
|
||||||
|
|
||||||
|
# 批量插入配置
|
||||||
|
batch_size = 10000
|
||||||
|
batch_count = 0
|
||||||
|
total_count = 0
|
||||||
|
insert_sql = f"insert into web_logs({columns_str}) values({placeholders})"
|
||||||
|
|
||||||
|
while True:
|
||||||
|
logs = selector.fetchmany(batch_size)
|
||||||
|
if not logs:
|
||||||
|
break
|
||||||
|
|
||||||
|
batch_count += 1
|
||||||
|
total_count += len(logs)
|
||||||
|
# 使用原生 executemany 批量插入
|
||||||
|
history_logs_conn.executemany(insert_sql, logs)
|
||||||
|
history_logs_conn.commit()
|
||||||
|
|
||||||
|
if batch_count % 10 == 0:
|
||||||
|
elapsed = time.time() - start_time
|
||||||
|
print(f"[{site_name}] 已迁移 {total_count} 条记录, 耗时 {elapsed:.2f}s")
|
||||||
|
|
||||||
|
print(f"[{site_name}] 共迁移 {total_count} 条记录")
|
||||||
|
|
||||||
|
# 清理历史数据
|
||||||
|
gcfg = getGlobalConf()
|
||||||
|
save_day = gcfg['global']["save_day"]
|
||||||
|
print(f"[{site_name}] 删除 {save_day} 天前的历史数据...")
|
||||||
|
|
||||||
|
time_now = time.localtime()
|
||||||
|
save_timestamp = time.mktime((time_now.tm_year, time_now.tm_mon, time_now.tm_mday - save_day, 0, 0, 0, 0, 0, 0))
|
||||||
|
delete_sql = f"delete from web_logs where time <= {save_timestamp}"
|
||||||
|
history_logs_conn.execute(delete_sql)
|
||||||
|
history_logs_conn.commit()
|
||||||
|
|
||||||
|
history_logs_conn.execute("VACUUM;")
|
||||||
|
history_logs_conn.commit()
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
if os.path.exists(hot_db_tmp):
|
||||||
|
os.remove(hot_db_tmp)
|
||||||
|
print(f"[{site_name}] logs to history error: {e}")
|
||||||
|
return mw.returnMsg(False, f"{site_name} logs migrate error: {e}")
|
||||||
|
|
||||||
|
# 3. 删除已迁移的数据并清理统计(仅 DELETE/VACUUM 期间互斥)
|
||||||
|
try:
|
||||||
|
mw.writeFile(migrating_flag, "yes")
|
||||||
|
time.sleep(0.5)
|
||||||
|
|
||||||
|
hot_db_conn = pSqliteDb('web_logs', site_name)
|
||||||
|
|
||||||
|
# 分批删除热日志
|
||||||
|
del_hot_log = f"delete from web_logs where time<{todayUt}"
|
||||||
|
print(f"[{site_name}] 删除已迁移的热日志...")
|
||||||
|
hot_db_conn.execute(del_hot_log)
|
||||||
|
|
||||||
|
# 删除过期统计数据
|
||||||
|
print(f"[{site_name}] 删除180天前的统计数据...")
|
||||||
|
save_time_key = time.strftime(
|
||||||
|
'%Y%m%d00', time.localtime(time.time() - 180 * 86400))
|
||||||
|
|
||||||
|
del_request_stat_sql = f"delete from request_stat where time<={save_time_key}"
|
||||||
|
hot_db_conn.execute(del_request_stat_sql)
|
||||||
|
hot_db_conn.execute(f"delete from spider_stat where time<={save_time_key}")
|
||||||
|
hot_db_conn.execute(f"delete from client_stat where time<={save_time_key}")
|
||||||
|
hot_db_conn.execute(f"delete from referer_stat where time<={save_time_key}")
|
||||||
|
|
||||||
|
hot_db_conn.commit()
|
||||||
|
print(f"[{site_name}] 压缩热数据库...")
|
||||||
|
hot_db_conn.execute("VACUUM;")
|
||||||
|
hot_db_conn.commit()
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
print(f"[{site_name}] delete hot logs error: {e}")
|
||||||
|
finally:
|
||||||
|
if os.path.exists(migrating_flag):
|
||||||
|
os.remove(migrating_flag)
|
||||||
|
if os.path.exists(hot_db_tmp):
|
||||||
|
os.remove(hot_db_tmp)
|
||||||
|
|
||||||
|
elapsed = time.time() - start_time
|
||||||
|
print(f"[{site_name}] 日志迁移完成,耗时 {elapsed:.2f}s")
|
||||||
|
|
||||||
|
if not mw.isAppleSystem():
|
||||||
|
mw.execShell("chown -R www:www " + getServerDir())
|
||||||
|
|
||||||
|
return mw.returnMsg(True, f"{site_name} logs migrate ok")
|
||||||
|
|
||||||
|
|
||||||
|
def migrateHotLogs(query_date="today"):
|
||||||
|
# 使用文件锁防止并发迁移
|
||||||
|
lock_file = getServerDir() + "/logs/migrate_hot_logs.lock"
|
||||||
|
lock_fd = None
|
||||||
|
|
||||||
|
try:
|
||||||
|
lock_fd = open(lock_file, 'w')
|
||||||
|
fcntl.flock(lock_fd.fileno(), fcntl.LOCK_EX | fcntl.LOCK_NB)
|
||||||
|
|
||||||
|
print("开始迁移热日志...")
|
||||||
|
sites = mw.M('sites').field('name').order("add_time").select()
|
||||||
|
|
||||||
|
unset_site = {"name": "unset"}
|
||||||
|
sites.append(unset_site)
|
||||||
|
|
||||||
|
total_sites = len(sites)
|
||||||
|
success_count = 0
|
||||||
|
fail_count = 0
|
||||||
|
|
||||||
|
for i, site_info in enumerate(sites):
|
||||||
|
site_name = site_info["name"]
|
||||||
|
print(f"\n[{i+1}/{total_sites}] 处理站点: {site_name}")
|
||||||
|
migrate_res = migrateSiteHotLogs(site_name, query_date)
|
||||||
|
if migrate_res["status"]:
|
||||||
|
success_count += 1
|
||||||
|
else:
|
||||||
|
fail_count += 1
|
||||||
|
print(f"[{site_name}] 迁移失败: {migrate_res['msg']}")
|
||||||
|
|
||||||
|
print(f"\n迁移完成! 成功: {success_count}, 失败: {fail_count}")
|
||||||
|
|
||||||
|
return mw.returnMsg(True, f"logs migrate ok, success: {success_count}, fail: {fail_count}")
|
||||||
|
|
||||||
|
except BlockingIOError:
|
||||||
|
print("正在迁移中,跳过")
|
||||||
|
return mw.returnMsg(True, "正在迁移中,跳过")
|
||||||
|
except Exception as e:
|
||||||
|
print(f"migrateHotLogs error: {e}")
|
||||||
|
return mw.returnMsg(False, f"migrateHotLogs error: {e}")
|
||||||
|
finally:
|
||||||
|
if lock_fd:
|
||||||
|
try:
|
||||||
|
fcntl.flock(lock_fd.fileno(), fcntl.LOCK_UN)
|
||||||
|
lock_fd.close()
|
||||||
|
if os.path.exists(lock_file):
|
||||||
|
os.remove(lock_file)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
@@ -0,0 +1,209 @@
|
|||||||
|
# coding:utf-8
|
||||||
|
|
||||||
|
import sys
|
||||||
|
import io
|
||||||
|
import os
|
||||||
|
import time
|
||||||
|
import json
|
||||||
|
|
||||||
|
web_dir = os.getcwd() + "/web"
|
||||||
|
if os.path.exists(web_dir):
|
||||||
|
sys.path.append(web_dir)
|
||||||
|
os.chdir(web_dir)
|
||||||
|
|
||||||
|
import core.mw as mw
|
||||||
|
from utils.crontab import crontab as MwCrontab
|
||||||
|
|
||||||
|
app_debug = False
|
||||||
|
if mw.isAppleSystem():
|
||||||
|
app_debug = True
|
||||||
|
|
||||||
|
|
||||||
|
def getPluginName():
|
||||||
|
return 'webstats'
|
||||||
|
|
||||||
|
|
||||||
|
def getPluginDir():
|
||||||
|
return mw.getPluginDir() + '/' + getPluginName()
|
||||||
|
|
||||||
|
|
||||||
|
def getServerDir():
|
||||||
|
return mw.getServerDir() + '/' + getPluginName()
|
||||||
|
|
||||||
|
|
||||||
|
def getConf():
|
||||||
|
conf = getServerDir() + "/lua/config.json"
|
||||||
|
return conf
|
||||||
|
|
||||||
|
|
||||||
|
def getGlobalConf():
|
||||||
|
conf = getConf()
|
||||||
|
content = mw.readFile(conf)
|
||||||
|
result = json.loads(content)
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
def pSqliteDb(dbname='web_logs', site_name='unset', fn="logs"):
|
||||||
|
|
||||||
|
db_dir = getServerDir() + '/logs/' + site_name
|
||||||
|
if not os.path.exists(db_dir):
|
||||||
|
mw.execShell('mkdir -p ' + db_dir)
|
||||||
|
|
||||||
|
name = fn
|
||||||
|
file = db_dir + '/' + name + '.db'
|
||||||
|
|
||||||
|
if not os.path.exists(file):
|
||||||
|
conn = mw.M(dbname).dbPos(db_dir, name)
|
||||||
|
sql = mw.readFile(getPluginDir() + '/conf/init.sql')
|
||||||
|
sql_list = sql.split(';')
|
||||||
|
for index in range(len(sql_list)):
|
||||||
|
conn.execute(sql_list[index], ())
|
||||||
|
else:
|
||||||
|
conn = mw.M(dbname).dbPos(db_dir, name)
|
||||||
|
|
||||||
|
conn.execute("PRAGMA synchronous = 0", ())
|
||||||
|
conn.execute("PRAGMA page_size = 4096", ())
|
||||||
|
conn.execute("PRAGMA journal_mode = wal", ())
|
||||||
|
|
||||||
|
conn.autoTextFactory()
|
||||||
|
|
||||||
|
# conn.text_factory = lambda x: str(x, encoding="utf-8", errors='ignore')
|
||||||
|
# conn.text_factory = lambda x: unicode(x, "utf-8", "ignore")
|
||||||
|
return conn
|
||||||
|
|
||||||
|
|
||||||
|
def migrateSiteHotLogs(site_name, query_date):
|
||||||
|
print(site_name, query_date)
|
||||||
|
|
||||||
|
migrating_flag = getServerDir() + "/logs/%s/migrating" % site_name
|
||||||
|
hot_db = getServerDir() + "/logs/%s/logs.db" % site_name
|
||||||
|
hot_db_tmp = getServerDir() + "/logs/%s/logs_tmp.db" % site_name
|
||||||
|
history_logs_db = getServerDir() + "/logs/%s/history_logs.db" % site_name
|
||||||
|
# 1. copy to tmp file
|
||||||
|
try:
|
||||||
|
import shutil
|
||||||
|
print("coping {} to {} ...".format(hot_db, hot_db_tmp))
|
||||||
|
mw.writeFile(migrating_flag, "yes")
|
||||||
|
time.sleep(3)
|
||||||
|
shutil.copy(hot_db, hot_db_tmp)
|
||||||
|
if not os.path.exists(hot_db_tmp):
|
||||||
|
return mw.returnMsg(False, "migrating fail, copy tmp file!")
|
||||||
|
except:
|
||||||
|
return mw.returnMsg(False, "{} migrating fail.".format(site_name))
|
||||||
|
finally:
|
||||||
|
if os.path.exists(migrating_flag):
|
||||||
|
os.remove(migrating_flag)
|
||||||
|
|
||||||
|
# 2. 从临时备份中迁移热日志数据到历史日志
|
||||||
|
print("begin tmp to hot log data ...")
|
||||||
|
try:
|
||||||
|
print("history file: {}".format(history_logs_db))
|
||||||
|
logs_conn = pSqliteDb('web_log', site_name, 'logs_tmp')
|
||||||
|
history_logs_conn = pSqliteDb('web_log', site_name, 'history_logs')
|
||||||
|
|
||||||
|
hot_db_columns = logs_conn.originExecute(
|
||||||
|
"PRAGMA table_info([web_logs])")
|
||||||
|
_columns = ",".join([c[1] for c in hot_db_columns if c[1] != "id"])
|
||||||
|
query_start = 0
|
||||||
|
todayTime = time.strftime('%Y-%m-%d 00:00:00', time.localtime())
|
||||||
|
todayUt = int(time.mktime(time.strptime(
|
||||||
|
todayTime, "%Y-%m-%d %H:%M:%S")))
|
||||||
|
|
||||||
|
logs_sql = "select {} from web_logs where time<{}".format(
|
||||||
|
_columns, todayUt)
|
||||||
|
selector = logs_conn.originExecute(logs_sql)
|
||||||
|
log = selector.fetchone()
|
||||||
|
while log:
|
||||||
|
params = ""
|
||||||
|
for field in log:
|
||||||
|
if params:
|
||||||
|
params += ","
|
||||||
|
if field is None:
|
||||||
|
field = "\'\'"
|
||||||
|
elif type(field) == str:
|
||||||
|
field = "\'" + field.replace("\'", "\"") + "\'"
|
||||||
|
params += str(field)
|
||||||
|
insert_sql = "insert into web_logs(" + \
|
||||||
|
_columns + ") values(" + params + ")"
|
||||||
|
history_logs_conn.execute(insert_sql)
|
||||||
|
log = selector.fetchone()
|
||||||
|
|
||||||
|
print("sorting historical data, this action takes a long time...")
|
||||||
|
history_logs_conn.execute("VACUUM;")
|
||||||
|
|
||||||
|
gcfg = getGlobalConf()
|
||||||
|
save_day = gcfg['global']["save_day"]
|
||||||
|
print("delete historical data {} days ago...".format(save_day))
|
||||||
|
time_now = time.localtime()
|
||||||
|
save_timestamp = time.mktime((time_now.tm_year, time_now.tm_mon, time_now.tm_mday - save_day, 0, 0, 0, 0, 0, 0))
|
||||||
|
delete_sql = "delete from web_logs where time <= {}".format(
|
||||||
|
save_timestamp)
|
||||||
|
print('delete history_logs')
|
||||||
|
print(delete_sql)
|
||||||
|
history_logs_conn.execute(delete_sql)
|
||||||
|
history_logs_conn.commit()
|
||||||
|
|
||||||
|
# 3. delete merged data and clean up statistics
|
||||||
|
print("delete merged thermal data...")
|
||||||
|
mw.writeFile(migrating_flag, "yes")
|
||||||
|
|
||||||
|
hot_db_conn = pSqliteDb('web_logs', site_name)
|
||||||
|
del_hot_log = "delete from web_logs where time<{}".format(todayUt)
|
||||||
|
print(del_hot_log)
|
||||||
|
r = hot_db_conn.execute(del_hot_log)
|
||||||
|
print("delete:", r)
|
||||||
|
print("deleting statistics over 180 days...")
|
||||||
|
save_time_key = time.strftime(
|
||||||
|
'%Y%m%d00', time.localtime(time.time() - 180 * 86400))
|
||||||
|
|
||||||
|
del_request_stat_sql = "delete from request_stat where time<={}".format(
|
||||||
|
save_time_key)
|
||||||
|
hot_db_conn.execute(del_request_stat_sql)
|
||||||
|
|
||||||
|
hot_db_conn.execute(
|
||||||
|
"delete from spider_stat where time<={}".format(save_time_key))
|
||||||
|
hot_db_conn.execute(
|
||||||
|
"delete from client_stat where time<={}".format(save_time_key))
|
||||||
|
hot_db_conn.execute(
|
||||||
|
"delete from referer_stat where time<={}".format(save_time_key))
|
||||||
|
hot_db_conn.commit()
|
||||||
|
print("clean up the hot database...")
|
||||||
|
hot_db_conn.execute("VACUUM;")
|
||||||
|
hot_db_conn.commit()
|
||||||
|
|
||||||
|
if os.path.exists(migrating_flag):
|
||||||
|
os.remove(migrating_flag)
|
||||||
|
except Exception as e:
|
||||||
|
if site_name:
|
||||||
|
print("{} logs to history error:{}".format(site_name, e))
|
||||||
|
else:
|
||||||
|
print("logs to history error:{}".format(e))
|
||||||
|
finally:
|
||||||
|
if os.path.exists(hot_db_tmp):
|
||||||
|
os.remove(hot_db_tmp)
|
||||||
|
|
||||||
|
print("{} logs migrate ok.".format(site_name))
|
||||||
|
|
||||||
|
if not mw.isAppleSystem():
|
||||||
|
mw.execShell("chown -R www:www " + getServerDir())
|
||||||
|
|
||||||
|
mw.opWeb('restart')
|
||||||
|
return mw.returnMsg(True, "{} logs migrate ok".format(site_name))
|
||||||
|
|
||||||
|
|
||||||
|
def migrateHotLogs(query_date="today"):
|
||||||
|
print("begin migrate hot logs")
|
||||||
|
sites = mw.M('sites').field('name').order("add_time").select()
|
||||||
|
|
||||||
|
unset_site = {"name": "unset"}
|
||||||
|
sites.append(unset_site)
|
||||||
|
|
||||||
|
# migrateSiteHotLogs('t1.cn', query_date)
|
||||||
|
|
||||||
|
for site_info in sites:
|
||||||
|
# print(site_info['name'])
|
||||||
|
site_name = site_info["name"]
|
||||||
|
migrate_res = migrateSiteHotLogs(site_name, query_date)
|
||||||
|
if not migrate_res["status"]:
|
||||||
|
print(migrate_res["msg"])
|
||||||
|
print("end migrate hot logs")
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
lua_shared_dict mw_total 100m;
|
||||||
|
lua_need_request_body off;
|
||||||
|
include {$SERVER_APP}/lua/webstats_log.lua;
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,667 @@
|
|||||||
|
log_by_lua_block {
|
||||||
|
|
||||||
|
local cpath = "{$SERVER_APP}/lua/"
|
||||||
|
if not package.cpath:find(cpath) then
|
||||||
|
package.cpath = cpath .. "?.so;" .. package.cpath
|
||||||
|
end
|
||||||
|
if not package.path:find(cpath) then
|
||||||
|
package.path = cpath .. "?.lua;" .. package.path
|
||||||
|
end
|
||||||
|
|
||||||
|
local ver = '0.2.4'
|
||||||
|
local debug_mode = true
|
||||||
|
|
||||||
|
local __C = require "webstats_common"
|
||||||
|
local C = __C:getInstance()
|
||||||
|
|
||||||
|
-- cache start ---
|
||||||
|
local cache = ngx.shared.mw_total
|
||||||
|
local function cache_set(server_name, id ,key, val)
|
||||||
|
local line_kv = "log_kv_"..server_name..'_'..id.."_"..key
|
||||||
|
-- cache:set(line_kv, val)
|
||||||
|
cache:set(line_kv, val)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function cache_clear(server_name, id, key)
|
||||||
|
local line_kv = "log_kv_"..server_name..'_'..id.."_"..key
|
||||||
|
cache:delete(line_kv)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function cache_get(server_name, id, key)
|
||||||
|
local line_kv = "log_kv_"..server_name..'_'..id.."_"..key
|
||||||
|
local value = cache:get(line_kv)
|
||||||
|
return value
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- cache end ---
|
||||||
|
|
||||||
|
-- domain config is import
|
||||||
|
local db = nil
|
||||||
|
local json = require "cjson"
|
||||||
|
local sqlite3 = require "lsqlite3"
|
||||||
|
local config = require "webstats_config"
|
||||||
|
local sites = require "webstats_sites"
|
||||||
|
|
||||||
|
-- string.gsub(C:get_sn(ngx.var.server_name),'_','.')
|
||||||
|
local server_name = C:get_sn(ngx.var.server_name)
|
||||||
|
|
||||||
|
|
||||||
|
C:setConfData(config, sites)
|
||||||
|
|
||||||
|
local auto_config = C:setInputSn(server_name)
|
||||||
|
|
||||||
|
local request_header = ngx.req.get_headers()
|
||||||
|
local method = ngx.req.get_method()
|
||||||
|
local excluded = false
|
||||||
|
|
||||||
|
local day = os.date("%d")
|
||||||
|
local number_day = tonumber(day)
|
||||||
|
local day_column = "day"..number_day
|
||||||
|
local flow_column = "flow"..number_day
|
||||||
|
local spider_column = "spider_flow"..number_day
|
||||||
|
--- default common var end ---
|
||||||
|
|
||||||
|
local function init_var()
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
--------------------- exclude_func start --------------------------
|
||||||
|
local function load_global_exclude_ip()
|
||||||
|
local load_key = "global_exclude_ip_load"
|
||||||
|
-- update global exclude ip
|
||||||
|
local global_exclude_ip = auto_config["exclude_ip"]
|
||||||
|
if global_exclude_ip then
|
||||||
|
for i, _ip in pairs(global_exclude_ip)
|
||||||
|
do
|
||||||
|
-- global
|
||||||
|
-- D("set global exclude ip: ".._ip)
|
||||||
|
if not cache:get("global_exclude_ip_".._ip) then
|
||||||
|
cache:set("global_exclude_ip_".._ip, true)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
-- set tag
|
||||||
|
cache:set(load_key, true)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function load_exclude_ip(input_server_name)
|
||||||
|
|
||||||
|
local load_key = input_server_name .. "_exclude_ip_load"
|
||||||
|
local site_config = config[input_server_name]
|
||||||
|
|
||||||
|
local site_exclude_ip = nil
|
||||||
|
if site_config then
|
||||||
|
site_exclude_ip = site_config["exclude_ip"]
|
||||||
|
end
|
||||||
|
|
||||||
|
-- update server_name exclude ip
|
||||||
|
if site_exclude_ip then
|
||||||
|
for i, _ip in pairs(site_exclude_ip)
|
||||||
|
do
|
||||||
|
cache:set(input_server_name .. "_exclude_ip_".._ip, true)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- set tag
|
||||||
|
cache:set(load_key, true)
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
local function filter_status()
|
||||||
|
if not auto_config['exclude_status'] then return false end
|
||||||
|
local the_status = tostring(ngx.status)
|
||||||
|
for _,v in ipairs(auto_config['exclude_status'])
|
||||||
|
do
|
||||||
|
if the_status == v then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
local function exclude_extension()
|
||||||
|
if not ngx.var.uri then return false end
|
||||||
|
if not auto_config['exclude_extension'] then return false end
|
||||||
|
for _,v in ipairs(auto_config['exclude_extension'])
|
||||||
|
do
|
||||||
|
if ngx.re.find(ngx.var.uri,"[.]"..v.."$",'ijo') then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
local function exclude_url()
|
||||||
|
if not ngx.var.uri then return false end
|
||||||
|
if not ngx.var.request_uri then return false end
|
||||||
|
if not auto_config['exclude_url'] then return false end
|
||||||
|
local the_uri = string.sub(ngx.var.request_uri, 2)
|
||||||
|
local url_conf = auto_config["exclude_url"]
|
||||||
|
for i,conf in ipairs(url_conf)
|
||||||
|
do
|
||||||
|
local mode = conf["mode"]
|
||||||
|
local url = conf["url"]
|
||||||
|
if mode == "regular" then
|
||||||
|
if ngx.re.find(the_uri, url, "ijo") then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if the_uri == url then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
local function exclude_ip(input_server_name, ip)
|
||||||
|
-- 排除IP匹配,分网站单独的配置和全局配置两种方式
|
||||||
|
local site_config = config[input_server_name]
|
||||||
|
local server_exclude_ips = nil
|
||||||
|
local check_server_exclude_ip = false
|
||||||
|
if site_config then
|
||||||
|
server_exclude_ips = site_config["exclude_ip"]
|
||||||
|
if not server_exclude_ips then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
for k, _ip in pairs(server_exclude_ips)
|
||||||
|
do
|
||||||
|
check_server_exclude_ip = true
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
-- D("server[" ..input_server_name.."]check exclude ip : "..tostring(check_server_exclude_ip))
|
||||||
|
if check_server_exclude_ip then
|
||||||
|
if cache:get(input_server_name .. "_exclude_ip_"..ip) then
|
||||||
|
-- D("-Exclude server ip:"..ip)
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if cache:get("global_exclude_ip_"..ip) then
|
||||||
|
-- D("*Excluded global ip:"..ip)
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
--------------------- exclude_func end ---------------------------
|
||||||
|
|
||||||
|
local function cache_logs_old(server_name)
|
||||||
|
|
||||||
|
-- make new id
|
||||||
|
local new_id = C:get_last_id(server_name)
|
||||||
|
|
||||||
|
local excluded = false
|
||||||
|
local ip = C:get_client_ip()
|
||||||
|
excluded = filter_status() or exclude_extension() or exclude_url() or exclude_ip(server_name, ip)
|
||||||
|
|
||||||
|
local ip_list = request_header["x-forwarded-for"]
|
||||||
|
if ip and not ip_list then
|
||||||
|
ip_list = ip
|
||||||
|
end
|
||||||
|
|
||||||
|
local remote_addr = ngx.var.remote_addr
|
||||||
|
if not string.find(ip_list, remote_addr) then
|
||||||
|
if remote_addr then
|
||||||
|
ip_list = ip_list .. "," .. remote_addr
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- local request_time = ngx.var.request_time
|
||||||
|
local request_time = C:get_request_time()
|
||||||
|
local client_port = ngx.var.remote_port
|
||||||
|
local real_server_name = ngx.var.server_name
|
||||||
|
local uri = ngx.var.uri
|
||||||
|
local status_code = ngx.status
|
||||||
|
local protocol = ngx.var.server_protocol
|
||||||
|
local request_uri = ngx.var.request_uri
|
||||||
|
local time_key = C:get_store_key()
|
||||||
|
local method = method
|
||||||
|
local body_length = C:get_length()
|
||||||
|
local domain = C:get_domain()
|
||||||
|
local referer = ngx.var.http_referer
|
||||||
|
|
||||||
|
local kv = {
|
||||||
|
id=new_id,
|
||||||
|
time_key=time_key,
|
||||||
|
time=ngx.time(),
|
||||||
|
ip=ip,
|
||||||
|
domain=domain,
|
||||||
|
server_name=server_name,
|
||||||
|
real_server_name=real_server_name,
|
||||||
|
method=method,
|
||||||
|
status_code=status_code,
|
||||||
|
uri=uri,
|
||||||
|
request_uri=request_uri,
|
||||||
|
body_length=body_length,
|
||||||
|
referer=referer,
|
||||||
|
user_agent=request_header['user-agent'],
|
||||||
|
protocol=protocol,
|
||||||
|
is_spider=0,
|
||||||
|
request_time=request_time,
|
||||||
|
excluded=excluded,
|
||||||
|
request_headers='',
|
||||||
|
ip_list=ip_list,
|
||||||
|
client_port=client_port
|
||||||
|
}
|
||||||
|
|
||||||
|
local request_stat_fields = "req=req+1,length=length+"..body_length
|
||||||
|
local spider_stat_fields = "x"
|
||||||
|
local client_stat_fields = "x"
|
||||||
|
|
||||||
|
if not excluded then
|
||||||
|
|
||||||
|
if status_code == 500 or (method=="POST" and config["record_post_args"] == true) or (status_code==403 and config["record_get_403_args"] == true) then
|
||||||
|
local data = ""
|
||||||
|
local ok, err = pcall(function() data = C:get_http_origin() end)
|
||||||
|
if ok and not err then
|
||||||
|
kv["request_headers"] = data
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if ngx.re.find("500,501,502,503,504,505,506,507,509,510,400,401,402,403,404,405,406,407,408,409,410,411,412,413,414,415,416,417,418,421,422,423,424,425,426,449,451,499", tostring(status_code), "jo") then
|
||||||
|
local field = "status_"..status_code
|
||||||
|
request_stat_fields = request_stat_fields .. ","..field.."="..field.."+1"
|
||||||
|
end
|
||||||
|
|
||||||
|
local lower_method = string.lower(method)
|
||||||
|
if ngx.re.find("get,post,put,patch,delete", lower_method, "ijo") then
|
||||||
|
local field = "http_"..lower_method
|
||||||
|
request_stat_fields = request_stat_fields .. ","..field.."="..field.."+1"
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
local ipc = 0
|
||||||
|
local pvc = 0
|
||||||
|
local uvc = 0
|
||||||
|
|
||||||
|
local is_spider, request_spider, spider_index = C:match_spider(kv['user_agent'])
|
||||||
|
if not is_spider then
|
||||||
|
|
||||||
|
client_stat_fields = C:match_client(kv['user_agent'])
|
||||||
|
if not client_stat_fields or #client_stat_fields == 0 then
|
||||||
|
client_stat_fields = request_stat_fields..",other=other+1"
|
||||||
|
end
|
||||||
|
|
||||||
|
pvc, uvc = C:statistics_request(ip, is_spider,body_length)
|
||||||
|
ipc = C:statistics_ipc(server_name,ip)
|
||||||
|
else
|
||||||
|
kv["is_spider"] = spider_index
|
||||||
|
local field = "spider"
|
||||||
|
spider_stat_fields = request_spider.."="..request_spider.."+"..1
|
||||||
|
request_stat_fields = request_stat_fields .. ","..field.."="..field.."+"..1
|
||||||
|
end
|
||||||
|
|
||||||
|
if ipc > 0 then
|
||||||
|
request_stat_fields = request_stat_fields..",ip=ip+1"
|
||||||
|
end
|
||||||
|
if uvc > 0 then
|
||||||
|
request_stat_fields = request_stat_fields..",uv=uv+1"
|
||||||
|
end
|
||||||
|
if pvc > 0 then
|
||||||
|
request_stat_fields = request_stat_fields..",pv=pv+1"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local stat_fields = request_stat_fields..";"..client_stat_fields..";"..spider_stat_fields
|
||||||
|
|
||||||
|
cache_set(server_name, new_id, "stat_fields", stat_fields)
|
||||||
|
cache_set(server_name, new_id, "log_kv", json.encode(kv))
|
||||||
|
end
|
||||||
|
|
||||||
|
local function cache_logs(input_sn)
|
||||||
|
|
||||||
|
-- make new id
|
||||||
|
local new_id = C:get_last_id(input_sn)
|
||||||
|
|
||||||
|
local excluded = false
|
||||||
|
local ip = C:get_client_ip()
|
||||||
|
excluded = filter_status() or exclude_extension() or exclude_url() or exclude_ip(input_sn, ip)
|
||||||
|
|
||||||
|
local ip_list = request_header["x-forwarded-for"]
|
||||||
|
if ip and not ip_list then
|
||||||
|
ip_list = ip
|
||||||
|
end
|
||||||
|
|
||||||
|
local remote_addr = ngx.var.remote_addr
|
||||||
|
|
||||||
|
-- 修复反向代理代过来的数据
|
||||||
|
if "table" == type(ip_list) then
|
||||||
|
ip_list = json.encode(ip_list)
|
||||||
|
end
|
||||||
|
|
||||||
|
if not string.find(ip_list, remote_addr) then
|
||||||
|
if remote_addr then
|
||||||
|
ip_list = ip_list .. "," .. remote_addr
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- local request_time = ngx.var.request_time
|
||||||
|
local request_time = C:get_request_time()
|
||||||
|
local client_port = ngx.var.remote_port
|
||||||
|
local real_server_name = input_sn
|
||||||
|
local uri = tostring(ngx.var.uri)
|
||||||
|
local status_code = ngx.status
|
||||||
|
local protocol = ngx.var.server_protocol
|
||||||
|
local request_uri = ngx.var.request_uri
|
||||||
|
local time_key = C:get_store_key()
|
||||||
|
local method = method
|
||||||
|
local body_length = C:get_length()
|
||||||
|
local domain = C:get_domain()
|
||||||
|
local referer = ngx.var.http_referer
|
||||||
|
|
||||||
|
local kv = {
|
||||||
|
id=new_id,
|
||||||
|
time_key=time_key,
|
||||||
|
time=ngx.time(),
|
||||||
|
ip=ip,
|
||||||
|
domain=domain,
|
||||||
|
server_name=input_sn,
|
||||||
|
real_server_name=real_server_name,
|
||||||
|
method=method,
|
||||||
|
status_code=status_code,
|
||||||
|
uri=uri,
|
||||||
|
request_uri=request_uri,
|
||||||
|
body_length=body_length,
|
||||||
|
referer=referer,
|
||||||
|
user_agent=request_header['user-agent'],
|
||||||
|
protocol=protocol,
|
||||||
|
is_spider=0,
|
||||||
|
request_time=request_time,
|
||||||
|
excluded=excluded,
|
||||||
|
request_headers='',
|
||||||
|
ip_list=ip_list,
|
||||||
|
client_port=client_port
|
||||||
|
}
|
||||||
|
|
||||||
|
-- C:D(json.encode(kv))
|
||||||
|
local request_stat_fields = {req=1,length=body_length}
|
||||||
|
|
||||||
|
local spider_stat_fields = {}
|
||||||
|
local client_stat_fields = {}
|
||||||
|
|
||||||
|
if not excluded then
|
||||||
|
if status_code == 500 or (method=="POST" and config['global']["record_post_args"] == true) or (status_code==403 and config['global']["record_get_403_args"] == true) then
|
||||||
|
local data = ""
|
||||||
|
local ok, err = pcall(function() data = C:get_http_origin() end)
|
||||||
|
if ok and not err then
|
||||||
|
kv["request_headers"] = data
|
||||||
|
else
|
||||||
|
C:D("debug request_headers error:"..tostring(err))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if ngx.re.find("500,501,502,503,504,505,506,507,509,510,400,401,402,403,404,405,406,407,408,409,410,411,412,413,414,415,416,417,418,421,422,423,424,425,426,449,451,499", tostring(status_code), "jo") then
|
||||||
|
local field = "status_"..status_code
|
||||||
|
request_stat_fields[field] = 1
|
||||||
|
end
|
||||||
|
|
||||||
|
-- D("method:"..method)
|
||||||
|
local lower_method = string.lower(method)
|
||||||
|
if ngx.re.find("get,post,put,patch,delete", lower_method, "ijo") then
|
||||||
|
local field = "http_"..lower_method
|
||||||
|
request_stat_fields[field] = 1
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
local ipc = 0
|
||||||
|
local pvc = 0
|
||||||
|
local uvc = 0
|
||||||
|
|
||||||
|
local is_spider, request_spider, spider_index = C:match_spider(kv['user_agent'])
|
||||||
|
if not is_spider then
|
||||||
|
|
||||||
|
client_stat_fields = C:match_client_arr(kv['user_agent'])
|
||||||
|
pvc, uvc = C:statistics_request(ip, is_spider,body_length)
|
||||||
|
ipc = C:statistics_ipc(input_sn,ip)
|
||||||
|
else
|
||||||
|
kv["is_spider"] = spider_index
|
||||||
|
local field = "spider"
|
||||||
|
spider_stat_fields[request_spider] = 1
|
||||||
|
request_stat_fields[field] = 1
|
||||||
|
end
|
||||||
|
|
||||||
|
if ipc > 0 then
|
||||||
|
request_stat_fields["ip"] = 1
|
||||||
|
end
|
||||||
|
if uvc > 0 then
|
||||||
|
request_stat_fields["uv"] = 1
|
||||||
|
end
|
||||||
|
if pvc > 0 then
|
||||||
|
request_stat_fields["pv"] = 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local stat_fields = {
|
||||||
|
request_stat_fields=request_stat_fields,
|
||||||
|
client_stat_fields=client_stat_fields,
|
||||||
|
spider_stat_fields=spider_stat_fields,
|
||||||
|
}
|
||||||
|
|
||||||
|
local data = {
|
||||||
|
server_name=input_sn,
|
||||||
|
stat_fields=stat_fields,
|
||||||
|
log_kv=kv,
|
||||||
|
}
|
||||||
|
|
||||||
|
local push_data = json.encode(data)
|
||||||
|
-- C:D(json.encode(push_data))
|
||||||
|
local key = C:getTotalKey()
|
||||||
|
ngx.shared.mw_total:rpush(key, push_data)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function store_logs_line(db, stmt, input_server_name, lineno)
|
||||||
|
local logvalue = cache_get(input_server_name, lineno, "log_kv")
|
||||||
|
if not logvalue then return false end
|
||||||
|
local logline = json.decode(logvalue)
|
||||||
|
|
||||||
|
local time = logline["time"]
|
||||||
|
local id = logline["id"]
|
||||||
|
local protocol = logline["protocol"]
|
||||||
|
local client_port = logline["client_port"]
|
||||||
|
local status_code = logline["status_code"]
|
||||||
|
local uri = logline["uri"]
|
||||||
|
local request_uri = logline["request_uri"]
|
||||||
|
local method = logline["method"]
|
||||||
|
local body_length = logline["body_length"]
|
||||||
|
local referer = logline["referer"]
|
||||||
|
local ip = logline["ip"]
|
||||||
|
local ip_list = logline["ip_list"]
|
||||||
|
local request_time = logline["request_time"]
|
||||||
|
local is_spider = logline["is_spider"]
|
||||||
|
local domain = logline["domain"]
|
||||||
|
local server_name = logline["server_name"]
|
||||||
|
local user_agent = logline["user_agent"]
|
||||||
|
local request_headers = logline["request_headers"]
|
||||||
|
local excluded = logline["excluded"]
|
||||||
|
|
||||||
|
local request_stat_fields = nil
|
||||||
|
local client_stat_fields = nil
|
||||||
|
local spider_stat_fields = nil
|
||||||
|
local stat_fields = cache_get(input_server_name, id, "stat_fields")
|
||||||
|
if stat_fields == nil then
|
||||||
|
-- D("Log stat fields is nil.")
|
||||||
|
-- D("Logdata:"..logvalue)
|
||||||
|
else
|
||||||
|
stat_fields = C:split(stat_fields, ";")
|
||||||
|
request_stat_fields = stat_fields[1]
|
||||||
|
client_stat_fields = stat_fields[2]
|
||||||
|
spider_stat_fields = stat_fields[3]
|
||||||
|
|
||||||
|
if "x" == client_stat_fields then
|
||||||
|
client_stat_fields = nil
|
||||||
|
end
|
||||||
|
|
||||||
|
if "x" == spider_stat_fields then
|
||||||
|
spider_stat_fields = nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local time_key = logline["time_key"]
|
||||||
|
if not excluded then
|
||||||
|
stmt:bind_names{
|
||||||
|
time=time,
|
||||||
|
ip=ip,
|
||||||
|
domain=domain,
|
||||||
|
server_name=server_name,
|
||||||
|
method=method,
|
||||||
|
status_code=status_code,
|
||||||
|
uri=request_uri,
|
||||||
|
body_length=body_length,
|
||||||
|
referer=referer,
|
||||||
|
user_agent=user_agent,
|
||||||
|
protocol=protocol,
|
||||||
|
request_time=request_time,
|
||||||
|
is_spider=is_spider,
|
||||||
|
request_headers=request_headers,
|
||||||
|
ip_list=ip_list,
|
||||||
|
client_port=client_port,
|
||||||
|
}
|
||||||
|
|
||||||
|
local res, err = stmt:step()
|
||||||
|
if tostring(res) == "5" then
|
||||||
|
-- D("step res:"..tostring(res))
|
||||||
|
-- D("step err:"..tostring(err))
|
||||||
|
-- D("the step database connection is busy, so it will be stored later.")
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
stmt:reset()
|
||||||
|
-- D("store_logs_line ok")
|
||||||
|
|
||||||
|
C:update_stat( db, "client_stat", time_key, client_stat_fields)
|
||||||
|
C:update_stat( db, "spider_stat", time_key, spider_stat_fields)
|
||||||
|
-- C:D("stat ok")
|
||||||
|
|
||||||
|
-- only count non spider requests
|
||||||
|
local ok, err = C:statistics_uri(db, request_uri, ngx.md5(request_uri), body_length)
|
||||||
|
local ok, err = C:statistics_ip(db, ip, body_length)
|
||||||
|
end
|
||||||
|
|
||||||
|
C:update_stat( db, "request_stat", time_key, request_stat_fields)
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
local function store_logs(input_sn)
|
||||||
|
if C:is_migrating(input_sn) == true then
|
||||||
|
-- D("migrating...")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local last_insert_id_key = input_sn.."_last_id"
|
||||||
|
local store_start_id_key = input_sn.."_store_start"
|
||||||
|
local last_id = cache:get(last_insert_id_key)
|
||||||
|
local store_start = cache:get(store_start_id_key)
|
||||||
|
if store_start == nil then
|
||||||
|
store_start = 1
|
||||||
|
end
|
||||||
|
local store_end = last_id
|
||||||
|
if store_end == nil then
|
||||||
|
store_end = 1
|
||||||
|
end
|
||||||
|
|
||||||
|
local worker_id = ngx.worker.id()
|
||||||
|
if C:is_working(input_sn) then
|
||||||
|
-- D("other workers are being stored, please store later.")
|
||||||
|
-- cache:delete(flush_data_key)
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
C:lock_working(input_sn)
|
||||||
|
|
||||||
|
local log_dir = "{$SERVER_APP}/logs"
|
||||||
|
local db_path = log_dir .. '/' .. input_sn .. "/logs.db"
|
||||||
|
local db, err = sqlite3.open(db_path)
|
||||||
|
|
||||||
|
if tostring(err) ~= 'nil' then
|
||||||
|
C:D("sqlite3 open error:"..tostring(err))
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
db:exec([[PRAGMA synchronous = 0]])
|
||||||
|
db:exec([[PRAGMA page_size = 4096]])
|
||||||
|
db:exec([[PRAGMA journal_mode = wal]])
|
||||||
|
db:exec([[PRAGMA journal_size_limit = 1073741824]])
|
||||||
|
|
||||||
|
local stmt2 = nil
|
||||||
|
if db ~= nil then
|
||||||
|
stmt2 = db:prepare[[INSERT INTO web_logs(
|
||||||
|
time, ip, domain, server_name, method, status_code, uri, body_length,
|
||||||
|
referer, user_agent, protocol, request_time, is_spider, request_headers, ip_list, client_port)
|
||||||
|
VALUES(:time, :ip, :domain, :server_name, :method, :status_code, :uri,
|
||||||
|
:body_length, :referer, :user_agent, :protocol, :request_time, :is_spider,
|
||||||
|
:request_headers, :ip_list, :client_port)]]
|
||||||
|
end
|
||||||
|
|
||||||
|
if db == nil or stmt2 == nil then
|
||||||
|
-- D("web data db error")
|
||||||
|
-- cache:set(storing_key, false)
|
||||||
|
if db and db:isopen() then
|
||||||
|
db:close()
|
||||||
|
end
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
status, errorString = db:exec([[BEGIN TRANSACTION]])
|
||||||
|
|
||||||
|
C:clean_stats(db, input_sn)
|
||||||
|
|
||||||
|
if store_end >= store_start then
|
||||||
|
for i=store_start, store_end, 1 do
|
||||||
|
-- D("store_start:"..store_start..":store_end:".. store_end)
|
||||||
|
if store_logs_line(db, stmt2, input_sn, i) then
|
||||||
|
cache_clear(input_sn, i, "log_kv")
|
||||||
|
cache_clear(input_sn, i, "stat_fields")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local res, err = stmt2:finalize()
|
||||||
|
if tostring(res) == "5" then
|
||||||
|
C:D("Finalize res:"..tostring(res)..",Finalize err:"..tostring(err))
|
||||||
|
end
|
||||||
|
|
||||||
|
local now_date = os.date("*t")
|
||||||
|
local save_day = config['global']["save_day"]
|
||||||
|
local save_date_timestamp = os.time{year=now_date.year,
|
||||||
|
month=now_date.month, day=now_date.day-save_day, hour=0}
|
||||||
|
-- delete expire data
|
||||||
|
db:exec("DELETE FROM web_logs WHERE time<"..tostring(save_date_timestamp))
|
||||||
|
|
||||||
|
local res, err = db:execute([[COMMIT]])
|
||||||
|
if db and db:isopen() then
|
||||||
|
db:close()
|
||||||
|
end
|
||||||
|
|
||||||
|
cache:set(store_start_id_key, store_end+1)
|
||||||
|
C:unlock_working(input_sn)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function run_app()
|
||||||
|
-- C:D("------------ debug start ------------")
|
||||||
|
init_var()
|
||||||
|
|
||||||
|
load_global_exclude_ip()
|
||||||
|
load_exclude_ip(server_name)
|
||||||
|
|
||||||
|
cache_logs(server_name)
|
||||||
|
-- C:cron()
|
||||||
|
|
||||||
|
-- cache_logs_old(server_name)
|
||||||
|
-- store_logs(server_name)
|
||||||
|
-- C:D("------------ debug end -------------")
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
local function run_app_ok()
|
||||||
|
if not debug_mode then return run_app() end
|
||||||
|
|
||||||
|
local presult, err = pcall( function() run_app() end)
|
||||||
|
if not presult then
|
||||||
|
C:D("debug error on :"..tostring(err))
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return run_app_ok()
|
||||||
|
}
|
||||||
|
|
||||||
@@ -7,6 +7,7 @@ PRAGMA journal_size_limit = 1073741824;
|
|||||||
CREATE TABLE IF NOT EXISTS `web_logs` (
|
CREATE TABLE IF NOT EXISTS `web_logs` (
|
||||||
`time` INTEGER,
|
`time` INTEGER,
|
||||||
`ip` TEXT,
|
`ip` TEXT,
|
||||||
|
`scheme` TEXT,
|
||||||
`domain` TEXT,
|
`domain` TEXT,
|
||||||
`server_name` TEXT,
|
`server_name` TEXT,
|
||||||
`method` TEXT,
|
`method` TEXT,
|
||||||
@@ -32,7 +33,8 @@ CREATE INDEX status_code_idx ON web_logs (`status_code`);
|
|||||||
CREATE INDEX request_time_idx ON web_logs (`request_time`);
|
CREATE INDEX request_time_idx ON web_logs (`request_time`);
|
||||||
CREATE INDEX is_spider_idx ON web_logs (`is_spider`);
|
CREATE INDEX is_spider_idx ON web_logs (`is_spider`);
|
||||||
CREATE INDEX body_length_idx ON web_logs (`body_length`);
|
CREATE INDEX body_length_idx ON web_logs (`body_length`);
|
||||||
CREATE INDEX all_union_idx ON web_logs(`status_code`, `time`, `ip`, `domain`, `server_name`, `method`, `is_spider`, `protocol`, `request_headers`, `ip_list`, `client_port`, `body_length`, `user_agent`, `referer`, `request_time`, `uri`);
|
CREATE INDEX scheme_idx ON web_logs (`scheme`);
|
||||||
|
CREATE INDEX all_union_idx ON web_logs(`status_code`, `time`, `ip`, `scheme`, `domain`, `server_name`, `method`, `is_spider`, `protocol`, `request_headers`, `ip_list`, `client_port`, `body_length`, `user_agent`, `referer`, `request_time`, `uri`);
|
||||||
|
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS `client_stat`(
|
CREATE TABLE IF NOT EXISTS `client_stat`(
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
lua_shared_dict mw_total 100m;
|
lua_shared_dict webstats_queue 128m;
|
||||||
|
lua_shared_dict webstats_cache 512m;
|
||||||
lua_need_request_body off;
|
lua_need_request_body off;
|
||||||
include {$SERVER_APP}/lua/webstats_log.lua;
|
log_by_lua_file {$SERVER_APP}/lua/webstats_log.lua;
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user