mirror of
https://github.com/midoks/mdserver-web.git
synced 2026-10-10 11:29:25 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
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 | ||
|
|
2fe17aefd9 | ||
|
|
acddca54cd | ||
|
|
7d80fb31ce | ||
|
|
8ac1d78053 | ||
|
|
468d6d7752 | ||
|
|
f49d789411 | ||
|
|
1f56115fbb | ||
|
|
20d277102e | ||
|
|
47b4036f09 | ||
|
|
ee9e154fec | ||
|
|
85256b4fb6 | ||
|
|
16be671f1d | ||
|
|
af880115ab | ||
|
|
e64ac8f616 | ||
|
|
a7d4206b77 | ||
|
|
5a80690404 | ||
|
|
9b0d71d4ac | ||
|
|
729f77d8db | ||
|
|
e89f96aa2d | ||
|
|
f05f81cace | ||
|
|
f4883ee708 | ||
|
|
043fb739d9 | ||
|
|
b19aa8702b | ||
|
|
f4e0744879 | ||
|
|
d7c822f86d | ||
|
|
c8f8e217e5 | ||
|
|
bfec7f1fe8 | ||
|
|
21fce1f618 | ||
|
|
b5987b57ad | ||
|
|
e8c1cb08a7 | ||
|
|
0de3a16898 | ||
|
|
278bd7f38e | ||
|
|
4a3b9db324 | ||
|
|
b3e8e96875 | ||
|
|
f5e50c6d76 | ||
|
|
c551c2ee1a | ||
|
|
3fb8406e7b | ||
|
|
50d12407c9 | ||
|
|
17931bb0ea | ||
|
|
6d30940920 | ||
|
|
3a4c985baf | ||
|
|
960d8b6cb8 | ||
|
|
9b7e9d4ffa | ||
|
|
c1a646c0d7 | ||
|
|
48ef0e7a65 | ||
|
|
8dff306a91 | ||
|
|
a935acbc95 | ||
|
|
b1f9c99eb1 | ||
|
|
0851f749c3 | ||
|
|
3a7d9f84c7 | ||
|
|
b43b35ccab | ||
|
|
5fc6eacc53 | ||
|
|
bd782362e8 | ||
|
|
32151a176f | ||
|
|
f7c88d2086 | ||
|
|
1eb76f2b90 | ||
|
|
226b3e049d | ||
|
|
7f0e9851cd | ||
|
|
15df77940e | ||
|
|
9781516552 | ||
|
|
a23264a542 | ||
|
|
0e7845985a | ||
|
|
93efe45347 | ||
|
|
a46f824e1e | ||
|
|
0de9f036bc | ||
|
|
275f2515d6 | ||
|
|
b4604928ec | ||
|
|
5a79b4021a | ||
|
|
280fd38039 | ||
|
|
b032364616 | ||
|
|
a430aaee97 | ||
|
|
f4ee2ca3b9 | ||
|
|
92b9212b31 | ||
|
|
73656e60ff | ||
|
|
401329d80c | ||
|
|
6131970724 | ||
|
|
85dcc4b78a | ||
|
|
34a1bf7e28 |
@@ -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
|
||||
|
||||
- 常规优化。
|
||||
|
||||
|
||||
+1
-1
@@ -183,7 +183,7 @@ def check502():
|
||||
verlist = [
|
||||
'52', '53', '54', '55', '56', '70',
|
||||
'71', '72', '73', '74', '80', '81',
|
||||
'82', '83', '84'
|
||||
'82', '83', '84', '85'
|
||||
]
|
||||
for ver in verlist:
|
||||
server_dir = mw.getServerDir()
|
||||
|
||||
@@ -122,7 +122,7 @@ def openPort():
|
||||
return True
|
||||
|
||||
def status():
|
||||
cmd = "ps aux|grep alist |grep -v grep | grep -v python | grep -v mdserver-web | awk '{print $2}'"
|
||||
cmd = "ps -ef|grep alist |grep -v grep | grep -v python | grep -v mdserver-web | awk '{print $2}'"
|
||||
data = mw.execShell(cmd)
|
||||
if data[0] == '':
|
||||
return 'stop'
|
||||
|
||||
@@ -174,7 +174,7 @@ def initDreplace():
|
||||
|
||||
|
||||
def status():
|
||||
cmd = "ps -ef|grep 'httpd/bin/httpd' |grep -v grep | grep -v python | awk '{print $2}'"
|
||||
cmd = "ps -ef|grep 'httpd' |grep -v grep | grep -v python | awk '{print $2}'"
|
||||
data = mw.execShell(cmd)
|
||||
if data[0] == '':
|
||||
return 'stop'
|
||||
|
||||
@@ -165,6 +165,7 @@ def initConf():
|
||||
"/www/server/alist/data/log",
|
||||
"/www/server/dztasks/logs",
|
||||
"/www/server/rsyncd/lsyncd.log",
|
||||
"/www/server/mdserver-web/logs",
|
||||
]
|
||||
for i in clogcom:
|
||||
if os.path.exists(i):
|
||||
|
||||
@@ -99,7 +99,7 @@ def readConfigTpl():
|
||||
|
||||
def status():
|
||||
data = mw.execShell(
|
||||
"ps aux|grep cloudreve |grep -v grep | grep -v python | grep -v mdserver-web | awk '{print $2}'")
|
||||
"ps -ef|grep cloudreve |grep -v grep | grep -v python | grep -v mdserver-web | awk '{print $2}'")
|
||||
|
||||
if data[0] == '':
|
||||
return 'stop'
|
||||
|
||||
@@ -106,7 +106,7 @@ def getPidFile():
|
||||
return tmp.groups()[0].strip()
|
||||
|
||||
def status():
|
||||
cmd = "ps aux|grep dztasks|grep -v grep|grep -v python|grep -v mdserver-web|awk '{print $2}'"
|
||||
cmd = "ps -ef|grep dztasks|grep -v grep|grep -v python|grep -v mdserver-web|awk '{print $2}'"
|
||||
data = mw.execShell(cmd)
|
||||
if data[0] == '':
|
||||
return 'stop'
|
||||
|
||||
@@ -113,7 +113,7 @@ def status():
|
||||
# if not os.path.exists(pid_file):
|
||||
# return 'stop'
|
||||
|
||||
cmd = "ps aux|grep gorse |grep -v grep | grep -v python | grep -v mdserver-web | awk '{print $2}'"
|
||||
cmd = "ps -ef|grep gorse |grep -v grep | grep -v python | grep -v mdserver-web | awk '{print $2}'"
|
||||
data = mw.execShell(cmd)
|
||||
|
||||
if data[0] == '':
|
||||
|
||||
@@ -84,7 +84,7 @@ def getPidFile():
|
||||
return tmp.groups()[0].strip()
|
||||
|
||||
def status():
|
||||
cmd = "ps aux|grep grafana |grep -v grep | grep -v python | grep -v mdserver-web | awk '{print $2}'"
|
||||
cmd = "ps -ef|grep grafana |grep -v grep | grep -v python | grep -v mdserver-web | awk '{print $2}'"
|
||||
data = mw.execShell(cmd)
|
||||
if data[0] == '':
|
||||
return 'stop'
|
||||
|
||||
@@ -118,7 +118,7 @@ def configScriptsTpl():
|
||||
|
||||
def status():
|
||||
data = mw.execShell(
|
||||
"ps aux|grep keepalived |grep -v grep | grep -v python | grep -v mdserver-web | awk '{print $2}'")
|
||||
"ps -ef|grep keepalived |grep -v grep | grep -v python| awk '{print $2}'")
|
||||
|
||||
if data[0] == '':
|
||||
return 'stop'
|
||||
|
||||
@@ -115,7 +115,7 @@ def status():
|
||||
return 'stop'
|
||||
|
||||
# data = mw.execShell(
|
||||
# "ps aux|grep redis |grep -v grep | grep -v python | grep -v mdserver-web | awk '{print $2}'")
|
||||
# "ps -ef|grep redis |grep -v grep | grep -v python | grep -v mdserver-web | awk '{print $2}'")
|
||||
|
||||
# if data[0] == '':
|
||||
# return 'stop'
|
||||
|
||||
@@ -91,7 +91,7 @@ def getPidFile():
|
||||
return tmp.groups()[0].strip()
|
||||
|
||||
def status():
|
||||
cmd = "ps aux|grep loki |grep -v grep | grep -v python | grep -v mdserver-web | awk '{print $2}'"
|
||||
cmd = "ps -ef|grep loki |grep -v grep | grep -v python | grep -v mdserver-web | awk '{print $2}'"
|
||||
data = mw.execShell(cmd)
|
||||
if data[0] == '':
|
||||
return 'stop'
|
||||
|
||||
@@ -585,8 +585,7 @@ def setMyDbPos():
|
||||
mw.writeFile(myfile, mycnf)
|
||||
start()
|
||||
|
||||
result = mw.execShell(
|
||||
'ps aux|grep mysqld| grep -v grep|grep -v python')
|
||||
result = mw.execShell('ps -ef|grep mysqld| grep -v grep|grep -v python')
|
||||
if len(result[0]) > 10:
|
||||
mw.writeFile('data/datadir.pl', t_datadir)
|
||||
return mw.returnJson(True, '存储目录迁移成功!')
|
||||
|
||||
@@ -96,7 +96,7 @@ def checkArgs(data, ck=[]):
|
||||
|
||||
|
||||
def status():
|
||||
cmd = "ps aux|grep " + getPluginName() + " |grep -v grep | grep -v mdserver-web | awk '{print $2}'"
|
||||
cmd = "ps -ef|grep " + getPluginName() + " |grep -v grep | grep -v mdserver-web | awk '{print $2}'"
|
||||
# print(cmd)
|
||||
data = mw.execShell(cmd)
|
||||
# print(data)
|
||||
|
||||
@@ -8,7 +8,7 @@ rootPath=$(dirname "$rootPath")
|
||||
serverPath=$(dirname "$rootPath")
|
||||
|
||||
sys_os=`uname`
|
||||
VERSION=1.6.39
|
||||
VERSION=1.6.42
|
||||
|
||||
echo $sys_os
|
||||
|
||||
|
||||
@@ -230,7 +230,7 @@ class classApi:
|
||||
def close_sync(self, args):
|
||||
# 取消迁移
|
||||
mw.execShell("kill -9 {}".format(self.get_pid()))
|
||||
mw.execShell("kill -9 $(ps aux|grep index.py|grep -v grep|awk '{print $2}')")
|
||||
mw.execShell("kill -9 $(ps -ef|grep index.py|grep -v grep|awk '{print $2}')")
|
||||
# 删除迁移配置
|
||||
time.sleep(1)
|
||||
if os.path.exists(self._INFO_FILE):
|
||||
@@ -1032,7 +1032,7 @@ def stepThree():
|
||||
|
||||
|
||||
def getPid():
|
||||
cmd = "ps aux|grep 'plugins/migration_api/index.py bg_process' |grep -v grep|awk '{print $2}'|xargs"
|
||||
cmd = "ps -ef|grep 'plugins/migration_api/index.py bg_process' |grep -v grep|awk '{print $2}'|xargs"
|
||||
result = mw.execShell(cmd)[0].strip()
|
||||
if not result:
|
||||
return None
|
||||
|
||||
+46
-14
@@ -154,8 +154,8 @@ def checkArgs(data, ck=[]):
|
||||
return (True, mw.returnJson(True, 'ok'))
|
||||
|
||||
def status():
|
||||
data = mw.execShell(
|
||||
"ps -ef|grep mongod |grep -v mongosh|grep -v grep | grep -v /Applications | grep -v python | grep -v mdserver-web | awk '{print $2}'")
|
||||
cmd = "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] == '':
|
||||
return 'stop'
|
||||
return 'start'
|
||||
@@ -196,25 +196,55 @@ def mongdbClientS():
|
||||
mg_root = pSqliteDb('config').where('id=?', (1,)).getField('mg_root')
|
||||
|
||||
if auth == 'disabled':
|
||||
client = pymongo.MongoClient(host=ip, port=int(port), directConnection=True)
|
||||
client = pymongo.MongoClient(host=ip, port=int(port))
|
||||
else:
|
||||
# print(auth,mg_root)
|
||||
client = pymongo.MongoClient(host=ip, port=int(port), directConnection=True, username='root',password=mg_root)
|
||||
# 使用 admin 数据库进行认证,兼容 MongoDB 3.0
|
||||
client = pymongo.MongoClient(host=ip, port=int(port), username='root', password=mg_root, authSource='admin')
|
||||
return client
|
||||
|
||||
def getMongoDBVersion():
|
||||
'''获取MongoDB版本号'''
|
||||
import pymongo
|
||||
port = getConfPort()
|
||||
ip = getConfLocalIp()
|
||||
try:
|
||||
# 先不使用认证连接
|
||||
client = pymongo.MongoClient(host=ip, port=int(port), serverSelectionTimeoutMS=5000)
|
||||
db = client.admin
|
||||
serverStatus = db.command('serverStatus')
|
||||
version = serverStatus.get('version', '4.0')
|
||||
client.close()
|
||||
return version
|
||||
except Exception as e:
|
||||
# 如果无法获取版本,默认返回 4.0(新版本兼容模式)
|
||||
return '4.0'
|
||||
|
||||
def isMongoDB3x():
|
||||
'''判断是否为MongoDB 3.x版本'''
|
||||
version = getMongoDBVersion()
|
||||
# 匹配 3.x 版本
|
||||
if version.startswith('3.'):
|
||||
return True
|
||||
return False
|
||||
|
||||
def mongdbClient():
|
||||
import pymongo
|
||||
port = getConfPort()
|
||||
auth = getConfAuth()
|
||||
ip = getConfLocalIp()
|
||||
mg_root = pSqliteDb('config').where('id=?', (1,)).getField('mg_root')
|
||||
# print(ip,port,auth,mg_root)
|
||||
|
||||
if auth == 'disabled':
|
||||
client = pymongo.MongoClient(host=ip, port=int(port), directConnection=True)
|
||||
client = pymongo.MongoClient(host=ip, port=int(port))
|
||||
else:
|
||||
# uri = "mongodb://root:"+mg_root+"@127.0.0.1:"+str(port)
|
||||
# client = pymongo.MongoClient(uri)
|
||||
client = pymongo.MongoClient(host=ip, port=int(port), directConnection=True, username='root',password=mg_root)
|
||||
# 根据MongoDB版本选择认证方式
|
||||
if isMongoDB3x():
|
||||
# MongoDB 3.x 使用 authSource 指定认证数据库
|
||||
client = pymongo.MongoClient(host=ip, port=int(port), username='root', password=mg_root, authSource='admin')
|
||||
else:
|
||||
# MongoDB 4.x+ 默认在 admin 数据库认证
|
||||
client = pymongo.MongoClient(host=ip, port=int(port), username='root', password=mg_root)
|
||||
return client
|
||||
|
||||
|
||||
@@ -711,7 +741,6 @@ def setRootPwd(version=''):
|
||||
def setUserPwd(version=''):
|
||||
|
||||
client = mongdbClient()
|
||||
db = client.admin
|
||||
sqlite_db = pSqliteDb('databases')
|
||||
|
||||
args = getArgs()
|
||||
@@ -724,6 +753,8 @@ def setUserPwd(version=''):
|
||||
uid = args['id']
|
||||
try:
|
||||
name = sqlite_db.where('id=?', (uid,)).getField('name')
|
||||
# 将用户创建在目标数据库中,而不是 admin 数据库
|
||||
db = client[name]
|
||||
user_roles = [{'role': 'dbOwner', 'db': name}, {'role': 'userAdmin', 'db': name}]
|
||||
|
||||
try:
|
||||
@@ -824,16 +855,16 @@ def getDbInfo():
|
||||
|
||||
def toDbBase(find):
|
||||
client = mongdbClient()
|
||||
db_admin = client.admin
|
||||
data_name = find['name']
|
||||
db = client[data_name]
|
||||
|
||||
db.zchat.insert_one({})
|
||||
user_roles = [{'role': 'dbOwner', 'db': data_name}, {'role': 'userAdmin', 'db': data_name}]
|
||||
# 将用户创建在目标数据库中,而不是 admin 数据库
|
||||
try:
|
||||
db_admin.command("createUser", find['username'], pwd=find['password'], roles=user_roles)
|
||||
db.command("createUser", find['username'], pwd=find['password'], roles=user_roles)
|
||||
except Exception as e:
|
||||
db_admin.command("updateUser", find['username'], pwd=find['password'], roles=user_roles)
|
||||
db.command("updateUser", find['username'], pwd=find['password'], roles=user_roles)
|
||||
return 1
|
||||
|
||||
def syncToDatabases():
|
||||
@@ -990,7 +1021,8 @@ def setDbAccess():
|
||||
user_roles.append(t)
|
||||
|
||||
client = mongdbClient()
|
||||
db = client.admin
|
||||
# 在目标数据库中操作用户,而不是 admin 数据库
|
||||
db = client[name]
|
||||
|
||||
try:
|
||||
db.command("updateUser", username, pwd=mg_pass, roles=user_roles)
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
"shell": "install.sh",
|
||||
"install_pre_inspection":true,
|
||||
"uninstall_pre_inspection":true,
|
||||
"versions":["4.4","5.0","6.0","7.0","8.0","8.2"],
|
||||
"versions":["3.0","4.4","5.0","6.0","7.0","8.0","8.2"],
|
||||
"tip": "soft",
|
||||
"checks": "server/mongodb",
|
||||
"path": "server/mongodb",
|
||||
|
||||
@@ -6,9 +6,20 @@ export PATH
|
||||
|
||||
# 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 3.0
|
||||
# cd /www/server/mdserver-web && python3 /www/server/mdserver-web/plugins/mongodb/index.py start
|
||||
|
||||
|
||||
# db.createUser({
|
||||
# user: "demo",
|
||||
# pwd: "123123",
|
||||
# roles: [{role: "dbOwner", db: "demo"}]
|
||||
# })
|
||||
|
||||
# db.auth("demo", "123123");
|
||||
# import
|
||||
# /www/server/mongodb/bin/mongorestore -h localhost -d demo --dir /tmp/*.json
|
||||
|
||||
|
||||
curPath=`pwd`
|
||||
rootPath=$(dirname "$curPath")
|
||||
@@ -78,6 +89,13 @@ Install_app()
|
||||
cd ${rootPath} && python3 ${rootPath}/plugins/mongodb/index.py start
|
||||
cd ${rootPath} && python3 ${rootPath}/plugins/mongodb/index.py initd_install
|
||||
fi
|
||||
|
||||
if [ "${VERSION}" == "3.0" ];then
|
||||
# 降低版本
|
||||
pip install pymongo==3.12.0
|
||||
else
|
||||
pip install pymongo
|
||||
fi
|
||||
}
|
||||
|
||||
Uninstall_app()
|
||||
|
||||
@@ -122,11 +122,12 @@ def mongdbClient():
|
||||
mg_root = pSqliteDb('config').where('id=?', (1,)).getField('mg_root')
|
||||
# print(ip,port,auth,mg_root)
|
||||
if auth == 'disabled':
|
||||
client = pymongo.MongoClient(host=ip, port=int(port), directConnection=True)
|
||||
client = pymongo.MongoClient(host=ip, port=int(port))
|
||||
else:
|
||||
# uri = "mongodb://root:"+mg_root+"@127.0.0.1:"+str(port)
|
||||
# client = pymongo.MongoClient(uri)
|
||||
client = pymongo.MongoClient(host=ip, port=int(port), directConnection=True, username='root',password=mg_root)
|
||||
# 使用 admin 数据库进行认证,兼容 MongoDB 3.0
|
||||
client = pymongo.MongoClient(host=ip, port=int(port), username='root', password=mg_root, authSource='admin')
|
||||
return client
|
||||
|
||||
class backupTools:
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
#!/bin/bash
|
||||
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin:/opt/homebrew/bin
|
||||
export PATH
|
||||
|
||||
curPath=`pwd`
|
||||
rootPath=$(dirname "$curPath")
|
||||
rootPath=$(dirname "$rootPath")
|
||||
rootPath=$(dirname "$rootPath")
|
||||
serverPath=$(dirname "$rootPath")
|
||||
|
||||
VERSION=3.0.15
|
||||
SYS_ARCH=`arch`
|
||||
|
||||
SYS_VERSION_ID=`cat /etc/*-release | grep VERSION_ID | awk -F = '{print $2}' | awk -F "\"" '{print $2}'`
|
||||
SYS_NAME=${SYS_VERSION_ID/./}
|
||||
SYS_NAME_LEN=`echo "$SYS_NAME" | wc -L`
|
||||
|
||||
if [ "$SYS_NAME_LEN" == "1" ];then
|
||||
SYS_NAME=${SYS_NAME}0
|
||||
fi
|
||||
|
||||
if [ "$SYS_ARCH" == "aarch64" ];then
|
||||
if [ "$SYS_NAME" -gt "82" ];then
|
||||
SYS_NAME="82"
|
||||
fi
|
||||
|
||||
if [ "$SYS_NAME" -lt "62" ];then
|
||||
SYS_NAME="62"
|
||||
fi
|
||||
else
|
||||
|
||||
if [ "$SYS_NAME" -gt "80" ];then
|
||||
SYS_NAME="80"
|
||||
fi
|
||||
|
||||
if [ "$SYS_NAME" -lt "70" ];then
|
||||
SYS_NAME="70"
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
# https://fastdl.mongodb.org/linux/mongodb-linux-aarch64-rhel82-4.4.23.tgz
|
||||
# https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-4.4.23.tgz
|
||||
# https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel80-4.4.23.tgz
|
||||
# https://fastdl.mongodb.org/linux/mongodb-linux-aarch64-rhel82-4.4.23.tgz
|
||||
# https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel80-4.4.23.tgz
|
||||
|
||||
MG_DIR=$serverPath/source/mongodb
|
||||
mkdir -p $MG_DIR
|
||||
|
||||
FILE_NAME=mongodb-linux-${SYS_ARCH}-${VERSION}
|
||||
FILE_NAME_TGZ=${FILE_NAME}.tgz
|
||||
|
||||
if [ ! -f $MG_DIR/${FILE_NAME_TGZ} ]; then
|
||||
wget --no-check-certificate -O $MG_DIR/${FILE_NAME_TGZ} https://fastdl.mongodb.org/linux/${FILE_NAME_TGZ}
|
||||
echo "wget --no-check-certificate -O $MG_DIR/${FILE_NAME_TGZ} https://fastdl.mongodb.org/linux/${FILE_NAME_TGZ}"
|
||||
fi
|
||||
|
||||
if [ ! -d $MG_DIR/${FILE_NAME} ];then
|
||||
cd $MG_DIR && tar -zxvf ${FILE_NAME_TGZ}
|
||||
fi
|
||||
|
||||
if [ ! -d $serverPath/mongodb/bin ];then
|
||||
mkdir -p $serverPath/mongodb
|
||||
cd $MG_DIR/${FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
||||
fi
|
||||
|
||||
cd ${MG_DIR} && rm -rf ${MG_DIR}/${FILE_NAME}
|
||||
@@ -0,0 +1,50 @@
|
||||
#!/bin/bash
|
||||
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin:/opt/homebrew/bin
|
||||
export PATH
|
||||
|
||||
curPath=`pwd`
|
||||
rootPath=$(dirname "$curPath")
|
||||
rootPath=$(dirname "$rootPath")
|
||||
rootPath=$(dirname "$rootPath")
|
||||
serverPath=$(dirname "$rootPath")
|
||||
|
||||
# https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-3.0.15.tgz
|
||||
VERSION=3.0.15
|
||||
SYS_ARCH=`arch`
|
||||
SYS_VERSION_ID=`cat /etc/*-release | grep VERSION_ID | awk -F = '{print $2}' | awk -F "\"" '{print $2}'`
|
||||
SYS_NAME=${SYS_VERSION_ID/./}
|
||||
|
||||
if [ "$SYS_NAME" -gt "10" ];then
|
||||
SYS_NAME="10"
|
||||
fi
|
||||
|
||||
if [ "$SYS_NAME" -lt "10" ];then
|
||||
SYS_NAME="10"
|
||||
fi
|
||||
|
||||
# FILE_NAME=mongodb-linux-${SYS_ARCH}-debian${SYS_NAME}-${VERSION}
|
||||
FILE_NAME=mongodb-linux-${SYS_ARCH}-${VERSION}
|
||||
FILE_NAME_TGZ=${FILE_NAME}.tgz
|
||||
|
||||
|
||||
MG_DIR=$serverPath/source/mongodb
|
||||
mkdir -p $MG_DIR
|
||||
|
||||
if [ ! -f $MG_DIR/${FILE_NAME_TGZ} ]; then
|
||||
wget --no-check-certificate -O $MG_DIR/${FILE_NAME_TGZ} https://fastdl.mongodb.org/linux/${FILE_NAME_TGZ}
|
||||
echo "wget --no-check-certificate -O $MG_DIR/${FILE_NAME_TGZ} https://fastdl.mongodb.org/linux/${FILE_NAME_TGZ}"
|
||||
fi
|
||||
|
||||
if [ ! -d $MG_DIR/${FILE_NAME_TGZ} ];then
|
||||
cd $MG_DIR && tar -zxvf ${FILE_NAME_TGZ}
|
||||
fi
|
||||
|
||||
if [ ! -d $serverPath/mongodb/bin ];then
|
||||
mkdir -p $serverPath/mongodb
|
||||
cd $MG_DIR/${FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
||||
fi
|
||||
|
||||
cd ${MG_DIR} && rm -rf ${MG_DIR}/${FILE_NAME}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
#!/bin/bash
|
||||
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin:/opt/homebrew/bin
|
||||
export PATH
|
||||
|
||||
curPath=`pwd`
|
||||
rootPath=$(dirname "$curPath")
|
||||
rootPath=$(dirname "$rootPath")
|
||||
rootPath=$(dirname "$rootPath")
|
||||
serverPath=$(dirname "$rootPath")
|
||||
|
||||
# https://fastdl.mongodb.org/osx/mongodb-osx-x86_64-3.0.15.tgz
|
||||
VERSION=3.0.15
|
||||
|
||||
MG_DIR=$serverPath/source/mongodb
|
||||
mkdir -p $MG_DIR
|
||||
|
||||
if [ ! -f $MG_DIR/mongodb-macos-x86_64-${VERSION}.tgz ]; then
|
||||
wget --no-check-certificate -O $MG_DIR/mongodb-macos-x86_64-${VERSION}.tgz https://fastdl.mongodb.org/osx/mongodb-macos-x86_64-${VERSION}.tgz
|
||||
echo "wget --no-check-certificate -O $MG_DIR/mongodb-macos-x86_64-${VERSION}.tgz https://fastdl.mongodb.org/osx/mongodb-macos-x86_64-${VERSION}.tgz"
|
||||
fi
|
||||
|
||||
if [ ! -d $MG_DIR/mongodb-macos-x86_64-${VERSION} ];then
|
||||
cd $MG_DIR && tar -zxvf mongodb-macos-x86_64-${VERSION}.tgz
|
||||
fi
|
||||
|
||||
if [ ! -d $serverPath/mongodb/bin ];then
|
||||
mkdir -p $serverPath/mongodb
|
||||
cd $MG_DIR/mongodb-macos-x86_64-${VERSION} && cp -rf ./bin $serverPath/mongodb
|
||||
fi
|
||||
@@ -0,0 +1,48 @@
|
||||
#!/bin/bash
|
||||
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin:/opt/homebrew/bin
|
||||
export PATH
|
||||
|
||||
curPath=`pwd`
|
||||
rootPath=$(dirname "$curPath")
|
||||
rootPath=$(dirname "$rootPath")
|
||||
rootPath=$(dirname "$rootPath")
|
||||
serverPath=$(dirname "$rootPath")
|
||||
|
||||
VERSION=3.0.15
|
||||
SYS_ARCH=`arch`
|
||||
|
||||
SYS_VERSION_ID=`cat /etc/*-release | grep VERSION_ID | awk -F = '{print $2}' | awk -F "\"" '{print $2}' | awk -F . '{print $1}'`
|
||||
|
||||
SYS_NAME="15"
|
||||
if [ "$SYS_VERSION_ID" -gt "15" ];then
|
||||
SYS_NAME="15"
|
||||
fi
|
||||
|
||||
if [ "$SYS_NAME" -lt "12" ];then
|
||||
SYS_NAME="12"
|
||||
fi
|
||||
|
||||
# https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-suse15-4.4.23.tgz
|
||||
# https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-suse12-4.4.23.tgz
|
||||
|
||||
MG_DIR=$serverPath/source/mongodb
|
||||
mkdir -p $MG_DIR
|
||||
|
||||
FILE_NAME=mongodb-linux-${SYS_ARCH}-${VERSION}
|
||||
FILE_NAME_TGZ=${FILE_NAME}.tgz
|
||||
|
||||
if [ ! -f $MG_DIR/${FILE_NAME_TGZ} ]; then
|
||||
wget --no-check-certificate -O $MG_DIR/${FILE_NAME_TGZ} https://fastdl.mongodb.org/linux/${FILE_NAME_TGZ}
|
||||
echo "wget --no-check-certificate -O $MG_DIR/${FILE_NAME_TGZ} https://fastdl.mongodb.org/linux/${FILE_NAME_TGZ}"
|
||||
fi
|
||||
|
||||
if [ ! -d $MG_DIR/${FILE_NAME} ];then
|
||||
cd $MG_DIR && tar -zxvf ${FILE_NAME_TGZ}
|
||||
fi
|
||||
|
||||
if [ ! -d $serverPath/mongodb/bin ];then
|
||||
mkdir -p $serverPath/mongodb
|
||||
cd $MG_DIR/${FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
||||
fi
|
||||
|
||||
cd ${MG_DIR} && rm -rf ${MG_DIR}/${FILE_NAME}
|
||||
@@ -0,0 +1,44 @@
|
||||
#!/bin/bash
|
||||
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin:/opt/homebrew/bin
|
||||
export PATH
|
||||
|
||||
curPath=`pwd`
|
||||
rootPath=$(dirname "$curPath")
|
||||
rootPath=$(dirname "$rootPath")
|
||||
rootPath=$(dirname "$rootPath")
|
||||
serverPath=$(dirname "$rootPath")
|
||||
|
||||
VERSION=3.0.15
|
||||
SYS_ARCH=`arch`
|
||||
|
||||
SYS_VERSION_ID=`cat /etc/*-release | grep VERSION_ID | awk -F = '{print $2}' | awk -F "\"" '{print $2}'`
|
||||
SYS_NAME=${SYS_VERSION_ID/./}
|
||||
SYS_NAME_LEN=`echo "$SYS_NAME" | wc -L`
|
||||
|
||||
if [ "$SYS_NAME_LEN" == "1" ];then
|
||||
SYS_NAME=${SYS_NAME}0
|
||||
fi
|
||||
|
||||
# https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-4.4.23.tgz
|
||||
|
||||
MG_DIR=$serverPath/source/mongodb
|
||||
mkdir -p $MG_DIR
|
||||
|
||||
FILE_NAME=mongodb-linux-${SYS_ARCH}-${VERSION}
|
||||
FILE_NAME_TGZ=${FILE_NAME}.tgz
|
||||
|
||||
if [ ! -f $MG_DIR/${FILE_NAME_TGZ} ]; then
|
||||
wget --no-check-certificate -O $MG_DIR/${FILE_NAME_TGZ} https://fastdl.mongodb.org/linux/${FILE_NAME_TGZ}
|
||||
echo "wget --no-check-certificate -O $MG_DIR/${FILE_NAME_TGZ} https://fastdl.mongodb.org/linux/${FILE_NAME_TGZ}"
|
||||
fi
|
||||
|
||||
if [ ! -d $MG_DIR/${FILE_NAME} ];then
|
||||
cd $MG_DIR && tar -zxvf ${FILE_NAME_TGZ}
|
||||
fi
|
||||
|
||||
if [ ! -d $serverPath/mongodb/bin ];then
|
||||
mkdir -p $serverPath/mongodb
|
||||
cd $MG_DIR/${FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
||||
fi
|
||||
|
||||
cd ${MG_DIR} && rm -rf ${MG_DIR}/${FILE_NAME}
|
||||
@@ -0,0 +1,46 @@
|
||||
#!/bin/bash
|
||||
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin:/opt/homebrew/bin
|
||||
export PATH
|
||||
|
||||
curPath=`pwd`
|
||||
rootPath=$(dirname "$curPath")
|
||||
rootPath=$(dirname "$rootPath")
|
||||
rootPath=$(dirname "$rootPath")
|
||||
serverPath=$(dirname "$rootPath")
|
||||
|
||||
VERSION=3.0.15
|
||||
SYS_ARCH=`arch`
|
||||
|
||||
SYS_VERSION_ID=`cat /etc/*-release | grep VERSION_ID | awk -F = '{print $2}' | awk -F "\"" '{print $2}'`
|
||||
SYS_NAME=${SYS_VERSION_ID/./}
|
||||
# https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu2004-4.4.23.tgz
|
||||
|
||||
if [ "$SYS_NAME" -gt "2004" ];then
|
||||
SYS_NAME="2004"
|
||||
fi
|
||||
|
||||
if [ "$SYS_NAME" -lt "1604" ];then
|
||||
SYS_NAME="1604"
|
||||
fi
|
||||
|
||||
MG_DIR=$serverPath/source/mongodb
|
||||
mkdir -p $MG_DIR
|
||||
|
||||
FILE_NAME=mongodb-linux-${SYS_ARCH}-${VERSION}
|
||||
FILE_NAME_TGZ=${FILE_NAME}.tgz
|
||||
|
||||
if [ ! -f $MG_DIR/${FILE_NAME_TGZ} ]; then
|
||||
wget --no-check-certificate -O $MG_DIR/${FILE_NAME_TGZ} https://fastdl.mongodb.org/linux/${FILE_NAME_TGZ}
|
||||
echo "wget --no-check-certificate -O $MG_DIR/${FILE_NAME_TGZ} https://fastdl.mongodb.org/linux/${FILE_NAME_TGZ}"
|
||||
fi
|
||||
|
||||
if [ ! -d $MG_DIR/${FILE_NAME} ];then
|
||||
cd $MG_DIR && tar -zxvf ${FILE_NAME_TGZ}
|
||||
fi
|
||||
|
||||
if [ ! -d $serverPath/mongodb/bin ];then
|
||||
mkdir -p $serverPath/mongodb
|
||||
cd $MG_DIR/${FILE_NAME} && cp -rf ./bin $serverPath/mongodb
|
||||
fi
|
||||
|
||||
cd ${MG_DIR} && rm -rf ${MG_DIR}/${FILE_NAME}
|
||||
@@ -65,7 +65,7 @@ cd ${MG_DIR} && rm -rf ${MG_DIR}/${TOOL_FILE_NAME}
|
||||
|
||||
|
||||
#--------------- mongodb database install ------------------ #
|
||||
TOOL_VERSION=100.9.4
|
||||
TOOL_VERSION=100.16.1
|
||||
TOOL_FILE_NAME=mongodb-database-tools-debian${SYS_NAME}-x86_64-${TOOL_VERSION}
|
||||
if [ "aarch64" == ${SYS_ARCH} ];then
|
||||
TOOL_FILE_NAME=mongodb-database-tools-debian${SYS_NAME}-arm64-${TOOL_VERSION}
|
||||
@@ -75,7 +75,8 @@ if [ "arm64" == ${SYS_ARCH} ];then
|
||||
TOOL_FILE_NAME=mongodb-database-tools-debian${SYS_NAME}-arm64-${TOOL_VERSION}
|
||||
fi
|
||||
|
||||
TOOL_FILE_NAME_TGZ=${TOOL_FILE_NAME}.zip
|
||||
# https://fastdl.mongodb.org/tools/db/mongodb-database-tools-debian10-x86_64-100.16.1.tgz
|
||||
TOOL_FILE_NAME_TGZ=${TOOL_FILE_NAME}.tgz
|
||||
if [ ! -f $MG_DIR/${TOOL_FILE_NAME_TGZ} ]; then
|
||||
wget --no-check-certificate -O $MG_DIR/${TOOL_FILE_NAME_TGZ} https://fastdl.mongodb.org/tools/db/${TOOL_FILE_NAME_TGZ}
|
||||
fi
|
||||
|
||||
@@ -78,7 +78,7 @@ def getArgs():
|
||||
|
||||
def status():
|
||||
data = mw.execShell(
|
||||
"ps aux|grep mosquitto |grep -v grep | grep -v python | grep -v mdserver-web | awk '{print $2}'")
|
||||
"ps -ef|grep mosquitto |grep -v grep | grep -v python | grep -v mdserver-web | awk '{print $2}'")
|
||||
|
||||
if data[0] == '':
|
||||
return 'stop'
|
||||
|
||||
@@ -57,7 +57,7 @@ app_start(){
|
||||
|
||||
app_stop(){
|
||||
echo -e "stopping mosquitto ... \c";
|
||||
arr=`ps aux | grep 'mosquitto' | grep -v grep | awk '{print $2}'`
|
||||
arr=`ps -ef | grep 'mosquitto' | grep -v grep | awk '{print $2}'`
|
||||
for p in ${arr[@]}
|
||||
do
|
||||
kill -9 $p > /dev/null 2>&1
|
||||
|
||||
@@ -25,14 +25,25 @@ sysName=$(uname | tr '[:upper:]' '[:lower:]')
|
||||
|
||||
ARCH=amd64
|
||||
get_arch() {
|
||||
echo "package main
|
||||
import (
|
||||
\"fmt\"
|
||||
\"runtime\"
|
||||
)
|
||||
func main() { fmt.Println(runtime.GOARCH) }" > /tmp/go_arch.go
|
||||
|
||||
ARCH=$(go run /tmp/go_arch.go)
|
||||
# 使用 bash 来识别架构
|
||||
local arch=$(uname -m)
|
||||
case $arch in
|
||||
x86_64|amd64)
|
||||
ARCH=amd64
|
||||
;;
|
||||
aarch64|arm64)
|
||||
ARCH=arm64
|
||||
;;
|
||||
armv7l|armv7)
|
||||
ARCH=armv7
|
||||
;;
|
||||
i686|i386)
|
||||
ARCH=386
|
||||
;;
|
||||
*)
|
||||
ARCH=amd64
|
||||
;;
|
||||
esac
|
||||
echo "ARCH:${ARCH}"
|
||||
}
|
||||
|
||||
|
||||
@@ -662,7 +662,7 @@ def setMyDbPos(version=''):
|
||||
mw.writeFile(myfile, mycnf)
|
||||
restart(version)
|
||||
|
||||
result = mw.execShell('ps aux|grep mysqld| grep -v grep|grep -v python')
|
||||
result = mw.execShell('ps -ef|grep mysqld| grep -v grep|grep -v python')
|
||||
if len(result[0]) > 10:
|
||||
mw.writeFile('data/datadir.pl', t_datadir)
|
||||
return mw.returnJson(True, '存储目录迁移成功!')
|
||||
|
||||
@@ -0,0 +1,116 @@
|
||||
[client]
|
||||
user = root
|
||||
#password = your_password
|
||||
port = 3306
|
||||
socket = {$SERVER_APP_PATH}/mysql.sock
|
||||
default-character-set = UTF8MB4
|
||||
|
||||
[mysqld]
|
||||
!include {$SERVER_APP_PATH}/etc/mode/classic.cnf
|
||||
|
||||
authentication_policy=caching_sha2_password
|
||||
pid-file = {$SERVER_APP_PATH}/data/mysql.pid
|
||||
user = mysql
|
||||
port = 3306
|
||||
socket = {$SERVER_APP_PATH}/mysql.sock
|
||||
basedir = {$SERVER_APP_PATH}
|
||||
datadir = {$SERVER_APP_PATH}/data
|
||||
log-error = {$SERVER_APP_PATH}/data/error.log
|
||||
server-id = {$SERVER_ID}
|
||||
#sql-mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
|
||||
|
||||
default_storage_engine = InnoDB
|
||||
|
||||
key_buffer_size = 8M
|
||||
table_open_cache = 32
|
||||
sort_buffer_size = 256K
|
||||
net_buffer_length = 4K
|
||||
read_buffer_size = 128K
|
||||
read_rnd_buffer_size = 256K
|
||||
myisam_sort_buffer_size = 4M
|
||||
thread_cache_size = 4
|
||||
lower_case_table_names=0
|
||||
tmp_table_size = 8M
|
||||
character-set-server = UTF8MB4
|
||||
|
||||
max_connections = 500
|
||||
max_connect_errors = 100
|
||||
open_files_limit = 2560
|
||||
max_allowed_packet = 128M
|
||||
|
||||
skip_name_resolve=1
|
||||
#skip-networking
|
||||
#skip-external-locking
|
||||
#loose-skip-innodb
|
||||
#skip-grant-tables
|
||||
|
||||
#skip-log-bin
|
||||
#disable-log-bin
|
||||
#skip-slave-start
|
||||
log-bin=mysql-bin
|
||||
slow_query_log=1
|
||||
slow-query-log-file={$SERVER_APP_PATH}/data/mysql-slow.log
|
||||
long_query_time=10
|
||||
#log_queries_not_using_indexes=1
|
||||
#log_slow_admin_statements=1
|
||||
#log_slow_replica_statements=1
|
||||
binlog_expire_logs_seconds=604800
|
||||
|
||||
relay-log=mdserver
|
||||
relay-log-index=mdserver
|
||||
|
||||
#多主设置
|
||||
#auto_increment_offset=2
|
||||
#auto_increment_increment=2
|
||||
|
||||
#master
|
||||
#sync_binlog=1
|
||||
|
||||
#binlog-do-db
|
||||
binlog-ignore-db = test
|
||||
binlog-ignore-db = mysql
|
||||
binlog-ignore-db = information_schema
|
||||
binlog-ignore-db = performance_schema
|
||||
|
||||
#slave
|
||||
log_replica_updates = 1
|
||||
# Prevent replication from starting automatically with MySQL
|
||||
#skip_replica_start = 1
|
||||
#replicate-do-db
|
||||
replica_skip_errors=1062,1396
|
||||
replicate-ignore-db = information_schema
|
||||
replicate-ignore-db = performance_schema
|
||||
replicate-ignore-db = mysql
|
||||
replicate-ignore-db = test
|
||||
|
||||
|
||||
innodb_data_home_dir = {$SERVER_APP_PATH}/data
|
||||
innodb_data_file_path = ibdata1:10M:autoextend
|
||||
innodb_log_group_home_dir = {$SERVER_APP_PATH}/data
|
||||
innodb_buffer_pool_size = 16M
|
||||
#innodb_log_file_size = 5M
|
||||
innodb_redo_log_capacity = 4G
|
||||
innodb_log_buffer_size = 8M
|
||||
innodb_flush_log_at_trx_commit = 1
|
||||
innodb_lock_wait_timeout = 120
|
||||
innodb_max_dirty_pages_pct = 90
|
||||
innodb_read_io_threads = 1
|
||||
innodb_write_io_threads = 1
|
||||
innodb_file_per_table=1
|
||||
|
||||
secure-file-priv={$SERVER_APP_PATH}/tmp
|
||||
|
||||
[mysqldump]
|
||||
quick
|
||||
|
||||
[mysql]
|
||||
no-auto-rehash
|
||||
|
||||
[myisamchk]
|
||||
key_buffer_size = 20M
|
||||
sort_buffer_size = 20M
|
||||
read_buffer = 2M
|
||||
write_buffer = 2M
|
||||
|
||||
[mysqlhotcopy]
|
||||
interactive-timeout
|
||||
@@ -802,7 +802,7 @@ def setMyDbPos(version):
|
||||
mw.writeFile(myfile, mycnf)
|
||||
start(version)
|
||||
|
||||
result = mw.execShell('ps aux|grep mysqld| grep -v grep|grep -v python')
|
||||
result = mw.execShell('ps -ef|grep mysqld| grep -v grep|grep -v python')
|
||||
if len(result[0]) > 10:
|
||||
mw.writeFile('data/datadir.pl', t_datadir)
|
||||
return mw.returnJson(True, '存储目录迁移成功!')
|
||||
|
||||
@@ -11,8 +11,8 @@
|
||||
"checks": "server/mysql/VERSION/bin/mysql",
|
||||
"path": "server/mysql/VERSION",
|
||||
"todo_versions":["5.6","5.7","8.0","8.2"],
|
||||
"versions":["5.5", "5.6", "5.7","8.0","8.2","8.3","8.4","9.0","9.1","9.2","9.3","9.4"],
|
||||
"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"],
|
||||
"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"],
|
||||
"shell":"install.sh",
|
||||
"checks":"server/mysql",
|
||||
"path":"server/mysql",
|
||||
|
||||
Executable
+230
@@ -0,0 +1,230 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
#!/bin/bash
|
||||
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin:/opt/homebrew/bin
|
||||
export PATH
|
||||
|
||||
# https://dev.mysql.com/downloads/mysql/
|
||||
|
||||
curPath=`pwd`
|
||||
rootPath=$(dirname "$curPath")
|
||||
rootPath=$(dirname "$rootPath")
|
||||
serverPath=$(dirname "$rootPath")
|
||||
sysName=`uname`
|
||||
|
||||
|
||||
mysqlDir=${serverPath}/source/mysql
|
||||
|
||||
_os=`uname`
|
||||
echo "use system: ${_os}"
|
||||
if [ ${_os} == "Darwin" ]; then
|
||||
OSNAME='macos'
|
||||
elif grep -Eq "openSUSE" /etc/*-release; then
|
||||
OSNAME='opensuse'
|
||||
zypper refresh
|
||||
elif grep -Eq "FreeBSD" /etc/*-release; then
|
||||
OSNAME='freebsd'
|
||||
pkg install -y wget unzip
|
||||
elif grep -Eqi "Arch" /etc/issue || grep -Eq "Arch" /etc/*-release; then
|
||||
OSNAME='arch'
|
||||
echo y | pacman -Sy unzip
|
||||
elif grep -Eqi "CentOS" /etc/issue || grep -Eq "CentOS" /etc/*-release; then
|
||||
OSNAME='centos'
|
||||
yum install -y wget zip unzip
|
||||
elif grep -Eqi "Fedora" /etc/issue || grep -Eq "Fedora" /etc/*-release; then
|
||||
OSNAME='fedora'
|
||||
yum install -y wget zip unzip
|
||||
elif grep -Eqi "Rocky" /etc/issue || grep -Eq "Rocky" /etc/*-release; then
|
||||
OSNAME='rocky'
|
||||
yum install -y wget zip unzip
|
||||
elif grep -Eqi "AlmaLinux" /etc/issue || grep -Eq "AlmaLinux" /etc/*-release; then
|
||||
OSNAME='alma'
|
||||
yum install -y wget zip unzip
|
||||
elif grep -Eqi "Debian" /etc/issue || grep -Eq "Debian" /etc/*-release; then
|
||||
OSNAME='debian'
|
||||
apt update -y
|
||||
apt install -y devscripts
|
||||
apt install -y wget zip unzip
|
||||
elif grep -Eqi "Ubuntu" /etc/issue || grep -Eq "Ubuntu" /etc/*-release; then
|
||||
OSNAME='ubuntu'
|
||||
apt install -y wget zip unzip
|
||||
else
|
||||
OSNAME='unknow'
|
||||
fi
|
||||
|
||||
VERSION_ID=`cat /etc/*-release | grep VERSION_ID | awk -F = '{print $2}' | awk -F "\"" '{print $2}'`
|
||||
|
||||
|
||||
VERSION=9.7.0
|
||||
# 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
|
||||
Install_mysql()
|
||||
{
|
||||
mkdir -p ${mysqlDir}
|
||||
echo '正在安装脚本文件...'
|
||||
|
||||
|
||||
# ----- cpu start ------
|
||||
if [ -z "${cpuCore}" ]; then
|
||||
cpuCore="1"
|
||||
fi
|
||||
|
||||
if [ -f /proc/cpuinfo ];then
|
||||
cpuCore=`cat /proc/cpuinfo | grep "processor" | wc -l`
|
||||
fi
|
||||
|
||||
MEM_INFO=$(free -m|grep Mem|awk '{printf("%.f",($2)/1024)}')
|
||||
if [ "${cpuCore}" != "1" ] && [ "${MEM_INFO}" != "0" ];then
|
||||
if [ "${cpuCore}" -gt "${MEM_INFO}" ];then
|
||||
cpuCore="${MEM_INFO}"
|
||||
fi
|
||||
else
|
||||
cpuCore="1"
|
||||
fi
|
||||
|
||||
if [ "$cpuCore" -gt "2" ];then
|
||||
cpuCore=`echo "$cpuCore" | awk '{printf("%.f",($1)*0.8)}'`
|
||||
else
|
||||
cpuCore="1"
|
||||
fi
|
||||
# ----- cpu end ------
|
||||
|
||||
cd ${rootPath}/plugins/mysql/lib && /bin/bash rpcgen.sh
|
||||
|
||||
INSTALL_CMD=cmake
|
||||
# check cmake version
|
||||
CMAKE_VERSION=`cmake -version | grep version | awk '{print $3}' | awk -F '.' '{print $1}'`
|
||||
if [ "$CMAKE_VERSION" -eq "2" ];then
|
||||
mkdir -p /var/log/mariadb
|
||||
touch /var/log/mariadb/mariadb.log
|
||||
INSTALL_CMD=cmake3
|
||||
fi
|
||||
|
||||
if [ ! -f ${mysqlDir}/mysql-${VERSION}.tar.gz ];then
|
||||
wget --no-check-certificate -O ${mysqlDir}/mysql-${VERSION}.tar.gz --tries=3 https://dev.mysql.com/get/Downloads/MySQL-9.4/mysql-${VERSION}.tar.gz
|
||||
fi
|
||||
|
||||
#检测文件是否损坏.
|
||||
md5_mysql_ok=c770f276fb84019be6fbe0a57b32efbc
|
||||
if [ -f ${mysqlDir}/mysql-${VERSION}.tar.gz ];then
|
||||
md5_mysql=`md5sum ${mysqlDir}/mysql-${VERSION}.tar.gz | awk '{print $1}'`
|
||||
if [ "${md5_mysql_ok}" == "${md5_mysql}" ]; then
|
||||
echo "mysql9.4 file check ok"
|
||||
else
|
||||
# 重新下载
|
||||
rm -rf ${mysqlDir}/mysql-${VERSION}
|
||||
wget --no-check-certificate -O ${mysqlDir}/mysql-${VERSION}.tar.gz --tries=3 https://cdn.mysql.com/archives/mysql-9.4/mysql-${VERSION}.tar.gz
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ ! -d ${mysqlDir}/mysql-${VERSION} ];then
|
||||
cd ${mysqlDir} && tar -zxvf ${mysqlDir}/mysql-${VERSION}.tar.gz
|
||||
fi
|
||||
|
||||
OPTIONS=''
|
||||
##check openssl version
|
||||
OPENSSL_VERSION=`openssl version|awk '{print $2}'|awk -F '.' '{print $1}'`
|
||||
if [ "${OPENSSL_VERSION}" -ge "3" ];then
|
||||
#openssl version to high
|
||||
cd ${rootPath}/plugins/php/lib && /bin/bash openssl.sh
|
||||
export PKG_CONFIG_PATH=$serverPath/lib/openssl/lib/pkgconfig
|
||||
OPTIONS="-DWITH_SSL=${serverPath}/lib/openssl"
|
||||
fi
|
||||
|
||||
WHERE_DIR_GCC=/usr/bin/gcc
|
||||
WHERE_DIR_GPP=/usr/bin/g++
|
||||
if [ "$OSNAME" == "centos" ] && [ "$VERSION_ID" == "7" ];then
|
||||
yum install -y libudev-devel
|
||||
yum install -y centos-release-scl
|
||||
yum install -y devtoolset-11-gcc devtoolset-11-gcc-c++ devtoolset-11-binutils
|
||||
|
||||
gcc --version
|
||||
WHERE_DIR_GCC=/opt/rh/devtoolset-11/root/usr/bin/gcc
|
||||
WHERE_DIR_GPP=/opt/rh/devtoolset-11/root/usr/bin/g++
|
||||
echo $WHERE_DIR_GCC
|
||||
echo $WHERE_DIR_GPP
|
||||
fi
|
||||
|
||||
if [ "$OSNAME" == "ubuntu" ];then
|
||||
apt install -y libudev-dev
|
||||
apt install -y libtirpc-dev
|
||||
apt install -y libssl-dev
|
||||
apt install -y libgssglue-dev
|
||||
apt install -y software-properties-common
|
||||
add-apt-repository -y ppa:ubuntu-toolchain-r/test
|
||||
|
||||
LIBTIRPC_VER=`pkg-config libtirpc --modversion`
|
||||
if [ ! -f ${mysqlDir}/libtirpc_1.3.3.orig.tar.bz2 ];then
|
||||
wget --no-check-certificate -O ${mysqlDir}/libtirpc_1.3.3.orig.tar.bz2 https://downloads.sourceforge.net/libtirpc/libtirpc-1.3.3.tar.bz2
|
||||
cd ${mysqlDir} && tar -jxvf libtirpc_1.3.3.orig.tar.bz2
|
||||
cd libtirpc-1.3.3 && ./configure
|
||||
fi
|
||||
|
||||
export PKG_CONFIG_PATH=/usr/lib/pkgconfig
|
||||
apt install -y gcc-11 g++-11
|
||||
WHERE_DIR_GCC=/usr/bin/gcc-11
|
||||
WHERE_DIR_GPP=/usr/bin/g++-11
|
||||
|
||||
|
||||
OPTIONS="${OPTIONS} -DFORCE_INSOURCE_BUILD=1"
|
||||
OPTIONS="${OPTIONS} -D_FORTIFY_SOURCE=2"
|
||||
fi
|
||||
|
||||
|
||||
if [ "$OSNAME" == "opensuse" ];then
|
||||
zypper install -y gcc11
|
||||
zypper install -y gcc11-c++
|
||||
|
||||
|
||||
WHERE_DIR_GCC=/usr/bin/gcc-11
|
||||
WHERE_DIR_GPP=/usr/bin/g++-11
|
||||
fi
|
||||
|
||||
if [ ! -d $serverPath/mysql ];then
|
||||
# -DCMAKE_CXX_STANDARD=17 \
|
||||
cd ${mysqlDir}/mysql-${VERSION} && ${INSTALL_CMD} \
|
||||
-DCMAKE_INSTALL_PREFIX=$serverPath/mysql \
|
||||
-DMYSQL_USER=mysql \
|
||||
-DMYSQL_TCP_PORT=3306 \
|
||||
-DMYSQL_UNIX_ADDR=/var/tmp/mysql.sock \
|
||||
-DWITH_MYISAM_STORAGE_ENGINE=1 \
|
||||
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
|
||||
-DWITH_MEMORY_STORAGE_ENGINE=1 \
|
||||
-DENABLED_LOCAL_INFILE=1 \
|
||||
-DWITH_PARTITION_STORAGE_ENGINE=1 \
|
||||
-DWITH_READLINE=1 \
|
||||
-DEXTRA_CHARSETS=all \
|
||||
-DDEFAULT_CHARSET=utf8mb4 \
|
||||
-DDEFAULT_COLLATION=utf8mb4_general_ci \
|
||||
-DDOWNLOAD_BOOST=1 \
|
||||
-DFORCE_INSOURCE_BUILD=1 \
|
||||
$OPTIONS \
|
||||
-DCMAKE_C_COMPILER=$WHERE_DIR_GCC \
|
||||
-DCMAKE_CXX_COMPILER=$WHERE_DIR_GPP \
|
||||
-DDOWNLOAD_BOOST=0 \
|
||||
-DWITH_BOOST=${mysqlDir}/mysql-${VERSION}/boost/
|
||||
make -j${cpuCore} && make install && make clean
|
||||
|
||||
if [ -d $serverPath/mysql ];then
|
||||
rm -rf ${mysqlDir}/mysql-${VERSION}
|
||||
echo '9.4' > $serverPath/mysql/version.pl
|
||||
echo "${VERSION}安装完成"
|
||||
else
|
||||
# rm -rf ${mysqlDir}/mysql-${VERSION}
|
||||
echo "${VERSION}安装失败"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
Uninstall_mysql()
|
||||
{
|
||||
rm -rf $serverPath/mysql
|
||||
echo '卸载完成'
|
||||
}
|
||||
|
||||
action=$1
|
||||
if [ "${1}" == "install" ];then
|
||||
Install_mysql
|
||||
else
|
||||
Uninstall_mysql
|
||||
fi
|
||||
@@ -4,11 +4,8 @@
|
||||
<div class="bt-w-menu">
|
||||
<p class="bgw" onclick="pluginService('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="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="pluginConfig('nezha', $('.plugin_version').attr('version'), 'conf');">配置文件</p>
|
||||
<p onclick="nezha.otherFunc();">维护功能</p>
|
||||
<p onclick="nezha.readme();">说明</p>
|
||||
</div>
|
||||
<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 io
|
||||
@@ -64,7 +65,7 @@ class App:
|
||||
return "Release failed {}".format(e)
|
||||
|
||||
def openPort(self):
|
||||
for i in ["9527", "5555"]:
|
||||
for i in ["8008"]:
|
||||
self.__release_port(i)
|
||||
return True
|
||||
|
||||
@@ -81,49 +82,36 @@ class App:
|
||||
path = self.getPluginDir() + "/init.d/nezha.tpl"
|
||||
return path
|
||||
|
||||
def getInitdAgentConfTpl(self):
|
||||
path = self.getPluginDir() + "/init.d/nezha-agent.tpl"
|
||||
return path
|
||||
def getDataDir(self):
|
||||
data = self.getServerDir()+"/dashboard/data/sqlite.db"
|
||||
return data
|
||||
|
||||
def getHomeDir(self):
|
||||
if mw.isAppleSystem():
|
||||
user = mw.execShell(
|
||||
"who | sed -n '2, 1p' |awk '{print $1}'")[0].strip()
|
||||
user = mw.execShell("who | sed -n '2, 1p' |awk '{print $1}'")[0].strip()
|
||||
return '/Users/' + user
|
||||
else:
|
||||
return '/root'
|
||||
|
||||
def getRunUser(self):
|
||||
if mw.isAppleSystem():
|
||||
user = mw.execShell(
|
||||
"who | sed -n '2, 1p' |awk '{print $1}'")[0].strip()
|
||||
user = mw.execShell("who | sed -n '2, 1p' |awk '{print $1}'")[0].strip()
|
||||
return user
|
||||
else:
|
||||
return 'root'
|
||||
|
||||
def status(self):
|
||||
cmd = "ps -ef|grep " + self.getPluginName() + \
|
||||
" |grep -v grep | grep -v nezha-agent | grep -v python | awk '{print $2}'"
|
||||
cmd = "ps -ef|grep nezha/dashboard |grep -v grep | grep -v python | awk '{print $2}'"
|
||||
data = mw.execShell(cmd)
|
||||
# mw.writeFileLog("data[0]:"+data[0])
|
||||
if data[0] == '':
|
||||
return "stop"
|
||||
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):
|
||||
|
||||
service_path = mw.getServerDir()
|
||||
content = content.replace('{$ROOT_PATH}', mw.getFatherDir())
|
||||
content = content.replace('{$SERVER_PATH}', service_path)
|
||||
content = content.replace('{$RUN_USER}', self.getRunUser())
|
||||
content = content.replace('{$HOME_DIR}', self.getHomeDir())
|
||||
|
||||
return content
|
||||
|
||||
def initDreplace(self):
|
||||
@@ -146,8 +134,8 @@ class App:
|
||||
|
||||
# systemd
|
||||
systemDir = mw.systemdCfgDir()
|
||||
systemService = systemDir + '/nezha.service'
|
||||
systemServiceTpl = self.getPluginDir() + '/init.d/nezha.service.tpl'
|
||||
systemService = systemDir + '/nezha-dashboard.service'
|
||||
systemServiceTpl = self.getPluginDir() + '/init.d/nezha-dashboard.service.tpl'
|
||||
if os.path.exists(systemDir) and not os.path.exists(systemService):
|
||||
service_path = mw.getServerDir()
|
||||
se_content = mw.readFile(systemServiceTpl)
|
||||
@@ -157,53 +145,11 @@ class App:
|
||||
|
||||
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):
|
||||
|
||||
file = self.initDreplace()
|
||||
|
||||
if not mw.isAppleSystem():
|
||||
cmd = 'systemctl {} {}'.format(method, self.getPluginName())
|
||||
cmd = 'systemctl {} {}'.format(method, "nezha-dashboard")
|
||||
data = mw.execShell(cmd)
|
||||
if data[1] == '':
|
||||
return 'ok'
|
||||
@@ -227,19 +173,6 @@ class App:
|
||||
return self.imOp('reload')
|
||||
|
||||
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)
|
||||
if data[1] == '':
|
||||
return 'ok'
|
||||
@@ -258,105 +191,59 @@ class App:
|
||||
return self.agentOp('reload')
|
||||
|
||||
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)
|
||||
if data[0] == '':
|
||||
return 'fail'
|
||||
return 'ok'
|
||||
|
||||
def initd_install(self):
|
||||
mw.execShell('systemctl enable nezha')
|
||||
mw.execShell('systemctl enable nezha-dashboard')
|
||||
return 'ok'
|
||||
|
||||
def initd_uninstall(self):
|
||||
mw.execShell('systemctl disable nezha')
|
||||
mw.execShell('systemctl disable nezha-dashboard')
|
||||
return 'ok'
|
||||
|
||||
def initd_status_agent(self):
|
||||
cmd = 'systemctl status nezha-agent | grep loaded | grep "enabled;"'
|
||||
data = mw.execShell(cmd)
|
||||
if data[0] == '':
|
||||
return 'fail'
|
||||
return 'ok'
|
||||
def getVersion(self):
|
||||
ver_file = self.getServerDir()+"/version.pl"
|
||||
return mw.readFile(ver_file).strip()
|
||||
|
||||
def initd_install_agent(self):
|
||||
mw.execShell('systemctl enable nezha-agent')
|
||||
return 'ok'
|
||||
def uninstall_pre_inspection(self):
|
||||
version = self.getVersion()
|
||||
data_dir = self.getDataDir()
|
||||
if os.path.exists(data_dir):
|
||||
self.stop()
|
||||
if mw.isDebugMode():
|
||||
return 'ok'
|
||||
|
||||
def initd_uninstall_agent(self):
|
||||
mw.execShell('systemctl disable nezha-agent')
|
||||
return 'ok'
|
||||
from utils.plugin import plugin as MwPlugin
|
||||
MwPlugin.instance().removeIndex(self.getPluginName(), version)
|
||||
|
||||
return "请手动删除NEZHA[{}]<br/> rm -rf {}".format(version, self.getServerDir())
|
||||
|
||||
def conf(self):
|
||||
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):
|
||||
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__":
|
||||
func = sys.argv[1]
|
||||
|
||||
@@ -1,17 +1,19 @@
|
||||
{
|
||||
"sort": 7,
|
||||
"ps": "哪吒监控面板/改造版",
|
||||
"ps": "哪吒监控面板",
|
||||
"name": "nezha",
|
||||
"title": "哪吒监控",
|
||||
"shell": "install.sh",
|
||||
"versions":["0.15.2"],
|
||||
"versions":["2.2.5","2.2.6","latest"],
|
||||
"tip": "soft",
|
||||
"checks": "server/nezha",
|
||||
"path": "server/nezha",
|
||||
"coexist": false,
|
||||
"uninstall_pre_inspection":true,
|
||||
"display": 1,
|
||||
"author": "midoks",
|
||||
"date": "2023-06-26",
|
||||
"home": "https://github.com/midoks/nezha",
|
||||
"home": "https://github.com/nezhahq/nezha",
|
||||
"doc1": "https://nezha.wiki/",
|
||||
"type": 0,
|
||||
"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
|
||||
#Group=root
|
||||
WorkingDirectory={$SERVER_PATH}/nezha/dashboard/
|
||||
ExecStart={$SERVER_PATH}/nezha/dashboard/nezha web
|
||||
ExecStart={$SERVER_PATH}/nezha/dashboard/app
|
||||
Restart=always
|
||||
#Environment=DEBUG=true
|
||||
|
||||
@@ -2,6 +2,16 @@
|
||||
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
|
||||
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`
|
||||
rootPath=$(dirname "$curPath")
|
||||
rootPath=$(dirname "$rootPath")
|
||||
@@ -30,12 +40,4 @@ if [ "${action}" == "uninstall" ];then
|
||||
rm -rf /lib/systemd/system/nezha.service
|
||||
systemctl daemon-reload
|
||||
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
|
||||
|
||||
+17
-88
@@ -31,14 +31,6 @@ var nezha = {
|
||||
}
|
||||
|
||||
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'){
|
||||
callback(ret_data);
|
||||
}
|
||||
@@ -82,102 +74,39 @@ var nezha = {
|
||||
}
|
||||
},'json');
|
||||
},
|
||||
|
||||
repeatPwd:function (a, id) {
|
||||
$("#"+id).val(randomStrPwd(a))
|
||||
},
|
||||
|
||||
save_cfg:function(version){
|
||||
var username = $("input[name='username']").val();
|
||||
var password = $("input[name='password']").val();
|
||||
|
||||
this.send({
|
||||
tips:'正在设置中...',
|
||||
data:{'username':username,'password':password},
|
||||
method:'nezha_save_cfg',
|
||||
otherFunc:function(){
|
||||
var con = '<p class="conf_p" style="text-align:center;">\
|
||||
<button class="btn btn-default btn-sm" onclick="nezha.cronAddCheck()">添加更新任务</button>\
|
||||
<button class="btn btn-default btn-sm" onclick="nezha.cronDelCheck()">删除更新任务</button>\
|
||||
</p>';
|
||||
$(".soft-man-con").html(con);
|
||||
},
|
||||
cronAddCheck: function(){
|
||||
nezha.send({
|
||||
tips:"请求中...",
|
||||
method: "cron_add_check",
|
||||
success:function(rdata){
|
||||
layer.msg(rdata.msg, { icon: rdata.status ? 1 : 2 });
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
cfg:function(version){
|
||||
this.send({
|
||||
tips:'正在获取中...',
|
||||
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',
|
||||
cronDelCheck:function(){
|
||||
nezha.send({
|
||||
tips:"请求中...",
|
||||
method: "cron_del_check",
|
||||
success:function(rdata){
|
||||
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 (){
|
||||
var readme = '<ul class="help-info-text c7">';
|
||||
readme += '<li>安装时不会自动启动。</li>';
|
||||
readme += '<li>哪吒面板是改造版,用户名和密码登录【面板配置】,不依赖github/gitee/gitlab。</li>';
|
||||
readme += '<li>Agent需要先手动填写正确信息。</li>';
|
||||
readme += '<li>默认用户和密码(admin:admin),务必在第一时间修改</li>';
|
||||
readme += '<li>经测试,修改(admin)密码后,需清空cookie,才能正常登录</li>';
|
||||
readme += '</ul>';
|
||||
$('.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,105 @@
|
||||
#!/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"
|
||||
|
||||
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
|
||||
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 "$NUMBER_LATEST_VERSION" > /www/server/nezha/version.pl
|
||||
fi
|
||||
echo "ok"
|
||||
+84
-62
@@ -7,52 +7,90 @@ rootPath=$(dirname "$curPath")
|
||||
rootPath=$(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 0.15.2
|
||||
# cd /Users/midoks/Desktop/mwdev/server/mdserver-web/plugins/nezha && bash install.sh install 0.15.2
|
||||
# cd /www/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 2.2.5
|
||||
|
||||
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() {
|
||||
TMP_ARCH=`arch`
|
||||
if [ "$TMP_ARCH" == "x86_64" ];then
|
||||
ARCH="amd64"
|
||||
elif [ "$TMP_ARCH" == "aarch64" ];then
|
||||
ARCH="arm64"
|
||||
else
|
||||
echo $ARCH
|
||||
fi
|
||||
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
|
||||
# China_IP
|
||||
# if [[ -z "${CN}" ]]; then
|
||||
# if [[ $(curl -m 10 -s https://ipapi.co/json | grep 'China') != "" ]]; then
|
||||
# CN=true
|
||||
# fi
|
||||
# fi
|
||||
|
||||
if [[ -z "${CN}" ]]; then
|
||||
GITHUB_RAW_URL="raw.githubusercontent.com/midoks/nezha/main"
|
||||
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
|
||||
GITHUB_RAW_URL="raw.githubusercontent.com/nezhahq/nezha/main"
|
||||
GITHUB_URL="github.com"
|
||||
}
|
||||
|
||||
# download file
|
||||
@@ -82,44 +120,29 @@ download_file() {
|
||||
|
||||
Install_dashborad(){
|
||||
echo '正在安装哪吒监控...'
|
||||
mkdir -p $serverPath/source
|
||||
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_URL="https://${GITHUB_URL}/midoks/nezha/releases/download/v${VERSION}/nezha-${OS}-${ARCH}.zip"
|
||||
DOWNLOAD_FILE="$nezhaDir/$filename"
|
||||
|
||||
DOWNLOAD_FILE="$(mktemp).zip"
|
||||
download_file $DOWNLOAD_URL $DOWNLOAD_FILE
|
||||
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
|
||||
rm -rf $DOWNLOAD_FILE
|
||||
fi
|
||||
echo "TARGET_DIR:"$TARGET_DIR
|
||||
|
||||
}
|
||||
|
||||
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
|
||||
if [ ! -f $TARGET_DIR/app ];then
|
||||
cd $TARGET_DIR && mv dashboard-linux-${ARCH} app && chmod +x app
|
||||
fi
|
||||
|
||||
unzip $DOWNLOAD_FILE -d $AGENT_TARGET_DIR
|
||||
|
||||
rm -rf $DOWNLOAD_FILE
|
||||
fi
|
||||
}
|
||||
@@ -128,25 +151,24 @@ Install_App()
|
||||
{
|
||||
load_vars
|
||||
get_arch
|
||||
check_init
|
||||
|
||||
Install_dashborad
|
||||
Install_agent
|
||||
|
||||
if [ -d $serverPath/nezha ];then
|
||||
echo "$VERSION" > $serverPath/nezha/version.pl
|
||||
cd ${rootPath} && python3 ${rootPath}/plugins/nezha/index.py init_cfg
|
||||
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 initd_uninstall_agent
|
||||
cd ${rootPath} && python3 ${rootPath}/plugins/nezha/index.py stop
|
||||
cd ${rootPath} && python3 ${rootPath}/plugins/nezha/index.py stop_agent
|
||||
rm -rf $serverPath/nezha
|
||||
echo "install fail"
|
||||
echo "uninstall successful"
|
||||
}
|
||||
|
||||
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
|
||||
@@ -27,6 +27,34 @@ function owPostN(method, args, callback){
|
||||
},'json');
|
||||
}
|
||||
|
||||
function owPostCallback(method, version, args,callback){
|
||||
var loadT = layer.msg('正在获取...', { icon: 16, time: 0, shade: 0.3 });
|
||||
|
||||
var req_data = {};
|
||||
req_data['name'] = 'op_waf';
|
||||
req_data['script']='op_waf_index';
|
||||
req_data['func'] = method;
|
||||
args['version'] = version;
|
||||
|
||||
if (typeof(args) == 'string'){
|
||||
req_data['args'] = JSON.stringify(str2Obj(args));
|
||||
} else {
|
||||
req_data['args'] = JSON.stringify(args);
|
||||
}
|
||||
|
||||
$.post('/plugins/callback', req_data, function(data) {
|
||||
layer.close(loadT);
|
||||
if (!data.status){
|
||||
layer.msg(data.msg,{icon:0,time:2000,shade: [0.3, '#000']});
|
||||
return;
|
||||
}
|
||||
|
||||
if(typeof(callback) == 'function'){
|
||||
callback(data);
|
||||
}
|
||||
},'json');
|
||||
}
|
||||
|
||||
|
||||
function getRuleByName(rule_name, callback){
|
||||
owPost('get_rule', {rule_name:rule_name}, function(data){
|
||||
@@ -1593,7 +1621,7 @@ function siteWafConfig(siteName, type) {
|
||||
|
||||
|
||||
function wafSite(){
|
||||
owPost('get_site_config', {}, function(data){
|
||||
owPostCallback('get_site_config', "", {}, function(data){
|
||||
var tmp = $.parseJSON(data.data);
|
||||
var rdata = $.parseJSON(tmp.data);
|
||||
var tbody = '';
|
||||
|
||||
Executable
+1458
File diff suppressed because it is too large
Load Diff
@@ -37,8 +37,8 @@ http
|
||||
client_max_body_size 20m;
|
||||
|
||||
# video big file opt
|
||||
aio threads;
|
||||
directio 4m;
|
||||
#aio threads;
|
||||
#directio 4m;
|
||||
output_buffers 16 512k;
|
||||
sendfile on;
|
||||
tcp_nopush on;
|
||||
@@ -55,18 +55,18 @@ http
|
||||
fastcgi_temp_file_write_size 256k;
|
||||
fastcgi_intercept_errors on;
|
||||
|
||||
zstd off;
|
||||
zstd_comp_level 6;
|
||||
zstd_min_length 256;
|
||||
zstd_types text/plain text/css text/xml text/javascript text/cache-manifest text/x-component text/vtt application/javascript application/json application/ld+json application/xml application/xhtml+xml application/rss+xml application/atom+xml application/manifest+json application/x-web-app-manifest+json application/vnd.geo+json application/vnd.ms-fontobject application/x-font-ttf application/wasm font/opentype image/svg+xml image/bmp;
|
||||
#zstd off;
|
||||
#zstd_comp_level 6;
|
||||
#zstd_min_length 256;
|
||||
#zstd_types text/plain text/css text/xml text/javascript text/cache-manifest text/x-component text/vtt application/javascript application/json application/ld+json application/xml application/xhtml+xml application/rss+xml application/atom+xml application/manifest+json application/x-web-app-manifest+json application/vnd.geo+json application/vnd.ms-fontobject application/x-font-ttf application/wasm font/opentype image/svg+xml image/bmp;
|
||||
|
||||
brotli off;
|
||||
brotli_min_length 256;
|
||||
brotli_buffers 32 8k;
|
||||
brotli_comp_level 4;
|
||||
brotli_window 16m;
|
||||
brotli_static on;
|
||||
brotli_types text/plain text/css text/xml text/javascript text/x-component application/javascript application/x-javascript application/json application/xml application/rss+xml application/atom+xml application/vnd.ms-fontobject application/x-font-ttf application/x-font-opentype application/x-font-truetype font/tpl font/opentype font/otf font/ttf image/svg+xml image/x-icon image/vnd.microsoft.icon application/wasm application/manifest+json;
|
||||
#brotli off;
|
||||
#brotli_min_length 256;
|
||||
#brotli_buffers 32 8k;
|
||||
#brotli_comp_level 4;
|
||||
#brotli_window 16m;
|
||||
#brotli_static on;
|
||||
#brotli_types text/plain text/css text/xml text/javascript text/x-component application/javascript application/x-javascript application/json application/xml application/rss+xml application/atom+xml application/vnd.ms-fontobject application/x-font-ttf application/x-font-opentype application/x-font-truetype font/tpl font/opentype font/otf font/ttf image/svg+xml image/x-icon image/vnd.microsoft.icon application/wasm application/manifest+json;
|
||||
|
||||
gzip on;
|
||||
gzip_min_length 1k;
|
||||
|
||||
@@ -439,6 +439,7 @@ def runInfo():
|
||||
data['Reading'] = tmp[11]
|
||||
data['Writing'] = tmp[13]
|
||||
data['Waiting'] = tmp[15]
|
||||
data["time"] = time.time()
|
||||
return mw.getJson(data)
|
||||
except Exception as e:
|
||||
try:
|
||||
@@ -453,6 +454,7 @@ def runInfo():
|
||||
data['Reading'] = tmp[11]
|
||||
data['Writing'] = tmp[13]
|
||||
data['Waiting'] = tmp[15]
|
||||
data["time"] = time.time()
|
||||
return mw.getJson(data)
|
||||
except Exception as e:
|
||||
return mw.returnJson(False, "oprenresty异常!")
|
||||
@@ -577,6 +579,31 @@ def setCfg():
|
||||
if not re.search(r"\d+", v):
|
||||
return mw.returnJson(False, '参数值错误,请输入数字整数')
|
||||
|
||||
if k == "brotli":
|
||||
if v == "on":
|
||||
# 批量替换所有以 #brotli 等开头的指令为 brotli
|
||||
rep_var = r"#+brotli[\w_]*\s+[^\;\n]+"
|
||||
newconf = lambda m: m.group(0).lstrip('#')
|
||||
content = re.sub(rep_var, newconf, content)
|
||||
if v == "off":
|
||||
# 批量替换所有以 brotli 开头且没有 # 前缀的指令为 #brotli
|
||||
rep_var = r"(?<!#)brotli[\w_]*\s+[^\;\n]+"
|
||||
newconf = lambda m: '#' + m.group(0)
|
||||
content = re.sub(rep_var, newconf, content)
|
||||
|
||||
|
||||
if k == "zstd":
|
||||
if v == "on":
|
||||
# 批量替换所有以 #zstd 开头的指令为 zstd
|
||||
rep_var = r"#+zstd[\w_]*\s+[^\;\n]+"
|
||||
newconf = lambda m: m.group(0).lstrip('#')
|
||||
content = re.sub(rep_var, newconf, content)
|
||||
if v == "off":
|
||||
# 批量替换所有以 zstd 开头且没有 # 前缀的指令为 #zstd
|
||||
rep_var = r"(?<!#)zstd[\w_]*\s+[^\;\n]+"
|
||||
newconf = lambda m: '#' + m.group(0)
|
||||
content = re.sub(rep_var, newconf, content)
|
||||
|
||||
if k == "worker_processes" :
|
||||
k_wca = "worker_cpu_affinity"
|
||||
rep_wca = r"%s\s+[^\;\n]+" % k_wca
|
||||
|
||||
@@ -13,6 +13,6 @@
|
||||
"home":"http://openresty.org",
|
||||
"date":"2017-11-24",
|
||||
"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"]
|
||||
}
|
||||
@@ -2,10 +2,10 @@
|
||||
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.21.4
|
||||
# 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.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: zstd" http://localhost
|
||||
@@ -14,6 +14,9 @@ export PATH
|
||||
# apt install ncat -y
|
||||
# nc -u -v www.xx.com 443
|
||||
|
||||
# /www/server/openresty/bin/openresty -v
|
||||
# service openresty restart
|
||||
|
||||
# cd /www/server/mdserver-web && python3 plugins/openresty/index.py run_info
|
||||
|
||||
curPath=`pwd`
|
||||
|
||||
@@ -109,36 +109,119 @@ function orPluginOpServiceOp(a,b,c,d,a,v,request_callback){
|
||||
});
|
||||
}
|
||||
|
||||
var optmp_status = null;
|
||||
var optmp_timer = null;
|
||||
|
||||
//查看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 });
|
||||
$.post('/plugins/run', {name:'openresty', func:'run_info'}, function(data) {
|
||||
layer.close(loadT);
|
||||
layer.close(loadT);
|
||||
try {
|
||||
var rdata = $.parseJSON(data.data);
|
||||
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;
|
||||
}
|
||||
|
||||
var con = "<div><table class='table table-hover table-bordered'>\
|
||||
<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>\
|
||||
</table></div>";
|
||||
$(".soft-man-con").html(con);
|
||||
}catch(err){
|
||||
showMsg(data.data, function(){}, null,3000);
|
||||
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>\
|
||||
<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 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(){
|
||||
orPost('get_cfg', {}, function(data){
|
||||
var rdata = $.parseJSON(data.data);
|
||||
|
||||
@@ -133,14 +133,22 @@ Install_openresty()
|
||||
fi
|
||||
|
||||
OPTIONS="${OPTIONS} --with-threads"
|
||||
OPTIONS="${OPTIONS} --with-file-aio"
|
||||
OPTIONS="${OPTIONS} --with-pcre-jit"
|
||||
OPTIONS="${OPTIONS} --with-http_gzip_static_module"
|
||||
|
||||
if [ ! -d ${openrestyDir}/zstd-nginx-module ];then
|
||||
if [ "$sysName" != "Darwin" ];then
|
||||
OPTIONS="${OPTIONS} --with-file-aio"
|
||||
fi
|
||||
|
||||
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"
|
||||
|
||||
@@ -134,14 +134,22 @@ Install_openresty()
|
||||
fi
|
||||
|
||||
OPTIONS="${OPTIONS} --with-threads"
|
||||
OPTIONS="${OPTIONS} --with-file-aio"
|
||||
OPTIONS="${OPTIONS} --with-pcre-jit"
|
||||
OPTIONS="${OPTIONS} --with-http_gzip_static_module"
|
||||
|
||||
if [ ! -d ${openrestyDir}/zstd-nginx-module ];then
|
||||
if [ "$sysName" != "Darwin" ];then
|
||||
OPTIONS="${OPTIONS} --with-file-aio"
|
||||
fi
|
||||
|
||||
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"
|
||||
|
||||
@@ -133,14 +133,22 @@ Install_openresty()
|
||||
fi
|
||||
|
||||
OPTIONS="${OPTIONS} --with-threads"
|
||||
OPTIONS="${OPTIONS} --with-file-aio"
|
||||
OPTIONS="${OPTIONS} --with-pcre-jit"
|
||||
OPTIONS="${OPTIONS} --with-http_gzip_static_module"
|
||||
|
||||
if [ ! -d ${openrestyDir}/zstd-nginx-module ];then
|
||||
if [ "$sysName" != "Darwin" ];then
|
||||
OPTIONS="${OPTIONS} --with-file-aio"
|
||||
fi
|
||||
|
||||
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"
|
||||
|
||||
@@ -149,14 +149,22 @@ Install_openresty()
|
||||
fi
|
||||
|
||||
OPTIONS="${OPTIONS} --with-threads"
|
||||
OPTIONS="${OPTIONS} --with-file-aio"
|
||||
OPTIONS="${OPTIONS} --with-pcre-jit"
|
||||
OPTIONS="${OPTIONS} --with-http_gzip_static_module"
|
||||
|
||||
if [ ! -d ${openrestyDir}/zstd-nginx-module ];then
|
||||
if [ "$sysName" != "Darwin" ];then
|
||||
OPTIONS="${OPTIONS} --with-file-aio"
|
||||
fi
|
||||
|
||||
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"
|
||||
|
||||
@@ -132,22 +132,31 @@ Install_openresty()
|
||||
fi
|
||||
|
||||
# br
|
||||
if [ ! -d ${openrestyDir}/openresty-${VERSION}/ngx_brotli ];then
|
||||
cd ${openrestyDir}/openresty-${VERSION} && git clone https://github.com/wxx9248/ngx_brotli.git
|
||||
cd ${openrestyDir}/openresty-${VERSION}/ngx_brotli && git submodule update --init
|
||||
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}/openresty-${VERSION}/ngx_brotli"
|
||||
OPTIONS="${OPTIONS} --add-module=${openrestyDir}/ngx_brotli"
|
||||
fi
|
||||
|
||||
OPTIONS="${OPTIONS} --with-threads"
|
||||
OPTIONS="${OPTIONS} --with-file-aio"
|
||||
OPTIONS="${OPTIONS} --with-pcre-jit"
|
||||
OPTIONS="${OPTIONS} --with-http_gzip_static_module"
|
||||
|
||||
if [ ! -d ${openrestyDir}/zstd-nginx-module ];then
|
||||
|
||||
if [ "$sysName" != "Darwin" ];then
|
||||
OPTIONS="${OPTIONS} --with-file-aio"
|
||||
fi
|
||||
|
||||
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"
|
||||
|
||||
@@ -14,7 +14,7 @@ sysName=`uname`
|
||||
action=$1
|
||||
type=$2
|
||||
|
||||
VERSION=1.29.2.3
|
||||
VERSION=1.29.2.5
|
||||
|
||||
openrestyDir=${serverPath}/source/openresty
|
||||
|
||||
@@ -140,15 +140,23 @@ Install_openresty()
|
||||
fi
|
||||
|
||||
OPTIONS="${OPTIONS} --with-threads"
|
||||
OPTIONS="${OPTIONS} --with-file-aio"
|
||||
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 ];then
|
||||
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"
|
||||
@@ -195,9 +203,9 @@ Install_openresty()
|
||||
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/zstd-nginx-module-master ];then
|
||||
# rm -rf $openrestyDir/zstd-nginx-module-master
|
||||
# fi
|
||||
|
||||
# if [ -d $openrestyDir/ngx_brotli ];then
|
||||
# rm -rf $openrestyDir/ngx_brotli
|
||||
|
||||
@@ -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
|
||||
export PATH
|
||||
|
||||
# cd /Users/midoks/Desktop/mwdev/server/mdserver-web/plugins/openresty && bash install.sh install 1.27.1.1
|
||||
# cd /www/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 rtmp
|
||||
|
||||
curPath=`pwd`
|
||||
rootPath=$(dirname "$curPath")
|
||||
@@ -14,7 +14,7 @@ sysName=`uname`
|
||||
action=$1
|
||||
type=$2
|
||||
|
||||
VERSION=1.27.1.2
|
||||
VERSION=1.29.2.5
|
||||
|
||||
openrestyDir=${serverPath}/source/openresty
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ expect {
|
||||
expect eof
|
||||
EOF
|
||||
|
||||
pids=$(ps aux | grep 'pgAdmin4:app' | grep -v grep | awk '{print $2}')
|
||||
pids=$(ps -ef | grep 'pgAdmin4:app' | grep -v grep | awk '{print $2}')
|
||||
arr=($pids)
|
||||
for p in ${arr[@]}
|
||||
do
|
||||
|
||||
@@ -76,11 +76,16 @@ def getFpmFile(version):
|
||||
|
||||
def status(version):
|
||||
# ps -ef|grep 'php/81' |grep -v grep | grep -v python | awk '{print $2}
|
||||
cmd = "ps -ef|grep 'php/" + version + "' |grep -v grep | grep -v python | awk '{print $2}'"
|
||||
data = mw.execShell(cmd)
|
||||
if data[0] == '':
|
||||
return 'stop'
|
||||
return 'start'
|
||||
# cmd = "ps -ef|grep 'php/" + version + "' |grep -v grep | grep -v python | awk '{print $2}'"
|
||||
# data = mw.execShell(cmd)
|
||||
# if data[0] == '':
|
||||
# return 'stop'
|
||||
# return 'start'
|
||||
pid_file = "/run/php/php{}-fpm.pid".format(version)
|
||||
if os.path.exists(pid_file):
|
||||
return 'start'
|
||||
return 'stop'
|
||||
|
||||
|
||||
|
||||
def contentReplace(content, version):
|
||||
|
||||
@@ -59,7 +59,7 @@ def getFpmConfFile(version):
|
||||
|
||||
def status_progress(version):
|
||||
# ps -ef|grep 'php/81' |grep -v grep | grep -v python | awk '{print $2}
|
||||
cmd = "ps aux|grep 'php/" + version + \
|
||||
cmd = "ps -ef|grep 'php/" + version + \
|
||||
"' |grep -v grep | grep -v python | awk '{print $2}'"
|
||||
data = mw.execShell(cmd)
|
||||
if data[0] == '':
|
||||
@@ -80,7 +80,7 @@ def status(version):
|
||||
sock文件判断是否启动
|
||||
'''
|
||||
sock = getPhpSocket(version)
|
||||
if sock.find(':'):
|
||||
if sock.find(':')>-1:
|
||||
return status_progress(version)
|
||||
|
||||
if not os.path.exists(sock):
|
||||
|
||||
@@ -88,7 +88,7 @@ def getFpmFile(version):
|
||||
|
||||
def status_progress(version):
|
||||
# ps -ef|grep 'php/81' |grep -v grep | grep -v python | awk '{print $2}
|
||||
cmd = "ps aux|grep 'php/" + version + \
|
||||
cmd = "ps -ef|grep 'php/" + version + \
|
||||
"' |grep -v grep | grep -v python | awk '{print $2}'"
|
||||
data = mw.execShell(cmd)
|
||||
if data[0] == '':
|
||||
@@ -109,7 +109,7 @@ def status(version):
|
||||
sock文件判断是否启动
|
||||
'''
|
||||
sock = getPhpSocket(version)
|
||||
if sock.find(':'):
|
||||
if sock.find(':')>-1:
|
||||
return status_progress(version)
|
||||
|
||||
if not os.path.exists(sock):
|
||||
|
||||
@@ -53,7 +53,7 @@ def getFpmConfFile(version):
|
||||
|
||||
def status_progress(version):
|
||||
# ps -ef|grep 'php/81' |grep -v grep | grep -v python | awk '{print $2}
|
||||
cmd = "ps aux|grep 'php/" + version + \
|
||||
cmd = "ps -ef|grep 'php/" + version + \
|
||||
"' |grep -v grep | grep -v python | awk '{print $2}'"
|
||||
data = mw.execShell(cmd)
|
||||
if data[0] == '':
|
||||
@@ -74,7 +74,7 @@ def status(version):
|
||||
sock文件判断是否启动
|
||||
'''
|
||||
sock = getPhpSocket(version)
|
||||
if sock.find(':'):
|
||||
if sock.find(':')>-1:
|
||||
return status_progress(version)
|
||||
|
||||
if not os.path.exists(sock):
|
||||
|
||||
@@ -16,19 +16,19 @@ SOURCE_ROOT=$rootPath/source/lib
|
||||
if [ ! -d ${SERVER_ROOT}/freetype_old ];then
|
||||
cd $SOURCE_ROOT
|
||||
|
||||
if [ ! -f $SOURCE_ROOT/freetype-2.7.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
|
||||
if [ ! -f $SOURCE_ROOT/freetype-2.8.1.tar.gz ];then
|
||||
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
|
||||
|
||||
if [ ! -d $SOURCE_ROOT/freetype-2.7.1 ];then
|
||||
tar zxvf freetype-2.7.1.tar.gz
|
||||
cd freetype-2.7.1
|
||||
if [ ! -d $SOURCE_ROOT/freetype-2.8.1 ];then
|
||||
tar zxvf freetype-2.8.1.tar.gz
|
||||
cd freetype-2.8.1
|
||||
else
|
||||
cd freetype-2.7.1
|
||||
cd freetype-2.8.1
|
||||
fi
|
||||
|
||||
./configure --prefix=${SERVER_ROOT}/freetype_old && make && make install
|
||||
cd $SOURCE_ROOT && rm -rf freetype-2.7.1
|
||||
cd $SOURCE_ROOT && rm -rf $SOURCE_ROOT/freetype-2.7.1
|
||||
cd $SOURCE_ROOT && rm -rf freetype-2.8.1
|
||||
cd $SOURCE_ROOT && rm -rf $SOURCE_ROOT/freetype-2.8.1
|
||||
#rm -rf freetype-2.7.1.tar.gz
|
||||
fi
|
||||
@@ -9,9 +9,9 @@ serverPath=$(dirname "$rootPath")
|
||||
sourcePath=${serverPath}/source
|
||||
sysName=`uname`
|
||||
|
||||
version=8.3.30
|
||||
version=8.3.31
|
||||
PHP_VER=83
|
||||
md5_file_ok=67f084d36852daab6809561a7c8023d130ca07fc6af8fb040684dd1414934d48
|
||||
md5_file_ok=66410cee07f4b2baeb0843140bb2a2b52ef930b5cf9b3d6e6d158b33aae8fa37
|
||||
Install_php()
|
||||
{
|
||||
#------------------------ install start ------------------------------------#
|
||||
|
||||
@@ -9,9 +9,9 @@ serverPath=$(dirname "$rootPath")
|
||||
sourcePath=${serverPath}/source
|
||||
sysName=`uname`
|
||||
|
||||
version=8.4.20
|
||||
version=8.4.22
|
||||
PHP_VER=84
|
||||
md5_file_ok=e454c6f7c89a42f41ebb06dc5c3578e8c8b5f1a3f0da6675665affab04e221f7
|
||||
md5_file_ok=696c0f6ad92e94c59059c1eb6e300842b8d050934226efcdf00f2a413cb083cf
|
||||
Install_php()
|
||||
{
|
||||
#------------------------ install start ------------------------------------#
|
||||
|
||||
@@ -9,9 +9,9 @@ serverPath=$(dirname "$rootPath")
|
||||
sourcePath=${serverPath}/source
|
||||
sysName=`uname`
|
||||
|
||||
version=8.5.5
|
||||
version=8.5.7
|
||||
PHP_VER=85
|
||||
md5_file_ok=95bec382f4bd00570a8ef52a58ec04d8d9b9a90494781f1c106d1b274a3902f2
|
||||
md5_file_ok=01ba2ed1c2658dacf91bebc8be6a4885f69b811c7993831fc48e26107ab29985
|
||||
Install_php()
|
||||
{
|
||||
#------------------------ install start ------------------------------------#
|
||||
|
||||
@@ -17,6 +17,9 @@ version=$2
|
||||
LIBNAME=gd
|
||||
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
|
||||
@@ -79,11 +82,24 @@ Install_lib()
|
||||
OPTIONS="$OPTIONS --with-xpm-dir"
|
||||
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`
|
||||
if [ "$find_ft2" == "" ];then
|
||||
if [ "$find_ft2" != "" ];then
|
||||
OPTIONS="$OPTIONS --with-freetype-dir=${serverPath}/lib/freetype_old"
|
||||
fi
|
||||
|
||||
|
||||
#--with-xpm
|
||||
# =${serverPath}/lib/freetype_old
|
||||
|
||||
@@ -51,7 +51,7 @@ Install_lib()
|
||||
echo "[opcache]" >> $serverPath/php/$version/etc/php.ini
|
||||
|
||||
if [ "$version" == "85" ];then
|
||||
echo "no zend_extension"
|
||||
echo "Force enable opcache in PHP 8.5+"
|
||||
else
|
||||
echo "zend_extension=${LIBNAME}.so" >> $serverPath/php/$version/etc/php.ini
|
||||
fi
|
||||
|
||||
@@ -38,7 +38,7 @@ pg_stop()
|
||||
|
||||
pg_status()
|
||||
{
|
||||
isStart=$(ps aux | grep 'postgres'| grep -v grep | grep -v 'postgresql status' | awk '{print $2}')
|
||||
isStart=$(ps -ef | grep 'postgres'| grep -v grep | grep -v 'postgresql status' | awk '{print $2}')
|
||||
if [ "$isStart" != '' ];then
|
||||
echo -e "\033[32mPostgreSQL (pid $isStart) already running\033[0m"
|
||||
else
|
||||
|
||||
@@ -84,7 +84,7 @@ def getPidFile():
|
||||
return tmp.groups()[0].strip()
|
||||
|
||||
def status():
|
||||
cmd = "ps aux|grep prometheus |grep -v grep | grep -v python | grep -v mdserver-web | awk '{print $2}'"
|
||||
cmd = "ps -ef|grep prometheus |grep -v grep | grep -v python | grep -v mdserver-web | awk '{print $2}'"
|
||||
data = mw.execShell(cmd)
|
||||
if data[0] == '':
|
||||
return 'stop'
|
||||
|
||||
@@ -114,7 +114,7 @@ def status():
|
||||
return 'stop'
|
||||
|
||||
# data = mw.execShell(
|
||||
# "ps aux|grep redis |grep -v grep | grep -v python | grep -v mdserver-web | awk '{print $2}'")
|
||||
# "ps -ef|grep redis |grep -v grep | grep -v python | grep -v mdserver-web | awk '{print $2}'")
|
||||
|
||||
# if data[0] == '':
|
||||
# return 'stop'
|
||||
|
||||
@@ -4,14 +4,14 @@
|
||||
"name": "redis",
|
||||
"title": "Redis",
|
||||
"shell": "install.sh",
|
||||
"versions":["4.0.14","5.0.14","6.0.20","6.2.21","7.0.15","7.2.13", "7.4.8", "8.0.6", "8.2.5", "8.4.2","8.6.1"],
|
||||
"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",
|
||||
"checks": "server/redis",
|
||||
"path": "server/redis",
|
||||
"display": 1,
|
||||
"author": "redis",
|
||||
"date": "2017-04-01",
|
||||
"home": "https://redis.io",
|
||||
"home": "https://download.redis.io/releases",
|
||||
"type": 0,
|
||||
"pid": "2"
|
||||
}
|
||||
|
||||
@@ -127,7 +127,7 @@ def getPidFile():
|
||||
|
||||
def status():
|
||||
data = mw.execShell(
|
||||
"ps aux|grep simpleping |grep -v grep | grep -v python | grep -v mdserver-web | awk '{print $2}'")
|
||||
"ps -ef|grep simpleping |grep -v grep | grep -v python | grep -v mdserver-web | awk '{print $2}'")
|
||||
|
||||
if data[0] == '':
|
||||
return 'stop'
|
||||
|
||||
@@ -74,11 +74,15 @@ def checkArgs(data, ck=[]):
|
||||
|
||||
|
||||
def status():
|
||||
data = mw.execShell(
|
||||
"ps -ef|grep supervisor | grep -v grep | grep -v index.py | awk '{print $2}'")
|
||||
if data[0] == '':
|
||||
return 'stop'
|
||||
return 'start'
|
||||
# data = mw.execShell(
|
||||
# "ps -ef|grep supervisor | grep -v grep | grep -v index.py | awk '{print $2}'")
|
||||
# if data[0] == '':
|
||||
# return 'stop'
|
||||
|
||||
pid_file = getServerDir() + "/run/supervisor.pid"
|
||||
if os.path.exists(pid_file):
|
||||
return "start"
|
||||
return 'stop'
|
||||
|
||||
|
||||
def initDreplace():
|
||||
|
||||
@@ -9,8 +9,12 @@ serverPath=$(dirname "$rootPath")
|
||||
|
||||
VERSION=$2
|
||||
|
||||
# cd /www/server/mdserver-web/plugins/supervisor && bash install.sh install 1.0
|
||||
# /www/server/mdserver-web/bin/supervisord -n -c /etc/supervisor/supervisord.conf
|
||||
# /www/server/mdserver-web/bin/supervisorctl -c /www/server/supervisor/supervisor.conf
|
||||
# cmd | status
|
||||
# systemctl status supervisor
|
||||
# journalctl -u supervisor -f
|
||||
|
||||
bash ${rootPath}/scripts/getos.sh
|
||||
OSNAME=`cat ${rootPath}/data/osname.pl`
|
||||
|
||||
@@ -23,13 +23,13 @@ fi
|
||||
|
||||
sys_start()
|
||||
{
|
||||
isStart=$(ps aux |grep -E "(system_safe)"|grep -v grep|grep -v '/bin/bash'|grep -v 'system_safe/system_safe.py start' | grep -v 'system_safe/system_safe.py reload' | grep -v 'system_safe/system_safe.py restart' | grep -v systemctl | grep -v '/bin/sh' | awk '{print $2}'|xargs)
|
||||
isStart=$(ps -ef |grep -E "(system_safe)"|grep -v grep|grep -v '/bin/bash'|grep -v 'system_safe/system_safe.py start' | grep -v 'system_safe/system_safe.py reload' | grep -v 'system_safe/system_safe.py restart' | grep -v systemctl | grep -v '/bin/sh' | awk '{print $2}'|xargs)
|
||||
if [ "$isStart" == '' ];then
|
||||
echo -e "Starting system_safe service... \c"
|
||||
cd $rootPath/mdserver-web
|
||||
nohup python3 plugins/system_safe/system_safe.py bg_start &> $mw_path/service.log &
|
||||
sleep 0.5
|
||||
isStart=$(ps aux |grep -E "(system_safe)"|grep -v grep|awk '{print $2}'|xargs)
|
||||
isStart=$(ps -ef |grep -E "(system_safe)"|grep -v grep|awk '{print $2}'|xargs)
|
||||
if [ "$isStart" == '' ];then
|
||||
echo -e "\033[31mfailed\033[0m"
|
||||
echo '------------------------------------------------------'
|
||||
@@ -47,7 +47,7 @@ sys_start()
|
||||
sys_stop()
|
||||
{
|
||||
echo -e "Stopping system_safe service... \c";
|
||||
pids=$(ps aux |grep -E "(system_safe)"|grep -v grep|grep -v '/bin/bash'|grep -v systemctl | grep -v 'system_safe/system_safe.py bg_stop'|grep -v 'system_safe/system_safe.py stop' | grep -v 'system_safe/system_safe.py reload' | grep -v 'system_safe/system_safe.py restart' |awk '{print $2}'|xargs)
|
||||
pids=$(ps -ef |grep -E "(system_safe)"|grep -v grep|grep -v '/bin/bash'|grep -v systemctl | grep -v 'system_safe/system_safe.py bg_stop'|grep -v 'system_safe/system_safe.py stop' | grep -v 'system_safe/system_safe.py reload' | grep -v 'system_safe/system_safe.py restart' |awk '{print $2}'|xargs)
|
||||
arr=($pids)
|
||||
for p in ${arr[@]}
|
||||
do
|
||||
@@ -60,7 +60,7 @@ sys_stop()
|
||||
|
||||
sys_status()
|
||||
{
|
||||
isStart=$(ps aux |grep -E "(system_safe)"|grep -v grep|grep -v systemctl|awk '{print $2}'|xargs)
|
||||
isStart=$(ps -ef |grep -E "(system_safe)"|grep -v grep|grep -v systemctl|awk '{print $2}'|xargs)
|
||||
if [ "$isStart" != '' ];then
|
||||
echo -e "\033[32msystem_safe service (pid $isStart) already running\033[0m"
|
||||
else
|
||||
|
||||
@@ -24,13 +24,13 @@ fi
|
||||
# cd /www/server/mdserver-web && python3 plugins/tamper_proof_py/tamper_proof_service.py start
|
||||
sys_start()
|
||||
{
|
||||
isStart=$(ps aux |grep -E "(tamper_proof_service)"|grep -v grep |grep -v 'tamper_proof_py/tamper_proof_service.py start' | grep -v 'tamper_proof_py/tamper_proof_service.py reload' | grep -v 'tamper_proof_py/tamper_proof_service.py restart' | grep -v systemctl | grep -v '/bin/sh' | grep -v '/bin/bash' | awk '{print $2}'|xargs)
|
||||
isStart=$(ps -ef |grep -E "(tamper_proof_service)"|grep -v grep |grep -v 'tamper_proof_py/tamper_proof_service.py start' | grep -v 'tamper_proof_py/tamper_proof_service.py reload' | grep -v 'tamper_proof_py/tamper_proof_service.py restart' | grep -v systemctl | grep -v '/bin/sh' | grep -v '/bin/bash' | awk '{print $2}'|xargs)
|
||||
if [ "$isStart" == '' ];then
|
||||
echo -e "Starting tamper_proof_service... \c"
|
||||
cd $rootPath/mdserver-web
|
||||
nohup python3 plugins/tamper_proof_py/tamper_proof_service.py start &> $mw_path/service.log &
|
||||
sleep 0.5
|
||||
isStart=$(ps aux |grep -E "(tamper_proof_service)"|grep -v grep|awk '{print $2}'|xargs)
|
||||
isStart=$(ps -ef |grep -E "(tamper_proof_service)"|grep -v grep|awk '{print $2}'|xargs)
|
||||
if [ "$isStart" == '' ];then
|
||||
echo -e "\033[31mfailed\033[0m"
|
||||
echo '------------------------------------------------------'
|
||||
@@ -48,7 +48,7 @@ sys_start()
|
||||
sys_stop()
|
||||
{
|
||||
echo -e "Stopping tamper_proof_service... \c";
|
||||
pids=$(ps aux |grep -E "(tamper_proof_service)"|grep -v grep|grep -v '/bin/bash'|grep -v systemctl | grep -v 'tamper_proof_py/tamper_proof_service.py stop' | grep -v 'tamper_proof_py/tamper_proof_service.py reload' | grep -v 'tamper_proof_py/tamper_proof_service.py restart' |awk '{print $2}'|xargs)
|
||||
pids=$(ps -ef |grep -E "(tamper_proof_service)"|grep -v grep|grep -v '/bin/bash'|grep -v systemctl | grep -v 'tamper_proof_py/tamper_proof_service.py stop' | grep -v 'tamper_proof_py/tamper_proof_service.py reload' | grep -v 'tamper_proof_py/tamper_proof_service.py restart' |awk '{print $2}'|xargs)
|
||||
arr=($pids)
|
||||
for p in ${arr[@]}
|
||||
do
|
||||
@@ -61,7 +61,7 @@ sys_stop()
|
||||
|
||||
sys_status()
|
||||
{
|
||||
isStart=$(ps aux |grep -E "(tamper_proof_service)"|grep -v grep|grep -v "init.d/tamper_proof_py"|grep -v systemctl|awk '{print $2}'|xargs)
|
||||
isStart=$(ps -ef |grep -E "(tamper_proof_service)"|grep -v grep|grep -v "init.d/tamper_proof_py"|grep -v systemctl|awk '{print $2}'|xargs)
|
||||
if [ "$isStart" != '' ];then
|
||||
echo -e "\033[32mtamper_proof_service (pid $isStart) already running\033[0m"
|
||||
else
|
||||
|
||||
@@ -625,7 +625,7 @@ class mainClass(object):
|
||||
if pid == self.panel_pid: return True
|
||||
if not self.task_pid:
|
||||
try:
|
||||
self.task_pid = int(mw.execShell("ps aux | grep 'python3 task.py' |grep -v grep|head -n1|awk '{print $2}'")[0])
|
||||
self.task_pid = int(mw.execShell("ps -ef | grep 'python3 task.py' |grep -v grep|head -n1|awk '{print $2}'")[0])
|
||||
except:
|
||||
self.task_pid = -1
|
||||
if pid == self.task_pid: return True
|
||||
|
||||
@@ -59,7 +59,7 @@ tg_start(){
|
||||
|
||||
tg_stop(){
|
||||
echo -e "stopping tgbot ... \c";
|
||||
arr=`ps aux|grep 'tgbot.py'|grep -v grep|awk '{print $2}'`
|
||||
arr=`ps -ef|grep 'tgbot.py'|grep -v grep|awk '{print $2}'`
|
||||
for p in ${arr[@]}
|
||||
do
|
||||
kill -9 $p > /dev/null 2>&1
|
||||
@@ -68,7 +68,7 @@ tg_stop(){
|
||||
|
||||
|
||||
echo -e "stopping tgpush ... \c";
|
||||
arr=`ps aux|grep 'tgpush.py'|grep -v grep|awk '{print $2}'`
|
||||
arr=`ps -ef|grep 'tgpush.py'|grep -v grep|awk '{print $2}'`
|
||||
for p in ${arr[@]}
|
||||
do
|
||||
kill -9 $p > /dev/null 2>&1
|
||||
|
||||
@@ -1,98 +0,0 @@
|
||||
# coding:utf-8
|
||||
|
||||
import sys
|
||||
import io
|
||||
import os
|
||||
import time
|
||||
import re
|
||||
import json
|
||||
import base64
|
||||
import threading
|
||||
|
||||
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
|
||||
|
||||
import telebot
|
||||
from telebot import types
|
||||
from telebot.util import quick_markup
|
||||
|
||||
# 广告推送实例
|
||||
|
||||
|
||||
chat_id = -1001578009023
|
||||
# chat_id = 5568699210
|
||||
|
||||
|
||||
def send_msg(bot, tag='ad', trigger_time=300):
|
||||
# 信号只在一个周期内执行一次|start
|
||||
lock_file = mw.getServerDir() + '/tgbot/lock.json'
|
||||
if not os.path.exists(lock_file):
|
||||
mw.writeFile(lock_file, '{}')
|
||||
|
||||
lock_data = json.loads(mw.readFile(lock_file))
|
||||
if tag in lock_data:
|
||||
diff_time = time.time() - lock_data[tag]['do_time']
|
||||
if diff_time >= trigger_time:
|
||||
lock_data[tag]['do_time'] = time.time()
|
||||
else:
|
||||
return False, 0, 0
|
||||
else:
|
||||
lock_data[tag] = {'do_time': time.time()}
|
||||
mw.writeFile(lock_file, json.dumps(lock_data))
|
||||
# 信号只在一个周期内执行一次|end
|
||||
keyboard = [
|
||||
[
|
||||
types.InlineKeyboardButton(
|
||||
text="海内外实名KYC-执照代付✅域名", url='https://t.me/kuadugongzuoshi')
|
||||
],
|
||||
[
|
||||
types.InlineKeyboardButton(
|
||||
text="高价收一切流量 @caifutong555", url='https://t.me/caifutong555')
|
||||
],
|
||||
[
|
||||
types.InlineKeyboardButton(
|
||||
text="18+资源采集", url='https://ckzy1.com')
|
||||
],
|
||||
[
|
||||
types.InlineKeyboardButton(
|
||||
text="代付-代实名-备案域名-国际云服务器", url='https://t.me/gjgzs2022')
|
||||
],
|
||||
[
|
||||
types.InlineKeyboardButton(
|
||||
text="实名认证/过人脸🕵️♀️各种账号处理✅", url='https://t.me/niuniu234')
|
||||
],
|
||||
[
|
||||
types.InlineKeyboardButton(
|
||||
text="官网", url='https://github.com/midoks/mdserver-web'),
|
||||
types.InlineKeyboardButton(
|
||||
text="💎DigitalVirt(赞助商)", url='https://digitalvirt.com/aff.php?aff=154')
|
||||
],
|
||||
[
|
||||
types.InlineKeyboardButton(
|
||||
text="论坛", url='https://bbs.midoks.icu'),
|
||||
types.InlineKeyboardButton(
|
||||
text="搜索", url='https://bbs.midoks.icu/search.php'),
|
||||
types.InlineKeyboardButton(
|
||||
text="@ME", url='tg://user?id=5568699210'),
|
||||
types.InlineKeyboardButton(
|
||||
text="300rmb/月", url='tg://user?id=5568699210')
|
||||
]
|
||||
]
|
||||
markup = types.InlineKeyboardMarkup(keyboard)
|
||||
image_file = mw.getPluginDir() + '/tgbot/static/image/ad.png'
|
||||
|
||||
telebot_image = telebot.types.InputFile(image_file)
|
||||
msg = bot.send_photo(chat_id, telebot_image, reply_markup=markup)
|
||||
|
||||
# print(msg.message_id)
|
||||
time.sleep(5 * 60)
|
||||
del_msg = bot.delete_message(chat_id=chat_id, message_id=msg.message_id)
|
||||
# print(del_msg)
|
||||
|
||||
|
||||
def run(bot):
|
||||
send_msg(bot, 'ad', 1 * 60 * 60)
|
||||
@@ -54,16 +54,11 @@ def send_msg(bot, tag='ad', trigger_time=300):
|
||||
mw.writeFile(lock_file, json.dumps(lock_data))
|
||||
# 信号只在一个周期内执行一次|end
|
||||
|
||||
# https://t.me/gjgzs2022 | 22/m | @GJ_gzs
|
||||
# 实名认证/过人脸🕵️♀️各种账号处理✅ | 30/m| next,6/30 | @nngzs
|
||||
# 18+资源采集| 4/m | next,7/14 | @liuxingyu123
|
||||
# 海内外实名KYC-执照代付✅域名| 17/m | next,6/17 | @kdgzs
|
||||
# 98影视采集| 21/m | next,11/21 | @liuxingyu123
|
||||
|
||||
keyboard = [
|
||||
[
|
||||
types.InlineKeyboardButton(
|
||||
text="海内外实名KYC-执照代付✅域名", url='https://t.me/kuadugongzuoshi')
|
||||
],
|
||||
[
|
||||
types.InlineKeyboardButton(
|
||||
text="高价收一切流量 @caifutong555", url='https://t.me/caifutong555')
|
||||
@@ -72,10 +67,6 @@ def send_msg(bot, tag='ad', trigger_time=300):
|
||||
types.InlineKeyboardButton(
|
||||
text="18+资源采集", url='https://ckzy1.com')
|
||||
],
|
||||
[
|
||||
types.InlineKeyboardButton(
|
||||
text="代付-代实名-备案域名-国际云服务器", url='https://t.me/gjgzs2022')
|
||||
],
|
||||
[
|
||||
types.InlineKeyboardButton(
|
||||
text="实名认证/过人脸🕵️♀️各种账号处理✅", url='https://t.me/niuniu234')
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 974 B |
@@ -1,27 +0,0 @@
|
||||
<div class="bt-form">
|
||||
<div class='plugin_version'></div>
|
||||
<div class="bt-w-main">
|
||||
<div class="bt-w-menu">
|
||||
<p class="bgw" onclick="pluginService('tgclient');">服务</p>
|
||||
<p onclick="pluginInitD('tgclient');">自启动</p>
|
||||
<p onclick="clientConf();">配置</p>
|
||||
<p onclick="botExtList();">扩展列表</p>
|
||||
<p onclick="pluginLogs('tgclient','','run_log');">日志</p>
|
||||
<p onclick="readme();">说明</p>
|
||||
</div>
|
||||
<div class="bt-w-con pd15">
|
||||
<div class="soft-man-con"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<style>
|
||||
.conf_p span{
|
||||
width: 70px;
|
||||
}
|
||||
</style>
|
||||
<script type="text/javascript">
|
||||
resetPluginWinHeight(350);
|
||||
$.getScript( "/plugins/file?name=tgclient&f=js/tgclient.js", function(){
|
||||
pluginService('tgclient');
|
||||
});
|
||||
</script>
|
||||
@@ -1,375 +0,0 @@
|
||||
# coding:utf-8
|
||||
|
||||
import sys
|
||||
import io
|
||||
import os
|
||||
import time
|
||||
import re
|
||||
import json
|
||||
import base64
|
||||
|
||||
web_dir = os.getcwd() + "/web"
|
||||
if os.path.exists(web_dir):
|
||||
sys.path.append(web_dir)
|
||||
os.chdir(web_dir)
|
||||
|
||||
import core.mw as mw
|
||||
|
||||
app_debug = False
|
||||
if mw.isAppleSystem():
|
||||
app_debug = True
|
||||
|
||||
|
||||
def getPluginName():
|
||||
return 'tgclient'
|
||||
|
||||
|
||||
def getPluginDir():
|
||||
return mw.getPluginDir() + '/' + getPluginName()
|
||||
|
||||
|
||||
def getServerDir():
|
||||
return mw.getServerDir() + '/' + getPluginName()
|
||||
|
||||
|
||||
def getInitDFile():
|
||||
if app_debug:
|
||||
return '/tmp/' + getPluginName()
|
||||
return '/etc/init.d/' + getPluginName()
|
||||
|
||||
|
||||
def getConfigData():
|
||||
cfg_path = getServerDir() + "/data.cfg"
|
||||
if not os.path.exists(cfg_path):
|
||||
mw.writeFile(cfg_path, '{}')
|
||||
t = mw.readFile(cfg_path)
|
||||
return json.loads(t)
|
||||
|
||||
|
||||
def writeConf(data):
|
||||
cfg_path = getServerDir() + "/data.cfg"
|
||||
mw.writeFile(cfg_path, json.dumps(data))
|
||||
return True
|
||||
|
||||
|
||||
def getExtCfg():
|
||||
cfg_path = getServerDir() + "/extend.cfg"
|
||||
if not os.path.exists(cfg_path):
|
||||
mw.writeFile(cfg_path, '{}')
|
||||
t = mw.readFile(cfg_path)
|
||||
return json.loads(t)
|
||||
|
||||
|
||||
def writeExtCfg(data):
|
||||
cfg_path = getServerDir() + "/extend.cfg"
|
||||
return mw.writeFile(cfg_path, json.dumps(data))
|
||||
|
||||
|
||||
def getInitDTpl():
|
||||
path = getPluginDir() + "/init.d/" + getPluginName() + ".tpl"
|
||||
return path
|
||||
|
||||
|
||||
def getArgs():
|
||||
args = sys.argv[2:]
|
||||
tmp = {}
|
||||
args_len = len(args)
|
||||
if args_len == 1:
|
||||
t = args[0].strip('{').strip('}')
|
||||
if t.strip() == '':
|
||||
tmp = []
|
||||
else:
|
||||
t = t.split(':')
|
||||
tmp[t[0]] = t[1]
|
||||
tmp[t[0]] = t[1]
|
||||
elif args_len > 1:
|
||||
for i in range(len(args)):
|
||||
t = args[i].split(':')
|
||||
tmp[t[0]] = t[1]
|
||||
return tmp
|
||||
|
||||
|
||||
def checkArgs(data, ck=[]):
|
||||
for i in range(len(ck)):
|
||||
if not ck[i] in data:
|
||||
return (False, mw.returnJson(False, '参数:(' + ck[i] + ')没有!'))
|
||||
return (True, mw.returnJson(True, 'ok'))
|
||||
|
||||
|
||||
def status():
|
||||
data = mw.execShell(
|
||||
"ps -ef|grep tgclient |grep -v grep | grep -v mdserver-web | awk '{print $2}'")
|
||||
if data[0] == '':
|
||||
return 'stop'
|
||||
return 'start'
|
||||
|
||||
|
||||
def initDreplace():
|
||||
|
||||
file_tpl = getInitDTpl()
|
||||
service_path = mw.getServerDir()
|
||||
app_path = service_path + '/' + getPluginName()
|
||||
|
||||
initD_path = getServerDir() + '/init.d'
|
||||
if not os.path.exists(initD_path):
|
||||
os.mkdir(initD_path)
|
||||
file_bin = initD_path + '/' + getPluginName()
|
||||
|
||||
# initd replace
|
||||
# if not os.path.exists(file_bin):
|
||||
content = mw.readFile(file_tpl)
|
||||
content = content.replace('{$SERVER_PATH}', service_path + '/mdserver-web')
|
||||
content = content.replace('{$APP_PATH}', app_path)
|
||||
|
||||
mw.writeFile(file_bin, content)
|
||||
mw.execShell('chmod +x ' + file_bin)
|
||||
|
||||
pyMainTplContent = mw.readFile(getPluginDir() + '/startup/tgclient.py')
|
||||
toPyMainPath = mw.getServerDir() + '/tgclient.py'
|
||||
mw.writeFile(toPyMainPath, pyMainTplContent)
|
||||
|
||||
# systemd
|
||||
systemDir = mw.systemdCfgDir()
|
||||
systemService = systemDir + '/tgclient.service'
|
||||
systemServiceTpl = getPluginDir() + '/init.d/tgclient.service.tpl'
|
||||
if os.path.exists(systemDir) and not os.path.exists(systemService):
|
||||
service_path = mw.getServerDir()
|
||||
se_content = mw.readFile(systemServiceTpl)
|
||||
se_content = se_content.replace('{$APP_PATH}', app_path)
|
||||
mw.writeFile(systemService, se_content)
|
||||
mw.execShell('systemctl daemon-reload')
|
||||
|
||||
return file_bin
|
||||
|
||||
|
||||
def tbOp(method):
|
||||
file = initDreplace()
|
||||
|
||||
if not mw.isAppleSystem():
|
||||
data = mw.execShell('systemctl ' + method + ' ' + getPluginName())
|
||||
if data[1] == '':
|
||||
return 'ok'
|
||||
return data[1]
|
||||
|
||||
data = mw.execShell(file + ' ' + method)
|
||||
# print(data)
|
||||
if data[1] == '':
|
||||
return 'ok'
|
||||
return 'ok'
|
||||
|
||||
|
||||
def start():
|
||||
return tbOp('start')
|
||||
|
||||
|
||||
def stop():
|
||||
return tbOp('stop')
|
||||
|
||||
|
||||
def restart():
|
||||
status = tbOp('restart')
|
||||
return status
|
||||
|
||||
|
||||
def reload():
|
||||
|
||||
tgbot_tpl = getPluginDir() + '/startup/tgclient.py'
|
||||
tgbot_dst = getServerDir() + '/tgclient.py'
|
||||
|
||||
content = mw.readFile(tgbot_tpl)
|
||||
mw.writeFile(tgbot_dst, content)
|
||||
|
||||
ext_src = getPluginDir() + '/startup/extend'
|
||||
ext_dst = getServerDir()
|
||||
|
||||
mw.execShell('cp -rf ' + ext_src + ' ' + ext_dst)
|
||||
|
||||
return tbOp('restart')
|
||||
|
||||
|
||||
def initdStatus():
|
||||
if mw.isAppleSystem():
|
||||
return "Apple Computer does not support"
|
||||
|
||||
shell_cmd = 'systemctl status ' + \
|
||||
getPluginName() + ' | grep loaded | grep "enabled;"'
|
||||
data = mw.execShell(shell_cmd)
|
||||
if data[0] == '':
|
||||
return 'fail'
|
||||
return 'ok'
|
||||
|
||||
|
||||
def initdInstall():
|
||||
if mw.isAppleSystem():
|
||||
return "Apple Computer does not support"
|
||||
|
||||
mw.execShell('systemctl enable ' + getPluginName())
|
||||
return 'ok'
|
||||
|
||||
|
||||
def initdUinstall():
|
||||
if mw.isAppleSystem():
|
||||
return "Apple Computer does not support"
|
||||
|
||||
mw.execShell('systemctl disable ' + getPluginName())
|
||||
return 'ok'
|
||||
|
||||
|
||||
def getClientConf():
|
||||
data = getConfigData()
|
||||
if 'bot' in data:
|
||||
return mw.returnJson(True, 'ok', data['bot'])
|
||||
return mw.returnJson(False, 'ok', {})
|
||||
|
||||
|
||||
def setClientConf():
|
||||
args = getArgs()
|
||||
data_args = checkArgs(args, ['api_id', 'api_hash'])
|
||||
if not data_args[0]:
|
||||
return data_args[1]
|
||||
|
||||
data = getConfigData()
|
||||
args['api_id'] = base64.b64decode(args['api_id']).decode('ascii')
|
||||
args['api_hash'] = base64.b64decode(args['api_hash']).decode('ascii')
|
||||
data['bot'] = args
|
||||
writeConf(data)
|
||||
|
||||
return mw.returnJson(True, '保存成功!', [])
|
||||
|
||||
|
||||
def installPreInspection():
|
||||
i = sys.version_info
|
||||
if i[0] < 3 or i[1] < 7:
|
||||
return "telebot在python小于3.7无法正常使用"
|
||||
return 'ok'
|
||||
|
||||
|
||||
def uninstallPreInspection():
|
||||
stop()
|
||||
return "请手动删除<br/> rm -rf {}".format(getServerDir())
|
||||
|
||||
|
||||
def getExtCfgByName(name):
|
||||
elist = getExtCfg()
|
||||
for x in elist:
|
||||
if x['name'] == name:
|
||||
return x
|
||||
return None
|
||||
|
||||
|
||||
def clientExtList():
|
||||
|
||||
args = getArgs()
|
||||
data_args = checkArgs(args, ['p'])
|
||||
if not data_args[0]:
|
||||
return data_args[1]
|
||||
|
||||
ext_path = getServerDir() + '/extend'
|
||||
if not os.path.exists(ext_path):
|
||||
return mw.returnJson(False, 'ok', [])
|
||||
elist_source = os.listdir(ext_path)
|
||||
|
||||
elist = []
|
||||
for e in elist_source:
|
||||
if e.endswith('py'):
|
||||
elist.append(e)
|
||||
|
||||
page = int(args['p'])
|
||||
page_size = 5
|
||||
|
||||
make_ext_list = []
|
||||
for ex in elist:
|
||||
tmp = {}
|
||||
tmp['name'] = ex
|
||||
edata = getExtCfgByName(ex)
|
||||
if edata:
|
||||
tmp['status'] = edata['status']
|
||||
else:
|
||||
tmp['status'] = 'stop'
|
||||
|
||||
tmp['tag'] = ex.split('_')[0]
|
||||
make_ext_list.append(tmp)
|
||||
|
||||
writeExtCfg(make_ext_list)
|
||||
dlist_sum = len(make_ext_list)
|
||||
|
||||
page_start = int((page - 1) * page_size)
|
||||
page_end = page_start + page_size
|
||||
|
||||
if page_end >= dlist_sum:
|
||||
ret_data = make_ext_list[page_start:]
|
||||
else:
|
||||
ret_data = make_ext_list[page_start:page_end]
|
||||
|
||||
data = {}
|
||||
data['data'] = ret_data
|
||||
data['args'] = args
|
||||
data['list'] = mw.getPage(
|
||||
{'count': dlist_sum, 'p': page, 'row': page_size, 'tojs': 'botExtListP'})
|
||||
|
||||
return mw.returnJson(True, 'ok', data)
|
||||
|
||||
|
||||
def setExtStatus():
|
||||
args = getArgs()
|
||||
data_args = checkArgs(args, ['name', 'status'])
|
||||
if not data_args[0]:
|
||||
return data_args[1]
|
||||
|
||||
elist = getExtCfg()
|
||||
name = args['name']
|
||||
status = args['status']
|
||||
for x in range(len(elist)):
|
||||
if elist[x]['name'] == name:
|
||||
elist[x]['status'] = status
|
||||
break
|
||||
|
||||
writeExtCfg(elist)
|
||||
|
||||
action = '开启'
|
||||
if status == 'stop':
|
||||
action = '关闭'
|
||||
|
||||
return mw.returnJson(True, action + '[' + name + ']扩展成功')
|
||||
|
||||
|
||||
def runLog():
|
||||
p = getServerDir() + '/task.log'
|
||||
return p
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
func = sys.argv[1]
|
||||
if func == 'status':
|
||||
print(status())
|
||||
elif func == 'start':
|
||||
print(start())
|
||||
elif func == 'stop':
|
||||
print(stop())
|
||||
elif func == 'restart':
|
||||
print(restart())
|
||||
elif func == 'reload':
|
||||
print(reload())
|
||||
elif func == 'initd_status':
|
||||
print(initdStatus())
|
||||
elif func == 'initd_install':
|
||||
print(initdInstall())
|
||||
elif func == 'initd_uninstall':
|
||||
print(initdUinstall())
|
||||
elif func == 'install_pre_inspection':
|
||||
print(installPreInspection())
|
||||
elif func == 'uninstall_pre_inspection':
|
||||
print(uninstallPreInspection())
|
||||
elif func == 'get_client_conf':
|
||||
print(getClientConf())
|
||||
elif func == 'set_client_conf':
|
||||
print(setClientConf())
|
||||
elif func == 'client_ext_list':
|
||||
print(clientExtList())
|
||||
elif func == 'set_ext_status':
|
||||
print(setExtStatus())
|
||||
elif func == 'run_log':
|
||||
print(runLog())
|
||||
|
||||
else:
|
||||
print('error')
|
||||
@@ -1,20 +0,0 @@
|
||||
{
|
||||
"sort": 7,
|
||||
"ps": "简单Telegram客服端管理",
|
||||
"name": "tgclient",
|
||||
"title": "tgclient",
|
||||
"shell": "install.sh",
|
||||
"versions":["1.1"],
|
||||
"tip": "soft",
|
||||
"checks": "server/tgclient",
|
||||
"path": "server/tgclient",
|
||||
"install_pre_inspection":true,
|
||||
"uninstall_pre_inspection":true,
|
||||
"display": 1,
|
||||
"author": "midoks",
|
||||
"date": "2023-03-06",
|
||||
"home": "https://my.telegram.org/apps",
|
||||
"depend_doc1":"https://docs.telethon.dev/en/stable/basic/installation.html",
|
||||
"type": 0,
|
||||
"pid": "5"
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
[Unit]
|
||||
Description=Tgbot Service
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=forking
|
||||
ExecStart={$APP_PATH}/init.d/tgclient start
|
||||
ExecStop={$APP_PATH}/init.d/tgclient stop
|
||||
ExecReload={$APP_PATH}/init.d/tgclient reload
|
||||
KillMode=process
|
||||
Restart=on-failure
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
@@ -1,86 +0,0 @@
|
||||
#!/bin/sh
|
||||
# chkconfig: 2345 55 25
|
||||
# description: Tgbot Service
|
||||
|
||||
### BEGIN INIT INFO
|
||||
# Provides: Tgbot
|
||||
# Required-Start: $all
|
||||
# Required-Stop: $all
|
||||
# Default-Start: 2 3 4 5
|
||||
# Default-Stop: 0 1 6
|
||||
# Short-Description: starts Tgbot
|
||||
# Description: starts the MDW-Web
|
||||
### END INIT INFO
|
||||
|
||||
# Simple Tgbot init.d script conceived to work on Linux systems
|
||||
# as it does use of the /proc filesystem.
|
||||
|
||||
PATH=/usr/local/bin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
|
||||
export LANG=en_US.UTF-8
|
||||
|
||||
|
||||
mw_path={$SERVER_PATH}
|
||||
PATH=$PATH:$mw_path/bin
|
||||
|
||||
if [ -f $mw_path/bin/activate ];then
|
||||
source $mw_path/bin/activate
|
||||
fi
|
||||
|
||||
tg_start(){
|
||||
|
||||
isStart=`ps -ef|grep 'tgclient.py' |grep -v grep | awk '{print $2}'`
|
||||
if [ "$isStart" == '' ];then
|
||||
echo -e "starting tgclient... \c"
|
||||
cd $mw_path
|
||||
echo "python3 {$APP_PATH}/tgclient.py"
|
||||
python3 {$APP_PATH}/tgclient.py >> {$APP_PATH}/task.log &
|
||||
isStart=""
|
||||
while [[ "$isStart" == "" ]];
|
||||
do
|
||||
echo -e ".\c"
|
||||
sleep 0.5
|
||||
isStart=`ps -ef|grep 'tgclient.py' |grep -v grep | awk '{print $2}'`
|
||||
let n+=1
|
||||
if [ $n -gt 20 ];then
|
||||
break;
|
||||
fi
|
||||
done
|
||||
if [ "$isStart" == '' ];then
|
||||
echo -e "\033[31mfailed\033[0m"
|
||||
echo -e "\033[31mError: tgclient service startup failed.\033[0m"
|
||||
return;
|
||||
fi
|
||||
echo -e "\033[32mdone\033[0m"
|
||||
else
|
||||
echo "starting tgclient...(pid $(echo $isStart)) already running"
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
tg_stop(){
|
||||
echo -e "stopping tgclient ... \c";
|
||||
arr=`ps aux|grep 'tgclient.py'|grep -v grep|awk '{print $2}'`
|
||||
for p in ${arr[@]}
|
||||
do
|
||||
kill -9 $p > /dev/null 2>&1
|
||||
done
|
||||
echo -e "\033[32mdone\033[0m"
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
tg_start
|
||||
;;
|
||||
stop)
|
||||
tg_stop
|
||||
;;
|
||||
restart|reload)
|
||||
tg_stop
|
||||
sleep 0.3
|
||||
tg_start
|
||||
;;
|
||||
*)
|
||||
echo "Please use start or stop as first argument"
|
||||
;;
|
||||
esac
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
#!/bin/bash
|
||||
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
|
||||
export PATH
|
||||
|
||||
curPath=`pwd`
|
||||
rootPath=$(dirname "$curPath")
|
||||
rootPath=$(dirname "$rootPath")
|
||||
serverPath=$(dirname "$rootPath")
|
||||
|
||||
VERSION=$2
|
||||
|
||||
# pip3 install ccxt
|
||||
if [ -f ${rootPath}/bin/activate ];then
|
||||
source ${rootPath}/bin/activate
|
||||
fi
|
||||
|
||||
pip3 install telethon
|
||||
|
||||
Install_App()
|
||||
{
|
||||
echo '正在安装脚本文件...'
|
||||
mkdir -p $serverPath/source
|
||||
mkdir -p $serverPath/tgclient
|
||||
echo "${VERSION}" > $serverPath/tgclient/version.pl
|
||||
|
||||
cp -rf ${rootPath}/plugins/tgclient/startup/* $serverPath/tgclient
|
||||
|
||||
cd ${rootPath} && python3 ${rootPath}/plugins/tgclient/index.py start
|
||||
cd ${rootPath} && python3 ${rootPath}/plugins/tgclient/index.py initd_install
|
||||
echo '安装完成'
|
||||
}
|
||||
|
||||
Uninstall_App()
|
||||
{
|
||||
if [ -f /usr/lib/systemd/system/tgclient.service ];then
|
||||
systemctl stop tgclient
|
||||
systemctl disable tgclient
|
||||
rm -rf /usr/lib/systemd/system/tgclient.service
|
||||
systemctl daemon-reload
|
||||
fi
|
||||
|
||||
if [ -f $serverPath/tgclient/initd/tgclient ];then
|
||||
$serverPath/tgclient/initd/tgclient stop
|
||||
fi
|
||||
|
||||
rm -rf $serverPath/tgclient
|
||||
echo "Uninstall_redis"
|
||||
}
|
||||
|
||||
action=$1
|
||||
if [ "${1}" == 'install' ];then
|
||||
Install_App
|
||||
else
|
||||
Uninstall_App
|
||||
fi
|
||||
@@ -1,163 +0,0 @@
|
||||
function readme(){
|
||||
var readme = '<ul class="help-info-text c7">';
|
||||
readme += '<li>在填写好配置信息好后,还要执行下面命令。进行手机号和短信码验证。再重启,即可正常使用</li>';
|
||||
readme += '<li>cd /www/server/mdserver-web && source bin/activate && python3 /www/server/tgclient/tgclient.py</li>';
|
||||
readme += '<li>https://my.telegram.org/auth</li>';
|
||||
readme += '</ul>';
|
||||
$('.soft-man-con').html(readme);
|
||||
}
|
||||
|
||||
function appPost(method, args,callback){
|
||||
var loadT = layer.msg('正在获取...', { icon: 16, time: 0, shade: 0.3 });
|
||||
|
||||
var req_data = {};
|
||||
req_data['name'] = 'tgclient';
|
||||
req_data['func'] = method;
|
||||
|
||||
if (typeof(args) == 'string'){
|
||||
req_data['args'] = JSON.stringify(toArrayObject(args));
|
||||
} else {
|
||||
req_data['args'] = JSON.stringify(args);
|
||||
}
|
||||
|
||||
$.post('/plugins/run', req_data, function(data) {
|
||||
layer.close(loadT);
|
||||
if(typeof(callback) == 'function'){
|
||||
callback(data);
|
||||
}
|
||||
},'json');
|
||||
}
|
||||
|
||||
function appPostCallbak(method, args,callback){
|
||||
var loadT = layer.msg('正在获取...', { icon: 16, time: 0, shade: 0.3 });
|
||||
|
||||
var req_data = {};
|
||||
req_data['name'] = 'tgclient';
|
||||
req_data['func'] = method;
|
||||
|
||||
if (typeof(args) == 'string'){
|
||||
req_data['args'] = JSON.stringify(toArrayObject(args));
|
||||
} else {
|
||||
req_data['args'] = JSON.stringify(args);
|
||||
}
|
||||
|
||||
$.post('/plugins/callback', req_data, function(data) {
|
||||
layer.close(loadT);
|
||||
if (!data.status){
|
||||
layer.msg(data.msg,{icon:0,time:2000,shade: [0.3, '#000']});
|
||||
return;
|
||||
}
|
||||
|
||||
if(typeof(callback) == 'function'){
|
||||
callback(data);
|
||||
}
|
||||
},'json');
|
||||
}
|
||||
|
||||
function clientConf(){
|
||||
appPost('get_client_conf','',function(data){
|
||||
var rdata = $.parseJSON(data.data);
|
||||
var api_id = 'api_id';
|
||||
var api_hash = 'api_hash';
|
||||
if(rdata['status']){
|
||||
db_data = rdata['data'];
|
||||
|
||||
// api_id, api_hash
|
||||
api_id = db_data['api_id'];
|
||||
api_hash = db_data['api_hash'];
|
||||
|
||||
}
|
||||
|
||||
var mlist = '';
|
||||
mlist += '<p><span>api_id</span><input style="width: 250px;" class="bt-input-text mr5" name="api_id" value="'+api_id+'" type="text"><font>必填写</font></p>';
|
||||
mlist += '<p><span>api_hash</span><input style="width: 250px;" class="bt-input-text mr5" name="api_hash" value="'+api_hash+'" type="text"><font>必填写</font></p>';
|
||||
var option = '<style>.conf_p p{margin-bottom: 2px}</style>\
|
||||
<div class="conf_p" style="margin-bottom:0">\
|
||||
' + mlist + '\
|
||||
<div style="margin-top:10px; padding-right:15px" class="text-right">\
|
||||
<button class="btn btn-success btn-sm" onclick="submitBotConf()">保存</button>\
|
||||
</div>\
|
||||
</div>';
|
||||
$(".soft-man-con").html(option);
|
||||
});
|
||||
}
|
||||
|
||||
function submitBotConf(){
|
||||
var pull_data = {};
|
||||
pull_data['api_id'] = base64_encode($('input[name="api_id"]').val());
|
||||
pull_data['api_hash'] = base64_encode($('input[name="api_hash"]').val());
|
||||
appPost('set_client_conf',pull_data,function(data){
|
||||
var rdata = $.parseJSON(data.data);
|
||||
layer.msg(rdata['msg'],{icon:rdata['status']?1:2,time:2000,shade: [0.3, '#000']});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function botExtList(){
|
||||
var body = '<div class="divtable mtb10">\
|
||||
<table class="table table-hover" width="100%" cellspacing="0" cellpadding="0" border="0">\
|
||||
<thead>\
|
||||
<tr>\
|
||||
<th width="20">脚本</th>\
|
||||
<th width="120">类型</th>\
|
||||
<th width="10">状态</th>\
|
||||
</tr>\
|
||||
</thead>\
|
||||
<tbody id="ext_list"></tbody>\
|
||||
</table>\
|
||||
<div class="dataTables_paginate paging_bootstrap pagination">\
|
||||
<ul id="ext_list_page" class="page"></ul>\
|
||||
</div>\
|
||||
</div>';
|
||||
$('.soft-man-con').html(body);
|
||||
botExtListP(1);
|
||||
}
|
||||
|
||||
function setBotExtStatus(name,status){
|
||||
appPost('set_ext_status',{'name':name,'status':status}, function(rdata){
|
||||
var rdata = $.parseJSON(rdata.data);
|
||||
layer.msg(rdata['msg'],);
|
||||
showMsg(rdata['msg'], function(){
|
||||
botExtListP(1);
|
||||
},{icon:rdata['status']?1:2,shade: [0.3, '#000']},2000);
|
||||
});
|
||||
}
|
||||
|
||||
function botExtListP(p=1){
|
||||
appPost('client_ext_list',{'p':p}, function(rdata){
|
||||
// console.log(rdata);
|
||||
var rdata = $.parseJSON(rdata.data);
|
||||
// console.log(rdata);
|
||||
var tBody = '';
|
||||
|
||||
if (!rdata.status && rdata.data.length == 0 ){
|
||||
var tBody = '<tr><td colspan="4"><div style="text-align:center;">无数据</div></td></tr>';
|
||||
} else{
|
||||
var ldata = rdata.data.data;
|
||||
for (var i = 0; i < ldata.length; i++) {
|
||||
tBody += '<tr data-name="'+ldata[i]['name']+'">'
|
||||
tBody += '<td>'+ldata[i]['name']+'</td>';
|
||||
tBody += '<td>'+ldata[i]['tag']+'</td>';
|
||||
|
||||
if (ldata[i]['status'] == 'start'){
|
||||
tBody += '<td><span style="color:#20a53a;cursor: pointer;" class="ext_status glyphicon glyphicon-play"></span></td>';
|
||||
} else{
|
||||
tBody += '<td><span style="color:red;cursor: pointer;" class="ext_status glyphicon glyphicon-pause"></span></td>';
|
||||
}
|
||||
tBody +='<tr>';
|
||||
}
|
||||
}
|
||||
|
||||
$('#ext_list').html(tBody);
|
||||
$('#ext_list_page').html(rdata.data.list);
|
||||
|
||||
$('#ext_list .ext_status').click(function(){
|
||||
var name = $(this).parent().parent().data('name');
|
||||
var status = 'stop';
|
||||
if ($(this).hasClass('glyphicon-pause')){
|
||||
status = 'start';
|
||||
}
|
||||
setBotExtStatus(name,status);
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -1,97 +0,0 @@
|
||||
# coding:utf-8
|
||||
|
||||
# func: 在其他发送推送AD
|
||||
# url: https://docs.telethon.dev/en/stable/modules/client.html
|
||||
import sys
|
||||
import io
|
||||
import os
|
||||
import time
|
||||
import re
|
||||
import json
|
||||
import base64
|
||||
import threading
|
||||
import asyncio
|
||||
|
||||
sys.path.append(os.getcwd() + "/class/core")
|
||||
import mw
|
||||
|
||||
from telethon import utils
|
||||
from telethon import functions, types
|
||||
from telethon.tl.functions.messages import AddChatUserRequest
|
||||
from telethon.tl.functions.channels import InviteToChannelRequest
|
||||
# 指定群ID
|
||||
chat_id_list = [-1001578009023]
|
||||
filter_g_id = [-1001771526434]
|
||||
|
||||
|
||||
msg_ad = "本人软件推广(10s)\n\n"
|
||||
msg_ad += "开源Linux面板【mdserver-web】,站长必备,无毒,源码为证。\n"
|
||||
msg_ad += "不收费,全靠TG乞讨! \n"
|
||||
msg_ad += "看个人简介,加入群聊,一起进步!\n"
|
||||
# msg_ad += "https://github.com/midoks/mdserver-web \n"
|
||||
# msg_ad += "\n"
|
||||
# msg_ad += "加入群聊,一起进步! \n"
|
||||
# msg_ad += "https://t.me/mdserver_web \n"
|
||||
# msg_ad += "不收费,无毒。源码为证。全靠TG乞讨!😭\n\n"
|
||||
# msg_ad += "捐赠地址 USDT(TRC20)\n"
|
||||
# msg_ad += "TVbNgrpeGBGZVm5gTLa21ADP7RpnPFhjya\n"
|
||||
# msg_ad += "日行一善,以后必定大富大贵\n"
|
||||
|
||||
|
||||
async def writeLog(log_str):
|
||||
if __name__ == "__main__":
|
||||
print(log_str)
|
||||
|
||||
now = mw.getDateFromNow()
|
||||
log_file = mw.getServerDir() + '/tgclient/task.log'
|
||||
mw.writeFileLog(now + ':' + log_str, log_file, limit_size=5 * 1024)
|
||||
return True
|
||||
|
||||
async def send_msg(client, chat_id, tag='ad', trigger_time=600):
|
||||
# 信号只在一个周期内执行一次|start
|
||||
lock_file = mw.getServerDir() + '/tgclient/lock.json'
|
||||
if not os.path.exists(lock_file):
|
||||
mw.writeFile(lock_file, '{}')
|
||||
|
||||
lock_data = json.loads(mw.readFile(lock_file))
|
||||
if tag in lock_data:
|
||||
diff_time = time.time() - lock_data[tag]['do_time']
|
||||
if diff_time >= trigger_time:
|
||||
lock_data[tag]['do_time'] = time.time()
|
||||
else:
|
||||
return False, 0, 0
|
||||
else:
|
||||
lock_data[tag] = {'do_time': time.time()}
|
||||
mw.writeFile(lock_file, json.dumps(lock_data))
|
||||
# 信号只在一个周期内执行一次|end
|
||||
|
||||
msg = await client.send_message(chat_id, msg_ad)
|
||||
await asyncio.sleep(10)
|
||||
await client.delete_messages(chat_id, msg)
|
||||
await asyncio.sleep(3)
|
||||
|
||||
async def run(client):
|
||||
client.parse_mode = 'html'
|
||||
# for chat_id in chat_id_list:
|
||||
# await send_msg(client, chat_id)
|
||||
# await asyncio.sleep(30)
|
||||
|
||||
info = await client.get_dialogs()
|
||||
for chat in info:
|
||||
if chat.is_group and not chat.id in filter_g_id:
|
||||
chat_id = str(chat.id)
|
||||
if chat_id[0:4] != '-100':
|
||||
continue
|
||||
|
||||
# print(chat)
|
||||
await writeLog('name:{0} id:{1} is_user:{2} is_channel:{3} is_group:{4}'.format(
|
||||
chat.name, chat.id, chat.is_user, chat.is_channel, chat.is_group))
|
||||
try:
|
||||
await send_msg(client, chat.id, 'ad_' + str(chat.id))
|
||||
except Exception as e:
|
||||
await writeLog(str(chat))
|
||||
await writeLog(str(e))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
pass
|
||||
@@ -1,69 +0,0 @@
|
||||
# coding:utf-8
|
||||
|
||||
# func: 自动检测已经注销群成员
|
||||
|
||||
import sys
|
||||
import io
|
||||
import os
|
||||
import time
|
||||
import re
|
||||
import json
|
||||
import base64
|
||||
import threading
|
||||
import asyncio
|
||||
|
||||
sys.path.append(os.getcwd() + "/class/core")
|
||||
import mw
|
||||
|
||||
import telebot
|
||||
from telebot import types
|
||||
from telebot.util import quick_markup
|
||||
|
||||
|
||||
# 指定群ID
|
||||
chat_id_list = [-1001979545570]
|
||||
# 别人群ID[有API调用限制]
|
||||
chat_id_list_other = [-1001578009023, -1001771526434]
|
||||
|
||||
async def writeLog(log_str):
|
||||
if __name__ == "__main__":
|
||||
print(log_str)
|
||||
|
||||
now = mw.getDateFromNow()
|
||||
log_file = mw.getServerDir() + '/tgclient/task.log'
|
||||
mw.writeFileLog(now + ':' + log_str, log_file, limit_size=5 * 1024)
|
||||
return True
|
||||
|
||||
async def run(client):
|
||||
for chat_id in chat_id_list:
|
||||
try:
|
||||
s = await client.send_message(chat_id, '开始自动检测已经注销群成员...')
|
||||
count = 0
|
||||
async for user in client.iter_participants(chat_id):
|
||||
if user.deleted:
|
||||
count += 1
|
||||
msg = await client.kick_participant(chat_id, user)
|
||||
|
||||
await client.edit_message(chat_id, s.id, '已经检测到有(%d)个账户已失效' % (count))
|
||||
await asyncio.sleep(3)
|
||||
await client.edit_message(chat_id, s.id, '自动检测已经注销群成员完毕!!!')
|
||||
await asyncio.sleep(3)
|
||||
await client.delete_messages(chat_id, s)
|
||||
except Exception as e:
|
||||
print(str(e))
|
||||
writeLog(str(e))
|
||||
|
||||
for chat_id in chat_id_list_other:
|
||||
try:
|
||||
async for user in client.iter_participants(chat_id):
|
||||
if user.deleted:
|
||||
msg = await client.kick_participant(chat_id, user)
|
||||
except Exception as e:
|
||||
print(str(e))
|
||||
writeLog(str(e))
|
||||
|
||||
await asyncio.sleep(300)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
pass
|
||||
@@ -1,55 +0,0 @@
|
||||
# coding:utf-8
|
||||
|
||||
# func: 自动邀请群成员
|
||||
|
||||
import sys
|
||||
import io
|
||||
import os
|
||||
import time
|
||||
import re
|
||||
import json
|
||||
import base64
|
||||
import threading
|
||||
import asyncio
|
||||
|
||||
sys.path.append(os.getcwd() + "/class/core")
|
||||
import mw
|
||||
|
||||
from telethon import utils
|
||||
from telethon import functions, types
|
||||
from telethon.tl.functions.messages import AddChatUserRequest
|
||||
from telethon.tl.functions.channels import InviteToChannelRequest
|
||||
# 指定群ID
|
||||
chat_id = -1001979545570
|
||||
filter_user_id = 5568699210
|
||||
filter_g_id = [-1001771526434]
|
||||
|
||||
|
||||
async def run(client):
|
||||
info = await client.get_dialogs()
|
||||
for chat in info:
|
||||
is_sleep = True
|
||||
print('name:{0} id:{1} is_user:{2} is_channel:{3} is_group:{4}'.format(
|
||||
chat.name, chat.id, chat.is_user, chat.is_channel, chat.is_group))
|
||||
if chat.is_group and chat.id != chat_id:
|
||||
list_user = []
|
||||
async for user in client.iter_participants(chat.id):
|
||||
if chat.id in filter_g_id:
|
||||
is_sleep = False
|
||||
continue
|
||||
|
||||
if filter_user_id != user.id and user.username != None and user.bot == False:
|
||||
list_user.append(user.username)
|
||||
print(list_user)
|
||||
try:
|
||||
await client(InviteToChannelRequest(
|
||||
channel=chat_id, # chat_id
|
||||
users=list_user, # 被邀请人id
|
||||
))
|
||||
except Exception as e:
|
||||
print(str(e))
|
||||
if is_sleep:
|
||||
await asyncio.sleep(90000)
|
||||
|
||||
if __name__ == "__main__":
|
||||
pass
|
||||
@@ -1,54 +0,0 @@
|
||||
# coding:utf-8
|
||||
|
||||
# func: 临时测试
|
||||
|
||||
import sys
|
||||
import io
|
||||
import os
|
||||
import time
|
||||
import re
|
||||
import json
|
||||
import base64
|
||||
import threading
|
||||
import asyncio
|
||||
|
||||
sys.path.append(os.getcwd() + "/class/core")
|
||||
import mw
|
||||
|
||||
from telethon import utils
|
||||
from telethon import functions, types
|
||||
from telethon.tl.functions.messages import AddChatUserRequest
|
||||
from telethon.tl.functions.channels import InviteToChannelRequest
|
||||
# 指定群ID
|
||||
chat_id = -1001979545570
|
||||
filter_user_id = 5568699210
|
||||
filter_g_id = [-1001771526434]
|
||||
|
||||
|
||||
async def run(client):
|
||||
|
||||
my_channel = await client.get_entity(PeerChannel(-1001173826177))
|
||||
print(my_channel)
|
||||
|
||||
for i in range(9999999999):
|
||||
try:
|
||||
v = -1001000000000 - i
|
||||
my_channel = await client.get_entity(PeerChannel(v))
|
||||
print(my_channel)
|
||||
except Exception as e:
|
||||
pass
|
||||
|
||||
# -1001809140739
|
||||
# -1001800000000
|
||||
# -1000000000001
|
||||
|
||||
info = await client.get_dialogs()
|
||||
for chat in info:
|
||||
if not chat.is_group and chat.is_channel:
|
||||
print('name:{0} id:{1} is_user:{2} is_channel:{3} is_group:{4}'.format(
|
||||
chat.name, chat.id, chat.is_user, chat.is_channel, chat.is_group))
|
||||
await asyncio.sleep(10)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
pass
|
||||
@@ -1 +0,0 @@
|
||||
push_*.py 识别为推送插件
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user