mirror of
https://github.com/midoks/mdserver-web.git
synced 2026-10-10 04:19:26 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
714acd20e5 | ||
|
|
bf58cd8acc | ||
|
|
059053d27c | ||
|
|
185e73c26a | ||
|
|
569511d321 | ||
|
|
f88bf5059f | ||
|
|
05b63b8d2b | ||
|
|
3a197b273d | ||
|
|
f4fdbab41c | ||
|
|
f6b2940657 | ||
|
|
78b9ac5df0 | ||
|
|
3ea4272307 | ||
|
|
efc7cee9ad | ||
|
|
5c4805453d | ||
|
|
f6da241c85 | ||
|
|
d5b6eb2325 | ||
|
|
6ed2cddf71 | ||
|
|
9c31d76442 | ||
|
|
7aecbaf7df | ||
|
|
ee81a86d24 | ||
|
|
0a60d66732 | ||
|
|
c3e3cff472 | ||
|
|
194d46eb6a | ||
|
|
d66bc94edc | ||
|
|
fb4ffcd343 | ||
|
|
10c235e317 | ||
|
|
9c156928d8 | ||
|
|
771905d7f6 | ||
|
|
cd21b3f3e7 | ||
|
|
982026db24 | ||
|
|
f9b91d9989 | ||
|
|
f7b1159bd7 | ||
|
|
6aa49ddbcf | ||
|
|
866eddac1d | ||
|
|
af0cce4216 | ||
|
|
3951322d86 | ||
|
|
dfdd16b444 | ||
|
|
aa8fec2b7e | ||
|
|
2a8958ab84 | ||
|
|
f5125670ee | ||
|
|
2a8d4fb7a9 | ||
|
|
59f7fe2290 | ||
|
|
928db6e7e7 | ||
|
|
f3927bd6cf | ||
|
|
bb92727b56 | ||
|
|
21b80b1fce | ||
|
|
637da92834 | ||
|
|
f5859626a9 | ||
|
|
003449eb0a | ||
|
|
d27f926191 | ||
|
|
7483247d4d | ||
|
|
1ad841d3af | ||
|
|
27376d879c | ||
|
|
8b824447c1 | ||
|
|
a1d26dcd45 | ||
|
|
5e68c7bf0a | ||
|
|
481ae16713 | ||
|
|
2d2bd39f9e | ||
|
|
7246a878a5 | ||
|
|
542ee3cdb0 | ||
|
|
69503b223b | ||
|
|
78d8fa7ebf | ||
|
|
21e9d8f2d8 | ||
|
|
3c6adfbd44 | ||
|
|
c0e70abe6d | ||
|
|
f174e71228 | ||
|
|
7a9a811ea6 | ||
|
|
c7e3d9d9a3 | ||
|
|
161f7a1bc0 | ||
|
|
175cce0131 | ||
|
|
3735897ed2 | ||
|
|
30bfa5a630 | ||
|
|
594fdb4712 | ||
|
|
31a441ea02 | ||
|
|
06f7087fad | ||
|
|
e7b8f5afdc | ||
|
|
6b57addfa7 | ||
|
|
aea435fbaf | ||
|
|
9cd6656946 | ||
|
|
4f7df4b3c3 | ||
|
|
70d12b7b8d | ||
|
|
fe576c820a | ||
|
|
b48a53e0d7 | ||
|
|
4701839c33 | ||
|
|
916bc67c4d | ||
|
|
d7bba830cc | ||
|
|
7a28f8f57a | ||
|
|
41ee25aa7b | ||
|
|
c8aa91cfa3 | ||
|
|
98f27498b0 | ||
|
|
5444fe6455 | ||
|
|
9627c6e47b | ||
|
|
13597d6282 | ||
|
|
d09494e3aa | ||
|
|
d35439d286 | ||
|
|
ced48bab47 | ||
|
|
fe2df6cc8d | ||
|
|
8bdfe15101 | ||
|
|
42e9983b88 | ||
|
|
9b7c0b6f99 | ||
|
|
e421292c9e | ||
|
|
7b4d31779a | ||
|
|
f3b09056f3 | ||
|
|
a92ccea6c5 | ||
|
|
9da77a0a9b | ||
|
|
c233ecaaa7 | ||
|
|
5828b8b8cb | ||
|
|
a4a1a2c83c | ||
|
|
0e20bc182c | ||
|
|
99c0b0a81a | ||
|
|
3fa199fec4 | ||
|
|
194c36c6d8 | ||
|
|
2fb542f6b4 | ||
|
|
60af43ed31 | ||
|
|
9f02cf9744 | ||
|
|
846bd270df | ||
|
|
d910d4f462 | ||
|
|
13f5b1bf02 | ||
|
|
1fc3fd6247 | ||
|
|
36e3feb886 | ||
|
|
0ca34afacd | ||
|
|
ffb3288f3d | ||
|
|
e2f68a73ed | ||
|
|
92fa8da2f6 | ||
|
|
7c96ddd63e | ||
|
|
c4e7872179 | ||
|
|
d399cb2bb4 | ||
|
|
985cbc7eca | ||
|
|
27ed21a17d | ||
|
|
972165ba1a | ||
|
|
e76eb4d0e8 | ||
|
|
fd05c40dbb | ||
|
|
a1a7fa5c82 | ||
|
|
531de1407f | ||
|
|
ca455f13e8 | ||
|
|
ab5342b01f | ||
|
|
a5a57c5718 | ||
|
|
27999b21e6 | ||
|
|
d2c6caeef2 | ||
|
|
de30d8a41f | ||
|
|
d3abc8e7b2 | ||
|
|
b7aad65eb5 | ||
|
|
240b1dec27 | ||
|
|
4756e0f68b | ||
|
|
59f62b948a | ||
|
|
0ab0741031 | ||
|
|
2fd2f6e844 | ||
|
|
e534c6177a | ||
|
|
897c6322fc | ||
|
|
201e93f946 | ||
|
|
a78fd957ec | ||
|
|
3ce037b0a1 | ||
|
|
f3176340f8 | ||
|
|
7bfe096e8d | ||
|
|
066428fca8 | ||
|
|
a1313846c8 | ||
|
|
0433123abd | ||
|
|
72e99844dd | ||
|
|
3a7882e7fa | ||
|
|
bec2a9a12c | ||
|
|
8f02363782 | ||
|
|
939c847f3e | ||
|
|
a623039db7 | ||
|
|
b7f49a1839 | ||
|
|
f1f60870f6 | ||
|
|
3b04739fd4 | ||
|
|
fdf1e0b0be | ||
|
|
d3385f526f | ||
|
|
20f9095b93 | ||
|
|
757cf483a2 | ||
|
|
1712cfd024 | ||
|
|
2b524cbe75 | ||
|
|
607d384000 | ||
|
|
14cdc7b82e | ||
|
|
c3219bcba2 |
@@ -99,11 +99,15 @@ docker run -itd --name mw-server --privileged=true -p 7200:7200 -p 80:80 -p 443:
|
|||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
### 版本更新 0.14.4
|
### 版本更新 0.15.0
|
||||||
|
|
||||||
* 安装优化,redat系列优化。
|
* debian12适配。
|
||||||
* PHP74-82在redat的安装修复(oniguruma)。
|
* 添加nezha插件。
|
||||||
* 面板端口修改优化。
|
* 优化域名ssl保存功能。
|
||||||
|
* 修复PHP扩展intl不加载问题(debian/ubuntu)。
|
||||||
|
* 修复redhat安装openresty缺少openssl-devel。
|
||||||
|
* docker插件-将就能用。
|
||||||
|
* tgbot接收和push任务分离。
|
||||||
|
|
||||||
### JSDelivr安装地址
|
### JSDelivr安装地址
|
||||||
|
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ from route import app, socketio
|
|||||||
from gevent.pywsgi import WSGIServer
|
from gevent.pywsgi import WSGIServer
|
||||||
from geventwebsocket.handler import WebSocketHandler
|
from geventwebsocket.handler import WebSocketHandler
|
||||||
|
|
||||||
|
|
||||||
from gevent import monkey
|
from gevent import monkey
|
||||||
monkey.patch_all()
|
monkey.patch_all()
|
||||||
|
|
||||||
|
|||||||
@@ -930,7 +930,8 @@ fi
|
|||||||
index).encode()
|
index).encode()
|
||||||
)
|
)
|
||||||
X509Req.set_pubkey(pk)
|
X509Req.set_pubkey(pk)
|
||||||
X509Req.set_version(2)
|
# X509Req.set_version(2)
|
||||||
|
X509Req.set_version(0)
|
||||||
X509Req.sign(pk, self.__digest)
|
X509Req.sign(pk, self.__digest)
|
||||||
return OpenSSL.crypto.dump_certificate_request(OpenSSL.crypto.FILETYPE_ASN1, X509Req)
|
return OpenSSL.crypto.dump_certificate_request(OpenSSL.crypto.FILETYPE_ASN1, X509Req)
|
||||||
|
|
||||||
|
|||||||
@@ -840,7 +840,8 @@ class cert_request:
|
|||||||
index).encode()
|
index).encode()
|
||||||
)
|
)
|
||||||
X509Req.set_pubkey(pk)
|
X509Req.set_pubkey(pk)
|
||||||
X509Req.set_version(2)
|
# X509Req.set_version(2)
|
||||||
|
X509Req.set_version(0)
|
||||||
X509Req.sign(pk, self.__digest)
|
X509Req.sign(pk, self.__digest)
|
||||||
return OpenSSL.crypto.dump_certificate_request(OpenSSL.crypto.FILETYPE_ASN1, X509Req)
|
return OpenSSL.crypto.dump_certificate_request(OpenSSL.crypto.FILETYPE_ASN1, X509Req)
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ from flask import request
|
|||||||
|
|
||||||
class config_api:
|
class config_api:
|
||||||
|
|
||||||
__version = '0.14.4'
|
__version = '0.15.0'
|
||||||
__api_addr = 'data/api.json'
|
__api_addr = 'data/api.json'
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|||||||
+1
-1
@@ -65,7 +65,7 @@ class Sql():
|
|||||||
self.__DB_TABLE = table
|
self.__DB_TABLE = table
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def where(self, where, param):
|
def where(self, where, param=()):
|
||||||
# WHERE条件
|
# WHERE条件
|
||||||
if where:
|
if where:
|
||||||
self.__OPT_WHERE = " WHERE " + where
|
self.__OPT_WHERE = " WHERE " + where
|
||||||
|
|||||||
+1
-1
@@ -1405,7 +1405,7 @@ def makeConf():
|
|||||||
file = getRunDir() + '/data/json/config.json'
|
file = getRunDir() + '/data/json/config.json'
|
||||||
if not os.path.exists(file):
|
if not os.path.exists(file):
|
||||||
c = {}
|
c = {}
|
||||||
c['title'] = '金蝉面板'
|
c['title'] = '金灵面板'
|
||||||
c['home'] = 'http://github/midoks/mdserver-web'
|
c['home'] = 'http://github/midoks/mdserver-web'
|
||||||
c['recycle_bin'] = True
|
c['recycle_bin'] = True
|
||||||
c['template'] = 'default'
|
c['template'] = 'default'
|
||||||
|
|||||||
@@ -71,8 +71,9 @@ class plugins_api:
|
|||||||
if not mw.isNumber(sType):
|
if not mw.isNumber(sType):
|
||||||
sType = 0
|
sType = 0
|
||||||
|
|
||||||
# print sPage
|
# print(sPage, sType)
|
||||||
data = self.getPluginList(sType, int(sPage))
|
search = request.args.get('search', '').lower()
|
||||||
|
data = self.getPluginList(sType, search, int(sPage))
|
||||||
return mw.getJson(data)
|
return mw.getJson(data)
|
||||||
|
|
||||||
def menuGetAbsPath(self, tag, path):
|
def menuGetAbsPath(self, tag, path):
|
||||||
@@ -781,7 +782,18 @@ class plugins_api:
|
|||||||
print(e)
|
print(e)
|
||||||
return plugins_info
|
return plugins_info
|
||||||
|
|
||||||
def getAllListPage(self, sType='0', page=1, pageSize=10):
|
def searchKey(self, info, kw):
|
||||||
|
try:
|
||||||
|
if info['title'].lower().find(kw) > -1:
|
||||||
|
return True
|
||||||
|
if info['ps'].lower().find(kw) > -1:
|
||||||
|
return True
|
||||||
|
if info['name'].lower().find(kw) > -1:
|
||||||
|
return True
|
||||||
|
except Exception as e:
|
||||||
|
return False
|
||||||
|
|
||||||
|
def getAllListPage(self, sType='0', kw='', page=1, pageSize=10):
|
||||||
plugins_info = []
|
plugins_info = []
|
||||||
for dirinfo in os.listdir(self.__plugin_dir):
|
for dirinfo in os.listdir(self.__plugin_dir):
|
||||||
if dirinfo[0:1] == '.':
|
if dirinfo[0:1] == '.':
|
||||||
@@ -792,11 +804,13 @@ class plugins_api:
|
|||||||
if os.path.exists(json_file):
|
if os.path.exists(json_file):
|
||||||
try:
|
try:
|
||||||
data = json.loads(mw.readFile(json_file))
|
data = json.loads(mw.readFile(json_file))
|
||||||
|
# 判断是否搜索
|
||||||
|
if kw != '' and not self.searchKey(data, kw):
|
||||||
|
continue
|
||||||
tmp_data = self.makeList(data, sType)
|
tmp_data = self.makeList(data, sType)
|
||||||
for index in range(len(tmp_data)):
|
for index in range(len(tmp_data)):
|
||||||
plugins_info.append(tmp_data[index])
|
plugins_info.append(tmp_data[index])
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(json_file)
|
|
||||||
print(mw.getTracebackInfo())
|
print(mw.getTracebackInfo())
|
||||||
|
|
||||||
start = (page - 1) * pageSize
|
start = (page - 1) * pageSize
|
||||||
@@ -927,14 +941,14 @@ class plugins_api:
|
|||||||
|
|
||||||
return plugins_info
|
return plugins_info
|
||||||
|
|
||||||
def getPluginList(self, sType, sPage=1, sPageSize=10):
|
def getPluginList(self, sType, kw='', sPage=1, sPageSize=10):
|
||||||
# print sType, sPage, sPageSize
|
# print(sType, kw, sPage, sPageSize)
|
||||||
|
|
||||||
ret = {}
|
ret = {}
|
||||||
ret['type'] = json.loads(mw.readFile(self.__type))
|
ret['type'] = json.loads(mw.readFile(self.__type))
|
||||||
# plugins_info = self.getAllListThread(sType)
|
# plugins_info = self.getAllListThread(sType)
|
||||||
# plugins_info = self.getAllListProcess(sType)
|
# plugins_info = self.getAllListProcess(sType)
|
||||||
data = self.getAllListPage(sType, sPage, sPageSize)
|
data = self.getAllListPage(sType, kw, sPage, sPageSize)
|
||||||
ret['data'] = data[0]
|
ret['data'] = data[0]
|
||||||
|
|
||||||
args = {}
|
args = {}
|
||||||
|
|||||||
+20
-5
@@ -101,19 +101,31 @@ class site_api:
|
|||||||
limit = request.form.get('limit', '10')
|
limit = request.form.get('limit', '10')
|
||||||
p = request.form.get('p', '1')
|
p = request.form.get('p', '1')
|
||||||
type_id = request.form.get('type_id', '0').strip()
|
type_id = request.form.get('type_id', '0').strip()
|
||||||
|
search = request.form.get('search', '').strip()
|
||||||
|
|
||||||
start = (int(p) - 1) * (int(limit))
|
start = (int(p) - 1) * (int(limit))
|
||||||
|
|
||||||
siteM = mw.M('sites').field('id,name,path,status,ps,addtime,edate')
|
siteM = mw.M('sites').field('id,name,path,status,ps,addtime,edate')
|
||||||
if type_id != '' and int(type_id) >= 0:
|
|
||||||
siteM.where('type_id=?', (type_id,))
|
sql_where = ''
|
||||||
|
if search != '':
|
||||||
|
sql_where = " name like '%" + search + "%' or ps like '%" + search + "%' "
|
||||||
|
|
||||||
|
if type_id != '' and int(type_id) >= 0 and search != '':
|
||||||
|
sql_where = sql_where + " and type_id=" + type_id + ""
|
||||||
|
elif type_id != '' and int(type_id) >= 0:
|
||||||
|
sql_where = " type_id=" + type_id
|
||||||
|
|
||||||
|
if sql_where != '':
|
||||||
|
siteM.where(sql_where)
|
||||||
|
|
||||||
_list = siteM.limit((str(start)) + ',' +
|
_list = siteM.limit((str(start)) + ',' +
|
||||||
limit).order('id desc').select()
|
limit).order('id desc').select()
|
||||||
|
|
||||||
for i in range(len(_list)):
|
if _list != None:
|
||||||
_list[i]['backup_count'] = mw.M('backup').where(
|
for i in range(len(_list)):
|
||||||
"pid=? AND type=?", (_list[i]['id'], 0)).count()
|
_list[i]['backup_count'] = mw.M('backup').where(
|
||||||
|
"pid=? AND type=?", (_list[i]['id'], 0)).count()
|
||||||
|
|
||||||
_ret = {}
|
_ret = {}
|
||||||
_ret['data'] = _list
|
_ret['data'] = _list
|
||||||
@@ -775,6 +787,9 @@ class site_api:
|
|||||||
mw.execShell('echo "lets" > "' + path + '/README"')
|
mw.execShell('echo "lets" > "' + path + '/README"')
|
||||||
elif ssl_type == 'acme':
|
elif ssl_type == 'acme':
|
||||||
ssl_acme_dir = mw.getAcmeDir() + '/' + site_name
|
ssl_acme_dir = mw.getAcmeDir() + '/' + site_name
|
||||||
|
if not os.path.exists(ssl_acme_dir):
|
||||||
|
ssl_acme_dir = mw.getAcmeDir() + '/' + site_name + '_ecc'
|
||||||
|
|
||||||
acme_csrpath = ssl_acme_dir + '/fullchain.cer'
|
acme_csrpath = ssl_acme_dir + '/fullchain.cer'
|
||||||
acme_keypath = ssl_acme_dir + '/' + site_name + '.key'
|
acme_keypath = ssl_acme_dir + '/' + site_name + '.key'
|
||||||
if mw.md5(mw.readFile(acme_csrpath)) == mw.md5(mw.readFile(csr_path)):
|
if mw.md5(mw.readFile(acme_csrpath)) == mw.md5(mw.readFile(csr_path)):
|
||||||
|
|||||||
+20
-17
@@ -16,6 +16,7 @@ cd /www/server/mdserver-web/plugins/php/versions && bash all_test.sh
|
|||||||
| CentOS 9 Stream |✅ |✅ |
|
| CentOS 9 Stream |✅ |✅ |
|
||||||
| Debian 10.3 |✅ |✅ |
|
| Debian 10.3 |✅ |✅ |
|
||||||
| Debian 11.3 |✅ |✅ |
|
| Debian 11.3 |✅ |✅ |
|
||||||
|
| Debian 12.0 |✅ |✅ |
|
||||||
| Ubuntu 18.04 |✅ |✅ |
|
| Ubuntu 18.04 |✅ |✅ |
|
||||||
| Ubuntu 20.04 |✅ |✅ |
|
| Ubuntu 20.04 |✅ |✅ |
|
||||||
| Ubuntu 22.04 |✅ |✅ |
|
| Ubuntu 22.04 |✅ |✅ |
|
||||||
@@ -28,23 +29,24 @@ cd /www/server/mdserver-web/plugins/php/versions && bash all_test.sh
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
| 系统名称 |PHP53 |PHP54 |PHP55 |PHP56 |PHP70 |PHP71 |PHP72 |PHP73 |PHP74 |PHP80 |PHP81 |
|
| 系统名称 |PHP53 |PHP54 |PHP55 |PHP56 |PHP70 |PHP71 |PHP72 |PHP73 |PHP74 |PHP80 |PHP81 |PHP82 |
|
||||||
| ----------------- |-------|-------|-------|-------|-------|-------|-------|-------|-------|-------|-------|
|
| ----------------- |-------|-------|-------|-------|-------|-------|-------|-------|-------|-------|-------|-------|
|
||||||
| CentOS 7.9 |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |
|
| CentOS 7.9 |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |
|
||||||
| CentOS 8.4 |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |
|
| CentOS 8.4 |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |
|
||||||
| CentOS 8 Stream |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |
|
| CentOS 8 Stream |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |
|
||||||
| CentOS 9 Stream |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |
|
| CentOS 9 Stream |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |
|
||||||
| Debian 10.3 |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |
|
| Debian 10.3 |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |
|
||||||
| Debian 11.3 |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |
|
| Debian 11.3 |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |
|
||||||
| Ubuntu 18.04 |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |
|
| Debian 12 |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |
|
||||||
| Ubuntu 20.04 |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |
|
| Ubuntu 18.04 |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |
|
||||||
| Ubuntu 22.04 |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |
|
| Ubuntu 20.04 |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |
|
||||||
| Fedora 31 |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |
|
| Ubuntu 22.04 |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |
|
||||||
| Fedora 32 |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |
|
| Fedora 31 |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |
|
||||||
| AlmaLinux 9 |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |
|
| Fedora 32 |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |
|
||||||
| RockyLinux 8.6 |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |
|
| AlmaLinux 9 |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |
|
||||||
| Arch Linux |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |
|
| RockyLinux 8.6 |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |
|
||||||
| openSUSE 15.4 |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |
|
| Arch Linux |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |
|
||||||
|
| openSUSE 15.4 |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -56,6 +58,7 @@ cd /www/server/mdserver-web/plugins/php/versions && bash all_test.sh
|
|||||||
| CentOS 9 Stream |✅ |✅ |✅ |✅ |
|
| CentOS 9 Stream |✅ |✅ |✅ |✅ |
|
||||||
| Debian 10.3 |✅ |✅ |✅ |✅ |
|
| Debian 10.3 |✅ |✅ |✅ |✅ |
|
||||||
| Debian 11.3 |✅ |✅ |✅ |✅ |
|
| Debian 11.3 |✅ |✅ |✅ |✅ |
|
||||||
|
| Debian 12 |✅ |✅ |✅ |✅ |
|
||||||
| Ubuntu 18.04 |✅ |✅ |✅ |✅ |
|
| Ubuntu 18.04 |✅ |✅ |✅ |✅ |
|
||||||
| Ubuntu 20.04 |✅ |✅ |✅ |✅ |
|
| Ubuntu 20.04 |✅ |✅ |✅ |✅ |
|
||||||
| Ubuntu 22.04 |✅ |✅ |✅ |✅ |
|
| Ubuntu 22.04 |✅ |✅ |✅ |✅ |
|
||||||
|
|||||||
@@ -1,10 +1,46 @@
|
|||||||
|
<style type="text/css">
|
||||||
|
|
||||||
|
.docker-sub {
|
||||||
|
border-bottom: 1px solid #ccc;
|
||||||
|
height: 30px;
|
||||||
|
line-height: 30px;
|
||||||
|
margin-bottom: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.docker-sub .on {
|
||||||
|
border-bottom: 2px solid #20a53a;
|
||||||
|
color: #20a53a;
|
||||||
|
font-weight: bold;
|
||||||
|
font-family: "宋体";
|
||||||
|
}
|
||||||
|
.docker-sub span {
|
||||||
|
display: inline-block;
|
||||||
|
font-size: 14px;
|
||||||
|
height: 30px;
|
||||||
|
padding: 0 25px;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.docker-environments {
|
||||||
|
resize: none;
|
||||||
|
width: 330px;
|
||||||
|
height: 80px;
|
||||||
|
line-height: 20px;
|
||||||
|
padding: 5px 8px;
|
||||||
|
border: 1px solid #ddd;
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
<div class="bt-form">
|
<div class="bt-form">
|
||||||
<div class='plugin_version'></div>
|
<div class='plugin_version'></div>
|
||||||
<div class="bt-w-main">
|
<div class="bt-w-main">
|
||||||
<div class="bt-w-menu">
|
<div class="bt-w-menu">
|
||||||
<p class="bgw" onclick="pluginService('docker');">服务</p>
|
<p class="bgw" onclick="pluginService('docker');">服务</p>
|
||||||
<p onclick="pluginInitD('docker');">自启动</p>
|
<p onclick="pluginInitD('docker');">自启动</p>
|
||||||
<p onclick="dockerList();">容器列表</p>
|
<p onclick="dockerConList();">容器列表</p>
|
||||||
|
<p onclick="dockerImageList();">镜像列表</p>
|
||||||
|
<p onclick="repoList();">仓库</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="bt-w-con pd15">
|
<div class="bt-w-con pd15">
|
||||||
<div class="soft-man-con"></div>
|
<div class="soft-man-con"></div>
|
||||||
@@ -12,7 +48,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
resetPluginWinWidth(700);
|
resetPluginWinWidth(800);
|
||||||
resetPluginWinHeight(400);
|
resetPluginWinHeight(400);
|
||||||
$.getScript( "/plugins/file?name=docker&f=js/docker.js", function(){
|
$.getScript( "/plugins/file?name=docker&f=js/docker.js", function(){
|
||||||
pluginService('docker', $('.plugin_version').attr('version'));
|
pluginService('docker', $('.plugin_version').attr('version'));
|
||||||
|
|||||||
+514
-14
@@ -5,15 +5,28 @@ import io
|
|||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
import re
|
import re
|
||||||
|
import json
|
||||||
|
|
||||||
sys.path.append(os.getcwd() + "/class/core")
|
sys.path.append(os.getcwd() + "/class/core")
|
||||||
import mw
|
import mw
|
||||||
|
|
||||||
|
import docker
|
||||||
|
|
||||||
|
|
||||||
app_debug = False
|
app_debug = False
|
||||||
if mw.isAppleSystem():
|
if mw.isAppleSystem():
|
||||||
app_debug = True
|
app_debug = True
|
||||||
|
|
||||||
|
|
||||||
|
def getDClient():
|
||||||
|
try:
|
||||||
|
client = docker.from_env()
|
||||||
|
except Exception as e:
|
||||||
|
client = docker.DockerClient(
|
||||||
|
base_url='unix:///Users/midoks/.docker/run/docker.sock')
|
||||||
|
return client
|
||||||
|
|
||||||
|
|
||||||
def getPluginName():
|
def getPluginName():
|
||||||
return 'docker'
|
return 'docker'
|
||||||
|
|
||||||
@@ -26,12 +39,6 @@ def getServerDir():
|
|||||||
return mw.getServerDir() + '/' + getPluginName()
|
return mw.getServerDir() + '/' + getPluginName()
|
||||||
|
|
||||||
|
|
||||||
def getInitDFile():
|
|
||||||
if app_debug:
|
|
||||||
return '/tmp/' + getPluginName()
|
|
||||||
return '/etc/init.d/' + getPluginName()
|
|
||||||
|
|
||||||
|
|
||||||
def getConf():
|
def getConf():
|
||||||
path = getServerDir() + "/redis.conf"
|
path = getServerDir() + "/redis.conf"
|
||||||
return path
|
return path
|
||||||
@@ -48,7 +55,7 @@ def getInitDTpl():
|
|||||||
|
|
||||||
|
|
||||||
def getArgs():
|
def getArgs():
|
||||||
args = sys.argv[3:]
|
args = sys.argv[2:]
|
||||||
tmp = {}
|
tmp = {}
|
||||||
args_len = len(args)
|
args_len = len(args)
|
||||||
|
|
||||||
@@ -57,19 +64,27 @@ def getArgs():
|
|||||||
if t.strip() == '':
|
if t.strip() == '':
|
||||||
tmp = []
|
tmp = []
|
||||||
else:
|
else:
|
||||||
t = t.split(':')
|
t = t.split(':', 1)
|
||||||
tmp[t[0]] = t[1]
|
tmp[t[0]] = t[1]
|
||||||
tmp[t[0]] = t[1]
|
tmp[t[0]] = t[1]
|
||||||
elif args_len > 1:
|
elif args_len > 1:
|
||||||
for i in range(len(args)):
|
for i in range(len(args)):
|
||||||
t = args[i].split(':')
|
t = args[i].split(':', 1)
|
||||||
tmp[t[0]] = t[1]
|
tmp[t[0]] = t[1]
|
||||||
return tmp
|
return tmp
|
||||||
|
|
||||||
|
|
||||||
|
def checkArgs(self, data, ck=[]):
|
||||||
|
for i in range(len(ck)):
|
||||||
|
print(data[i])
|
||||||
|
if not ck[i] in data:
|
||||||
|
return (False, mw.returnJson(False, '参数:(' + ck[i] + ')没有!'))
|
||||||
|
return (True, mw.returnJson(True, 'ok'))
|
||||||
|
|
||||||
|
|
||||||
def status():
|
def status():
|
||||||
data = mw.execShell(
|
data = mw.execShell(
|
||||||
"ps -ef|grep dockerd |grep -v grep | grep -v python | grep -v mdserver-web | awk '{print $2}'")
|
"ps -ef|grep docker |grep -v grep | grep -v python | grep -v mdserver-web | awk '{print $2}'")
|
||||||
|
|
||||||
if data[0] == '':
|
if data[0] == '':
|
||||||
return 'stop'
|
return 'stop'
|
||||||
@@ -138,9 +153,466 @@ def initdUinstall():
|
|||||||
mw.execShell('systemctl disable ' + getPluginName())
|
mw.execShell('systemctl disable ' + getPluginName())
|
||||||
return 'ok'
|
return 'ok'
|
||||||
|
|
||||||
|
# UTC时间转换为时间戳
|
||||||
|
|
||||||
def runLog():
|
|
||||||
return getServerDir() + '/data/redis.log'
|
def utc_to_local(utc_time_str, utc_format='%Y-%m-%dT%H:%M:%S'):
|
||||||
|
import pytz
|
||||||
|
import datetime
|
||||||
|
import time
|
||||||
|
local_tz = pytz.timezone('Asia/Chongqing')
|
||||||
|
local_format = "%Y-%m-%d %H:%M"
|
||||||
|
utc_dt = datetime.datetime.strptime(utc_time_str, utc_format)
|
||||||
|
local_dt = utc_dt.replace(tzinfo=pytz.utc).astimezone(local_tz)
|
||||||
|
time_str = local_dt.strftime(local_format)
|
||||||
|
return int(time.mktime(time.strptime(time_str, local_format)))
|
||||||
|
|
||||||
|
|
||||||
|
def conList():
|
||||||
|
c = getDClient()
|
||||||
|
clist = c.containers.list(all=True)
|
||||||
|
conList = []
|
||||||
|
for con in clist:
|
||||||
|
tmp = con.attrs
|
||||||
|
tmp['Created'] = utc_to_local(tmp['Created'].split('.')[0])
|
||||||
|
conList.append(tmp)
|
||||||
|
return conList
|
||||||
|
|
||||||
|
|
||||||
|
def conListData():
|
||||||
|
try:
|
||||||
|
clist = conList()
|
||||||
|
except Exception as e:
|
||||||
|
return mw.returnJson(False, '未开启Docker')
|
||||||
|
return mw.returnJson(True, 'ok', clist)
|
||||||
|
|
||||||
|
|
||||||
|
def dockerRemoveCon():
|
||||||
|
args = getArgs()
|
||||||
|
data = checkArgs(args, ['Hostname'])
|
||||||
|
if not data[0]:
|
||||||
|
return data[1]
|
||||||
|
|
||||||
|
Hostname = args['Hostname']
|
||||||
|
|
||||||
|
c = getDClient()
|
||||||
|
try:
|
||||||
|
conFind = c.containers.get(Hostname)
|
||||||
|
try:
|
||||||
|
path_list = conFind.attrs['GraphDriver'][
|
||||||
|
'Data']['LowerDir'].split(':')
|
||||||
|
for i in path_list:
|
||||||
|
mw.execShell('chattr -R -i %s' % i)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
conFind.remove(force=True)
|
||||||
|
return mw.returnJson(True, '成功删除!')
|
||||||
|
except docker.errors.APIError as ex:
|
||||||
|
return mw.returnJson(False, '删除失败!' + str(ex))
|
||||||
|
|
||||||
|
|
||||||
|
def dockerLogCon():
|
||||||
|
|
||||||
|
args = getArgs()
|
||||||
|
data = checkArgs(args, ['Hostname'])
|
||||||
|
if not data[0]:
|
||||||
|
return data[1]
|
||||||
|
|
||||||
|
Hostname = args['Hostname']
|
||||||
|
|
||||||
|
c = getDClient()
|
||||||
|
try:
|
||||||
|
conFind = c.containers.get(Hostname)
|
||||||
|
if not conFind:
|
||||||
|
return mw.returnJson(False, 'The specified container does not exist!')
|
||||||
|
log = conFind.logs()
|
||||||
|
if not isinstance(log, str):
|
||||||
|
log = log.decode()
|
||||||
|
return mw.returnJson(True, log)
|
||||||
|
except docker.errors.APIError as ex:
|
||||||
|
return mw.returnJson(False, 'Get Logs failed')
|
||||||
|
|
||||||
|
|
||||||
|
def dockerRunCon():
|
||||||
|
# 启动容器
|
||||||
|
args = getArgs()
|
||||||
|
data = checkArgs(args, ['Hostname'])
|
||||||
|
if not data[0]:
|
||||||
|
return data[1]
|
||||||
|
|
||||||
|
Hostname = args['Hostname']
|
||||||
|
c = getDClient()
|
||||||
|
try:
|
||||||
|
conFind = c.containers.get(Hostname)
|
||||||
|
if not conFind:
|
||||||
|
return mw.returnJson(False, 'The specified container does not exist!')
|
||||||
|
conFind.start()
|
||||||
|
return mw.returnJson(True, '启动成功!')
|
||||||
|
except docker.errors.APIError as ex:
|
||||||
|
return mw.returnJson(False, '启动失败!' + str(ex))
|
||||||
|
|
||||||
|
|
||||||
|
def dockerStopCon():
|
||||||
|
# 停止容器
|
||||||
|
args = getArgs()
|
||||||
|
data = checkArgs(args, ['Hostname'])
|
||||||
|
if not data[0]:
|
||||||
|
return data[1]
|
||||||
|
|
||||||
|
Hostname = args['Hostname']
|
||||||
|
c = getDClient()
|
||||||
|
try:
|
||||||
|
conFind = c.containers.get(Hostname)
|
||||||
|
if not conFind:
|
||||||
|
return mw.returnJson(False, 'The specified container does not exist!')
|
||||||
|
conFind.stop()
|
||||||
|
return mw.returnJson(True, '停止成功!')
|
||||||
|
except docker.errors.APIError as ex:
|
||||||
|
return mw.returnJson(False, '停止失败!' + str(ex))
|
||||||
|
|
||||||
|
|
||||||
|
def dockerExec():
|
||||||
|
# 容器执行命令
|
||||||
|
args = getArgs()
|
||||||
|
data = checkArgs(args, ['Hostname'])
|
||||||
|
if not data[0]:
|
||||||
|
return data[1]
|
||||||
|
|
||||||
|
Hostname = args['Hostname']
|
||||||
|
|
||||||
|
debug_path = 'data/debug.pl'
|
||||||
|
if os.path.exists(debug_path):
|
||||||
|
return mw.returnJson(False, '开发模式不能进入!')
|
||||||
|
|
||||||
|
c = getDClient()
|
||||||
|
try:
|
||||||
|
conFind = c.containers.get(Hostname)
|
||||||
|
cmd = 'docker container exec -it %s /bin/sh' % Hostname
|
||||||
|
return mw.returnJson(True, cmd)
|
||||||
|
except docker.errors.APIError as ex:
|
||||||
|
return mw.returnJson(False, '连接失败!')
|
||||||
|
|
||||||
|
|
||||||
|
def imageList():
|
||||||
|
imageList = []
|
||||||
|
c = getDClient()
|
||||||
|
ilist = c.images.list()
|
||||||
|
for image in ilist:
|
||||||
|
tmp_attrs = image.attrs
|
||||||
|
if len(tmp_attrs['RepoTags']) == 1:
|
||||||
|
tmp_image = {}
|
||||||
|
tmp_image['Id'] = tmp_attrs['Id'].split(':')[1][:12]
|
||||||
|
tmp_image['RepoTags'] = tmp_attrs['RepoTags'][0]
|
||||||
|
tmp_image['Size'] = tmp_attrs['Size']
|
||||||
|
tmp_image['Labels'] = tmp_attrs['Config']['Labels']
|
||||||
|
tmp_image['Comment'] = tmp_attrs['Comment']
|
||||||
|
tmp_image['Created'] = utc_to_local(
|
||||||
|
tmp_attrs['Created'].split('.')[0])
|
||||||
|
imageList.append(tmp_image)
|
||||||
|
else:
|
||||||
|
for i in range(len(tmp_attrs['RepoTags'])):
|
||||||
|
tmp_image = {}
|
||||||
|
tmp_image['Id'] = tmp_attrs['Id'].split(':')[1][:12]
|
||||||
|
tmp_image['RepoTags'] = tmp_attrs['RepoTags'][i]
|
||||||
|
tmp_image['Size'] = tmp_attrs['Size']
|
||||||
|
tmp_image['Labels'] = tmp_attrs['Config']['Labels']
|
||||||
|
tmp_image['Comment'] = tmp_attrs['Comment']
|
||||||
|
tmp_image['Created'] = utc_to_local(
|
||||||
|
tmp_attrs['Created'].split('.')[0])
|
||||||
|
imageList.append(tmp_image)
|
||||||
|
imageList = sorted(imageList, key=lambda x: x['Created'], reverse=True)
|
||||||
|
return imageList
|
||||||
|
|
||||||
|
|
||||||
|
def dockerPull():
|
||||||
|
# pull Dockr 官方镜像
|
||||||
|
args = getArgs()
|
||||||
|
data = checkArgs(args, ['images'])
|
||||||
|
if not data[0]:
|
||||||
|
return data[1]
|
||||||
|
|
||||||
|
images = args['images']
|
||||||
|
if ':' in images:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
images = images + ':latest'
|
||||||
|
|
||||||
|
c = getDClient()
|
||||||
|
try:
|
||||||
|
ret = c.images.pull(images)
|
||||||
|
if ret:
|
||||||
|
return mw.returnJson(True, '拉取成功!')
|
||||||
|
else:
|
||||||
|
return mw.returnJson(False, '拉取失败,请检查镜像名称或是否需要登录docker进行下载')
|
||||||
|
except:
|
||||||
|
ret = mw.execShell('docker image pull %s' % images)
|
||||||
|
if 'invalid' in ret[-1]:
|
||||||
|
return mw.returnJson(False, '拉取失败,请检查镜像名称或是否需要登录docker进行下载')
|
||||||
|
else:
|
||||||
|
return mw.returnJson(True, '拉取成功!')
|
||||||
|
|
||||||
|
|
||||||
|
def dockerPlulPath(path):
|
||||||
|
if not path and path == '':
|
||||||
|
return mw.returnJson(False, 'Invalid address')
|
||||||
|
|
||||||
|
ret = mw.execShell('docker image pull %s' % path)
|
||||||
|
if 'invalid' in ret[-1]:
|
||||||
|
return mw.returnJson(False, '拉取失败,请检查镜像名称或是否需要登录docker进行下载')
|
||||||
|
else:
|
||||||
|
return mw.returnJson(True, '拉取成功!')
|
||||||
|
|
||||||
|
|
||||||
|
def dockerPullReg():
|
||||||
|
# pull Dockr 官方镜像
|
||||||
|
args = getArgs()
|
||||||
|
data = checkArgs(args, ['path'])
|
||||||
|
if not data[0]:
|
||||||
|
return data[1]
|
||||||
|
|
||||||
|
path = args['path']
|
||||||
|
return dockerPlulPath(path)
|
||||||
|
|
||||||
|
|
||||||
|
# 判断镜像是否存在
|
||||||
|
def checkImage(path):
|
||||||
|
image_list = imageList()
|
||||||
|
for i in image_list:
|
||||||
|
if path == i["RepoTags"]:
|
||||||
|
return mw.returnData(False, '镜像已存在!')
|
||||||
|
|
||||||
|
|
||||||
|
def dockerPullPrivateNew():
|
||||||
|
# pull Dockr 官方镜像
|
||||||
|
args = getArgs()
|
||||||
|
data = checkArgs(args, ['path'])
|
||||||
|
if not data[0]:
|
||||||
|
return data[1]
|
||||||
|
|
||||||
|
path = args['path']
|
||||||
|
check = checkImage(path)
|
||||||
|
if check:
|
||||||
|
return mw.getJson(check)
|
||||||
|
|
||||||
|
my_repo = repoList()
|
||||||
|
if not my_repo:
|
||||||
|
return mw.returnJson(False, '未登录任何私人存储库,请登录然后拉取')
|
||||||
|
return dockerPlulPath(path)
|
||||||
|
|
||||||
|
|
||||||
|
def imageListData():
|
||||||
|
try:
|
||||||
|
ilist = imageList()
|
||||||
|
except Exception as e:
|
||||||
|
return mw.returnJson(False, '未开启Docker')
|
||||||
|
return mw.returnJson(True, 'ok', ilist)
|
||||||
|
|
||||||
|
|
||||||
|
def dockerRemoveImage():
|
||||||
|
args = getArgs()
|
||||||
|
data = checkArgs(args, ['imageId', 'repoTags'])
|
||||||
|
if not data[0]:
|
||||||
|
return data[1]
|
||||||
|
|
||||||
|
repoTags = args['repoTags']
|
||||||
|
imageId = args['imageId']
|
||||||
|
|
||||||
|
c = getDClient()
|
||||||
|
try:
|
||||||
|
c.images.remove(repoTags)
|
||||||
|
return mw.returnJson(True, '成功删除')
|
||||||
|
except:
|
||||||
|
try:
|
||||||
|
c.images.remove(imageId)
|
||||||
|
return mw.returnJson(True, '成功删除!')
|
||||||
|
except docker.errors.APIError as ex:
|
||||||
|
return mw.returnJson(False, '删除失败, 当前镜像正在使用!')
|
||||||
|
|
||||||
|
|
||||||
|
def dockerLoginCheck(user_name, user_pass, registry):
|
||||||
|
# 登陆验证
|
||||||
|
cmd = 'docker login -u=%s -p %s %s' % (user_name, user_pass, registry)
|
||||||
|
# print(cmd)
|
||||||
|
login_test = mw.execShell(cmd)
|
||||||
|
# print(login_test)
|
||||||
|
ret = 'required$|Error'
|
||||||
|
ret2 = re.findall(ret, login_test[-1])
|
||||||
|
if len(ret2) == 0:
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
def getDockerIpList():
|
||||||
|
# 取IP列表
|
||||||
|
path = getServerDir()
|
||||||
|
ipConf = path + '/iplist.json'
|
||||||
|
if not os.path.exists(ipConf):
|
||||||
|
return []
|
||||||
|
iplist = json.loads(mw.readFile(ipConf))
|
||||||
|
return iplist
|
||||||
|
|
||||||
|
|
||||||
|
def getDockerCreateInfo():
|
||||||
|
# 取创建依赖
|
||||||
|
import psutil
|
||||||
|
data = {}
|
||||||
|
data['images'] = imageList()
|
||||||
|
data['memSize'] = int(psutil.virtual_memory().total / 1024 / 1024)
|
||||||
|
data['iplist'] = getDockerIpList()
|
||||||
|
return mw.returnJson(True, 'ok!', data)
|
||||||
|
|
||||||
|
|
||||||
|
def __release_port(port):
|
||||||
|
from collections import namedtuple
|
||||||
|
try:
|
||||||
|
import firewall_api
|
||||||
|
firewall_api.firewall_api().addAcceptPortArgs(port, 'docker', 'port')
|
||||||
|
return port
|
||||||
|
except Exception as e:
|
||||||
|
return "Release failed {}".format(e)
|
||||||
|
|
||||||
|
|
||||||
|
def dockerCreateCon():
|
||||||
|
args = getArgs()
|
||||||
|
data = checkArgs(args, ['environments', 'command',
|
||||||
|
'entrypoint', 'image', 'mem_limit', 'ports', 'volumes'])
|
||||||
|
if not data[0]:
|
||||||
|
return data[1]
|
||||||
|
|
||||||
|
environments = args['environments']
|
||||||
|
environments = environments.strip().split()
|
||||||
|
|
||||||
|
command = args['command']
|
||||||
|
entrypoint = args['entrypoint']
|
||||||
|
image = args['image']
|
||||||
|
mem_limit = args['mem_limit']
|
||||||
|
ports = args['ports']
|
||||||
|
ports = ports.replace('[', '(').replace(']', ')')
|
||||||
|
volumes = args['volumes']
|
||||||
|
|
||||||
|
# if __name__ == "__main__":
|
||||||
|
# print(args)
|
||||||
|
try:
|
||||||
|
|
||||||
|
c = getDClient()
|
||||||
|
conObject = c.containers.run(
|
||||||
|
image=image,
|
||||||
|
mem_limit=mem_limit + 'M',
|
||||||
|
ports=eval(ports),
|
||||||
|
auto_remove=False,
|
||||||
|
command=command,
|
||||||
|
detach=True,
|
||||||
|
stdin_open=True,
|
||||||
|
tty=True,
|
||||||
|
entrypoint=entrypoint,
|
||||||
|
privileged=True,
|
||||||
|
volumes=json.loads(volumes),
|
||||||
|
cpu_shares=10,
|
||||||
|
environment=environments
|
||||||
|
)
|
||||||
|
if conObject:
|
||||||
|
__release_port(ports)
|
||||||
|
return mw.returnJson(True, '创建成功!')
|
||||||
|
|
||||||
|
return mw.returnJson(False, '创建失败!')
|
||||||
|
except docker.errors.APIError as ex:
|
||||||
|
return mw.returnJson(False, '创建失败!' + str(ex))
|
||||||
|
|
||||||
|
|
||||||
|
def dockerLogin():
|
||||||
|
args = getArgs()
|
||||||
|
|
||||||
|
# print(args)
|
||||||
|
data = checkArgs(args, ['user', 'passwd', 'hub_name',
|
||||||
|
'namespace', 'registry', 'repository_name'])
|
||||||
|
if not data[0]:
|
||||||
|
return data[1]
|
||||||
|
|
||||||
|
user_name = args['user']
|
||||||
|
user_pass = args['passwd']
|
||||||
|
registry = args['registry']
|
||||||
|
hub_name = args['hub_name']
|
||||||
|
namespace = args['namespace']
|
||||||
|
repository_name = args['repository_name']
|
||||||
|
|
||||||
|
ret_status = dockerLoginCheck(user_name, user_pass, registry)
|
||||||
|
path = getServerDir()
|
||||||
|
if ret_status:
|
||||||
|
user_file = path + '/user.json'
|
||||||
|
user_info = mw.readFile(user_file)
|
||||||
|
if not user_info:
|
||||||
|
user_info = []
|
||||||
|
else:
|
||||||
|
user_info = json.loads(user_info)
|
||||||
|
|
||||||
|
ret = {}
|
||||||
|
ret['user_name'] = user_name
|
||||||
|
ret['user_pass'] = user_pass
|
||||||
|
ret['registry'] = registry
|
||||||
|
ret['hub_name'] = hub_name
|
||||||
|
ret['namespace'] = namespace
|
||||||
|
ret['repository_name'] = repository_name
|
||||||
|
if not registry:
|
||||||
|
ret['registry'] = "docker.io"
|
||||||
|
user_info.append(ret)
|
||||||
|
mw.writeFile(user_file, json.dumps(user_info))
|
||||||
|
return mw.returnJson(True, '成功登录!')
|
||||||
|
return mw.returnJson(False, '登录失败!')
|
||||||
|
|
||||||
|
|
||||||
|
# 删除用户信息
|
||||||
|
def delete_user_info(registry):
|
||||||
|
path = getServerDir()
|
||||||
|
user_file = path + '/user.json'
|
||||||
|
user_info = mw.readFile(user_file)
|
||||||
|
if user_info:
|
||||||
|
user_info = json.loads(user_info)
|
||||||
|
for i in range(len(user_info)):
|
||||||
|
if registry in user_info[i].values():
|
||||||
|
del(user_info[i])
|
||||||
|
mw.writeFile(user_file, json.dumps(user_info))
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
def dockerLogout():
|
||||||
|
args = getArgs()
|
||||||
|
data = checkArgs(args, ['registry'])
|
||||||
|
if not data[0]:
|
||||||
|
return data[1]
|
||||||
|
|
||||||
|
registry = args['registry']
|
||||||
|
if registry == "docker.io":
|
||||||
|
registry = ""
|
||||||
|
login_test = mw.execShell('docker logout %s' % registry)
|
||||||
|
if registry == "":
|
||||||
|
registry = "docker.io"
|
||||||
|
ret = 'required$|Error'
|
||||||
|
ret2 = re.findall(ret, login_test[-1])
|
||||||
|
delete_user_info(registry)
|
||||||
|
if len(ret2) == 0:
|
||||||
|
return mw.returnJson(True, '退出成功')
|
||||||
|
else:
|
||||||
|
return mw.returnJson(True, '退出失败')
|
||||||
|
|
||||||
|
|
||||||
|
def repoList():
|
||||||
|
path = getServerDir()
|
||||||
|
repostory_info = []
|
||||||
|
user_file = path + '/user.json'
|
||||||
|
|
||||||
|
if os.path.exists(user_file):
|
||||||
|
user_info = mw.readFile(user_file)
|
||||||
|
user_info = json.loads(user_info)
|
||||||
|
for i in user_info:
|
||||||
|
tmp = {}
|
||||||
|
tmp["hub_name"] = i["hub_name"]
|
||||||
|
tmp["registry"] = i["registry"]
|
||||||
|
tmp["namespace"] = i["namespace"]
|
||||||
|
tmp['repository_name'] = i["repository_name"]
|
||||||
|
repostory_info.append(tmp)
|
||||||
|
|
||||||
|
return mw.returnJson(True, 'ok', repostory_info)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
@@ -163,7 +635,35 @@ if __name__ == "__main__":
|
|||||||
print(initdUinstall())
|
print(initdUinstall())
|
||||||
elif func == 'conf':
|
elif func == 'conf':
|
||||||
print(getConf())
|
print(getConf())
|
||||||
elif func == 'run_log':
|
elif func == 'con_list':
|
||||||
print(runLog())
|
print(conListData())
|
||||||
|
elif func == 'docker_con_log':
|
||||||
|
print(dockerLogCon())
|
||||||
|
elif func == 'docker_remove_con':
|
||||||
|
print(dockerRemoveCon())
|
||||||
|
elif func == 'docker_run_con':
|
||||||
|
print(dockerRunCon())
|
||||||
|
elif func == 'docker_stop_con':
|
||||||
|
print(dockerStopCon())
|
||||||
|
elif func == 'docker_exec':
|
||||||
|
print(dockerExec())
|
||||||
|
elif func == 'docker_pull':
|
||||||
|
print(dockerPull())
|
||||||
|
elif func == 'docker_pull_reg':
|
||||||
|
print(dockerPullReg())
|
||||||
|
elif func == 'image_list':
|
||||||
|
print(imageListData())
|
||||||
|
elif func == 'get_docker_create_info':
|
||||||
|
print(getDockerCreateInfo())
|
||||||
|
elif func == 'docker_create_con':
|
||||||
|
print(dockerCreateCon())
|
||||||
|
elif func == 'docker_remove_image':
|
||||||
|
print(dockerRemoveImage())
|
||||||
|
elif func == 'docker_login':
|
||||||
|
print(dockerLogin())
|
||||||
|
elif func == 'docker_logout':
|
||||||
|
print(dockerLogout())
|
||||||
|
elif func == 'repo_list':
|
||||||
|
print(repoList())
|
||||||
else:
|
else:
|
||||||
print('error')
|
print('error')
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
"author": "Zend",
|
"author": "Zend",
|
||||||
"date": "2017-04-01",
|
"date": "2017-04-01",
|
||||||
"home": "https://docker.io",
|
"home": "https://docker.io",
|
||||||
|
"doc1":"https://docker-py.readthedocs.io/",
|
||||||
"type": 0,
|
"type": 0,
|
||||||
"pid": "2"
|
"pid": "2"
|
||||||
}
|
}
|
||||||
@@ -13,13 +13,17 @@ serverPath=$(dirname "$rootPath")
|
|||||||
install_tmp=${rootPath}/tmp/mw_install.pl
|
install_tmp=${rootPath}/tmp/mw_install.pl
|
||||||
VERSION=$2
|
VERSION=$2
|
||||||
|
|
||||||
|
if [ -f ${rootPath}/bin/activate ];then
|
||||||
|
source ${rootPath}/bin/activate
|
||||||
|
fi
|
||||||
|
|
||||||
Install_Docker()
|
Install_Docker()
|
||||||
{
|
{
|
||||||
which docker
|
# which docker
|
||||||
if [ "$?" == "0" ];then
|
# if [ "$?" == "0" ];then
|
||||||
echo '安装已经完成docker' > $install_tmp
|
# echo '安装已经完成docker' > $install_tmp
|
||||||
exit 0
|
# exit 0
|
||||||
fi
|
# fi
|
||||||
|
|
||||||
echo '正在安装脚本文件...' > $install_tmp
|
echo '正在安装脚本文件...' > $install_tmp
|
||||||
mkdir -p $serverPath/source
|
mkdir -p $serverPath/source
|
||||||
@@ -28,6 +32,9 @@ Install_Docker()
|
|||||||
curl -fsSL https://get.docker.com | bash
|
curl -fsSL https://get.docker.com | bash
|
||||||
mkdir -p $serverPath/docker
|
mkdir -p $serverPath/docker
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
pip install docker
|
||||||
|
pip install pytz
|
||||||
|
|
||||||
if [ -d $serverPath/docker ];then
|
if [ -d $serverPath/docker ];then
|
||||||
echo "${VERSION}" > $serverPath/docker/version.pl
|
echo "${VERSION}" > $serverPath/docker/version.pl
|
||||||
|
|||||||
+725
-2
@@ -53,8 +53,731 @@ function dPostCallbak(method, version, args,callback){
|
|||||||
},'json');
|
},'json');
|
||||||
}
|
}
|
||||||
|
|
||||||
function dockerList(){
|
|
||||||
$(".soft-man-con").html('');
|
function logsCon(id){
|
||||||
|
dPost('docker_con_log','',{Hostname:id},function(rdata){
|
||||||
|
var rdata = $.parseJSON(rdata.data);
|
||||||
|
if(!rdata.status) {
|
||||||
|
layer.msg(rdata.msg,{icon:2});
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
layer.open({
|
||||||
|
type:1,
|
||||||
|
title:'Docker日志',
|
||||||
|
area: '600px',
|
||||||
|
closeBtn: 2,
|
||||||
|
content:'<div class="bt-form">'
|
||||||
|
+'<pre class="crontab-log" style="overflow: auto; \
|
||||||
|
border: 0px none; line-height:23px;padding: 15px; \
|
||||||
|
margin: 0px; white-space: pre-wrap; height: 405px; \
|
||||||
|
background-color: rgb(51,51,51);color:#f1f1f1;\
|
||||||
|
border-radius:0px;">'+ (rdata.msg == '' ? 'No logs':rdata.msg) +'</pre>'
|
||||||
|
+'</div>',
|
||||||
|
success:function(index,layers){
|
||||||
|
$(".crontab-log").scrollTop(1000000);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function deleteCon(Hostname){
|
||||||
|
// 删除容器
|
||||||
|
safeMessage('删除容器 ', '删除容器 ['+Hostname+'], 确定?',function(){
|
||||||
|
dPost('docker_remove_con','',{Hostname:Hostname},function(rdata){
|
||||||
|
var rdata = $.parseJSON(rdata.data);
|
||||||
|
showMsg(rdata.msg,function(){
|
||||||
|
if(rdata.status) {
|
||||||
|
dockerConListRender();
|
||||||
|
}
|
||||||
|
},{icon:rdata.status?1:2});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function startCon(Hostname){
|
||||||
|
dPost('docker_run_con','',{Hostname:Hostname},function(rdata){
|
||||||
|
var rdata = $.parseJSON(rdata.data);
|
||||||
|
showMsg(rdata.msg,function(){
|
||||||
|
if(rdata.status) {
|
||||||
|
dockerConListRender();
|
||||||
|
}
|
||||||
|
},{icon:rdata.status?1:2});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function stopCon(Hostname){
|
||||||
|
dPost('docker_stop_con','',{Hostname:Hostname},function(rdata){
|
||||||
|
var rdata = $.parseJSON(rdata.data);
|
||||||
|
showMsg(rdata.msg,function(){
|
||||||
|
if(rdata.status) {
|
||||||
|
dockerConListRender();
|
||||||
|
}
|
||||||
|
},{icon:rdata.status?1:2});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function execCon(Hostname){
|
||||||
|
webShell();
|
||||||
|
var pdata_socket = {};
|
||||||
|
var shell = setInterval(function(){
|
||||||
|
if($('.term-box').length == 0){
|
||||||
|
pdata_socket['data'] = 'exit\n';
|
||||||
|
socket.emit('webssh',pdata_socket);
|
||||||
|
setTimeout(function(){socket.emit('webssh',pdata_socket['data']);},1000);
|
||||||
|
clearInterval(shell);
|
||||||
|
}
|
||||||
|
},500);
|
||||||
|
setTimeout(function(){
|
||||||
|
dPost('docker_exec','',{Hostname:Hostname},function(res){
|
||||||
|
var res = $.parseJSON(res.data);
|
||||||
|
if(!res.status){
|
||||||
|
layer.msg(res.msg,{icon:res.status?1:2});
|
||||||
|
}else{
|
||||||
|
pdata_socket['data'] = 'clear && ' + res.msg +'\n'
|
||||||
|
socket.emit('webssh',pdata_socket);
|
||||||
|
setTimeout(function(){socket.emit('webssh',pdata_socket['data']);},1000);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function dockerConListRender(){
|
||||||
|
dPost('con_list', '', {}, function(rdata){
|
||||||
|
var rdata = $.parseJSON(rdata.data);
|
||||||
|
console.log(rdata);
|
||||||
|
if (!rdata.status){
|
||||||
|
layer.msg(rdata.msg,{icon:2,time:2000});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
var list = '';
|
||||||
|
var rlist = rdata.data;
|
||||||
|
|
||||||
|
for (var i = 0; i < rlist.length; i++) {
|
||||||
|
var docker_status = 'stop';
|
||||||
|
var status = '<span class="glyphicon glyphicon-pause" style="color:red;font-size:12px"></span>';
|
||||||
|
if (rlist[i]['State']['Status'] == 'running'){
|
||||||
|
docker_status = 'start';
|
||||||
|
status = '<span class="glyphicon glyphicon-play" style="color:#20a53a;font-size:12px"></span>';
|
||||||
|
}
|
||||||
|
|
||||||
|
var op = '';
|
||||||
|
op += '<a href="javascript:;" onclick="execCon(\''+rlist[i]['Config']['Hostname']+'\')" class="btlink">终端</a> | ';
|
||||||
|
op += '<a href="javascript:;" onclick="logsCon(\''+rlist[i]['Id']+'\')" class="btlink">日志</a> | ';
|
||||||
|
op += '<a href="javascript:;" onclick="deleteCon(\''+rlist[i]['Config']['Hostname']+'\')" class="btlink">删除</a>';
|
||||||
|
|
||||||
|
list += '<tr>';
|
||||||
|
list += '<td>'+rlist[i]['Name'].substring(1)+'</td>';
|
||||||
|
list += '<td>'+rlist[i]['Config']['Image']+'</td>';
|
||||||
|
list += '<td>'+getFormatTime(rlist[i]['Created'])+'</td>';
|
||||||
|
|
||||||
|
|
||||||
|
if (docker_status == 'start'){
|
||||||
|
list += '<td style="cursor:pointer;" align="center" onclick="stopCon(\''+rlist[i]['Config']['Hostname']+'\')">'+status+'</td>';
|
||||||
|
} else{
|
||||||
|
list += '<td style="cursor:pointer;" align="center" onclick="startCon(\''+rlist[i]['Config']['Hostname']+'\')">'+status+'</td>';
|
||||||
|
}
|
||||||
|
list += '<td class="text-right">'+op+'</td>';
|
||||||
|
list += '</tr>';
|
||||||
|
}
|
||||||
|
|
||||||
|
$('#con_list tbody').html(list);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function createConTemplate(){
|
||||||
|
|
||||||
|
dPost('get_docker_create_info','',{},function(rdata){
|
||||||
|
var rdata = $.parseJSON(rdata.data);
|
||||||
|
console.log(rdata);
|
||||||
|
var rdata = rdata.data;
|
||||||
|
var imageOpt = '';
|
||||||
|
for(var i=0;i<rdata.images.length;i++){
|
||||||
|
var imageName = rdata.images[i].RepoTags.indexOf('panel') == -1? rdata.images[i].RepoTags:'aaPanel:'+rdata.images[i].RepoTags.split(':')[1];
|
||||||
|
imageOpt += '<option value="'+rdata.images[i].RepoTags+'">'+imageName+'</option>';
|
||||||
|
}
|
||||||
|
var iplistOpt = '';
|
||||||
|
for(var i=0;i<rdata.iplist.length;i++){
|
||||||
|
iplistOpt += '<option value="'+rdata.iplist[i].address+'">'+rdata.iplist[i].address+'</option>';
|
||||||
|
}
|
||||||
|
|
||||||
|
var layer_index = layer.open({
|
||||||
|
type: 1,
|
||||||
|
title: "创建容器",
|
||||||
|
area: '556',
|
||||||
|
closeBtn: 2,
|
||||||
|
shadeClose: false,
|
||||||
|
btn: ['确定', '取消'],
|
||||||
|
content: '<div class="bt-form pd20 pb70 ceart-docker new_tname">\
|
||||||
|
<div class="line">\
|
||||||
|
<span class="tname">镜像</span>\
|
||||||
|
<div class="info-r c4"><select class="bt-input-text docker-image" style="width:330px">'+imageOpt+'</select></div>\
|
||||||
|
</div>\
|
||||||
|
<div class="line">\
|
||||||
|
<span class="tname">绑定IP</span>\
|
||||||
|
<div class="info-r c4"><select class="bt-input-text docker-address" style="width:330px"><option value="0.0.0.0">0.0.0.0</optin>'+iplistOpt+'</select></div>\
|
||||||
|
</div>\
|
||||||
|
<div class="line">\
|
||||||
|
<span class="tname">端口映射</span>\
|
||||||
|
<div class="info-r c4">\
|
||||||
|
<div class="type-port">\
|
||||||
|
<input class="bt-input-text" name="name1" type="number" placeholder="容器端口" style="width:110px;margin-right:15px">\
|
||||||
|
<select class="bt-input-text" style="width:90px;margin-right:15px"><option value="TCP">TCP</optin><option value="UDP">UDP</optin></select>\
|
||||||
|
<input class="bt-input-text" name="name2" type="number" placeholder="服务器端口" style="width:90px">\
|
||||||
|
<span class="plus glyphicon glyphicon-plus" style="color: #20a53a;font-size: 11px;"></span>\
|
||||||
|
</div>\
|
||||||
|
<div class="divtable" style="max-height:100px;overflow:auto; margin-top:15px;width:330px;padding-left: 0px;">\
|
||||||
|
<table class="table table-hover">\
|
||||||
|
<tbody id="portabletr"><tr class="more1"><td>当前未添加端口映射</td></tr></tbody>\
|
||||||
|
</table>\
|
||||||
|
</div>\
|
||||||
|
</div>\
|
||||||
|
</div>\
|
||||||
|
<div class="line">\
|
||||||
|
<span class="tname">目录映射</span>\
|
||||||
|
<div class="info-r c4">\
|
||||||
|
<div class="type-volumes">\
|
||||||
|
<input class="bt-input-text" name="path1" type="text" placeholder="容器目录" style="width:110px;margin-right:15px">\
|
||||||
|
<select class="bt-input-text" style="width:90px;margin-right:15px"><option value="rw">read-write</optin><option value="ro">read only</optin></select>\
|
||||||
|
<input class="bt-input-text" name="path2" type="text" placeholder="服务器目录" style="width:90px">\
|
||||||
|
<span class="plus2 glyphicon glyphicon-plus" style="color: #20a53a;font-size: 11px;"></span>\
|
||||||
|
</div>\
|
||||||
|
<div class="divtable" style="max-height:100px;overflow:auto; margin-top:15px;width:330px;padding-left: 0px;">\
|
||||||
|
<table class="table table-hover">\
|
||||||
|
<tbody id="portabletr2"><tr class="more2"><td>当前未添加目录映射</td></tr></tbody>\
|
||||||
|
</table>\
|
||||||
|
</div>\
|
||||||
|
</div>\
|
||||||
|
</div>\
|
||||||
|
<div class="line">\
|
||||||
|
<span class="tname" style="height: auto;line-height: 20px;">环境变量<br>(每行一个)</span>\
|
||||||
|
<div class="info-r c4" style="margin-bottom: 0;">\
|
||||||
|
<div class="type-volumes">\
|
||||||
|
<textarea placeholder="Add variables format as following, one per line:\nJAVA_HOME=/usr/local/java8 HOSTNAME=master" name="environments" class="docker-environments"></textarea>\
|
||||||
|
</div>\
|
||||||
|
</div>\
|
||||||
|
</div>\
|
||||||
|
<div class="line">\
|
||||||
|
<span class="tname">内存配额</span>\
|
||||||
|
<div class="info-r c4"><input class="bt-input-text mr5 docker-mem" type="number" style="width:100px" value="'+parseInt(rdata.memSize/2)+'">\
|
||||||
|
<span class="dc-un">MB</span><i class="help">不超过, '+ rdata.memSize +'MB</i></div>\
|
||||||
|
</div>\
|
||||||
|
<div class="line">\
|
||||||
|
<span class="tname">CPU配额</span>\
|
||||||
|
<div class="info-r c4">\
|
||||||
|
<input class="bt-input-text mr5 docker-cpu" type="number" max="100" min="1" style="width:100px" value="100">\
|
||||||
|
<span class="dc-un"></span><i class="help">越大,占用的CPU越多</i></div>\
|
||||||
|
</div>\
|
||||||
|
<div class="line">\
|
||||||
|
<span class="tname">执行命令</span>\
|
||||||
|
<div class="info-r c4"><input class="bt-input-text docker-command" type="text" style="width:330px" value="" placeholder="/bin/bash"></div>\
|
||||||
|
</div>\
|
||||||
|
<div class="line" style="display:none">\
|
||||||
|
<span class="tname">entrypoint</span>\
|
||||||
|
<div class="info-r c4"><input class="bt-input-text docker-entrypoint" type="text" style="width:300px" value=""></div>\
|
||||||
|
</div>\
|
||||||
|
</div>',
|
||||||
|
success:function(){
|
||||||
|
$(".bt-cancel").click(function(){
|
||||||
|
layer.close(layer_index);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
$(".plus").click(function(){
|
||||||
|
var name1 = $(".type-port input[name='name1']").val();
|
||||||
|
var name2 = $(".type-port input[name='name2']").val();
|
||||||
|
if(name1 < 1 || name1 > 65535 || name2 < 1 || name2 > 65535 || isNaN(name1) || isNaN(name2)){
|
||||||
|
layer.msg('Port setting value range is invalid, range [1-65535]',{icon:2});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var portval = $('#portabletr')[0].childNodes;
|
||||||
|
for(var i=0;i<portval.length;i++){
|
||||||
|
if(portval[i].childNodes[0].innerText == '当前未添加目录映射') continue;
|
||||||
|
var sport = portval[i].childNodes[2].innerText;
|
||||||
|
if(name2 == sport){
|
||||||
|
layer.msg('The port ['+name2+'] is already in the mapping list!',{icon:2});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var address = $('.docker-address').val();
|
||||||
|
if(address == '0.0.0.0'){
|
||||||
|
address = '*';
|
||||||
|
}
|
||||||
|
var port = address + ':' + name2;
|
||||||
|
var loadT = layer.msg('Testing <img src="/static/img/ing.gif">',{icon:16,time:0,shade: [0.3, "#000"]});
|
||||||
|
$.post('/plugin?action=a&name=docker&s=IsPortExists',{port:port},function(rdata){
|
||||||
|
layer.close(loadT);
|
||||||
|
if(rdata !== false){
|
||||||
|
layer.msg('Port ['+name2+'] is already in the mapping list!',{icon:2});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var selecttype = $(".type-port select").val();
|
||||||
|
var portable= '<tr><td>'+name1+'</td><td>'+selecttype+'</td><td>'+name2+'</td><td class="text-right" width="60"><a href="javascript:;" class="btlink minus">Del</a></td></tr>';
|
||||||
|
$("#portabletr").append(portable);
|
||||||
|
$(".more1").remove();
|
||||||
|
$(".minus").click(function(){
|
||||||
|
$(this).parents("tr").remove();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
$(".plus2").click(function(){
|
||||||
|
var path1 = $(".type-volumes input[name='path1']").val();
|
||||||
|
var path2 = $(".type-volumes input[name='path2']").val();
|
||||||
|
|
||||||
|
var notPath = ['/boot','/bin','/sbin','/etc','/usr/bin','/usr/sbin','/dev']
|
||||||
|
if($.inArray(path2,notPath) != -1){
|
||||||
|
layer.msg('Cannot map' + path2,{icon:2});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var portval = $('#portabletr2')[0].childNodes;
|
||||||
|
for(var i=0;i<portval.length;i++){
|
||||||
|
if(portval[i].childNodes[0].innerText == '当前未添加目录映射') continue;
|
||||||
|
var sport = portval[i].childNodes[2].innerText;
|
||||||
|
if(path2 == sport){
|
||||||
|
layer.msg('Directory ['+path2+'] is already in the mapping list!',{icon:2});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var selecttype = $(".type-volumes select").val();
|
||||||
|
var portable= '<tr>\
|
||||||
|
<td class="td_width_1" title="'+path1+'">'+path1+'</td>\
|
||||||
|
<td>'+selecttype+'</td><td title="'+path2+'" class="td_width_1" style="max-width: 138px;">'+path2+'</td>\
|
||||||
|
<td class="text-right" width="50"><a href="javascript:;" class="btlink minus2">Del</a></td>\
|
||||||
|
</tr>';
|
||||||
|
$("#portabletr2").append(portable);
|
||||||
|
$(".more2").remove();
|
||||||
|
$(".minus2").click(function(){
|
||||||
|
$(this).parents("tr").remove();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
yes:function(layero,layer_id){
|
||||||
|
var ports = {};
|
||||||
|
var volumes = {};
|
||||||
|
var portval = $('#portabletr')[0].childNodes;
|
||||||
|
var address = $('.docker-address').val();
|
||||||
|
var portval2 = $('#portabletr2')[0].childNodes;
|
||||||
|
var command = $('.docker-command').val()
|
||||||
|
var entrypoint = $('.docker-entrypoint').val()
|
||||||
|
var accept = [];
|
||||||
|
|
||||||
|
//遍历端口映射
|
||||||
|
for(var i=0;i<portval.length;i++){
|
||||||
|
// console.log(portval[i].childNodes[0].innerText);
|
||||||
|
if(portval[i].childNodes[0].innerText == '当前未添加端口映射') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
var port = portval[i].childNodes[0].innerText.replace(/\s/g,'');
|
||||||
|
var dport = port + '/' + portval[i].childNodes[1].innerText.toLowerCase().replace(/\s/g,'');
|
||||||
|
var sport = [address,parseInt(portval[i].childNodes[2].innerText.replace(/\s/g,''))];
|
||||||
|
ports[dport] = sport
|
||||||
|
accept.push(port);
|
||||||
|
}
|
||||||
|
|
||||||
|
//遍历目录映射
|
||||||
|
volumes['/sys/fs/cgroup'] = {'bind':'/sys/fs/cgroup', 'mode': 'rw'};
|
||||||
|
for(var i=0;i<portval2.length;i++){
|
||||||
|
if(portval2[i].childNodes[0].innerText.replace(/\s/g,' ') == '当前未添加目录映射') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
var dpath = portval2[i].childNodes[2].innerText.replace(/\s/g,'');
|
||||||
|
var spath = {'bind':portval2[i].childNodes[0].innerText.replace(/\s/g,''),'mode':portval2[i].childNodes[1].innerText.toLowerCase().replace(/\s/g,'')};
|
||||||
|
volumes[dpath] = spath
|
||||||
|
}
|
||||||
|
|
||||||
|
var data = {
|
||||||
|
image:$('.docker-image').val(),
|
||||||
|
ports:JSON.stringify(ports),
|
||||||
|
accept:JSON.stringify(accept),
|
||||||
|
volumes:JSON.stringify(volumes),
|
||||||
|
environments:$('.docker-environments').val(),
|
||||||
|
mem_limit:$('.docker-mem').val(),
|
||||||
|
cpu_shares:$('.docker-cpu').val(),
|
||||||
|
command:command,
|
||||||
|
entrypoint:entrypoint
|
||||||
|
}
|
||||||
|
|
||||||
|
if(data.mem_limit > rdata.memSize){
|
||||||
|
layer.msg('内存配额不能大于物理内存 ['+rdata.memSize+']!',{icon:2});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(data.cpu_shares > 100 || data.cpu_shares < 1){
|
||||||
|
layer.msg('CPU配额设置值范围应为 [1-100]!',{icon:2});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
dPost('docker_create_con','', data, function(rdata){
|
||||||
|
var rdata = $.parseJSON(rdata.data);
|
||||||
|
showMsg(rdata.msg,function(){
|
||||||
|
if(rdata.status) {
|
||||||
|
layer.close(layer_index);
|
||||||
|
dockerConListRender();
|
||||||
|
}
|
||||||
|
},{ icon: rdata.status ? 1 : 2 });
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function dockerConList(){
|
||||||
|
|
||||||
|
var con = '<div class="safe bgw">\
|
||||||
|
<button onclick="createConTemplate();" class="btn btn-success btn-sm" type="button" style="margin-right: 5px;">创建容器</button>\
|
||||||
|
<div class="divtable mtb10">\
|
||||||
|
<div class="tablescroll">\
|
||||||
|
<table id="con_list" class="table table-hover" width="100%" cellspacing="0" cellpadding="0" border="0" style="border: 0 none;">\
|
||||||
|
<thead><tr>\
|
||||||
|
<th>名称</th>\
|
||||||
|
<th>镜像</th>\
|
||||||
|
<th>创建时间</th>\
|
||||||
|
<th>状态</th>\
|
||||||
|
<th style="text-align:right;">操作</th></tr></thead>\
|
||||||
|
<tbody></tbody></table>\
|
||||||
|
</div>\
|
||||||
|
</div>\
|
||||||
|
</div>';
|
||||||
|
|
||||||
|
$(".soft-man-con").html(con);
|
||||||
|
dockerConListRender();
|
||||||
|
}
|
||||||
|
|
||||||
|
function deleteImages(tag, id){
|
||||||
|
safeMessage('删除镜像','删除镜像['+tag+'],确定?',function(){
|
||||||
|
dPost('docker_remove_image','', {imageId:id,repoTags:tag},function(rdata){
|
||||||
|
var rdata = $.parseJSON(rdata.data);
|
||||||
|
showMsg(rdata.msg,function(){
|
||||||
|
if(rdata.status) {
|
||||||
|
dockerImageListRender();
|
||||||
|
}
|
||||||
|
},{ icon: rdata.status ? 1 : 2 });
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function pullImages(tag, id){
|
||||||
|
console.log(tag, id);
|
||||||
|
layer.msg('开发中!',{ icon: 2 });
|
||||||
|
}
|
||||||
|
|
||||||
|
function dockerImageListRender(){
|
||||||
|
dPost('image_list', '', {}, function(rdata){
|
||||||
|
var rdata = $.parseJSON(rdata.data);
|
||||||
|
console.log(rdata);
|
||||||
|
if (!rdata.status){
|
||||||
|
layer.msg(rdata.msg,{icon:2,time:2000});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var list = '';
|
||||||
|
var rlist = rdata.data;
|
||||||
|
|
||||||
|
for (var i = 0; i < rlist.length; i++) {
|
||||||
|
|
||||||
|
var tag = rlist[i]['RepoTags'].split(":")[1];
|
||||||
|
|
||||||
|
var license = 'null';
|
||||||
|
var desc = 'null';
|
||||||
|
if (rlist[i]['Labels'] == null){
|
||||||
|
license = 'free';
|
||||||
|
}
|
||||||
|
|
||||||
|
var op = '';
|
||||||
|
op += '<a href="javascript:;" onclick="pullImages(\''+rlist[i]['RepoTags']+'\',\''+rlist[i]['Id']+'\')" class="btlink">拉取</a> | ';
|
||||||
|
op += '<a href="javascript:;" onclick="deleteImages(\''+rlist[i]['RepoTags']+'\',\''+rlist[i]['Id']+'\')" class="btlink">删除</a>';
|
||||||
|
|
||||||
|
list += '<tr>';
|
||||||
|
list += '<td>'+rlist[i]['RepoTags']+'</td>';
|
||||||
|
list += '<td>'+tag+'</td>';
|
||||||
|
list += '<td>'+toSize(rlist[i]['Size'])+'</td>';
|
||||||
|
list += '<td>'+license+'</td>';
|
||||||
|
list += '<td>'+desc+'</td>';
|
||||||
|
list += '<td class="text-right">'+op+'</td>';
|
||||||
|
list += '</tr>';
|
||||||
|
}
|
||||||
|
|
||||||
|
$('#con_list tbody').html(list);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function dockerPullImagesFileTemplate(){
|
||||||
|
// 拉取镜像文件模板
|
||||||
|
var layer_index = layer.open({
|
||||||
|
type: 1,
|
||||||
|
title: "获取镜像",
|
||||||
|
area: '500px',
|
||||||
|
closeBtn: 2,
|
||||||
|
shadeClose: false,
|
||||||
|
content: '<div class="bt-docker pd20">'+
|
||||||
|
'<div class="docker-sub">'+
|
||||||
|
'<span class="on">官方库</span>'+
|
||||||
|
'<span>公共库</span>'+
|
||||||
|
'<span>私有库</span>'+
|
||||||
|
'</div>'+
|
||||||
|
'<div class="bt-form bt-docker-con">'+
|
||||||
|
'<div class="conter official_pull pd15"><div class="line">'+
|
||||||
|
'<span class="tname">镜像名:</span>\
|
||||||
|
<div class="info-r c4">\
|
||||||
|
<input class="bt-input-text mr5" type="text" name="official_pull_name" style="width:218px" value="">\
|
||||||
|
<button type="button" class="btn btn-sm btn-success official_pull_btn">获取</button>\
|
||||||
|
</div>'+
|
||||||
|
'</div></div>'+
|
||||||
|
'<div class="conter public_pull pd15" style="display: none;"><div class="line">'+
|
||||||
|
'<span class="tname">镜像名:</span>\
|
||||||
|
<div class="info-r c4">\
|
||||||
|
<input class="bt-input-text mr5" type="text" name="public_pull_path" style="width:218px" value="">\
|
||||||
|
<button type="button" class="btn btn-sm btn-success public_pull_btn">获取</button>\
|
||||||
|
</div>'+
|
||||||
|
'</div></div>'+
|
||||||
|
'<div class="conter private_pull pd15" style="display: none;">'+
|
||||||
|
'<div class="line"><span class="tname">镜像地址:</span>\
|
||||||
|
<div class="info-r c4">\
|
||||||
|
<input class="bt-input-text mr5" type="text" name="private_pull_path" style="width:218px" value="">\
|
||||||
|
<button type="button" class="btn btn-sm btn-success private_pull_btn">获取</button>\
|
||||||
|
</div>\
|
||||||
|
</div>\
|
||||||
|
</div>\
|
||||||
|
</div>\
|
||||||
|
</div>',
|
||||||
|
success:function(layero,layer_id){
|
||||||
|
|
||||||
|
$('.docker-sub span').click(function(){
|
||||||
|
var index = $(this).index();
|
||||||
|
$(this).addClass('on').siblings().removeClass('on');
|
||||||
|
$(this).parent().next().find('.conter').eq(index).show().siblings().hide();
|
||||||
|
});
|
||||||
|
|
||||||
|
$('.official_pull_btn').click(function(){
|
||||||
|
var name = $('[name="official_pull_name"]').val();
|
||||||
|
if(name == ''){
|
||||||
|
layer.msg('镜像名不能为空!');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
dPost('docker_pull','',{images:name}, function(rdata){
|
||||||
|
var rdata = $.parseJSON(rdata.data);
|
||||||
|
showMsg(rdata.msg,function(){
|
||||||
|
if(rdata.status) {
|
||||||
|
layer.close(layer_index);
|
||||||
|
dockerImageListRender();
|
||||||
|
|
||||||
|
}
|
||||||
|
},{ icon: rdata.status ? 1 : 2 });
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
$('.public_pull_btn').click(function(){
|
||||||
|
var path = $('[name="public_pull_path"]').val();
|
||||||
|
if(path == ''){
|
||||||
|
layer.msg('公共网络镜像地址不能为空。');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
dPost('docker_pull_reg','',{path:path}, function(rdata){
|
||||||
|
var rdata = $.parseJSON(rdata.data);
|
||||||
|
showMsg(rdata.msg,function(){
|
||||||
|
if(rdata.status) {
|
||||||
|
layer.close(layer_index);
|
||||||
|
dockerImageListRender();
|
||||||
|
}
|
||||||
|
},{ icon: rdata.status ? 1 : 2 });
|
||||||
|
});
|
||||||
|
});
|
||||||
|
$('.private_pull_btn').click(function(){
|
||||||
|
var path = $('[name="private_pull_path"]').val();
|
||||||
|
if(path == ''){
|
||||||
|
layer.msg('专用镜像地址不能为空!');
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
dPost('docker_pull_private_new','',{path:path}, function(rdata){
|
||||||
|
var rdata = $.parseJSON(rdata.data);
|
||||||
|
showMsg(rdata.msg,function(){
|
||||||
|
if(rdata.status) {
|
||||||
|
layer.close(layer_index);
|
||||||
|
dockerImageListRender();
|
||||||
|
}
|
||||||
|
},{ icon: rdata.status ? 1 : 2 });
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function dockerImageList(){
|
||||||
|
|
||||||
|
var con = '<div class="safe bgw">\
|
||||||
|
<button onclick="dockerPullImagesFileTemplate()" class="btn btn-success btn-sm" type="button" style="margin-right: 5px;">获取镜像</button>\
|
||||||
|
<div class="divtable mtb10">\
|
||||||
|
<div class="tablescroll">\
|
||||||
|
<table id="con_list" class="table table-hover" width="100%" cellspacing="0" cellpadding="0" border="0" style="border: 0 none;">\
|
||||||
|
<thead><tr>\
|
||||||
|
<th>名称</th>\
|
||||||
|
<th>版本</th>\
|
||||||
|
<th>大小</th>\
|
||||||
|
<th>证书</th>\
|
||||||
|
<th>描述</th>\
|
||||||
|
<th style="text-align:right;">操作</th></tr></thead>\
|
||||||
|
<tbody></tbody></table>\
|
||||||
|
</div>\
|
||||||
|
<div id="databasePage" class="dataTables_paginate paging_bootstrap page"></div>\
|
||||||
|
</div>\
|
||||||
|
</div>';
|
||||||
|
|
||||||
|
$(".soft-man-con").html(con);
|
||||||
|
|
||||||
|
dockerImageListRender();
|
||||||
|
}
|
||||||
|
|
||||||
|
// login
|
||||||
|
function repoLogin(){
|
||||||
|
var _option1= "";
|
||||||
|
var obj = {hub_name: "", namespace: "",name: "", registry: "", user_pass: "", user_name: "",arry: ['Docker Repository','Other Repository']};
|
||||||
|
for(var i = 0; i< obj.arry.length;i++){
|
||||||
|
_option1 += '<option value="'+ obj.arry[i] +'">'+ obj.arry[i] +'</option>';
|
||||||
|
}
|
||||||
|
var layer_index = layer.open({
|
||||||
|
type: 1,
|
||||||
|
title: "登录到存储库",
|
||||||
|
area: '450px',
|
||||||
|
closeBtn: 2,
|
||||||
|
shadeClose: false,
|
||||||
|
content: '<div class="bt-docker-con docker_content">'+
|
||||||
|
'<style>.line .tname{width:120px;}</style>'+
|
||||||
|
'<div class="soft-man-con pd20 pb70 private_pull">'+
|
||||||
|
'<div class="line"><span class="tname">Repository Type</span><div class="info-r c4"><select class="bt-input-text mr5 project_version" name="dtype" style="width:250px">'+ _option1 +'</select></div></div>'+
|
||||||
|
'<div class="line"><span class="tname">Name:</span><div class="info-r"><input class="bt-input-text" type="text" name="ctm_name" style="width:250px" value="'+obj.name+'"></div></div>'+
|
||||||
|
'<div class="line"><span class="tname">Username:</span><div class="info-r"><input class="bt-input-text" type="text" name="user" style="width:250px" value="'+obj.user_name+'"></div></div>'+
|
||||||
|
'<div class="line"><span class="tname">Password:</span><div class="info-r"><input class="bt-input-text" type="password" name="passwd" style="width:250px" value="'+obj.user_pass+'"></div></div>'+
|
||||||
|
'<div class="line"><span class="tname">Repository Name:</span><div class="info-r"><input class="bt-input-text" type="text" name="hub_name" style="width:250px" value="'+obj.hub_name+'"></div></div>'+
|
||||||
|
'<div class="line"><span class="tname">Namespaces:</span><div class="info-r"><input class="bt-input-text" type="text" name="namespace" style="width:250px" value="'+obj.namespace+'"></div></div>'+
|
||||||
|
'<div class="line" style="display:none"><span class="tname">Registry:</span><div class="info-r"><input class="bt-input-text" type="text" name="registry" style="width:250px" value="'+obj.registry+'"></div></div>'+
|
||||||
|
'<div class="bt-form-submit-btn"><button type="button" class="btn btn-sm btn-success login_aliyun">登录</button></div>'+
|
||||||
|
'</div>'+
|
||||||
|
'</div>',
|
||||||
|
success:function(){
|
||||||
|
$('[name="dtype"]').change(function(e){
|
||||||
|
var docker_type = $(this).val();
|
||||||
|
if(docker_type == 'Other Repository'){
|
||||||
|
$('.docker_content .line').show();
|
||||||
|
}else{
|
||||||
|
$('.docker_content .line').filter(":lt(3)").show().end().filter(":gt(4)").hide();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$('.login_aliyun').click(function(){
|
||||||
|
var user = $('[name="user"]').val(),
|
||||||
|
passwd = $('[name="passwd"]').val(),
|
||||||
|
registry = $('[name="registry"]').val(),
|
||||||
|
name = $('[name="ctm_name"]').val(),
|
||||||
|
hub_name = $('[name="hub_name"]').val(),
|
||||||
|
namespace = $('[name="namespace"]').val();
|
||||||
|
|
||||||
|
var args = {
|
||||||
|
user:user,
|
||||||
|
passwd:passwd,
|
||||||
|
registry:'',
|
||||||
|
repository_name:name,
|
||||||
|
hub_name:hub_name,
|
||||||
|
namespace:namespace
|
||||||
|
};
|
||||||
|
if($('[name="dtype"]').val() == 'Docker Repository'){
|
||||||
|
args.registry = '';
|
||||||
|
}else{
|
||||||
|
args.registry = registry;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(obj);
|
||||||
|
dPost('docker_login', '', args, function(rdata){
|
||||||
|
var rdata = $.parseJSON(rdata.data);
|
||||||
|
console.log(rdata);
|
||||||
|
layer.msg(rdata.msg,{icon:rdata.status?1:2});
|
||||||
|
if(res.status){
|
||||||
|
repoListRender();
|
||||||
|
layer.close(layer_index);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function delRepo(address){
|
||||||
|
safeMessage('退出','你将退出 ['+address+'],确定?',function(){
|
||||||
|
dPost('docker_logout', '',
|
||||||
|
{registry:address},
|
||||||
|
function(rdata){
|
||||||
|
var rdata = $.parseJSON(rdata.data);
|
||||||
|
layer.msg(rdata.msg,{icon:rdata.status?1:2});
|
||||||
|
if(rdata.status) {
|
||||||
|
repoListRender();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function repoListRender(){
|
||||||
|
dPost('repo_list', '', {}, function(rdata){
|
||||||
|
var rdata = $.parseJSON(rdata.data);
|
||||||
|
console.log(rdata);
|
||||||
|
if (!rdata.status){
|
||||||
|
layer.msg(rdata.msg,{icon:2,time:2000});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var list = '';
|
||||||
|
var rlist = rdata.data;
|
||||||
|
|
||||||
|
for (var i = 0; i < rlist.length; i++) {
|
||||||
|
|
||||||
|
list += '<tr>';
|
||||||
|
list += '<td>'+rlist[i]['hub_name']+'</td>';
|
||||||
|
list += '<td>'+rlist[i]['repository_name']+'</td>';
|
||||||
|
list += '<td>'+rlist[i]['namespace']+'</td>';
|
||||||
|
list += '<td>'+rlist[i]['registry']+'</td>';
|
||||||
|
list += '<td class="text-right"><a href="javascript:;" onclick="delRepo(\''+rlist[i]['registry']+'\')" class="btlink">删除</a></td>';
|
||||||
|
list += '</tr>';
|
||||||
|
}
|
||||||
|
|
||||||
|
$('#con_list tbody').html(list);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
function repoList(){
|
||||||
|
|
||||||
|
var con = '<div class="safe bgw">\
|
||||||
|
<button id="docker_login" title="" class="btn btn-success btn-sm" type="button" style="margin-right: 5px;">登录</button>\
|
||||||
|
<div class="divtable mtb10">\
|
||||||
|
<div class="tablescroll">\
|
||||||
|
<table id="con_list" class="table table-hover" width="100%" cellspacing="0" cellpadding="0" border="0" style="border: 0 none;">\
|
||||||
|
<thead><tr>\
|
||||||
|
<th>Name</th>\
|
||||||
|
<th>Repository Name</th>\
|
||||||
|
<th>NameSpace</th>\
|
||||||
|
<th>地址</th>\
|
||||||
|
<th style="text-align:right;">操作</th></tr></thead>\
|
||||||
|
<tbody>\
|
||||||
|
' + '</tbody></table>\
|
||||||
|
</div>\
|
||||||
|
<div id="databasePage" class="dataTables_paginate paging_bootstrap page"></div>\
|
||||||
|
</div>\
|
||||||
|
</div>';
|
||||||
|
|
||||||
|
$(".soft-man-con").html(con);
|
||||||
|
|
||||||
|
//login
|
||||||
|
$('#docker_login').click(function(){
|
||||||
|
repoLogin();
|
||||||
|
});
|
||||||
|
|
||||||
|
repoListRender();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ max_connections = 500
|
|||||||
max_connect_errors = 100
|
max_connect_errors = 100
|
||||||
open_files_limit = 65535
|
open_files_limit = 65535
|
||||||
|
|
||||||
skip-name-resolve=1
|
skip_name_resolve=1
|
||||||
#skip-grant-tables
|
#skip-grant-tables
|
||||||
#skip-networking
|
#skip-networking
|
||||||
#skip-external-locking
|
#skip-external-locking
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ max_connections = 500
|
|||||||
max_connect_errors = 100
|
max_connect_errors = 100
|
||||||
open_files_limit = 65535
|
open_files_limit = 65535
|
||||||
|
|
||||||
skip-name-resolve=1
|
skip_name_resolve=1
|
||||||
#skip-grant-tables
|
#skip-grant-tables
|
||||||
#skip-networking
|
#skip-networking
|
||||||
#skip-external-locking
|
#skip-external-locking
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ max_connect_errors = 100
|
|||||||
open_files_limit = 2560
|
open_files_limit = 2560
|
||||||
max_allowed_packet = 128M
|
max_allowed_packet = 128M
|
||||||
|
|
||||||
skip_name_resolve = 1
|
skip_name_resolve=1
|
||||||
skip-ssl
|
skip-ssl
|
||||||
#skip-networking
|
#skip-networking
|
||||||
#skip-external-locking
|
#skip-external-locking
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ max_connect_errors = 100
|
|||||||
open_files_limit = 2560
|
open_files_limit = 2560
|
||||||
max_allowed_packet = 128M
|
max_allowed_packet = 128M
|
||||||
|
|
||||||
skip_name_resolve = 1
|
skip_name_resolve=1
|
||||||
#skip-networking
|
#skip-networking
|
||||||
#skip-external-locking
|
#skip-external-locking
|
||||||
#loose-skip-innodb
|
#loose-skip-innodb
|
||||||
|
|||||||
@@ -181,7 +181,7 @@ function changeMySQLDataPath(act) {
|
|||||||
$.post('/database?action=GetMySQLInfo', '', function(rdata) {
|
$.post('/database?action=GetMySQLInfo', '', function(rdata) {
|
||||||
var LimitCon = '<p class="conf_p">\
|
var LimitCon = '<p class="conf_p">\
|
||||||
<input id="datadir" class="phpUploadLimit bt-input-text mr5" style="width:350px;" type="text" value="' + rdata.datadir + '" name="datadir">\
|
<input id="datadir" class="phpUploadLimit bt-input-text mr5" style="width:350px;" type="text" value="' + rdata.datadir + '" name="datadir">\
|
||||||
<span onclick="ChangePath(\'datadir\')" class="glyphicon glyphicon-folder-open cursor mr20" style="width:auto"></span><button class="btn btn-success btn-sm" onclick="changeMySQLDataPath(1)">' + lan.soft.mysql_to + '</button>\
|
<span onclick="changePath(\'datadir\')" class="glyphicon glyphicon-folder-open cursor mr20" style="width:auto"></span><button class="btn btn-success btn-sm" onclick="changeMySQLDataPath(1)">' + lan.soft.mysql_to + '</button>\
|
||||||
</p>';
|
</p>';
|
||||||
$(".soft-man-con").html(LimitCon);
|
$(".soft-man-con").html(LimitCon);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -86,6 +86,7 @@ Install_mysql()
|
|||||||
make -j${cpuCore} && make install && make clean
|
make -j${cpuCore} && make install && make clean
|
||||||
|
|
||||||
if [ -d $serverPath/mysql ];then
|
if [ -d $serverPath/mysql ];then
|
||||||
|
rm -rf ${mysqlDir}/mysql-${VERSION}
|
||||||
echo '5.5' > $serverPath/mysql/version.pl
|
echo '5.5' > $serverPath/mysql/version.pl
|
||||||
echo '安装完成' > $install_tmp
|
echo '安装完成' > $install_tmp
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -105,6 +105,7 @@ Install_mysql()
|
|||||||
|
|
||||||
|
|
||||||
if [ -d $serverPath/mysql ];then
|
if [ -d $serverPath/mysql ];then
|
||||||
|
rm -rf ${mysqlDir}/mysql-${VERSION}
|
||||||
echo '5.6' > $serverPath/mysql/version.pl
|
echo '5.6' > $serverPath/mysql/version.pl
|
||||||
echo '安装完成' > $install_tmp
|
echo '安装完成' > $install_tmp
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -118,6 +118,7 @@ Install_mysql()
|
|||||||
make -j${cpuCore} && make install && make clean
|
make -j${cpuCore} && make install && make clean
|
||||||
|
|
||||||
if [ -d $serverPath/mysql ];then
|
if [ -d $serverPath/mysql ];then
|
||||||
|
rm -rf ${mysqlDir}/mysql-${VERSION}
|
||||||
echo '5.7' > $serverPath/mysql/version.pl
|
echo '5.7' > $serverPath/mysql/version.pl
|
||||||
echo '安装完成' > $install_tmp
|
echo '安装完成' > $install_tmp
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -210,6 +210,7 @@ Install_mysql()
|
|||||||
make -j${cpuCore} && make install && make clean
|
make -j${cpuCore} && make install && make clean
|
||||||
|
|
||||||
if [ -d $serverPath/mysql ];then
|
if [ -d $serverPath/mysql ];then
|
||||||
|
rm -rf ${mysqlDir}/mysql-${VERSION}
|
||||||
echo '8.0' > $serverPath/mysql/version.pl
|
echo '8.0' > $serverPath/mysql/version.pl
|
||||||
echo '安装完成' > $install_tmp
|
echo '安装完成' > $install_tmp
|
||||||
else
|
else
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 878 B |
Executable
+26
@@ -0,0 +1,26 @@
|
|||||||
|
<div class="bt-form">
|
||||||
|
<div class="bt-w-main">
|
||||||
|
<div class='plugin_version'></div>
|
||||||
|
<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="nezha.readme();">说明</p>
|
||||||
|
</div>
|
||||||
|
<div class="bt-w-con pd15">
|
||||||
|
<div class="soft-man-con"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
resetPluginWinHeight(530);
|
||||||
|
$.getScript( "/plugins/file?name=nezha&f=js/nezha.js", function(){
|
||||||
|
nezha.init();
|
||||||
|
pluginService('nezha');
|
||||||
|
});
|
||||||
|
</script>
|
||||||
Executable
+364
@@ -0,0 +1,364 @@
|
|||||||
|
# coding:utf-8
|
||||||
|
|
||||||
|
import sys
|
||||||
|
import io
|
||||||
|
import os
|
||||||
|
import time
|
||||||
|
import re
|
||||||
|
import socket
|
||||||
|
import json
|
||||||
|
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
|
sys.path.append(os.getcwd() + "/class/core")
|
||||||
|
import mw
|
||||||
|
|
||||||
|
app_debug = False
|
||||||
|
if mw.isAppleSystem():
|
||||||
|
app_debug = True
|
||||||
|
|
||||||
|
|
||||||
|
class App:
|
||||||
|
__setupPath = '/www/server/nezha'
|
||||||
|
__cfg = ''
|
||||||
|
__agent_cfg = ''
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
self.__setupPath = self.getServerDir()
|
||||||
|
self.__cfg = self.__setupPath + '/nezha.cfg'
|
||||||
|
self.__agent_cfg = self.__setupPath + '/agent.cfg'
|
||||||
|
|
||||||
|
def getArgs(self):
|
||||||
|
args = sys.argv[2:]
|
||||||
|
tmp = {}
|
||||||
|
args_len = len(args)
|
||||||
|
|
||||||
|
if args_len == 1:
|
||||||
|
t = args[0].strip('{').strip('}')
|
||||||
|
t = t.split(':', 1)
|
||||||
|
tmp[t[0]] = t[1]
|
||||||
|
elif args_len > 1:
|
||||||
|
for i in range(len(args)):
|
||||||
|
t = args[i].split(':', 1)
|
||||||
|
tmp[t[0]] = t[1]
|
||||||
|
|
||||||
|
return tmp
|
||||||
|
|
||||||
|
def checkArgs(self, data, ck=[]):
|
||||||
|
for i in range(len(ck)):
|
||||||
|
if not ck[i] in data:
|
||||||
|
return (False, mw.returnJson(False, '参数:(' + ck[i] + ')没有!'))
|
||||||
|
return (True, mw.returnJson(True, 'ok'))
|
||||||
|
|
||||||
|
def __release_port(self, port):
|
||||||
|
from collections import namedtuple
|
||||||
|
try:
|
||||||
|
import firewall_api
|
||||||
|
firewall_api.firewall_api().addAcceptPortArgs(port, 'nezha', 'port')
|
||||||
|
return port
|
||||||
|
except Exception as e:
|
||||||
|
return "Release failed {}".format(e)
|
||||||
|
|
||||||
|
def openPort(self):
|
||||||
|
for i in ["9527", "5555"]:
|
||||||
|
self.__release_port(i)
|
||||||
|
return True
|
||||||
|
|
||||||
|
def getPluginName(self):
|
||||||
|
return 'nezha'
|
||||||
|
|
||||||
|
def getPluginDir(self):
|
||||||
|
return mw.getPluginDir() + '/' + self.getPluginName()
|
||||||
|
|
||||||
|
def getServerDir(self):
|
||||||
|
return mw.getServerDir() + '/' + self.getPluginName()
|
||||||
|
|
||||||
|
def getInitdConfTpl(self):
|
||||||
|
path = self.getPluginDir() + "/init.d/nezha.tpl"
|
||||||
|
return path
|
||||||
|
|
||||||
|
def getInitdAgentConfTpl(self):
|
||||||
|
path = self.getPluginDir() + "/init.d/nezha-agent.tpl"
|
||||||
|
return path
|
||||||
|
|
||||||
|
def getHomeDir(self):
|
||||||
|
if mw.isAppleSystem():
|
||||||
|
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()
|
||||||
|
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}'"
|
||||||
|
data = mw.execShell(cmd)
|
||||||
|
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.getRootDir())
|
||||||
|
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):
|
||||||
|
|
||||||
|
file_tpl = self.getInitdConfTpl()
|
||||||
|
service_path = mw.getServerDir()
|
||||||
|
|
||||||
|
initD_path = self.getServerDir() + '/init.d'
|
||||||
|
if not os.path.exists(initD_path):
|
||||||
|
os.mkdir(initD_path)
|
||||||
|
self.openPort()
|
||||||
|
|
||||||
|
file_bin = initD_path + '/' + self.getPluginName()
|
||||||
|
|
||||||
|
if not os.path.exists(file_bin):
|
||||||
|
content = mw.readFile(file_tpl)
|
||||||
|
content = self.contentReplace(content)
|
||||||
|
mw.writeFile(file_bin, content)
|
||||||
|
mw.execShell('chmod +x ' + file_bin)
|
||||||
|
|
||||||
|
# systemd
|
||||||
|
systemDir = mw.systemdCfgDir()
|
||||||
|
systemService = systemDir + '/nezha.service'
|
||||||
|
systemServiceTpl = self.getPluginDir() + '/init.d/nezha.service.tpl'
|
||||||
|
if os.path.exists(systemDir) and not os.path.exists(systemService):
|
||||||
|
service_path = mw.getServerDir()
|
||||||
|
se_content = mw.readFile(systemServiceTpl)
|
||||||
|
se_content = self.contentReplace(se_content)
|
||||||
|
mw.writeFile(systemService, se_content)
|
||||||
|
mw.execShell('systemctl daemon-reload')
|
||||||
|
|
||||||
|
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())
|
||||||
|
data = mw.execShell(cmd)
|
||||||
|
if data[1] == '':
|
||||||
|
return 'ok'
|
||||||
|
return 'fail'
|
||||||
|
|
||||||
|
data = mw.execShell(file + ' ' + method)
|
||||||
|
if data[1] == '':
|
||||||
|
return 'ok'
|
||||||
|
return data[0]
|
||||||
|
|
||||||
|
def start(self):
|
||||||
|
return self.imOp('start')
|
||||||
|
|
||||||
|
def stop(self):
|
||||||
|
return self.imOp('stop')
|
||||||
|
|
||||||
|
def restart(self):
|
||||||
|
return self.imOp('restart')
|
||||||
|
|
||||||
|
def reload(self):
|
||||||
|
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'
|
||||||
|
return data[0]
|
||||||
|
|
||||||
|
def start_agent(self):
|
||||||
|
return self.agOp('start')
|
||||||
|
|
||||||
|
def stop_agent(self):
|
||||||
|
return self.agOp('stop')
|
||||||
|
|
||||||
|
def restart_agent(self):
|
||||||
|
return self.agOp('restart')
|
||||||
|
|
||||||
|
def reload_agent(self):
|
||||||
|
return self.agentOp('reload')
|
||||||
|
|
||||||
|
def initd_status(self):
|
||||||
|
cmd = 'systemctl status nezha | grep loaded | grep "enabled;"'
|
||||||
|
data = mw.execShell(cmd)
|
||||||
|
if data[0] == '':
|
||||||
|
return 'fail'
|
||||||
|
return 'ok'
|
||||||
|
|
||||||
|
def initd_install(self):
|
||||||
|
mw.execShell('systemctl enable nezha')
|
||||||
|
return 'ok'
|
||||||
|
|
||||||
|
def initd_uninstall(self):
|
||||||
|
mw.execShell('systemctl disable nezha')
|
||||||
|
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 initd_install_agent(self):
|
||||||
|
mw.execShell('systemctl enable nezha-agent')
|
||||||
|
return 'ok'
|
||||||
|
|
||||||
|
def initd_uninstall_agent(self):
|
||||||
|
mw.execShell('systemctl disable nezha-agent')
|
||||||
|
return 'ok'
|
||||||
|
|
||||||
|
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'
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
func = sys.argv[1]
|
||||||
|
classApp = App()
|
||||||
|
try:
|
||||||
|
data = eval("classApp." + func + "()")
|
||||||
|
print(data)
|
||||||
|
except Exception as e:
|
||||||
|
print('error:' + str(e))
|
||||||
Executable
+18
@@ -0,0 +1,18 @@
|
|||||||
|
{
|
||||||
|
"sort": 7,
|
||||||
|
"ps": "哪吒监控面板/改造版",
|
||||||
|
"name": "nezha",
|
||||||
|
"title": "哪吒监控",
|
||||||
|
"shell": "install.sh",
|
||||||
|
"versions":["0.15.2"],
|
||||||
|
"tip": "soft",
|
||||||
|
"checks": "server/nezha",
|
||||||
|
"path": "server/nezha",
|
||||||
|
"display": 1,
|
||||||
|
"author": "midoks",
|
||||||
|
"date": "2023-06-26",
|
||||||
|
"home": "https://github.com/midoks/nezha",
|
||||||
|
"doc1": "https://nezha.wiki/",
|
||||||
|
"type": 0,
|
||||||
|
"pid": "5"
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
[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
|
||||||
@@ -0,0 +1,90 @@
|
|||||||
|
#!/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
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Nezha Dashborad
|
||||||
|
After=syslog.target
|
||||||
|
After=network.target
|
||||||
|
After=mariadb.service mysqld.service postgresql.service memcached.service redis.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/dashboard/
|
||||||
|
ExecStart={$SERVER_PATH}/nezha/dashboard/nezha web
|
||||||
|
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
|
||||||
@@ -0,0 +1,87 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# chkconfig: 2345 55 25
|
||||||
|
# description: Nezha Service
|
||||||
|
|
||||||
|
### BEGIN INIT INFO
|
||||||
|
# Provides: Nezha
|
||||||
|
# Required-Start: $all
|
||||||
|
# Required-Stop: $all
|
||||||
|
# Default-Start: 2 3 4 5
|
||||||
|
# Default-Stop: 0 1 6
|
||||||
|
# Short-Description: starts Nezha
|
||||||
|
# Description: starts the Nezha
|
||||||
|
### 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
|
||||||
|
LOG_PATH={$SERVER_PATH}/${SERVICENAME}/logs
|
||||||
|
APP_PATH={$SERVER_PATH}/${SERVICENAME}/dashboard
|
||||||
|
|
||||||
|
|
||||||
|
app_start(){
|
||||||
|
isStart=`ps -ef|grep "${SERVICENAME} web" | 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} web >> ${LOG_PATH}/${SERVICENAME}.log 2>&1 &
|
||||||
|
isStart=""
|
||||||
|
while [[ "$isStart" == "" ]];
|
||||||
|
do
|
||||||
|
echo -e ".\c"
|
||||||
|
sleep 0.5
|
||||||
|
isStart=$(ps -ef|grep "${SERVICENAME} web" |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} web" | 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} web" | 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
|
||||||
Executable
+43
@@ -0,0 +1,43 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
|
||||||
|
export PATH
|
||||||
|
|
||||||
|
curPath=`pwd`
|
||||||
|
rootPath=$(dirname "$curPath")
|
||||||
|
rootPath=$(dirname "$rootPath")
|
||||||
|
serverPath=$(dirname "$rootPath")
|
||||||
|
|
||||||
|
install_tmp=${rootPath}/tmp/mw_install.pl
|
||||||
|
|
||||||
|
action=$1
|
||||||
|
type=$2
|
||||||
|
|
||||||
|
if [ "${2}" == "" ];then
|
||||||
|
echo '缺少安装脚本...' > $install_tmp
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -d $curPath/versions/$2 ];then
|
||||||
|
echo '缺少安装脚本2...' > $install_tmp
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
sh -x $curPath/versions/$2/install.sh $1
|
||||||
|
|
||||||
|
if [ "${action}" == "uninstall" ];then
|
||||||
|
if [ -f /usr/lib/systemd/system/nezha.service ] || [ -f /lib/systemd/system/nezha.service ] ;then
|
||||||
|
systemctl stop nezha
|
||||||
|
systemctl disable nezha
|
||||||
|
rm -rf /usr/lib/systemd/system/nezha.service
|
||||||
|
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
|
||||||
Executable
+184
@@ -0,0 +1,184 @@
|
|||||||
|
var nezha = {
|
||||||
|
plugin_name: 'nezha',
|
||||||
|
init: function () {
|
||||||
|
var _this = this;
|
||||||
|
},
|
||||||
|
|
||||||
|
send:function(info){
|
||||||
|
var tips = info['tips'];
|
||||||
|
var method = info['method'];
|
||||||
|
var args = info['data'];
|
||||||
|
var callback = info['success'];
|
||||||
|
|
||||||
|
var loadT = layer.msg(tips, { icon: 16, time: 0, shade: 0.3 });
|
||||||
|
|
||||||
|
var data = {};
|
||||||
|
data['name'] = 'nezha';
|
||||||
|
data['func'] = method;
|
||||||
|
data['version'] = $('.plugin_version').attr('version');
|
||||||
|
|
||||||
|
if (typeof(args) == 'string'){
|
||||||
|
data['args'] = JSON.stringify(toArrayObject(args));
|
||||||
|
} else {
|
||||||
|
data['args'] = JSON.stringify(args);
|
||||||
|
}
|
||||||
|
|
||||||
|
$.post('/plugins/run', data, function(res) {
|
||||||
|
layer.close(loadT);
|
||||||
|
if (!res.status){
|
||||||
|
layer.msg(res.msg,{icon:2,time:10000});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
},'json');
|
||||||
|
},
|
||||||
|
|
||||||
|
postCallback:function(info){
|
||||||
|
var tips = info['tips'];
|
||||||
|
var method = info['method'];
|
||||||
|
var args = info['data'];
|
||||||
|
var callback = info['success'];
|
||||||
|
|
||||||
|
var loadT = layer.msg(tips, { icon: 16, time: 0, shade: 0.3 });
|
||||||
|
|
||||||
|
var data = {};
|
||||||
|
data['name'] = 'nezha';
|
||||||
|
data['func'] = method;
|
||||||
|
data['version'] = $('.plugin_version').attr('version');
|
||||||
|
|
||||||
|
if (typeof(args) == 'string'){
|
||||||
|
data['args'] = JSON.stringify(toArrayObject(args));
|
||||||
|
} else {
|
||||||
|
data['args'] = JSON.stringify(args);
|
||||||
|
}
|
||||||
|
|
||||||
|
$.post('/plugins/callback', data, function(res) {
|
||||||
|
layer.close(loadT);
|
||||||
|
if (!res.status){
|
||||||
|
layer.msg(res.msg,{icon:2,time:10000});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var ret_data = $.parseJSON(res.data);
|
||||||
|
if (!ret_data.status){
|
||||||
|
layer.msg(ret_data.msg,{icon:2,time:2000});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(typeof(callback) == 'function'){
|
||||||
|
callback(res);
|
||||||
|
}
|
||||||
|
},'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',
|
||||||
|
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',
|
||||||
|
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 += '</ul>';
|
||||||
|
$('.soft-man-con').html(readme);
|
||||||
|
}
|
||||||
|
}
|
||||||
Executable
+158
@@ -0,0 +1,158 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
|
||||||
|
export PATH
|
||||||
|
|
||||||
|
curPath=`pwd`
|
||||||
|
rootPath=$(dirname "$curPath")
|
||||||
|
rootPath=$(dirname "$rootPath")
|
||||||
|
serverPath=$(dirname "$rootPath")
|
||||||
|
|
||||||
|
install_tmp=${rootPath}/tmp/mw_install.pl
|
||||||
|
VERSION=0.15.2
|
||||||
|
|
||||||
|
# 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
|
||||||
|
|
||||||
|
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"
|
||||||
|
|
||||||
|
get_arch() {
|
||||||
|
TMP_ARCH=`arch`
|
||||||
|
if [ "$TMP_ARCH" == "x86_64" ];then
|
||||||
|
ARCH="amd64"
|
||||||
|
elif [ "$TMP_ARCH" == "aarch64" ];then
|
||||||
|
ARCH="arm64"
|
||||||
|
else
|
||||||
|
echo $ARCH
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
# 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 '正在安装哪吒监控...' > $install_tmp
|
||||||
|
mkdir -p $serverPath/source
|
||||||
|
|
||||||
|
if [ ! -f $TARGET_DIR/nezha ];then
|
||||||
|
|
||||||
|
DOWNLOAD_URL="https://${GITHUB_URL}/midoks/nezha/releases/download/v${VERSION}/nezha-${OS}-${ARCH}.zip"
|
||||||
|
|
||||||
|
DOWNLOAD_FILE="$(mktemp).zip"
|
||||||
|
download_file $DOWNLOAD_URL $DOWNLOAD_FILE
|
||||||
|
|
||||||
|
if [ ! -d $TARGET_DIR ]; then
|
||||||
|
mkdir -p $TARGET_DIR
|
||||||
|
fi
|
||||||
|
|
||||||
|
unzip $DOWNLOAD_FILE -d $TARGET_DIR
|
||||||
|
rm -rf $DOWNLOAD_FILE
|
||||||
|
fi
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Install_agent(){
|
||||||
|
echo -e "正在下载监控端" > $install_tmp
|
||||||
|
mkdir -p $serverPath/source
|
||||||
|
|
||||||
|
version=v0.15.1
|
||||||
|
|
||||||
|
AGENT_TARGET_DIR="$serverPath/nezha/agent"
|
||||||
|
|
||||||
|
DOWNLOAD_URL="https://${GITHUB_URL}/nezhahq/agent/releases/download/${version}/nezha-agent_${OS}_${ARCH}.zip"
|
||||||
|
DOWNLOAD_FILE="$(mktemp).zip"
|
||||||
|
|
||||||
|
if [ ! -f $AGENT_TARGET_DIR/nezha-agent ];then
|
||||||
|
download_file $DOWNLOAD_URL $DOWNLOAD_FILE
|
||||||
|
|
||||||
|
if [ ! -d $AGENT_TARGET_DIR ]; then
|
||||||
|
mkdir -p $AGENT_TARGET_DIR
|
||||||
|
fi
|
||||||
|
|
||||||
|
unzip $DOWNLOAD_FILE -d $AGENT_TARGET_DIR
|
||||||
|
rm -rf $DOWNLOAD_FILE
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
Install_App()
|
||||||
|
{
|
||||||
|
load_vars
|
||||||
|
get_arch
|
||||||
|
|
||||||
|
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
|
||||||
|
echo 'install successful' > $install_tmp
|
||||||
|
}
|
||||||
|
|
||||||
|
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" > $install_tmp
|
||||||
|
}
|
||||||
|
|
||||||
|
action=$1
|
||||||
|
if [ "${1}" == 'install' ];then
|
||||||
|
Install_App
|
||||||
|
else
|
||||||
|
Uninstall_App
|
||||||
|
fi
|
||||||
@@ -7,6 +7,7 @@ Description=The PHP {$VERSION} FastCGI Process Manager
|
|||||||
After=network.target
|
After=network.target
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
|
Environment="LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/www/server/lib/icu/lib"
|
||||||
PIDFile={$SERVER_PATH}/php/{$VERSION}/var/run/php-fpm.pid
|
PIDFile={$SERVER_PATH}/php/{$VERSION}/var/run/php-fpm.pid
|
||||||
ExecStart={$SERVER_PATH}/php/{$VERSION}/sbin/php-fpm --nodaemonize --fpm-config {$SERVER_PATH}/php/{$VERSION}/etc/php-fpm.conf
|
ExecStart={$SERVER_PATH}/php/{$VERSION}/sbin/php-fpm --nodaemonize --fpm-config {$SERVER_PATH}/php/{$VERSION}/etc/php-fpm.conf
|
||||||
ExecReload=/bin/kill -USR2 $MAINPID
|
ExecReload=/bin/kill -USR2 $MAINPID
|
||||||
|
|||||||
@@ -59,6 +59,7 @@ if [ "${action}" == "install" ] && [ -d ${serverPath}/php/${type} ];then
|
|||||||
echo "install PHP${type} extend start"
|
echo "install PHP${type} extend start"
|
||||||
|
|
||||||
# cd /www/server/mdserver-web/plugins/php/versions/common && bash iconv.sh install 53
|
# cd /www/server/mdserver-web/plugins/php/versions/common && bash iconv.sh install 53
|
||||||
|
# cd /www/server/mdserver-web/plugins/php/versions/common && bash intl.sh install 73
|
||||||
# cd /www/server/mdserver-web/plugins/php/versions/common && bash gd.sh install 56
|
# cd /www/server/mdserver-web/plugins/php/versions/common && bash gd.sh install 56
|
||||||
# cd /www/server/mdserver-web/plugins/php/versions/common && bash openssl.sh install 56
|
# cd /www/server/mdserver-web/plugins/php/versions/common && bash openssl.sh install 56
|
||||||
# cd /www/server/mdserver-web/plugins/php/versions/common && bash sodium.sh install 81
|
# cd /www/server/mdserver-web/plugins/php/versions/common && bash sodium.sh install 81
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ function version_lt() { test "$(echo "$@" | tr " " "\n" | sort -rV | head -n 1)"
|
|||||||
function version_ge() { test "$(echo "$@" | tr " " "\n" | sort -rV | head -n 1)" == "$1"; }
|
function version_ge() { test "$(echo "$@" | tr " " "\n" | sort -rV | head -n 1)" == "$1"; }
|
||||||
|
|
||||||
|
|
||||||
version=8.0.27
|
version=8.0.29
|
||||||
PHP_VER=80
|
PHP_VER=80
|
||||||
Install_php()
|
Install_php()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ function version_lt() { test "$(echo "$@" | tr " " "\n" | sort -rV | head -n 1)"
|
|||||||
function version_ge() { test "$(echo "$@" | tr " " "\n" | sort -rV | head -n 1)" == "$1"; }
|
function version_ge() { test "$(echo "$@" | tr " " "\n" | sort -rV | head -n 1)" == "$1"; }
|
||||||
|
|
||||||
|
|
||||||
version=8.1.15
|
version=8.1.20
|
||||||
PHP_VER=81
|
PHP_VER=81
|
||||||
Install_php()
|
Install_php()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ function version_lt() { test "$(echo "$@" | tr " " "\n" | sort -rV | head -n 1)"
|
|||||||
function version_ge() { test "$(echo "$@" | tr " " "\n" | sort -rV | head -n 1)" == "$1"; }
|
function version_ge() { test "$(echo "$@" | tr " " "\n" | sort -rV | head -n 1)" == "$1"; }
|
||||||
|
|
||||||
|
|
||||||
version=8.2.2
|
version=8.2.7
|
||||||
PHP_VER=82
|
PHP_VER=82
|
||||||
Install_php()
|
Install_php()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -38,9 +38,10 @@ done
|
|||||||
|
|
||||||
cd $DIR
|
cd $DIR
|
||||||
PHP_VER_LIST=(53 54 55 56 70 71 72 73 74 80 81 82)
|
PHP_VER_LIST=(53 54 55 56 70 71 72 73 74 80 81 82)
|
||||||
|
# yar
|
||||||
PHP_EXT_LIST=(ioncube ZendGuardLoader pdo mysqlnd sqlite3 openssl pcntl opcache mcrypt fileinfo \
|
PHP_EXT_LIST=(ioncube ZendGuardLoader pdo mysqlnd sqlite3 openssl pcntl opcache mcrypt fileinfo \
|
||||||
exif gd intl memcache memcached redis imagemagick xdebug xhprof \
|
exif gd intl memcache memcached redis imagemagick xdebug xhprof \
|
||||||
swoole yaf yar yac apc mongo mongodb solr seaslog mbstring iconv phalcon)
|
swoole yaf yac apc mongo mongodb solr seaslog mbstring iconv phalcon)
|
||||||
|
|
||||||
for PHP_VER in ${PHP_VER_LIST[@]}; do
|
for PHP_VER in ${PHP_VER_LIST[@]}; do
|
||||||
echo "php${PHP_VER} -- start"
|
echo "php${PHP_VER} -- start"
|
||||||
|
|||||||
@@ -11,9 +11,37 @@ rootPath=$(dirname "$rootPath")
|
|||||||
serverPath=$(dirname "$rootPath")
|
serverPath=$(dirname "$rootPath")
|
||||||
sourcePath=${serverPath}/source/php
|
sourcePath=${serverPath}/source/php
|
||||||
|
|
||||||
|
|
||||||
|
# _os=`uname`
|
||||||
|
|
||||||
|
# if [ ${_os} == "Darwin" ]; then
|
||||||
|
# OSNAME='macos'
|
||||||
|
# elif grep -Eq "openSUSE" /etc/*-release; then
|
||||||
|
# OSNAME='opensuse'
|
||||||
|
# elif grep -Eq "FreeBSD" /etc/*-release; then
|
||||||
|
# OSNAME='freebsd'
|
||||||
|
# elif grep -Eqi "CentOS" /etc/issue || grep -Eqi "CentOS" /etc/*-release; then
|
||||||
|
# OSNAME='rhel'
|
||||||
|
# elif grep -Eqi "Fedora" /etc/issue || grep -Eqi "Fedora" /etc/*-release; then
|
||||||
|
# OSNAME='rhel'
|
||||||
|
# elif grep -Eqi "Rocky" /etc/issue || grep -Eqi "Rocky" /etc/*-release; then
|
||||||
|
# OSNAME='rhel'
|
||||||
|
# elif grep -Eqi "AlmaLinux" /etc/issue || grep -Eqi "AlmaLinux" /etc/*-release; then
|
||||||
|
# OSNAME='rhel'
|
||||||
|
# elif grep -Eqi "Amazon Linux" /etc/issue || grep -Eqi "Amazon Linux" /etc/*-release; then
|
||||||
|
# OSNAME='amazon'
|
||||||
|
# elif grep -Eqi "Debian" /etc/issue || grep -Eqi "Debian" /etc/*-release; then
|
||||||
|
# OSNAME='debian'
|
||||||
|
# elif grep -Eqi "Ubuntu" /etc/issue || grep -Eqi "Ubuntu" /etc/*-release; then
|
||||||
|
# OSNAME='ubuntu'
|
||||||
|
# else
|
||||||
|
# OSNAME='unknow'
|
||||||
|
# fi
|
||||||
|
|
||||||
actionType=$1
|
actionType=$1
|
||||||
version=$2
|
version=$2
|
||||||
|
|
||||||
|
|
||||||
LIBNAME=intl
|
LIBNAME=intl
|
||||||
LIBV=0
|
LIBV=0
|
||||||
|
|
||||||
@@ -33,7 +61,9 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
OPTIONS=''
|
OPTIONS=''
|
||||||
if [ "$version" -lt "71" ];then
|
if [ "$version" -lt "74" ];then
|
||||||
|
|
||||||
|
# cd /www/server/mdserver-web/plugins/php/lib && /bin/bash icu.sh
|
||||||
cd ${rootPath}/plugins/php/lib && /bin/bash icu.sh
|
cd ${rootPath}/plugins/php/lib && /bin/bash icu.sh
|
||||||
OPTIONS="--with-icu-dir=${serverPath}/lib/icu"
|
OPTIONS="--with-icu-dir=${serverPath}/lib/icu"
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ if [ "$version" -lt "73" ];then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$version" -gt "74" ];then
|
if [ "$version" -gt "74" ];then
|
||||||
LIBV=5.1.2
|
LIBV=5.2.1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
LIB_PATH_NAME=lib/php
|
LIB_PATH_NAME=lib/php
|
||||||
|
|||||||
@@ -32,6 +32,11 @@ if [ "$version" -eq "72" ] || [ "$version" -eq "73" ];then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
if [ "$version" -gt "74" ];then
|
||||||
|
LIBV=3.3.5
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
LIB_PATH_NAME=lib/php
|
LIB_PATH_NAME=lib/php
|
||||||
if [ -d $serverPath/php/${version}/lib64 ];then
|
if [ -d $serverPath/php/${version}/lib64 ];then
|
||||||
LIB_PATH_NAME=lib64
|
LIB_PATH_NAME=lib64
|
||||||
|
|||||||
@@ -51,10 +51,11 @@ Install_pureftp()
|
|||||||
|
|
||||||
# https://github.com/jedisct1/pure-ftpd/releases/download/1.0.49/pure-ftpd-1.0.49.tar.gz
|
# https://github.com/jedisct1/pure-ftpd/releases/download/1.0.49/pure-ftpd-1.0.49.tar.gz
|
||||||
# https://download.pureftpd.org/pub/pure-ftpd/releases/pure-ftpd-1.0.49.tar.gz
|
# https://download.pureftpd.org/pub/pure-ftpd/releases/pure-ftpd-1.0.49.tar.gz
|
||||||
# DOWNLOAD=https://github.com/jedisct1/pure-ftpd/releases/download/${VER}/pure-ftpd-${VER}.tar.gz
|
|
||||||
|
|
||||||
VER=$1
|
VER=$1
|
||||||
DOWNLOAD=https://download.pureftpd.org/pub/pure-ftpd/releases/pure-ftpd-${VER}.tar.gz
|
DOWNLOAD=https://github.com/jedisct1/pure-ftpd/releases/download/${VER}/pure-ftpd-${VER}.tar.gz
|
||||||
|
# DOWNLOAD=https://download.pureftpd.org/pub/pure-ftpd/releases/pure-ftpd-${VER}.tar.gz
|
||||||
|
|
||||||
# curl -sSLo pure-ftpd-1.0.49.tar.gz https://download.pureftpd.org/pub/pure-ftpd/releases/pure-ftpd-1.0.49.tar.gz
|
# curl -sSLo pure-ftpd-1.0.49.tar.gz https://download.pureftpd.org/pub/pure-ftpd/releases/pure-ftpd-1.0.49.tar.gz
|
||||||
if [ ! -f $serverPath/source/pureftp/pure-ftpd-${VER}.tar.gz ];then
|
if [ ! -f $serverPath/source/pureftp/pure-ftpd-${VER}.tar.gz ];then
|
||||||
@@ -68,14 +69,14 @@ Install_pureftp()
|
|||||||
md5_check=`md5sum $serverPath/source/pureftp/pure-ftpd-${VER}.tar.gz | awk '{print $1}'`
|
md5_check=`md5sum $serverPath/source/pureftp/pure-ftpd-${VER}.tar.gz | awk '{print $1}'`
|
||||||
if [ "${md5_ok}" == "${md5_check}" ]; then
|
if [ "${md5_ok}" == "${md5_check}" ]; then
|
||||||
echo "pure-ftpd file check ok"
|
echo "pure-ftpd file check ok"
|
||||||
else
|
|
||||||
# 重新下载
|
|
||||||
rm -rf $serverPath/source/pureftp/pure-ftpd-${VER}
|
|
||||||
wget --no-check-certificate -O $serverPath/source/pureftp/pure-ftpd-${VER}.tar.gz $DOWNLOAD
|
|
||||||
# curl -sSLo $serverPath/source/pureftp/pure-ftpd-${VER}.tar.gz $DOWNLOAD
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Last Download Method
|
||||||
|
if [ ! -f $serverPath/source/pureftp/pure-ftpd-${VER}.tar.gz ];then
|
||||||
|
wget --no-check-certificate -O $serverPath/source/pureftp/pure-ftpd-${VER}.tar.gz https://dl.midoks.me/soft/ftp/pure-ftpd-${VER}.tar.gz -T 3
|
||||||
|
fi
|
||||||
|
|
||||||
if [ ! -d $serverPath/source/pureftp/pure-ftpd-${VER} ];then
|
if [ ! -d $serverPath/source/pureftp/pure-ftpd-${VER} ];then
|
||||||
cd $serverPath/source/pureftp && tar zxvf pure-ftpd-${VER}.tar.gz
|
cd $serverPath/source/pureftp && tar zxvf pure-ftpd-${VER}.tar.gz
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -923,10 +923,12 @@
|
|||||||
"python",
|
"python",
|
||||||
"python3",
|
"python3",
|
||||||
"ifdown",
|
"ifdown",
|
||||||
"node"
|
"node",
|
||||||
|
"sd-pam"
|
||||||
],
|
],
|
||||||
"process_exclude": [
|
"process_exclude": [
|
||||||
"php-fpm",
|
"php-fpm",
|
||||||
|
"git",
|
||||||
"mysqld",
|
"mysqld",
|
||||||
"mongod",
|
"mongod",
|
||||||
"dockerd",
|
"dockerd",
|
||||||
|
|||||||
@@ -171,6 +171,12 @@ def reload():
|
|||||||
content = mw.readFile(tgbot_tpl)
|
content = mw.readFile(tgbot_tpl)
|
||||||
mw.writeFile(tgbot_dst, content)
|
mw.writeFile(tgbot_dst, content)
|
||||||
|
|
||||||
|
tgpush_tpl = getPluginDir() + '/startup/tgpush.py'
|
||||||
|
tgpush_dst = getServerDir() + '/tgpush.py'
|
||||||
|
|
||||||
|
content = mw.readFile(tgpush_tpl)
|
||||||
|
mw.writeFile(tgpush_dst, content)
|
||||||
|
|
||||||
ext_src = getPluginDir() + '/startup/extend'
|
ext_src = getPluginDir() + '/startup/extend'
|
||||||
ext_dst = getServerDir()
|
ext_dst = getServerDir()
|
||||||
|
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ tg_start(){
|
|||||||
echo -e "starting tgbot... \c"
|
echo -e "starting tgbot... \c"
|
||||||
cd $mw_path
|
cd $mw_path
|
||||||
python3 {$APP_PATH}/tgbot.py >> {$APP_PATH}/task.log &
|
python3 {$APP_PATH}/tgbot.py >> {$APP_PATH}/task.log &
|
||||||
|
python3 {$APP_PATH}/tgpush.py >> {$APP_PATH}/push.log &
|
||||||
isStart=""
|
isStart=""
|
||||||
while [[ "$isStart" == "" ]];
|
while [[ "$isStart" == "" ]];
|
||||||
do
|
do
|
||||||
@@ -64,6 +65,15 @@ tg_stop(){
|
|||||||
kill -9 $p > /dev/null 2>&1
|
kill -9 $p > /dev/null 2>&1
|
||||||
done
|
done
|
||||||
echo -e "\033[32mdone\033[0m"
|
echo -e "\033[32mdone\033[0m"
|
||||||
|
|
||||||
|
|
||||||
|
echo -e "stopping tgpush ... \c";
|
||||||
|
arr=`ps aux|grep 'tgpush.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
|
case "$1" in
|
||||||
|
|||||||
@@ -41,30 +41,34 @@ def send_msg(bot, tag='ad', trigger_time=300):
|
|||||||
mw.writeFile(lock_file, json.dumps(lock_data))
|
mw.writeFile(lock_file, json.dumps(lock_data))
|
||||||
# 信号只在一个周期内执行一次|end
|
# 信号只在一个周期内执行一次|end
|
||||||
|
|
||||||
# https://t.me/gjgzs2022 | 19/m
|
# https://t.me/gjgzs2022 | 22/m
|
||||||
# ♻️CMS导航网♻️/💰流量变现💰 | 28/m
|
# 代付支付宝微信❤️淘宝帮付/💰流量变现💰集团收量/🕵️♀️实名认证/接码✅过人脸👤 | 28/m
|
||||||
# CK资源采集 |29/m
|
# https://zhaoziyuan.la/ | 15/m | 2m | next,7/15
|
||||||
# https://zhaoziyuan.la/ | 15/m | 2m | next,5/15
|
# 香港高防CDN |9/m
|
||||||
keyboard = [
|
keyboard = [
|
||||||
[
|
[
|
||||||
types.InlineKeyboardButton(
|
types.InlineKeyboardButton(
|
||||||
text="CK资源采集", url='https://ckzy1.com/')
|
text="实卡接码🙎♂️代实名/过人脸🅾️开飞机会员", url='https://t.me/gjgzs2022')
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
types.InlineKeyboardButton(
|
types.InlineKeyboardButton(
|
||||||
text="♻️CMS导航网♻️", url='https://t.me/maccms_jccms')
|
text="香港高防CDN、免实名、试用30天", url='https://www.100dun.com')
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
types.InlineKeyboardButton(
|
types.InlineKeyboardButton(
|
||||||
text="💰流量变现💰", url='https://t.me/taohaozhan')
|
text="🕵️♀️实名认证/接码✅过人脸👤", url='https://t.me/zhanzhangyewu')
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
types.InlineKeyboardButton(
|
types.InlineKeyboardButton(
|
||||||
text="🙎♂️代实名🙍♀️过人脸🅾️国际阿里云腾讯云(赞助商)", url='https://t.me/gjgzs2022')
|
text="代付支付宝微信❤️淘宝帮付", url='https://t.me/Uxuanzhenpin')
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
types.InlineKeyboardButton(
|
types.InlineKeyboardButton(
|
||||||
text="倩倩CDN服务器", url='https://t.me/KLT_12'),
|
text="💰流量变现💰集团收量", url='https://t.me/taohaozhan')
|
||||||
|
],
|
||||||
|
[
|
||||||
|
types.InlineKeyboardButton(
|
||||||
|
text="官网", url='https://github.com/midoks/mdserver-web'),
|
||||||
types.InlineKeyboardButton(
|
types.InlineKeyboardButton(
|
||||||
text="💎DigitalVirt(赞助商)", url='https://digitalvirt.com/aff.php?aff=154')
|
text="💎DigitalVirt(赞助商)", url='https://digitalvirt.com/aff.php?aff=154')
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -22,6 +22,16 @@ chat_id = -1001578009023
|
|||||||
# chat_id = 5568699210
|
# chat_id = 5568699210
|
||||||
|
|
||||||
|
|
||||||
|
def writeLog(log_str):
|
||||||
|
if __name__ == "__main__":
|
||||||
|
print(log_str)
|
||||||
|
|
||||||
|
now = mw.getDateFromNow()
|
||||||
|
log_file = mw.getServerDir() + '/tgbot/task.log'
|
||||||
|
mw.writeFileLog(now + ':' + log_str, log_file, limit_size=5 * 1024)
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
def get_newest_tid():
|
def get_newest_tid():
|
||||||
|
|
||||||
api_new = 'https://bbs.midoks.me/plugin.php?id=external_api&f=bbs_newest'
|
api_new = 'https://bbs.midoks.me/plugin.php?id=external_api&f=bbs_newest'
|
||||||
@@ -86,7 +96,13 @@ def send_msg(bot, tag='ad', trigger_time=300):
|
|||||||
|
|
||||||
|
|
||||||
def run(bot):
|
def run(bot):
|
||||||
send_msg(bot, 'push_bbs_newest_tid', 300)
|
|
||||||
|
try:
|
||||||
|
send_msg(bot, 'push_bbs_newest_tid', 300)
|
||||||
|
except Exception as e:
|
||||||
|
writeLog('-----push_bbs_newest_tid error start -------')
|
||||||
|
print(mw.getTracebackInfo())
|
||||||
|
writeLog('-----push_bbs_newest_tid error start -------')
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|||||||
@@ -22,6 +22,16 @@ chat_id = -1001578009023
|
|||||||
# chat_id = 5568699210
|
# chat_id = 5568699210
|
||||||
|
|
||||||
|
|
||||||
|
def writeLog(log_str):
|
||||||
|
if __name__ == "__main__":
|
||||||
|
print(log_str)
|
||||||
|
|
||||||
|
now = mw.getDateFromNow()
|
||||||
|
log_file = mw.getServerDir() + '/tgbot/task.log'
|
||||||
|
mw.writeFileLog(now + ':' + log_str, log_file, limit_size=5 * 1024)
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
def send_msg(bot, tag='ad', trigger_time=300):
|
def send_msg(bot, tag='ad', trigger_time=300):
|
||||||
# 信号只在一个周期内执行一次|start
|
# 信号只在一个周期内执行一次|start
|
||||||
lock_file = mw.getServerDir() + '/tgbot/lock.json'
|
lock_file = mw.getServerDir() + '/tgbot/lock.json'
|
||||||
@@ -40,29 +50,33 @@ def send_msg(bot, tag='ad', trigger_time=300):
|
|||||||
mw.writeFile(lock_file, json.dumps(lock_data))
|
mw.writeFile(lock_file, json.dumps(lock_data))
|
||||||
# 信号只在一个周期内执行一次|end
|
# 信号只在一个周期内执行一次|end
|
||||||
|
|
||||||
# https://t.me/gjgzs2022 | 19/m
|
# https://t.me/gjgzs2022 | 22/m
|
||||||
# ♻️CMS导航网♻️/💰流量变现💰 | 28/m
|
# 代付支付宝微信❤️淘宝帮付/💰流量变现💰集团收量/🕵️♀️实名认证/接码✅过人脸👤 | 28/m
|
||||||
# CK资源采集 |29/m
|
# 香港高防CDN |9/m
|
||||||
keyboard = [
|
keyboard = [
|
||||||
[
|
[
|
||||||
types.InlineKeyboardButton(
|
types.InlineKeyboardButton(
|
||||||
text="CK资源采集", url='https://ckzy1.com/')
|
text="实卡接码🙎♂️代实名/过人脸🅾️开飞机会员", url='https://t.me/gjgzs2022')
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
types.InlineKeyboardButton(
|
types.InlineKeyboardButton(
|
||||||
text="♻️CMS导航网♻️", url='https://t.me/maccms_jccms')
|
text="香港高防CDN、免实名、试用30天", url='https://www.100dun.com')
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
types.InlineKeyboardButton(
|
types.InlineKeyboardButton(
|
||||||
text="💰流量变现💰", url='https://t.me/taohaozhan')
|
text="🕵️♀️实名认证/接码✅过人脸👤", url='https://t.me/zhanzhangyewu')
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
types.InlineKeyboardButton(
|
types.InlineKeyboardButton(
|
||||||
text="🙎♂️代实名🙍♀️过人脸🅾️国际阿里云腾讯云(赞助商)", url='https://t.me/gjgzs2022')
|
text="代付支付宝微信❤️淘宝帮付", url='https://t.me/Uxuanzhenpin')
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
types.InlineKeyboardButton(
|
types.InlineKeyboardButton(
|
||||||
text="倩倩CDN服务器", url='https://t.me/KLT_12'),
|
text="💰流量变现💰集团收量", url='https://t.me/taohaozhan')
|
||||||
|
],
|
||||||
|
[
|
||||||
|
types.InlineKeyboardButton(
|
||||||
|
text="官网", url='https://github.com/midoks/mdserver-web'),
|
||||||
types.InlineKeyboardButton(
|
types.InlineKeyboardButton(
|
||||||
text="💎DigitalVirt(赞助商)", url='https://digitalvirt.com/aff.php?aff=154')
|
text="💎DigitalVirt(赞助商)", url='https://digitalvirt.com/aff.php?aff=154')
|
||||||
],
|
],
|
||||||
@@ -94,7 +108,7 @@ def send_msg(bot, tag='ad', trigger_time=300):
|
|||||||
|
|
||||||
def run(bot):
|
def run(bot):
|
||||||
try:
|
try:
|
||||||
send_msg(bot, 'notice_msg', 180)
|
send_msg(bot, 'notice_msg', 90)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
writeLog('-----push_notice_msg error start -------')
|
writeLog('-----push_notice_msg error start -------')
|
||||||
print(mw.getTracebackInfo())
|
print(mw.getTracebackInfo())
|
||||||
|
|||||||
@@ -95,15 +95,6 @@ for p in init_list:
|
|||||||
writeLog(mw.getTracebackInfo())
|
writeLog(mw.getTracebackInfo())
|
||||||
writeLog('-----init error end -------')
|
writeLog('-----init error end -------')
|
||||||
|
|
||||||
# @bot.message_handler(commands=['start', 'help'])
|
|
||||||
# def hanle_start_help(message):
|
|
||||||
# bot.reply_to(message, "hello world")
|
|
||||||
|
|
||||||
|
|
||||||
# @bot.message_handler(commands=['mw_echo'])
|
|
||||||
# def hanle_mw_echo(message):
|
|
||||||
# bot.reply_to(message, message.text)
|
|
||||||
|
|
||||||
|
|
||||||
@bot.message_handler(commands=['chat_id'])
|
@bot.message_handler(commands=['chat_id'])
|
||||||
def hanle_get_chat_id(message):
|
def hanle_get_chat_id(message):
|
||||||
@@ -136,42 +127,6 @@ def callback_query_handler(call):
|
|||||||
writeLog('-----callback_query_handler error end -------')
|
writeLog('-----callback_query_handler error end -------')
|
||||||
|
|
||||||
|
|
||||||
def runBotPushTask():
|
|
||||||
plist = getStartExtCfgByTag('push')
|
|
||||||
for p in plist:
|
|
||||||
try:
|
|
||||||
script = p['name'].split('.')[0]
|
|
||||||
__import__(script).run(bot)
|
|
||||||
except Exception as e:
|
|
||||||
writeLog('-----runBotPushTask error start -------')
|
|
||||||
writeLog(mw.getTracebackInfo())
|
|
||||||
writeLog('-----runBotPushTask error end -------')
|
|
||||||
|
|
||||||
|
|
||||||
def botPush():
|
|
||||||
while True:
|
|
||||||
runBotPushTask()
|
|
||||||
time.sleep(1)
|
|
||||||
|
|
||||||
|
|
||||||
def runBotPushOtherTask():
|
|
||||||
plist = getStartExtCfgByTag('other')
|
|
||||||
for p in plist:
|
|
||||||
try:
|
|
||||||
script = p['name'].split('.')[0]
|
|
||||||
__import__(script).run(bot)
|
|
||||||
except Exception as e:
|
|
||||||
writeLog('-----runBotPushOtherTask error start -------')
|
|
||||||
writeLog(mw.getTracebackInfo())
|
|
||||||
writeLog('-----runBotPushOtherTask error end -------')
|
|
||||||
|
|
||||||
|
|
||||||
def botPushOther():
|
|
||||||
while True:
|
|
||||||
runBotPushOtherTask()
|
|
||||||
time.sleep(1)
|
|
||||||
|
|
||||||
|
|
||||||
def runBot(bot):
|
def runBot(bot):
|
||||||
try:
|
try:
|
||||||
bot.polling()
|
bot.polling()
|
||||||
@@ -184,14 +139,6 @@ def runBot(bot):
|
|||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
||||||
# 机器人推送任务
|
|
||||||
botPushTask = threading.Thread(target=botPush)
|
|
||||||
botPushTask.start()
|
|
||||||
|
|
||||||
# 机器人其他推送任务
|
|
||||||
botPushOtherTask = threading.Thread(target=botPushOther)
|
|
||||||
botPushOtherTask.start()
|
|
||||||
|
|
||||||
writeLog('启动成功')
|
writeLog('启动成功')
|
||||||
runBot(bot)
|
runBot(bot)
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,132 @@
|
|||||||
|
# coding:utf-8
|
||||||
|
|
||||||
|
import sys
|
||||||
|
import io
|
||||||
|
import os
|
||||||
|
import time
|
||||||
|
import re
|
||||||
|
import json
|
||||||
|
import base64
|
||||||
|
import threading
|
||||||
|
|
||||||
|
sys.path.append(os.getcwd() + "/class/core")
|
||||||
|
import mw
|
||||||
|
|
||||||
|
import telebot
|
||||||
|
|
||||||
|
|
||||||
|
def getPluginName():
|
||||||
|
return 'tgbot'
|
||||||
|
|
||||||
|
|
||||||
|
def getPluginDir():
|
||||||
|
return mw.getPluginDir() + '/' + getPluginName()
|
||||||
|
|
||||||
|
|
||||||
|
def getServerDir():
|
||||||
|
return mw.getServerDir() + '/' + getPluginName()
|
||||||
|
|
||||||
|
|
||||||
|
sys.path.append(getServerDir() + "/extend")
|
||||||
|
|
||||||
|
|
||||||
|
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 getStartExtCfgByTag(tag='push'):
|
||||||
|
# 获取开启的扩展
|
||||||
|
elist = getExtCfg()
|
||||||
|
rlist = []
|
||||||
|
for x in elist:
|
||||||
|
if x['tag'] == tag and x['status'] == 'start':
|
||||||
|
rlist.append(x)
|
||||||
|
return rlist
|
||||||
|
|
||||||
|
|
||||||
|
def writeLog(log_str):
|
||||||
|
if __name__ == "__main__":
|
||||||
|
print(log_str)
|
||||||
|
|
||||||
|
now = mw.getDateFromNow()
|
||||||
|
log_file = getServerDir() + '/push.log'
|
||||||
|
mw.writeFileLog(now + ':' + log_str, log_file, limit_size=5 * 1024)
|
||||||
|
return True
|
||||||
|
|
||||||
|
# start tgbot
|
||||||
|
cfg = getConfigData()
|
||||||
|
while True:
|
||||||
|
cfg = getConfigData()
|
||||||
|
if 'bot' in cfg and 'app_token' in cfg['bot']:
|
||||||
|
if cfg['bot']['app_token'] != '' and cfg['bot']['app_token'] != 'app_token':
|
||||||
|
break
|
||||||
|
writeLog('等待输入配置,填写app_token')
|
||||||
|
time.sleep(3)
|
||||||
|
|
||||||
|
|
||||||
|
bot = telebot.TeleBot(cfg['bot']['app_token'])
|
||||||
|
|
||||||
|
|
||||||
|
def runBotPushTask():
|
||||||
|
plist = getStartExtCfgByTag('push')
|
||||||
|
for p in plist:
|
||||||
|
try:
|
||||||
|
script = p['name'].split('.')[0]
|
||||||
|
__import__(script).run(bot)
|
||||||
|
except Exception as e:
|
||||||
|
writeLog('-----runBotPushTask error start -------')
|
||||||
|
writeLog(mw.getTracebackInfo())
|
||||||
|
writeLog('-----runBotPushTask error end -------')
|
||||||
|
|
||||||
|
|
||||||
|
def botPush():
|
||||||
|
while True:
|
||||||
|
runBotPushTask()
|
||||||
|
time.sleep(1)
|
||||||
|
|
||||||
|
|
||||||
|
def runBotPushOtherTask():
|
||||||
|
plist = getStartExtCfgByTag('other')
|
||||||
|
for p in plist:
|
||||||
|
try:
|
||||||
|
script = p['name'].split('.')[0]
|
||||||
|
__import__(script).run(bot)
|
||||||
|
except Exception as e:
|
||||||
|
writeLog('-----runBotPushOtherTask error start -------')
|
||||||
|
writeLog(mw.getTracebackInfo())
|
||||||
|
writeLog('-----runBotPushOtherTask error end -------')
|
||||||
|
|
||||||
|
|
||||||
|
def botPushOther():
|
||||||
|
while True:
|
||||||
|
runBotPushOtherTask()
|
||||||
|
time.sleep(1)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
|
||||||
|
# 机器人推送任务
|
||||||
|
botPushTask = threading.Thread(target=botPush)
|
||||||
|
botPushTask.start()
|
||||||
|
|
||||||
|
# 机器人其他推送任务
|
||||||
|
botPushOtherTask = threading.Thread(target=botPushOther)
|
||||||
|
botPushOtherTask.start()
|
||||||
@@ -2,6 +2,7 @@ function readme(){
|
|||||||
var readme = '<ul class="help-info-text c7">';
|
var readme = '<ul class="help-info-text c7">';
|
||||||
readme += '<li>在填写好配置信息好后,还要执行下面命令。进行手机号和短信码验证。再重启,即可正常使用</li>';
|
readme += '<li>在填写好配置信息好后,还要执行下面命令。进行手机号和短信码验证。再重启,即可正常使用</li>';
|
||||||
readme += '<li>cd /www/server/mdserver-web && source bin/activate && python3 /www/server/tgclient/tgclient.py</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>';
|
readme += '</ul>';
|
||||||
$('.soft-man-con').html(readme);
|
$('.soft-man-con').html(readme);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,8 +24,9 @@ chat_id_list = [-1001578009023]
|
|||||||
filter_g_id = [-1001771526434]
|
filter_g_id = [-1001771526434]
|
||||||
|
|
||||||
|
|
||||||
msg_ad = "本人软件推广(30s)\n\n"
|
msg_ad = "本人软件推广(10s)\n\n"
|
||||||
msg_ad += "开源地址(Linux面板) mdserver-web,站长必备,不收费,无毒。源码为证。全靠TG乞讨! \n"
|
msg_ad += "开源Linux面板【mdserver-web】,站长必备,无毒,源码为证。\n"
|
||||||
|
msg_ad += "不收费,全靠TG乞讨! \n"
|
||||||
msg_ad += "看个人简介,加入群聊,一起进步!\n"
|
msg_ad += "看个人简介,加入群聊,一起进步!\n"
|
||||||
# msg_ad += "https://github.com/midoks/mdserver-web \n"
|
# msg_ad += "https://github.com/midoks/mdserver-web \n"
|
||||||
# msg_ad += "\n"
|
# msg_ad += "\n"
|
||||||
@@ -65,7 +66,7 @@ async def send_msg(client, chat_id, tag='ad', trigger_time=600):
|
|||||||
# 信号只在一个周期内执行一次|end
|
# 信号只在一个周期内执行一次|end
|
||||||
|
|
||||||
msg = await client.send_message(chat_id, msg_ad)
|
msg = await client.send_message(chat_id, msg_ad)
|
||||||
await asyncio.sleep(30)
|
await asyncio.sleep(10)
|
||||||
await client.delete_messages(chat_id, msg)
|
await client.delete_messages(chat_id, msg)
|
||||||
await asyncio.sleep(3)
|
await asyncio.sleep(3)
|
||||||
|
|
||||||
@@ -78,13 +79,19 @@ async def run(client):
|
|||||||
info = await client.get_dialogs()
|
info = await client.get_dialogs()
|
||||||
for chat in info:
|
for chat in info:
|
||||||
if chat.is_group and not chat.id in filter_g_id:
|
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)
|
# print(chat)
|
||||||
await writeLog('name:{0} id:{1} is_user:{2} is_channel:{3} is_group:{4}'.format(
|
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))
|
chat.name, chat.id, chat.is_user, chat.is_channel, chat.is_group))
|
||||||
try:
|
try:
|
||||||
await send_msg(client, chat.id, 'ad_' + str(chat.id))
|
await send_msg(client, chat.id, 'ad_' + str(chat.id))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
await writeLog(str(chat))
|
||||||
await writeLog(str(e))
|
await writeLog(str(e))
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
pass
|
pass
|
||||||
|
|||||||
@@ -21,22 +21,47 @@ from telebot.util import quick_markup
|
|||||||
|
|
||||||
|
|
||||||
# 指定群ID
|
# 指定群ID
|
||||||
chat_id_list = [-1001578009023, -1001979545570]
|
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):
|
async def run(client):
|
||||||
for chat_id in chat_id_list:
|
for chat_id in chat_id_list:
|
||||||
s = await client.send_message(chat_id, '开始自动检测已经注销群成员...')
|
try:
|
||||||
count = 0
|
s = await client.send_message(chat_id, '开始自动检测已经注销群成员...')
|
||||||
async for user in client.iter_participants(chat_id):
|
count = 0
|
||||||
if user.deleted:
|
async for user in client.iter_participants(chat_id):
|
||||||
count += 1
|
if user.deleted:
|
||||||
msg = await client.kick_participant(chat_id, user)
|
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 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)
|
|
||||||
await asyncio.sleep(300)
|
await asyncio.sleep(300)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,54 @@
|
|||||||
|
# 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
|
||||||
+6
-6
@@ -1,22 +1,22 @@
|
|||||||
setuptools>=33.1.1
|
setuptools>=33.1.1
|
||||||
Werkzeug>=1.0.1
|
Werkzeug>=1.0.1
|
||||||
wheel==0.37.1
|
wheel>=0.37.1
|
||||||
gunicorn==20.1.0
|
gunicorn==20.1.0
|
||||||
requests==2.27.1
|
requests==2.27.1
|
||||||
urllib3>=1.21.1
|
urllib3>=1.21.1
|
||||||
flask==2.0.3
|
flask>=2.0.3
|
||||||
flask-session==0.3.2
|
flask-session==0.3.2
|
||||||
flask-helper==0.19
|
flask-helper==0.19
|
||||||
flask-bcrypt==1.0.1
|
flask-bcrypt==1.0.1
|
||||||
flask-caching>=1.10.1
|
flask-caching>=1.10.1
|
||||||
cache==1.0.3
|
cache==1.0.3
|
||||||
gevent==21.12.0
|
gevent==22.10.2
|
||||||
gevent-websocket==0.10.1
|
gevent-websocket==0.10.1
|
||||||
psutil==5.9.1
|
psutil==5.9.1
|
||||||
chardet==3.0.4
|
chardet==3.0.4
|
||||||
flask-sqlalchemy==2.3.2
|
flask-sqlalchemy==2.3.2
|
||||||
pyOpenSSL==22.0.0
|
pyOpenSSL==23.2.0
|
||||||
cryptography==36.0.1
|
cryptography>=40.0.2
|
||||||
configparser==5.2.0
|
configparser==5.2.0
|
||||||
python-engineio==4.3.2
|
python-engineio==4.3.2
|
||||||
python-socketio>=4.2.0
|
python-socketio>=4.2.0
|
||||||
@@ -30,4 +30,4 @@ Jinja2>=2.11.2
|
|||||||
PyMySQL==1.0.2
|
PyMySQL==1.0.2
|
||||||
whitenoise==5.3.0
|
whitenoise==5.3.0
|
||||||
pyTelegramBotAPI
|
pyTelegramBotAPI
|
||||||
telebot
|
telebot
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
#PROXY-START/
|
||||||
|
# root /www/server/nezha/dashboard/resource;
|
||||||
|
location / {
|
||||||
|
proxy_pass http://127.0.0.1:9527;
|
||||||
|
proxy_set_header Host $http_host;
|
||||||
|
proxy_set_header Upgrade $http_upgrade;
|
||||||
|
}
|
||||||
|
location ~ ^/(ws|terminal/.+)$ {
|
||||||
|
proxy_pass http://127.0.0.1:9527;
|
||||||
|
proxy_http_version 1.1;
|
||||||
|
proxy_set_header Upgrade $http_upgrade;
|
||||||
|
proxy_set_header Connection "Upgrade";
|
||||||
|
proxy_set_header Host $http_host;
|
||||||
|
}
|
||||||
|
#PROXY-END/
|
||||||
+234
-63
@@ -233,16 +233,41 @@ function changePathCallback(default_dir, callback) {
|
|||||||
closeBtn: 1,
|
closeBtn: 1,
|
||||||
shift: 5,
|
shift: 5,
|
||||||
shadeClose: false,
|
shadeClose: false,
|
||||||
content: "<div class='changepath'><div class='path-top'><button type='button' class='btn btn-default btn-sm' onclick='backFile()'><span class='glyphicon glyphicon-share-alt'></span>返回</button>\
|
content: "<div class='changepath'>\
|
||||||
<div class='place' id='PathPlace'>当前路径:<span></span></div></div><div class='path-con'><div class='path-con-left'><dl><dt id='changecomlist' onclick='backMyComputer()'>计算机</dt></dl></div>\
|
<div class='path-top'>\
|
||||||
<div class='path-con-right'><ul class='default' id='computerDefautl'></ul><div class='file-list divtable'>\
|
<button type='button' class='btn btn-default btn-sm' onclick='backFile()'>\
|
||||||
<table class='table table-hover' style='border:0 none'>\
|
<span class='glyphicon glyphicon-share-alt'></span>返回\
|
||||||
<thead><tr class='file-list-head'><th width='40%'>文件名</th><th width='20%'>修改时间</th><th width='10%'>权限</th><th width='10%'>所有者</th><th width='10%'></th></tr></thead>\
|
</button>\
|
||||||
<tbody id='tbody' class='list-list'></tbody></table></div></div></div></div><div class='getfile-btn' style='margin-top:0'>\
|
<div class='place' id='PathPlace'>当前路径:<span></span></div>\
|
||||||
<button type='button' class='btn btn-default btn-sm pull-left' onclick='createFolder()'>新建文件夹</button>\
|
</div>\
|
||||||
<button type='button' class='btn btn-danger btn-sm mr5 btn-close'>关闭</button>\
|
<div class='path-con'>\
|
||||||
<button type='button' class='btn btn-success btn-sm btn-choose'>选择</button>\
|
<div class='path-con-left'>\
|
||||||
</div>",
|
<dl><dt id='changecomlist' onclick='backMyComputer()'>计算机</dt></dl>\
|
||||||
|
</div>\
|
||||||
|
<div class='path-con-right'>\
|
||||||
|
<ul class='default' id='computerDefautl'></ul>\
|
||||||
|
<div class='file-list divtable'>\
|
||||||
|
<table class='table table-hover' style='border:0 none'>\
|
||||||
|
<thead>\
|
||||||
|
<tr class='file-list-head'>\
|
||||||
|
<th width='40%'>文件名</th>\
|
||||||
|
<th width='20%'>修改时间</th>\
|
||||||
|
<th width='10%'>权限</th>\
|
||||||
|
<th width='10%'>所有者</th>\
|
||||||
|
<th width='10%'></th>\
|
||||||
|
</tr>\
|
||||||
|
</thead>\
|
||||||
|
<tbody id='tbody' class='list-list'></tbody>\
|
||||||
|
</table>\
|
||||||
|
</div>\
|
||||||
|
</div>\
|
||||||
|
</div>\
|
||||||
|
</div>\
|
||||||
|
<div class='getfile-btn' style='margin-top:0'>\
|
||||||
|
<button type='button' class='btn btn-default btn-sm pull-left' onclick='createFolder()'>新建文件夹</button>\
|
||||||
|
<button type='button' class='btn btn-danger btn-sm mr5 btn-close'>关闭</button>\
|
||||||
|
<button type='button' class='btn btn-success btn-sm btn-choose'>选择</button>\
|
||||||
|
</div>",
|
||||||
success:function(layero,layer_index){
|
success:function(layero,layer_index){
|
||||||
$('.btn-close').click(function(){
|
$('.btn-close').click(function(){
|
||||||
layer.close(layer_index);
|
layer.close(layer_index);
|
||||||
@@ -274,16 +299,38 @@ function changePath(d) {
|
|||||||
closeBtn: 1,
|
closeBtn: 1,
|
||||||
shift: 5,
|
shift: 5,
|
||||||
shadeClose: false,
|
shadeClose: false,
|
||||||
content: "<div class='changepath'><div class='path-top'><button type='button' class='btn btn-default btn-sm' onclick='backFile()'><span class='glyphicon glyphicon-share-alt'></span>返回</button>\
|
content: "\
|
||||||
<div class='place' id='PathPlace'>当前路径:<span></span></div></div><div class='path-con'><div class='path-con-left'><dl><dt id='changecomlist' onclick='backMyComputer()'>计算机</dt></dl></div>\
|
<div class='changepath'>\
|
||||||
<div class='path-con-right'><ul class='default' id='computerDefautl'></ul><div class='file-list divtable'>\
|
<div class='path-top'>\
|
||||||
<table class='table table-hover' style='border:0 none'>\
|
<button type='button' class='btn btn-default btn-sm' onclick='backFile()'><span class='glyphicon glyphicon-share-alt'></span>返回</button>\
|
||||||
<thead><tr class='file-list-head'><th width='40%'>文件名</th><th width='20%'>修改时间</th><th width='10%'>权限</th><th width='10%'>所有者</th><th width='10%'></th></tr></thead>\
|
<div class='place' id='PathPlace'>当前路径:<span></span></div>\
|
||||||
<tbody id='tbody' class='list-list'></tbody></table></div></div></div></div><div class='getfile-btn' style='margin-top:0'>\
|
</div>\
|
||||||
|
<div class='path-con'>\
|
||||||
|
<div class='path-con-left'><dl><dt id='changecomlist' onclick='backMyComputer()'>计算机</dt></dl></div>\
|
||||||
|
<div class='path-con-right'>\
|
||||||
|
<ul class='default' id='computerDefautl'></ul>\
|
||||||
|
<div class='file-list divtable'>\
|
||||||
|
<table class='table table-hover' style='border:0 none'>\
|
||||||
|
<thead>\
|
||||||
|
<tr class='file-list-head'>\
|
||||||
|
<th width='40%'>文件名</th>\
|
||||||
|
<th width='20%'>修改时间</th>\
|
||||||
|
<th width='10%'>权限</th>\
|
||||||
|
<th width='10%'>所有者</th>\
|
||||||
|
<th width='10%'></th>\
|
||||||
|
</tr>\
|
||||||
|
</thead>\
|
||||||
|
<tbody id='tbody' class='list-list'></tbody>\
|
||||||
|
</table>\
|
||||||
|
</div>\
|
||||||
|
</div>\
|
||||||
|
</div>\
|
||||||
|
</div>\
|
||||||
|
<div class='getfile-btn' style='margin-top:0'>\
|
||||||
<button type='button' class='btn btn-default btn-sm pull-left' onclick='createFolder()'>新建文件夹</button>\
|
<button type='button' class='btn btn-default btn-sm pull-left' onclick='createFolder()'>新建文件夹</button>\
|
||||||
<button type='button' class='btn btn-danger btn-sm mr5' onclick=\"layer.close(getCookie('changePath'))\">关闭</button>\
|
<button type='button' class='btn btn-danger btn-sm mr5' onclick=\"layer.close(getCookie('changePath'))\">关闭</button>\
|
||||||
<button type='button' class='btn btn-success btn-sm' onclick='getfilePath()'>选择</button>\
|
<button type='button' class='btn btn-success btn-sm' onclick='getfilePath()'>选择</button>\
|
||||||
</div>"
|
</div>"
|
||||||
});
|
});
|
||||||
setCookie("changePath", c);
|
setCookie("changePath", c);
|
||||||
var b = $("#" + d).val();
|
var b = $("#" + d).val();
|
||||||
@@ -323,7 +370,13 @@ function getDiskList(b) {
|
|||||||
e = e.substring(0, 10) + "..."
|
e = e.substring(0, 10) + "..."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
d += "<tr><td onclick=\"getDiskList('" + h.PATH + "/" + g[0] + "')\" title='" + g[0] + "'><span class='glyphicon glyphicon-folder-open'></span>" + e + "</td><td>" + getLocalTime(g[2]) + "</td><td>" + g[3] + "</td><td>" + g[4] + "</td><td><span class='delfile-btn' onclick=\"NewDelFile('" + h.PATH + "/" + g[0] + "')\">X</span></td></tr>"
|
d += "<tr>\
|
||||||
|
<td onclick=\"getDiskList('" + h.PATH + "/" + g[0] + "')\" title='" + g[0] + "'>\
|
||||||
|
<span class='glyphicon glyphicon-folder-open'></span>" + e + "</td><td>" + getLocalTime(g[2]) + "</td>\
|
||||||
|
<td>" + g[3] + "</td>\
|
||||||
|
<td>" + g[4] + "</td>\
|
||||||
|
<td><span class='delfile-btn' onclick=\"NewDelFile('" + h.PATH + "/" + g[0] + "')\">X</span></td>\
|
||||||
|
</tr>";
|
||||||
}
|
}
|
||||||
if(h.FILES != null && h.FILES != "") {
|
if(h.FILES != null && h.FILES != "") {
|
||||||
for(var f = 0; f < h.FILES.length; f++) {
|
for(var f = 0; f < h.FILES.length; f++) {
|
||||||
@@ -337,7 +390,13 @@ function getDiskList(b) {
|
|||||||
e = e.substring(0, 10) + "..."
|
e = e.substring(0, 10) + "..."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
d += "<tr><td title='" + g[0] + "'><span class='glyphicon glyphicon-file'></span>" + e + "</td><td>" + getLocalTime(g[2]) + "</td><td>" + g[3] + "</td><td>" + g[4] + "</td><td></td></tr>"
|
d += "<tr>\
|
||||||
|
<td title='" + g[0] + "'><span class='glyphicon glyphicon-file'></span>" + e + "</td>\
|
||||||
|
<td>" + getLocalTime(g[2]) + "</td>\
|
||||||
|
<td>" + g[3] + "</td>\
|
||||||
|
<td>" + g[4] + "</td>\
|
||||||
|
<td></td>\
|
||||||
|
</tr>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$(".default").hide();
|
$(".default").hide();
|
||||||
@@ -720,7 +779,12 @@ function safeMessage(j, h, g, f) {
|
|||||||
area: "350px",
|
area: "350px",
|
||||||
closeBtn: 1,
|
closeBtn: 1,
|
||||||
shadeClose: true,
|
shadeClose: true,
|
||||||
content: "<div class='bt-form webDelete pd20 pb70'><p>" + h + "</p>" + f + "<div class='vcode'>"+lan.bt.cal_msg+"<span class='text'>" + sumtext + "</span>=<input type='number' id='vcodeResult' value=''></div><div class='bt-form-submit-btn'><button type='button' class='btn btn-danger btn-sm bt-cancel'>"+lan.public.cancel+"</button> <button type='button' id='toSubmit' class='btn btn-success btn-sm' >"+lan.public.ok+"</button></div></div>"
|
content: "<div class='bt-form webDelete pd20 pb70'>\
|
||||||
|
<p>" + h + "</p>" + f + "<div class='vcode'>"+lan.bt.cal_msg+"<span class='text'>" + sumtext + "</span>=<input type='number' id='vcodeResult' value=''></div>\
|
||||||
|
<div class='bt-form-submit-btn'>\
|
||||||
|
<button type='button' class='btn btn-danger btn-sm bt-cancel'>"+lan.public.cancel+"</button>\
|
||||||
|
<button type='button' id='toSubmit' class='btn btn-success btn-sm' >"+lan.public.ok+"</button></div>\
|
||||||
|
</div>"
|
||||||
});
|
});
|
||||||
$("#vcodeResult").focus().keyup(function(a) {
|
$("#vcodeResult").focus().keyup(function(a) {
|
||||||
if(a.keyCode == 13) {
|
if(a.keyCode == 13) {
|
||||||
@@ -856,16 +920,32 @@ function GetTaskList(a) {
|
|||||||
case "-1":
|
case "-1":
|
||||||
f = true;
|
f = true;
|
||||||
if(g.data[d].type != "download") {
|
if(g.data[d].type != "download") {
|
||||||
b = "<li><span class='titlename'>" + g.data[d].name + "</span><span class='state'>正在安装 <img src='/static/img/ing.gif'> | <a href=\"javascript:removeTask(" + g.data[d].id + ")\">关闭</a></span><span class='opencmd'></span><pre class='cmd'></pre></li>"
|
b = "<li>\
|
||||||
|
<span class='titlename'>" + g.data[d].name + "</span>\
|
||||||
|
<span class='state'>正在安装 <img src='/static/img/ing.gif'> | <a href=\"javascript:removeTask(" + g.data[d].id + ")\">关闭</a></span>\
|
||||||
|
<span class='opencmd'></span><pre class='cmd'></pre>\
|
||||||
|
</li>";
|
||||||
} else {
|
} else {
|
||||||
b = "<li><div class='line-progress' style='width:0%'></div><span class='titlename'>" + g.data[d].name + "<a id='speed' style='margin-left:130px;'>0.0M/12.5M</a></span><span class='com-progress'>0%</span><span class='state'>下载中 <img src='/static/img/ing.gif'> | <a href=\"javascript:removeTask(" + g.data[d].id + ")\">"+lan.public.close+"</a></span></li>"
|
b = "<li>\
|
||||||
|
<div class='line-progress' style='width:0%'></div>\
|
||||||
|
<span class='titlename'>" + g.data[d].name + "<a id='speed' style='margin-left:130px;'>0.0M/12.5M</a></span>\
|
||||||
|
<span class='com-progress'>0%</span><span class='state'>\
|
||||||
|
下载中 <img src='/static/img/ing.gif'> | <a href=\"javascript:removeTask(" + g.data[d].id + ")\">"+lan.public.close+"</a>\
|
||||||
|
</span>\
|
||||||
|
</li>";
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "0":
|
case "0":
|
||||||
c += "<li><span class='titlename'>" + g.data[d].name + "</span><span class='state'>等待</span> | <a href=\"javascript:removeTask(" + g.data[d].id + ")\">删除</a></li>";
|
c += "<li>\
|
||||||
|
<span class='titlename'>" + g.data[d].name + "</span>\
|
||||||
|
<span class='state'>等待</span> | <a href=\"javascript:removeTask(" + g.data[d].id + ")\">删除</a>\
|
||||||
|
</li>";
|
||||||
break;
|
break;
|
||||||
case "1":
|
case "1":
|
||||||
e += "<li><span class='titlename'>" + g.data[d].name + "</span><span class='state'>" + g.data[d].addtime + " "+'已完成'+" "+ '耗时' + (g.data[d].end - g.data[d].start)+"秒</span></li>"
|
e += "<li>\
|
||||||
|
<span class='titlename'>" + g.data[d].name + "</span>\
|
||||||
|
<span class='state'>" + g.data[d].addtime + " "+'已完成'+" "+ '耗时' + (g.data[d].end - g.data[d].start)+"秒</span>\
|
||||||
|
</li>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$("#srunning").html(b + c);
|
$("#srunning").html(b + c);
|
||||||
@@ -1070,7 +1150,8 @@ function bindPanel(a,type,ip,btid,url,user,pw){
|
|||||||
btn = "<button type='button' class='btn btn-success btn-sm' onclick=\"bindPanel(1,'b')\">添加</button>";
|
btn = "<button type='button' class='btn btn-success btn-sm' onclick=\"bindPanel(1,'b')\">添加</button>";
|
||||||
} else {
|
} else {
|
||||||
titleName = '修改关联' + ip;
|
titleName = '修改关联' + ip;
|
||||||
btn = "<button type='button' class='btn btn-default btn-sm' onclick=\"bindPaneldel('"+btid+"')\">删除</button><button type='button' class='btn btn-success btn-sm' onclick=\"bindPanel(1,'c','"+ip+"','"+btid+"')\" style='margin-left:7px'>修改</button>";
|
btn = "<button type='button' class='btn btn-default btn-sm' onclick=\"bindPaneldel('"+btid+"')\">删除</button>\
|
||||||
|
<button type='button' class='btn btn-success btn-sm' onclick=\"bindPanel(1,'c','"+ip+"','"+btid+"')\" style='margin-left:7px'>修改</button>";
|
||||||
}
|
}
|
||||||
if(url == undefined) url="http://";
|
if(url == undefined) url="http://";
|
||||||
if(user == undefined) user="";
|
if(user == undefined) user="";
|
||||||
@@ -1255,13 +1336,37 @@ function remind(a){
|
|||||||
for(var d = 0; d < g.data.length; d++) {
|
for(var d = 0; d < g.data.length; d++) {
|
||||||
if(g.data[d].status != '1'){
|
if(g.data[d].status != '1'){
|
||||||
task_count++;
|
task_count++;
|
||||||
e += '<tr><td><input type="checkbox"></td><td><div class="titlename c3">'+g.data[d].name+'</span><span class="rs-status">【'+lan.bt.task_the+'】<span><span class="rs-time">耗时['+ getSFM(g.data[d].end - g.data[d].start) +']</span></div></td><td class="text-right c3">'+g.data[d].addtime+'</td></tr>'
|
e += '<tr>\
|
||||||
|
<td><input type="checkbox"></td>\
|
||||||
|
<td>\
|
||||||
|
<div class="titlename c3">\
|
||||||
|
<span>'+g.data[d].name+'</span>\
|
||||||
|
<span class="rs-status">【'+lan.bt.task_the+'】<span>\
|
||||||
|
<span class="rs-time">耗时['+ getSFM(g.data[d].end - g.data[d].start) +']</span>\
|
||||||
|
</div>\
|
||||||
|
</td>\
|
||||||
|
<td class="text-right c3">'+g.data[d].addtime+'</td>\
|
||||||
|
</tr>';
|
||||||
} else{
|
} else{
|
||||||
e += '<tr><td><input type="checkbox"></td><td><div class="titlename c3">'+g.data[d].name+'</span><span class="rs-status">【'+lan.bt.task_ok+'】<span><span class="rs-time">耗时['+ getSFM(g.data[d].end - g.data[d].start) +']</span></div></td><td class="text-right c3">'+g.data[d].addtime+'</td></tr>';
|
e += '<tr>\
|
||||||
|
<td><input type="checkbox"></td>\
|
||||||
|
<td>\
|
||||||
|
<div class="titlename c3">'+g.data[d].name+'</span>\
|
||||||
|
<span class="rs-status">【'+lan.bt.task_ok+'】<span>\
|
||||||
|
<span class="rs-time">耗时['+ getSFM(g.data[d].end - g.data[d].start) +']</span>\
|
||||||
|
</div>\
|
||||||
|
</td>\
|
||||||
|
<td class="text-right c3">'+g.data[d].addtime+'</td>\
|
||||||
|
</tr>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var con = '<div class="divtable"><table class="table table-hover">\
|
var con = '<div class="divtable"><table class="table table-hover">\
|
||||||
<thead><tr><th width="20"><input id="Rs-checkAll" type="checkbox" onclick="RscheckSelect()"></th><th>'+lan.bt.task_name+'</th><th class="text-right">'+lan.bt.task_time+'</th></tr></thead>\
|
<thead>\
|
||||||
|
<tr>\
|
||||||
|
<th width="20"><input id="Rs-checkAll" type="checkbox" onclick="RscheckSelect()"></th>\
|
||||||
|
<th>'+lan.bt.task_name+'</th><th class="text-right">'+lan.bt.task_time+'</th>\
|
||||||
|
</tr>\
|
||||||
|
</thead>\
|
||||||
<tbody id="remind">'+e+'</tbody>\
|
<tbody id="remind">'+e+'</tbody>\
|
||||||
</table></div>\
|
</table></div>\
|
||||||
<div class="mtb15" style="height:32px">\
|
<div class="mtb15" style="height:32px">\
|
||||||
@@ -1325,12 +1430,26 @@ function getReloads() {
|
|||||||
c += f[e] + "<br>"
|
c += f[e] + "<br>"
|
||||||
}
|
}
|
||||||
if(h.task[g].name.indexOf("扫描") != -1) {
|
if(h.task[g].name.indexOf("扫描") != -1) {
|
||||||
b = "<li><span class='titlename'>" + h.task[g].name + "</span><span class='state'>正在扫描<img src='/static/img/ing.gif'> | <a href=\"javascript:removeTask(" + h.task[g].id + ")\">关闭</a></span><span class='opencmd'></span><div class='cmd'>" + c + "</div></li>"
|
b = "<li>\
|
||||||
|
<span class='titlename'>" + h.task[g].name + "</span>\
|
||||||
|
<span class='state'>正在扫描<img src='/static/img/ing.gif'> | <a href=\"javascript:removeTask(" + h.task[g].id + ")\">关闭</a></span>\
|
||||||
|
<span class='opencmd'></span>\
|
||||||
|
<div class='cmd'>" + c + "</div>\
|
||||||
|
</li>";
|
||||||
} else {
|
} else {
|
||||||
b = "<li><span class='titlename'>" + h.task[g].name + "</span><span class='state'>正在安装<img src='/static/img/ing.gif'> | <a href=\"javascript:removeTask(" + h.task[g].id + ")\">关闭</a></span><div class='cmd'>" + c + "</div></li>"
|
b = "<li>\
|
||||||
|
<span class='titlename'>" + h.task[g].name + "</span>\
|
||||||
|
<span class='state'>正在安装<img src='/static/img/ing.gif'> | <a href=\"javascript:removeTask(" + h.task[g].id + ")\">关闭</a></span>\
|
||||||
|
<div class='cmd'>" + c + "</div>\
|
||||||
|
</li>";
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
b = "<li><div class='line-progress' style='width:" + h.msg.pre + "%'></div><span class='titlename'>" + h.task[g].name + "<a style='margin-left:130px;'>" + (toSize(h.msg.used) + "/" + toSize(h.msg.total)) + "</a></span><span class='com-progress'>" + h.msg.pre + "%</span><span class='state'>"+lan.bt.task_downloading+" <img src='/static/img/ing.gif'> | <a href=\"javascript:removeTask(" + h.task[g].id + ")\">"+lan.public.close+"</a></span></li>"
|
b = "<li>\
|
||||||
|
<div class='line-progress' style='width:" + h.msg.pre + "%'></div>\
|
||||||
|
<span class='titlename'>" + h.task[g].name + "<a style='margin-left:130px;'>" + (toSize(h.msg.used) + "/" + toSize(h.msg.total)) + "</a></span>\
|
||||||
|
<span class='com-progress'>" + h.msg.pre + "%</span>\
|
||||||
|
<span class='state'>"+lan.bt.task_downloading+" <img src='/static/img/ing.gif'> | <a href=\"javascript:removeTask(" + h.task[g].id + ")\">"+lan.public.close+"</a></span>\
|
||||||
|
</li>"
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
d += "<li><span class='titlename'>" + h.task[g].name + "</span><span class='state'>等待 | <a style='color:green' href=\"javascript:removeTask(" + h.task[g].id + ')">删除</a></span></li>'
|
d += "<li><span class='titlename'>" + h.task[g].name + "</span><span class='state'>等待 | <a style='color:green' href=\"javascript:removeTask(" + h.task[g].id + ')">删除</a></span></li>'
|
||||||
@@ -1380,14 +1499,24 @@ function tasklist(a){
|
|||||||
case "-1":
|
case "-1":
|
||||||
f = true;
|
f = true;
|
||||||
if(g.data[d].type != "download") {
|
if(g.data[d].type != "download") {
|
||||||
b = "<li><span class='titlename'>" + g.data[d].name + "</span><span class='state pull-right c6'>正在安装<img src='/static/img/ing.gif'> | <a class='btlink' href=\"javascript:removeTask(" + g.data[d].id + ")\">关闭</a></span><span class='opencmd'></span><pre class='cmd'></pre></li>"
|
b = "<li>\
|
||||||
|
<span class='titlename'>" + g.data[d].name + "</span>\
|
||||||
|
<span class='state pull-right c6'>正在安装<img src='/static/img/ing.gif'> | <a class='btlink' href=\"javascript:removeTask(" + g.data[d].id + ")\">关闭</a></span>\
|
||||||
|
<span class='opencmd'></span><pre class='cmd'></pre>\
|
||||||
|
</li>";
|
||||||
} else {
|
} else {
|
||||||
b = "<li><div class='line-progress' style='width:0%'></div><span class='titlename'>" + g.data[d].name + "<a id='speed' style='margin-left:130px;'>0.0M/12.5M</a></span><span class='com-progress'>0%</span><span class='state'>下载中 <img src='/static/img/ing.gif'> | <a href=\"javascript:removeTask(" + g.data[d].id + ")\">关闭</a></span></li>"
|
b = "<li>\
|
||||||
|
<div class='line-progress' style='width:0%'></div><span class='titlename'>" + g.data[d].name + "<a id='speed' style='margin-left:130px;'>0.0M/12.5M</a></span>\
|
||||||
|
<span class='com-progress'>0%</span><span class='state'>下载中 <img src='/static/img/ing.gif'> | <a href=\"javascript:removeTask(" + g.data[d].id + ")\">关闭</a></span>\
|
||||||
|
</li>";
|
||||||
}
|
}
|
||||||
task_count++;
|
task_count++;
|
||||||
break;
|
break;
|
||||||
case "0":
|
case "0":
|
||||||
c += "<li><span class='titlename'>" + g.data[d].name + "</span><span class='state pull-right c6'>等待</span> | <a href=\"javascript:removeTask(" + g.data[d].id + ")\" class='btlink'>"+lan.public.del+"</a></li>";
|
c += "<li>\
|
||||||
|
<span class='titlename'>" + g.data[d].name + "</span>\
|
||||||
|
<span class='state pull-right c6'>等待</span> | <a href=\"javascript:removeTask(" + g.data[d].id + ")\" class='btlink'>"+lan.public.del+"</a>\
|
||||||
|
</li>";
|
||||||
task_count++;
|
task_count++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -1704,7 +1833,8 @@ function showSpeed(filename) {
|
|||||||
* 显示进度窗口
|
* 显示进度窗口
|
||||||
*/
|
*/
|
||||||
function showSpeedWindow(msg, speed_log_func_name, callback){
|
function showSpeedWindow(msg, speed_log_func_name, callback){
|
||||||
var speed_msg = "<pre style='margin-bottom: 0px;height:250px;text-align: left;background-color: #000;color: #fff;white-space: pre-wrap;' id='speed_log_lst'>[MSG]</pre>";
|
var speed_msg = "<pre style='margin-bottom: 0px;height:250px;text-align: left;background-color: #000;\
|
||||||
|
color: #fff;white-space: pre-wrap;' id='speed_log_lst'>[MSG]</pre>";
|
||||||
var showSpeedKey = layer.open({
|
var showSpeedKey = layer.open({
|
||||||
title: false,
|
title: false,
|
||||||
type: 1,
|
type: 1,
|
||||||
@@ -1924,14 +2054,19 @@ function utf8to16(str) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function pluginService(_name, version){
|
function pluginService(_name, version, _suffix_name=''){
|
||||||
var data = {name:_name, func:'status'}
|
|
||||||
|
var default_name = 'status';
|
||||||
|
if ( _suffix_name != '' ){
|
||||||
|
default_name = 'status_'+_suffix_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
var data = {name:_name, func:default_name};
|
||||||
if ( typeof(version) != 'undefined' ){
|
if ( typeof(version) != 'undefined' ){
|
||||||
data['version'] = version;
|
data['version'] = version;
|
||||||
} else {
|
} else {
|
||||||
version = '';
|
version = '';
|
||||||
}
|
}
|
||||||
// console.log(version);
|
|
||||||
|
|
||||||
var loadT = layer.msg('正在获取...', { icon: 16, time: 0, shade: 0.3 });
|
var loadT = layer.msg('正在获取...', { icon: 16, time: 0, shade: 0.3 });
|
||||||
$.post('/plugins/run', data, function(data) {
|
$.post('/plugins/run', data, function(data) {
|
||||||
@@ -1941,27 +2076,39 @@ function pluginService(_name, version){
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (data.data == 'start'){
|
if (data.data == 'start'){
|
||||||
pluginSetService(_name, true, version);
|
pluginSetService(_name, true, version, _suffix_name);
|
||||||
} else {
|
} else {
|
||||||
pluginSetService(_name, false, version);
|
pluginSetService(_name, false, version, _suffix_name);
|
||||||
}
|
}
|
||||||
},'json');
|
},'json');
|
||||||
}
|
}
|
||||||
|
|
||||||
function pluginSetService(_name ,status, version){
|
function pluginSetService(_name ,status, version, _suffix_name=''){
|
||||||
|
|
||||||
|
var default_name = 'status';
|
||||||
|
var restart_name = 'restart';
|
||||||
|
var reload_name = 'reload';
|
||||||
|
var status_ss = (status?'stop':'start');
|
||||||
|
if ( _suffix_name != '' ){
|
||||||
|
default_name = 'status_'+_suffix_name;
|
||||||
|
restart_name = 'restart_'+_suffix_name;
|
||||||
|
reload_name = 'reload_'+_suffix_name;
|
||||||
|
status_ss = status_ss+'_'+_suffix_name;
|
||||||
|
}
|
||||||
|
|
||||||
var serviceCon ='<p class="status">当前状态:<span>'+(status ? '开启' : '关闭' )+
|
var serviceCon ='<p class="status">当前状态:<span>'+(status ? '开启' : '关闭' )+
|
||||||
'</span><span style="color: '+
|
'</span><span style="color: '+
|
||||||
(status?'#20a53a;':'red;')+
|
(status?'#20a53a;':'red;')+
|
||||||
' margin-left: 3px;" class="glyphicon ' + (status?'glyphicon glyphicon-play':'glyphicon-pause')+'"></span></p><div class="sfm-opt">\
|
' margin-left: 3px;" class="glyphicon ' + (status?'glyphicon glyphicon-play':'glyphicon-pause')+'"></span></p><div class="sfm-opt">\
|
||||||
<button class="btn btn-default btn-sm" onclick="pluginOpService(\''+_name+'\',\''+(status?'stop':'start')+'\',\''+version+'\')">'+(status?'停止':'启动')+'</button>\
|
<button class="btn btn-default btn-sm" onclick="pluginOpService(\''+_name+'\',\''+status_ss+'\',\''+version+'\',\''+_suffix_name+'\')">'+(status?'停止':'启动')+'</button>\
|
||||||
<button class="btn btn-default btn-sm" onclick="pluginOpService(\''+_name+'\',\'restart\',\''+version+'\')">重启</button>\
|
<button class="btn btn-default btn-sm" onclick="pluginOpService(\''+_name+'\',\''+restart_name+'\',\''+version+'\',\''+_suffix_name+'\')">重启</button>\
|
||||||
<button class="btn btn-default btn-sm" onclick="pluginOpService(\''+_name+'\',\'reload\',\''+version+'\')">重载配置</button>\
|
<button class="btn btn-default btn-sm" onclick="pluginOpService(\''+_name+'\',\''+reload_name+'\',\''+version+'\',\''+_suffix_name+'\')">重载配置</button>\
|
||||||
</div>';
|
</div>';
|
||||||
$(".soft-man-con").html(serviceCon);
|
$(".soft-man-con").html(serviceCon);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function pluginOpService(a, b, v) {
|
function pluginOpService(a, b, v, _suffix_name='') {
|
||||||
|
|
||||||
var c = "name=" + a + "&func=" + b;
|
var c = "name=" + a + "&func=" + b;
|
||||||
if(v != ''){
|
if(v != ''){
|
||||||
@@ -1969,26 +2116,33 @@ function pluginOpService(a, b, v) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var d = "";
|
var d = "";
|
||||||
|
|
||||||
|
b = b.split('_')[0];
|
||||||
switch(b) {
|
switch(b) {
|
||||||
case "stop":d = '停止';break;
|
case "stop":d = '停止';break;
|
||||||
case "start":d = '启动';break;
|
case "start":d = '启动';break;
|
||||||
case "restart":d = '重启';break;
|
case "restart":d = '重启';break;
|
||||||
case "reload":d = '重载';break;
|
case "reload":d = '重载';break;
|
||||||
}
|
}
|
||||||
layer.confirm( msgTpl('您真的要{1}{2}{3}服务吗?', [d,a,v]), {icon:3,closeBtn: 1}, function() {
|
|
||||||
var e = layer.msg(msgTpl('正在{1}{2}{3}服务,请稍候...',[d,a,v]), {icon: 16,time: 0});
|
_ver = v;
|
||||||
|
if(v != ''){
|
||||||
|
_ver = '【' + v + '】';
|
||||||
|
}
|
||||||
|
|
||||||
|
layer.confirm( msgTpl('您真的要{1}{2}{3}服务吗?', [d,a,_ver]), {icon:3,closeBtn: 1}, function() {
|
||||||
|
var e = layer.msg(msgTpl('正在{1}{2}{3}服务,请稍候...',[d,a,_ver]), {icon: 16,time: 0});
|
||||||
$.post("/plugins/run", c, function(g) {
|
$.post("/plugins/run", c, function(g) {
|
||||||
layer.close(e);
|
layer.close(e);
|
||||||
|
|
||||||
|
var f = g.data == 'ok' ? msgTpl('{1}{2}服务已{3}',[a,_ver,d]) : msgTpl('{1}{2}服务{3}失败!',[a,_ver,d]);
|
||||||
var f = g.data == 'ok' ? msgTpl('{1}{2}服务已{3}',[a,v,d]) : msgTpl('{1}{2}服务{3}失败!',[a,v,d]);
|
|
||||||
layer.msg(f, {icon: g.data == 'ok' ? 1 : 2});
|
layer.msg(f, {icon: g.data == 'ok' ? 1 : 2});
|
||||||
|
|
||||||
if( b != "reload" && g.data == 'ok' ) {
|
if( b != "reload" && g.data == 'ok' ) {
|
||||||
if ( b == 'start' ) {
|
if ( b == 'start' ) {
|
||||||
pluginSetService(a, true, v);
|
pluginSetService(a, true, v, _suffix_name);
|
||||||
} else if ( b == 'stop' ){
|
} else if ( b == 'stop' ){
|
||||||
pluginSetService(a, false, v);
|
pluginSetService(a, false, v, _suffix_name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2209,14 +2363,18 @@ function pluginConfigSave(fileName) {
|
|||||||
},'json');
|
},'json');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function pluginInitD(_name, _version, _suffix_name=''){
|
||||||
|
|
||||||
function pluginInitD(_name,_version){
|
|
||||||
if (typeof _version == 'undefined'){
|
if (typeof _version == 'undefined'){
|
||||||
_version = '';
|
_version = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var default_name = 'initd_status';
|
||||||
|
if ( _suffix_name != '' ){
|
||||||
|
default_name = 'initd_status_'+_suffix_name;
|
||||||
|
}
|
||||||
|
|
||||||
var loadT = layer.msg('正在获取...', { icon: 16, time: 0, shade: 0.3 });
|
var loadT = layer.msg('正在获取...', { icon: 16, time: 0, shade: 0.3 });
|
||||||
$.post('/plugins/run', {name:_name, func:'initd_status',version : _version}, function(data) {
|
$.post('/plugins/run', {name:_name, func:default_name, version : _version}, function(data) {
|
||||||
layer.close(loadT);
|
layer.close(loadT);
|
||||||
if( !data.status ){
|
if( !data.status ){
|
||||||
layer.msg(data.msg,{icon:0,time:3000,shade: [0.3, '#000']});
|
layer.msg(data.msg,{icon:0,time:3000,shade: [0.3, '#000']});
|
||||||
@@ -2227,35 +2385,48 @@ function pluginInitD(_name,_version){
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (data.data == 'ok'){
|
if (data.data == 'ok'){
|
||||||
pluginSetInitD(_name, _version, true);
|
pluginSetInitD(_name, _version, true, _suffix_name);
|
||||||
} else {
|
} else {
|
||||||
pluginSetInitD(_name, _version, false);
|
pluginSetInitD(_name, _version, false, _suffix_name);
|
||||||
}
|
}
|
||||||
},'json');
|
},'json');
|
||||||
}
|
}
|
||||||
|
|
||||||
function pluginSetInitD(_name, _version, status){
|
function pluginSetInitD(_name, _version, status,_suffix_name=''){
|
||||||
|
|
||||||
|
var default_name = (status?'initd_uninstall':'initd_install');
|
||||||
|
if ( _suffix_name != '' ){
|
||||||
|
default_name = default_name + '_' + _suffix_name;
|
||||||
|
}
|
||||||
|
|
||||||
var serviceCon ='<p class="status">当前状态:<span>'+(status ? '已加载' : '未加载' )+
|
var serviceCon ='<p class="status">当前状态:<span>'+(status ? '已加载' : '未加载' )+
|
||||||
'</span><span style="color: '+
|
'</span><span style="color: '+
|
||||||
(status?'#20a53a;':'red;')+
|
(status?'#20a53a;':'red;')+
|
||||||
' margin-left: 3px;" class="glyphicon ' + (status?'glyphicon glyphicon-play':'glyphicon-pause')+'"></span></p><div class="sfm-opt">\
|
' margin-left: 3px;" class="glyphicon ' + (status?'glyphicon glyphicon-play':'glyphicon-pause')+'"></span></p><div class="sfm-opt">\
|
||||||
<button class="btn btn-default btn-sm" onclick="pluginOpInitD(\''+_name+'\',\''+_version+'\',\''+(status?'initd_uninstall':'initd_install')+'\')">'+(status?'卸载':'加载')+'</button>\
|
<button class="btn btn-default btn-sm" onclick="pluginOpInitD(\''+_name+'\',\''+_version+'\',\''+default_name+'\',\''+_suffix_name+'\')">'+(status?'卸载':'加载')+'</button>\
|
||||||
</div>';
|
</div>';
|
||||||
$(".soft-man-con").html(serviceCon);
|
$(".soft-man-con").html(serviceCon);
|
||||||
}
|
}
|
||||||
|
|
||||||
function pluginOpInitD(a, _version, b) {
|
function pluginOpInitD(a, _version, b, _suffix_name='') {
|
||||||
var c = "name=" + a + "&func=" + b + "&version="+_version;
|
var c = "name=" + a + "&func=" + b + "&version="+_version;
|
||||||
var d = "";
|
var d = "";
|
||||||
|
b = b.split('_'+_suffix_name)[0];
|
||||||
switch(b) {
|
switch(b) {
|
||||||
case "initd_install":d = '加载';break;
|
case "initd_install":d = '加载';break;
|
||||||
case "initd_uninstall":d = '卸载';break;
|
case "initd_uninstall":d = '卸载';break;
|
||||||
}
|
}
|
||||||
layer.confirm( msgTpl('您真的要{1}{2}{3}服务吗?', [d,a,_version]), {icon:3,closeBtn: 1}, function() {
|
|
||||||
var e = layer.msg(msgTpl('正在{1}{2}{3}服务,请稍候...',[d,a,_version]), {icon: 16,time: 0});
|
_ver = _version;
|
||||||
|
if(_version != ''){
|
||||||
|
_ver = '【' + _version + '】';
|
||||||
|
}
|
||||||
|
|
||||||
|
layer.confirm( msgTpl('您真的要{1}{2}{3}服务吗?', [d,a,_ver]), {icon:3,closeBtn: 1}, function() {
|
||||||
|
var e = layer.msg(msgTpl('正在{1}{2}{3}服务,请稍候...',[d,a,_ver]), {icon: 16,time: 0});
|
||||||
$.post("/plugins/run", c, function(g) {
|
$.post("/plugins/run", c, function(g) {
|
||||||
layer.close(e);
|
layer.close(e);
|
||||||
var f = g.data == 'ok' ? msgTpl('{1}{3}服务已{2}',[a,d,_version]) : msgTpl('{1}{3}服务{2}失败!',[a,d,_version]);
|
var f = g.data == 'ok' ? msgTpl('{1}{3}服务已{2}',[a,d,_ver]) : msgTpl('{1}{3}服务{2}失败!',[a,d,_ver]);
|
||||||
layer.msg(f, {icon: g.data == 'ok' ? 1 : 2});
|
layer.msg(f, {icon: g.data == 'ok' ? 1 : 2});
|
||||||
|
|
||||||
if ( b == 'initd_install' && g.data == 'ok' ) {
|
if ( b == 'initd_install' && g.data == 'ok' ) {
|
||||||
|
|||||||
+11
-10
@@ -4,8 +4,8 @@
|
|||||||
* @param {String} search 搜索条件
|
* @param {String} search 搜索条件
|
||||||
*/
|
*/
|
||||||
function getWeb(page, search, type_id) {
|
function getWeb(page, search, type_id) {
|
||||||
search = $("#SearchValue").prop("value");
|
var search = $("#SearchValue").prop("value");
|
||||||
page = page == undefined ? '1':page;
|
var page = page == undefined ? '1':page;
|
||||||
var order = getCookie('order');
|
var order = getCookie('order');
|
||||||
if(order){
|
if(order){
|
||||||
order = '&order=' + order;
|
order = '&order=' + order;
|
||||||
@@ -127,7 +127,7 @@
|
|||||||
if(databak == null){
|
if(databak == null){
|
||||||
databak = '';
|
databak = '';
|
||||||
}
|
}
|
||||||
$(this).hide().after("<input class='baktext' type='text' data-id='"+dataid+"' name='bak' value='" + databak + "' placeholder='备注信息' onblur='getBakPost(\"sites\")' />");
|
$(this).hide().after("<input class='baktext' type='text' data-id='"+dataid+"' data-page='"+page+"' name='bak' value='" + databak + "' placeholder='备注信息' onblur='getBakPost(\"sites\")' />");
|
||||||
$(".baktext").focus();
|
$(".baktext").focus();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -138,22 +138,23 @@
|
|||||||
|
|
||||||
function getBakPost(b) {
|
function getBakPost(b) {
|
||||||
$(".baktext").hide().prev().show();
|
$(".baktext").hide().prev().show();
|
||||||
var c = $(".baktext").attr("data-id");
|
var id = $(".baktext").attr("data-id");
|
||||||
|
var page = $(".baktext").attr("data-page");
|
||||||
var a = $(".baktext").val();
|
var a = $(".baktext").val();
|
||||||
if(a == "") {
|
if(a == "") {
|
||||||
a = '空';
|
a = '空';
|
||||||
}
|
}
|
||||||
setWebPs(b, c, a);
|
setWebPs(b, id, a,page);
|
||||||
$("a[data-id='" + c + "']").html(a);
|
$("a[data-id='" + id + "']").html(a);
|
||||||
$(".baktext").remove();
|
$(".baktext").remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
function setWebPs(b, e, a) {
|
function setWebPs(b, id, ps,page) {
|
||||||
var d = layer.load({shade: true,shadeClose: false});
|
var d = layer.load({shade: true,shadeClose: false});
|
||||||
var c = 'ps=' + a;
|
var ps = 'ps=' + ps;
|
||||||
$.post('/site/set_ps', 'id=' + e + "&" + c, function(data) {
|
$.post('/site/set_ps', 'id=' + id + "&" + ps, function(data) {
|
||||||
if(data['status']) {
|
if(data['status']) {
|
||||||
getWeb(1);
|
getWeb(page);
|
||||||
layer.closeAll();
|
layer.closeAll();
|
||||||
layer.msg('修改成功!', {icon: 1});
|
layer.msg('修改成功!', {icon: 1});
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -54,8 +54,8 @@
|
|||||||
<ul id="rmenu" class="dropdown-menu" style="display:none">
|
<ul id="rmenu" class="dropdown-menu" style="display:none">
|
||||||
<li onclick="javascript:batch(1);"><a style="cursor: pointer;">复制</a></li>
|
<li onclick="javascript:batch(1);"><a style="cursor: pointer;">复制</a></li>
|
||||||
<li onclick="javascript:batch(2);"><a style="cursor: pointer;">剪切</a></li>
|
<li onclick="javascript:batch(2);"><a style="cursor: pointer;">剪切</a></li>
|
||||||
<li onclick="javascript:batch(5);"><a style="cursor: pointer;">权限</a></li>
|
<li onclick="javascript:batch(3);"><a style="cursor: pointer;">权限</a></li>
|
||||||
<li onclick="javascript:batch(3);"><a style="cursor: pointer;">压缩</a></li>
|
<li onclick="javascript:batch(5);"><a style="cursor: pointer;">压缩</a></li>
|
||||||
<li onclick="javascript:batch(4);"><a style="cursor: pointer;">删除</a></li>
|
<li onclick="javascript:batch(4);"><a style="cursor: pointer;">删除</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
|||||||
@@ -9,8 +9,8 @@
|
|||||||
<a class="plr10 c4" href="/">首页</a>/<span class="plr10 c4">软件管理</span>
|
<a class="plr10 c4" href="/">首页</a>/<span class="plr10 c4">软件管理</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="search pull-right">
|
<div class="search pull-right">
|
||||||
<form target="hid" onsubmit='getSList()'>
|
<form target="_self" onsubmit='getSList();return false;'>
|
||||||
<input type="text" id="SearchValue" class="ser-text pull-left" placeholder="搜索" />
|
<input type="text" id="SearchValue" class="ser-text pull-left" placeholder="搜索" autocomplete="false" />
|
||||||
<button type="button" class="ser-sub pull-left" onclick='getSList()'></button>
|
<button type="button" class="ser-sub pull-left" onclick='getSList()'></button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
+12
-5
@@ -56,16 +56,24 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
# cn=$(curl --insecure -fsSL -m 10 https://ipinfo.io/json | grep "\"country\": \"CN\"")
|
# HTTP_PREFIX="https://"
|
||||||
|
# LOCAL_ADDR=common
|
||||||
|
# ping -c 1 github.com > /dev/null 2>&1
|
||||||
|
# if [ "$?" != "0" ];then
|
||||||
|
# LOCAL_ADDR=cn
|
||||||
|
# HTTP_PREFIX="https://ghproxy.com/"
|
||||||
|
# fi
|
||||||
|
|
||||||
|
cn=$(curl -fsSL -m 10 -s http://ipinfo.io/json | grep "\"country\": \"CN\"")
|
||||||
HTTP_PREFIX="https://"
|
HTTP_PREFIX="https://"
|
||||||
LOCAL_ADDR=common
|
LOCAL_ADDR=common
|
||||||
ping -c 1 github.com > /dev/null 2>&1
|
if [ ! -z "$cn" ];then
|
||||||
if [ "$?" != "0" ];then
|
|
||||||
LOCAL_ADDR=cn
|
LOCAL_ADDR=cn
|
||||||
HTTP_PREFIX="https://ghproxy.com/"
|
HTTP_PREFIX="https://ghproxy.com/"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
echo "local:${LOCAL_ADDR}"
|
||||||
|
|
||||||
if [ $OSNAME != "macos" ];then
|
if [ $OSNAME != "macos" ];then
|
||||||
if id www &> /dev/null ;then
|
if id www &> /dev/null ;then
|
||||||
echo ""
|
echo ""
|
||||||
@@ -106,7 +114,6 @@ if [ $OSNAME != "macos" ];then
|
|||||||
tar xvzf /tmp/acme.tar.gz -C /tmp
|
tar xvzf /tmp/acme.tar.gz -C /tmp
|
||||||
cd /tmp/acme.sh-master
|
cd /tmp/acme.sh-master
|
||||||
bash acme.sh install
|
bash acme.sh install
|
||||||
cd -
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -d /root/.acme.sh ];then
|
if [ ! -d /root/.acme.sh ];then
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
apt-get update -y
|
apt-get update -y
|
||||||
apt install -y wget curl lsof unzip tar cron expect locate
|
apt install -y wget curl lsof unzip tar cron expect locate lrzsz
|
||||||
apt install -y python3-pip python3-dev python3-venv
|
apt install -y python3-pip python3-dev python3-venv
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -158,6 +158,7 @@ if [ $VERSION_ID -ge 8 ];then
|
|||||||
libpng libpng-devel libstdc++.so.6 libtirpc libtirpc-devel libtool libtool-libs libwebp libwebp-devel \
|
libpng libpng-devel libstdc++.so.6 libtirpc libtirpc-devel libtool libtool-libs libwebp libwebp-devel \
|
||||||
libxml2 libxml2-devel libxslt libxslt-devel libarchive make mysql-devel ncurses ncurses-devel net-tools \
|
libxml2 libxml2-devel libxslt libxslt-devel libarchive make mysql-devel ncurses ncurses-devel net-tools \
|
||||||
oniguruma oniguruma-devel patch pcre pcre-devel perl perl-Data-Dumper perl-devel procps psmisc python3-devel \
|
oniguruma oniguruma-devel patch pcre pcre-devel perl perl-Data-Dumper perl-devel procps psmisc python3-devel \
|
||||||
|
openssl openssl-devel \
|
||||||
readline-devel rpcgen sqlite-devel tar unzip vim-minimal wget zip zlib zlib-devel ;
|
readline-devel rpcgen sqlite-devel tar unzip vim-minimal wget zip zlib zlib-devel ;
|
||||||
do
|
do
|
||||||
# dnf --enablerepo=remi,appstream,baseos,epel,extras,powertools install -y oniguruma5php-devel
|
# dnf --enablerepo=remi,appstream,baseos,epel,extras,powertools install -y oniguruma5php-devel
|
||||||
|
|||||||
@@ -75,6 +75,7 @@ apt install -y net-tools
|
|||||||
apt install -y python3-dev
|
apt install -y python3-dev
|
||||||
apt install -y autoconf
|
apt install -y autoconf
|
||||||
apt install -y gcc
|
apt install -y gcc
|
||||||
|
apt install -y lrzsz
|
||||||
|
|
||||||
apt install -y libffi-dev
|
apt install -y libffi-dev
|
||||||
apt install -y cmake automake make
|
apt install -y cmake automake make
|
||||||
|
|||||||
+12
-9
@@ -60,19 +60,23 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# HTTP_PREFIX="https://"
|
||||||
|
# LOCAL_ADDR=common
|
||||||
|
# ping -c 1 github.com > /dev/null 2>&1
|
||||||
|
# if [ "$?" != "0" ];then
|
||||||
|
# LOCAL_ADDR=cn
|
||||||
|
# HTTP_PREFIX="https://ghproxy.com/"
|
||||||
|
# fi
|
||||||
|
|
||||||
|
cn=$(curl -fsSL -m 10 -s http://ipinfo.io/json | grep "\"country\": \"CN\"")
|
||||||
HTTP_PREFIX="https://"
|
HTTP_PREFIX="https://"
|
||||||
LOCAL_ADDR=common
|
LOCAL_ADDR=common
|
||||||
ping -c 1 github.com > /dev/null 2>&1
|
if [ ! -z "$cn" ];then
|
||||||
if [ "$?" != "0" ];then
|
|
||||||
LOCAL_ADDR=cn
|
LOCAL_ADDR=cn
|
||||||
HTTP_PREFIX="https://ghproxy.com/"
|
HTTP_PREFIX="https://ghproxy.com/"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# cn=$(curl -fsSL -m 10 http://ipinfo.io/json | grep "\"country\": \"CN\"")
|
echo "local:${LOCAL_ADDR}"
|
||||||
# HTTP_PREFIX="https://"
|
|
||||||
# if [ ! -z "$cn" ];then
|
|
||||||
# HTTP_PREFIX="https://ghproxy.com/"
|
|
||||||
# fi
|
|
||||||
|
|
||||||
if [ $OSNAME != "macos" ];then
|
if [ $OSNAME != "macos" ];then
|
||||||
mkdir -p /www/server
|
mkdir -p /www/server
|
||||||
@@ -106,7 +110,6 @@ if [ $OSNAME != "macos" ];then
|
|||||||
tar xvzf /tmp/acme.tar.gz -C /tmp
|
tar xvzf /tmp/acme.tar.gz -C /tmp
|
||||||
cd /tmp/acme.sh-master
|
cd /tmp/acme.sh-master
|
||||||
bash acme.sh install
|
bash acme.sh install
|
||||||
cd -
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -d /root/.acme.sh ];then
|
if [ ! -d /root/.acme.sh ];then
|
||||||
|
|||||||
+44
-20
@@ -1,6 +1,15 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
|
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
|
||||||
|
|
||||||
|
function version_gt() { test "$(echo "$@" | tr " " "\n" | sort -V | head -n 1)" != "$1"; }
|
||||||
|
function version_le() { test "$(echo "$@" | tr " " "\n" | sort -V | head -n 1)" == "$1"; }
|
||||||
|
function version_lt() { test "$(echo "$@" | tr " " "\n" | sort -rV | head -n 1)" != "$1"; }
|
||||||
|
function version_ge() { test "$(echo "$@" | tr " " "\n" | sort -rV | head -n 1)" == "$1"; }
|
||||||
|
|
||||||
|
P_VER=`python3 -V | awk '{print $2}'`
|
||||||
|
echo "python:$P_VER"
|
||||||
|
sleep 3
|
||||||
|
|
||||||
curPath=`pwd`
|
curPath=`pwd`
|
||||||
rootPath=$(dirname "$curPath")
|
rootPath=$(dirname "$curPath")
|
||||||
serverPath=$(dirname "$rootPath")
|
serverPath=$(dirname "$rootPath")
|
||||||
@@ -48,15 +57,20 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# HTTP_PREFIX="https://"
|
||||||
|
# LOCAL_ADDR=common
|
||||||
|
# ping -c 1 github.com > /dev/null 2>&1
|
||||||
|
# if [ "$?" != "0" ];then
|
||||||
|
# LOCAL_ADDR=cn
|
||||||
|
# HTTP_PREFIX="https://ghproxy.com/"
|
||||||
|
# fi
|
||||||
|
|
||||||
|
cn=$(curl -fsSL -m 10 -s http://ipinfo.io/json | grep "\"country\": \"CN\"")
|
||||||
HTTP_PREFIX="https://"
|
HTTP_PREFIX="https://"
|
||||||
LOCAL_ADDR=common
|
LOCAL_ADDR=common
|
||||||
ping -c 1 ipinfo.io > /dev/null 2>&1
|
if [ ! -z "$cn" ];then
|
||||||
if [ "$?" == "0" ];then
|
LOCAL_ADDR=cn
|
||||||
CN=$(curl -fsSL -m 10 http://ipinfo.io/json | grep "\"country\": \"CN\"")
|
HTTP_PREFIX="https://ghproxy.com/"
|
||||||
if [ ! -z "$CN" ];then
|
|
||||||
LOCAL_ADDR=cn
|
|
||||||
HTTP_PREFIX="https://ghproxy.com/"
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
PIPSRC="https://pypi.python.org/simple"
|
PIPSRC="https://pypi.python.org/simple"
|
||||||
@@ -64,32 +78,42 @@ if [ "$LOCAL_ADDR" != "common" ];then
|
|||||||
PIPSRC="https://pypi.tuna.tsinghua.edu.cn/simple"
|
PIPSRC="https://pypi.tuna.tsinghua.edu.cn/simple"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
echo "local:${LOCAL_ADDR}"
|
||||||
echo "pypi source:$PIPSRC"
|
echo "pypi source:$PIPSRC"
|
||||||
|
|
||||||
#面板需要的库
|
#面板需要的库
|
||||||
if [ ! -f /usr/local/bin/pip3 ] && [ ! -f /usr/bin/pip3 ];then
|
if [ ! -f /usr/local/bin/pip3 ] && [ ! -f /usr/bin/pip3 ];then
|
||||||
python3 -m pip install --upgrade pip setuptools wheel -i $PIPSRC
|
python3 -m pip install --upgrade pip setuptools wheel -i $PIPSRC
|
||||||
|
|
||||||
|
which pip3 && pip3 install --upgrade pip -i $PIPSRC
|
||||||
|
pip3 install --upgrade pip setuptools wheel -i $PIPSRC
|
||||||
fi
|
fi
|
||||||
|
|
||||||
which pip && pip install --upgrade pip -i $PIPSRC
|
|
||||||
pip3 install --upgrade pip setuptools wheel -i $PIPSRC
|
|
||||||
|
|
||||||
cd /www/server/mdserver-web && pip3 install -r /www/server/mdserver-web/requirements.txt -i $PIPSRC
|
|
||||||
|
|
||||||
# pip3 install flask-caching==1.10.1
|
|
||||||
# pip3 install mysqlclient
|
|
||||||
|
|
||||||
if [ ! -f /www/server/mdserver-web/bin/activate ];then
|
if [ ! -f /www/server/mdserver-web/bin/activate ];then
|
||||||
cd /www/server/mdserver-web && python3 -m venv .
|
if version_ge "$P_VER" "3.11.0" ;then
|
||||||
|
cd /www/server/mdserver-web && python3 -m venv /www/server/mdserver-web
|
||||||
|
else
|
||||||
|
cd /www/server/mdserver-web && pip3 install -r /www/server/mdserver-web/requirements.txt -i $PIPSRC
|
||||||
|
cd /www/server/mdserver-web && python3 -m venv .
|
||||||
|
fi
|
||||||
cd /www/server/mdserver-web && source /www/server/mdserver-web/bin/activate
|
cd /www/server/mdserver-web && source /www/server/mdserver-web/bin/activate
|
||||||
else
|
else
|
||||||
cd /www/server/mdserver-web && source /www/server/mdserver-web/bin/activate
|
cd /www/server/mdserver-web && source /www/server/mdserver-web/bin/activate
|
||||||
fi
|
fi
|
||||||
|
|
||||||
pip install --upgrade pip -i $PIPSRC
|
pip3 install --upgrade pip -i $PIPSRC
|
||||||
pip3 install --upgrade setuptools -i $PIPSRC
|
pip3 install --upgrade setuptools -i $PIPSRC
|
||||||
cd /www/server/mdserver-web && pip3 install -r /www/server/mdserver-web/requirements.txt -i $PIPSRC
|
cd /www/server/mdserver-web && pip3 install -r /www/server/mdserver-web/requirements.txt -i $PIPSRC
|
||||||
|
|
||||||
echo "lib ok!"
|
|
||||||
# pip3 install flask-caching==1.10.1
|
|
||||||
# pip3 install mysqlclient
|
|
||||||
|
|
||||||
|
# Different versions use different python lib
|
||||||
|
P_VER_D=`echo "$P_VER"|awk -F '.' '{print $1}'`
|
||||||
|
P_VER_M=`echo "$P_VER"|awk -F '.' '{print $2}'`
|
||||||
|
NEW_P_VER=${P_VER_D}.${P_VER_M}
|
||||||
|
|
||||||
|
if [ -f /www/server/mdserver-web/version/r${NEW_P_VER}.txt ];then
|
||||||
|
echo "cd /www/server/mdserver-web && pip3 install -r /www/server/mdserver-web/version/r${NEW_P_VER}.txt"
|
||||||
|
cd /www/server/mdserver-web && pip3 install -r /www/server/mdserver-web/version/r${NEW_P_VER}.txt -i $PIPSRC
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "lib ok!"
|
||||||
+13
-5
@@ -54,15 +54,23 @@ else
|
|||||||
OSNAME='unknow'
|
OSNAME='unknow'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# cn=$(curl -fsSL -m 10 http://ipinfo.io/json | grep "\"country\": \"CN\"")
|
# HTTP_PREFIX="https://"
|
||||||
|
# LOCAL_ADDR=common
|
||||||
|
# ping -c 1 github.com > /dev/null 2>&1
|
||||||
|
# if [ "$?" != "0" ];then
|
||||||
|
# LOCAL_ADDR=cn
|
||||||
|
# HTTP_PREFIX="https://ghproxy.com/"
|
||||||
|
# fi
|
||||||
|
|
||||||
|
cn=$(curl -fsSL -m 10 -s http://ipinfo.io/json | grep "\"country\": \"CN\"")
|
||||||
HTTP_PREFIX="https://"
|
HTTP_PREFIX="https://"
|
||||||
LOCAL_ADDR=common
|
LOCAL_ADDR=common
|
||||||
ping -c 1 github.com > /dev/null 2>&1
|
if [ ! -z "$cn" ];then
|
||||||
if [ "$?" != "0" ];then
|
|
||||||
LOCAL_ADDR=cn
|
LOCAL_ADDR=cn
|
||||||
HTTP_PREFIX="https://ghproxy.com/"
|
HTTP_PREFIX="https://ghproxy.com/"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
CP_CMD=/usr/bin/cp
|
CP_CMD=/usr/bin/cp
|
||||||
if [ -f /bin/cp ];then
|
if [ -f /bin/cp ];then
|
||||||
CP_CMD=/bin/cp
|
CP_CMD=/bin/cp
|
||||||
@@ -78,7 +86,7 @@ if [ "$LOCAL_ADDR" != "common" ];then
|
|||||||
rm -rf /tmp/master.zip
|
rm -rf /tmp/master.zip
|
||||||
rm -rf /tmp/mdserver-web
|
rm -rf /tmp/mdserver-web
|
||||||
else
|
else
|
||||||
curl --insecure -sSLo /tmp/dev.zip https://github.com/midoks/mdserver-web/archive/refs/heads/dev.zip
|
curl --insecure -sSLo /tmp/dev.zip ${HTTP_PREFIX}github.com/midoks/mdserver-web/archive/refs/heads/dev.zip
|
||||||
cd /tmp && unzip /tmp/dev.zip
|
cd /tmp && unzip /tmp/dev.zip
|
||||||
$CP_CMD -rf /tmp/mdserver-web-dev/* /www/server/mdserver-web
|
$CP_CMD -rf /tmp/mdserver-web-dev/* /www/server/mdserver-web
|
||||||
rm -rf /tmp/dev.zip
|
rm -rf /tmp/dev.zip
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
cryptography==36.0.1
|
||||||
|
flask==2.0.3
|
||||||
|
pyOpenSSL==22.0.0
|
||||||
Reference in New Issue
Block a user