Merge branch 'dev' into mysql-ya

This commit is contained in:
midoks
2022-07-06 08:44:14 +08:00
357 changed files with 3526 additions and 2636 deletions
+1 -1
View File
@@ -16,7 +16,7 @@ jobs:
build:
strategy:
matrix:
os: [ubuntu-latest]
os: [ubuntu-20.04, ubuntu-18.04, ubuntu-22.04]
runs-on: ${{ matrix.os }}
#runs-on: ubuntu-latest
+1 -1
View File
@@ -16,7 +16,7 @@ jobs:
build:
strategy:
matrix:
os: [ubuntu-latest]
os: [ubuntu-20.04, ubuntu-18.04, ubuntu-22.04]
runs-on: ${{ matrix.os }}
#runs-on: ubuntu-latest
+1 -1
View File
@@ -16,7 +16,7 @@ jobs:
build:
strategy:
matrix:
os: [ubuntu-latest]
os: [ubuntu-20.04, ubuntu-18.04, ubuntu-22.04]
runs-on: ${{ matrix.os }}
#runs-on: ubuntu-latest
+1
View File
@@ -142,3 +142,4 @@ data/edate.pl
plugins/l2tp
plugins/openlitespeed
plugins/gdrive
debug.out
+2 -2
View File
@@ -20,7 +20,7 @@
基本上可以使用,后续会继续优化!欢迎提供意见!
- 吹水组 - https://t.me/mdserver_web
- [兼容性测试报告](/compatibility.md)
### 主要插件介绍
* OpenResty - 轻量级,占有内存少,并发能力强。
@@ -30,7 +30,6 @@
* phpMyAdmin - 著名Web端MySQL管理工具。
* Memcached - 一个高性能的分布式内存对象缓存系统。
* Redis - 一个高性能的KV数据库。
* CSVN - 最流行的SVN代码共享管理软件。
* PureFtpd - 一款专注于程序健壮和软件安全的免费FTP服务器软件。
* Gogs - 一款极易搭建的自助Git服务。
* Rsyncd - 通用同步服务。
@@ -106,6 +105,7 @@ curl -fsSL https://raw.githubusercontent.com/midoks/mdserver-web/dev/scripts/up
### 微信赞助
[![截图](/route/static/img/weixin_zz.jpg)](/route/static/img/weixin_zz.jpg)
### 无图不真相
[![截图](/route/static/mdw.jpg)](/route/static/mdw.jpg)
+5
View File
@@ -1,5 +1,10 @@
# coding:utf-8
# pip install profiler_online
# 性能测试
# from profiler_online import run_profiler
# run_profiler()
from gevent import monkey
monkey.patch_all()
+3 -4
View File
@@ -15,10 +15,9 @@ from flask import request
class config_api:
# 本版解决自启动问题
# 文件管理重命名
# 优化计划任务管理
__version = '0.8.6.1'
# 进行中.
# 兼容主流Linux系统
__version = '0.8.6.3'
def __init__(self):
pass
+1 -3
View File
@@ -210,7 +210,6 @@ class files_api:
try:
name = mw.M('tasks').where('id=?', (mid,)).getField('name')
status = mw.M('tasks').where('id=?', (mid,)).getField('status')
# print(name, status)
mw.M('tasks').delete(mid)
if status == '-1':
task_pid = mw.execShell(
@@ -220,8 +219,7 @@ class files_api:
for i in range(len(task_list)):
self.removeTaskRecursion(task_list[i])
isTask = mw.getRootDir() + '/tmp/panelTask.pl'
mw.writeFile(isTask, 'True')
mw.triggerTask()
system_api.system_api().restartTask()
except:
system_api.system_api().restartTask()
+19 -10
View File
@@ -597,20 +597,29 @@ def getLocalIpBack():
def getLocalIp():
# 取本地外网IP
filename = 'data/iplist.txt'
try:
import re
filename = 'data/iplist.txt'
ipaddress = readFile(filename)
if not ipaddress or ipaddress == '127.0.0.1':
import urllib
url = 'https://v6r.ipip.net/?format=text'
req = urllib.request.urlopen(url, timeout=10)
ipaddress = req.read().decode('utf-8')
writeFile(filename, ipaddress)
raise
return ipaddress
except Exception as ex:
return '127.0.0.1'
except Exception as e:
cmd = "curl -4 -sS --connect-timeout 5 -m 60 https://v6r.ipip.net/?format=text"
ip = execShell(cmd)
result = ip[0].strip()
if result == '':
raise
writeFile(filename, result)
return result
except Exception as e:
cmd = "curl -6 -sS --connect-timeout 5 -m 60 https://v6r.ipip.net/?format=text"
ip = execShell(cmd)
result = ip[0].strip()
if result == '':
return '127.0.0.1'
writeFile(filename, result)
return result
return '127.0.0.1'
def inArray(arrays, searchStr):
-2
View File
@@ -2,7 +2,6 @@
import math
import string
import mw
class Page():
@@ -29,7 +28,6 @@ class Page():
__END_NUM = None # 结束行
def __init__(self):
# tmp = mw.getMsg('PAGE')
if False:
self.__PREV = tmp['PREV']
self.__NEXT = tmp['NEXT']
+10 -3
View File
@@ -43,6 +43,9 @@ class plugins_api:
def __init__(self):
self.setupPath = 'server'
self.__plugin_dir = mw.getRunDir() + '/plugins'
self.__type = mw.getRunDir() + '/data/json/type.json'
self.__index = mw.getRunDir() + '/data/json/index.json'
##### ----- start ----- ###
def listApi(self):
@@ -482,6 +485,7 @@ class plugins_api:
"setup": False,
"setup_version": "",
"status": False,
"install_pre_inspection": False,
}
if checks.find('VERSION') > -1:
@@ -504,6 +508,9 @@ class plugins_api:
else:
pInfo['setup_version'] = self.getVersion(pInfo['install_checks'])
# pluginInfo['status'] = self.checkStatus(pluginInfo)
if 'install_pre_inspection' in info:
pInfo['install_pre_inspection'] = info['install_pre_inspection']
pInfo['status'] = False
return pInfo
@@ -794,8 +801,8 @@ class plugins_api:
return mw.returnJson(True, '删除成功!')
# shell 调用
def run(self, name, func, version, args='', script='index'):
path = mw.getRunDir() + '/' + self.__plugin_dir + \
def run(self, name, func, version='', args='', script='index'):
path = self.__plugin_dir + \
'/' + name + '/' + script + '.py'
py = 'python3 ' + path
@@ -817,7 +824,7 @@ class plugins_api:
# 映射包调用
def callback(self, name, func, args='', script='index'):
package = mw.getRunDir() + '/plugins/' + name
package = self.__plugin_dir + '/' + name
if not os.path.exists(package):
return (False, "插件不存在!")
+335 -27
View File
@@ -3,6 +3,7 @@
import time
import os
import sys
from urllib.parse import urlparse
import mw
import re
import json
@@ -44,6 +45,11 @@ class site_api:
mw.execShell("mkdir -p " + self.redirectPath +
" && chmod -R 755 " + self.redirectPath)
self.proxyPath = self.setupPath + '/nginx/proxy'
if not os.path.exists(self.proxyPath):
mw.execShell("mkdir -p " + self.proxyPath +
" && chmod -R 755 " + self.proxyPath)
self.logsPath = mw.getRootDir() + '/wwwlogs'
# ssl conf
if mw.isAppleSystem():
@@ -129,7 +135,7 @@ class site_api:
mid = request.form.get('id', '')
name = request.form.get('name', '')
return self.stop(self, mid, name)
return self.stop(mid, name)
def stop(self, mid, name):
path = self.setupPath + '/stop'
@@ -287,7 +293,7 @@ class site_api:
domains.append(tmp)
data['domains'] = domains
data['email'] = mw.M('users').getField('email')
if data['email'] == '287962566@qq.com':
if data['email'] == 'midoks@163.com':
data['email'] = ''
return mw.returnJson(True, 'OK', data)
@@ -574,9 +580,12 @@ class site_api:
file = self.getHostConf(siteName)
if os.path.exists(file):
siteConf = mw.readFile(file)
if siteConf.find('301-START') != -1:
if siteConf.find('301-END') != -1:
return mw.returnJson(False, '检测到您的站点做了301重定向设置,请先关闭重定向!')
if siteConf.find('PROXY-END') != -1:
return mw.returnJson(False, '检测到您的站点做了反向代理设置,请先关闭反向代理!')
letpath = self.sslDir + siteName
csrpath = letpath + "/fullchain.pem" # 生成证书路径
keypath = letpath + "/privkey.pem" # 密钥文件路径
@@ -780,6 +789,10 @@ class site_api:
siteName = request.form.get('siteName', '')
return self.getLogs(siteName)
def getErrorLogsApi(self):
siteName = request.form.get('siteName', '')
return self.getErrorLogs(siteName)
def getSitePhpVersionApi(self):
siteName = request.form.get('siteName', '')
return self.getSitePhpVersion(siteName)
@@ -823,6 +836,30 @@ class site_api:
port = request.form.get('port', '')
return self.add(webname, port, ps, path, version)
def checkWebStatusApi(self):
'''
创建站点检查web服务
'''
if not mw.isInstalledWeb():
return mw.returnJson(False, '请安装并启动OpenResty服务!')
# 这个快点
pid = mw.getServerDir() + '/openresty/nginx/logs/nginx.pid'
if not os.path.exists(pid):
return mw.returnJson(False, '请启动OpenResty服务!')
# path = mw.getServerDir() + '/openresty/init.d/openresty'
# data = mw.execShell(path + " status")
# if data[0].strip().find('stopped') != -1:
# return mw.returnJson(False, '请启动OpenResty服务!')
# import plugins_api
# data = plugins_api.plugins_api().run('openresty', 'status')
# if data[0].strip() == 'stop':
# return mw.returnJson(False, '请启动OpenResty服务!')
return mw.returnJson(True, 'OK')
def addDomainApi(self):
isError = mw.checkWebConfig()
if isError != True:
@@ -1075,7 +1112,7 @@ class site_api:
# self.closeHasPwd(get)
filename = self.passPath + '/' + siteName + '.pass'
print(filename)
# print(filename)
passconf = username + ':' + mw.hasPwd(password)
if siteName == 'phpmyadmin':
@@ -1176,6 +1213,31 @@ class site_api:
path = request.form.get('path', '0')
return self.delete(sid, webname, path)
# 操作 重定向配置
def operateRedirectConf(self, siteName, method='start'):
vhost_file = self.vhostPath + '/' + siteName + '.conf'
content = mw.readFile(vhost_file)
cnf_301 = '''
# 301-START
include %s/*.conf;
# 301-END
''' % (self.getRedirectPath( siteName))
cnf_301_source = '''
# 301-START
'''
# print('operateRedirectConf', content.find('#301-END'))
if content.find('#301-END') != -1:
if method == 'stop':
rep = '#301-START(\n|.){1,500}#301-END'
content = re.sub(rep, '#301-START', content)
else:
if method == 'start':
content = re.sub(cnf_301_source, cnf_301, content)
mw.writeFile(vhost_file, content)
# get_redirect_status
def getRedirectApi(self):
_siteName = request.form.get("siteName", '')
@@ -1230,8 +1292,9 @@ class site_api:
if rule_test != True:
mw.writeFile("{}/{}/{}.conf".format(self.redirectPath,
_siteName, _id), _old_config)
return mw.returnJson(False, "Nginx 配置测试不通过, 请重试: {}".format(rule_test))
return mw.returnJson(False, "OpenResty 配置测试不通过, 请重试: {}".format(rule_test))
self.operateRedirectConf(_siteName, 'start')
mw.restartWeb()
return mw.returnJson(True, "ok")
@@ -1309,6 +1372,8 @@ class site_api:
mw.writeFile(data_path, json.dumps(data))
mw.writeFile(
"{}/{}.conf".format(self.getRedirectPath(_siteName), _id), file_content)
self.operateRedirectConf(_siteName, 'start')
mw.restartWeb()
return mw.returnJson(True, "ok")
@@ -1330,6 +1395,9 @@ class site_api:
break
# write database
mw.writeFile(data_path, json.dumps(data))
# data is empty ,should stop
if len(data) == 0:
self.operateRedirectConf(_siteName, 'stop')
# remove conf file
mw.execShell(
"rm -rf {}/{}.conf".format(self.getRedirectPath(_siteName), _id))
@@ -1337,21 +1405,234 @@ class site_api:
return mw.returnJson(False, "删除失败!")
return mw.returnJson(True, "删除成功!")
def getProxyListApi(self):
siteName = request.form.get('siteName', '')
conf_path = self.getHostConf(siteName)
old_conf = mw.readFile(conf_path)
rep = "(#PROXY-START(\n|.)+#PROXY-END)"
url_rep = "proxy_pass (.*);|ProxyPass\s/\s(.*)|Host\s(.*);"
host_rep = "Host\s(.*);"
# 操作 反向代理配置
def operateProxyConf(self, siteName, method='start'):
vhost_file = self.vhostPath + '/' + siteName + '.conf'
content = mw.readFile(vhost_file)
proxyUrl = self.__read_config(self.__proxyfile)
sitename = sitename
proxylist = []
for i in proxyUrl:
if i["sitename"] == sitename:
proxylist.append(i)
return mw.getJson(proxylist)
proxy_cnf = '''
# PROXY-START
include %s/*.conf;
# PROXY-END
''' % (self.getProxyPath(siteName))
proxy_cnf_source = '''
# PROXY-START
'''
if content.find('#PROXY-END') != -1:
if method == 'stop':
rep = '#PROXY-START(\n|.){1,500}#PROXY-END'
content = re.sub(rep, '#PROXY-START', content)
else:
if method == 'start':
content = re.sub(proxy_cnf_source, proxy_cnf, content)
mw.writeFile(vhost_file, content)
def getProxyConfApi(self):
_siteName = request.form.get("siteName", '')
_id = request.form.get("id", '')
if _id == '' or _siteName == '':
return mw.returnJson(False, "必填项不能为空!")
conf_file = "{}/{}/{}.conf".format(self.proxyPath, _siteName, _id)
if not os.path.exists(conf_file):
conf_file = "{}/{}/{}.conf.txt".format(
self.proxyPath, _siteName, _id)
data = mw.readFile(conf_file)
if data == False:
return mw.returnJson(False, "获取失败!")
return mw.returnJson(True, "ok", {"result": data})
def setProxyStatusApi(self):
_siteName = request.form.get("siteName", '')
_status = request.form.get("status", '')
_id = request.form.get("id", '')
if _status == '' or _siteName == '' or _id == '':
return mw.returnJson(False, "必填项不能为空!")
conf_file = "{}/{}/{}.conf".format(self.proxyPath, _siteName, _id)
conf_txt = "{}/{}/{}.conf.txt".format(self.proxyPath, _siteName, _id)
if _status == '1':
mw.execShell('mv ' + conf_txt + ' ' + conf_file)
else:
mw.execShell('mv ' + conf_file + ' ' + conf_txt)
mw.restartWeb()
return mw.returnJson(True, "OK")
def saveProxyConfApi(self):
_siteName = request.form.get("siteName", '')
_id = request.form.get("id", '')
_config = request.form.get("config", "")
if _id == '' or _siteName == '':
return mw.returnJson(False, "必填项不能为空!")
_old_config = mw.readFile(
"{}/{}/{}.conf".format(self.proxyPath, _siteName, _id))
if _old_config == False:
return mw.returnJson(False, "非法操作")
mw.writeFile("{}/{}/{}.conf".format(self.proxyPath,
_siteName, _id), _config)
rule_test = mw.checkWebConfig()
if rule_test != True:
mw.writeFile("{}/{}/{}.conf".format(self.proxyPath,
_siteName, _id), _old_config)
return mw.returnJson(False, "OpenResty 配置测试不通过, 请重试: {}".format(rule_test))
self.operateRedirectConf(_siteName, 'start')
mw.restartWeb()
return mw.returnJson(True, "ok")
# 读取 网站 反向代理列表
def getProxyListApi(self):
_siteName = request.form.get('siteName', '')
data_path = self.getProxytDataPath(_siteName)
data_content = mw.readFile(data_path)
# not exists
if data_content == False:
mw.execShell("mkdir {}/{}".format(self.proxyPath, _siteName))
return mw.returnJson(True, "", {"result": [], "count": 0})
try:
data = json.loads(data_content)
except:
mw.execShell("rm -rf {}/{}".format(self.proxyPath, _siteName))
return mw.returnJson(True, "", {"result": [], "count": 0})
tmp = []
for proxy in data:
proxy_dir = "{}/{}".format(self.proxyPath, _siteName)
proxy_dir_file = proxy_dir + '/' + proxy['id'] + '.conf'
if os.path.exists(proxy_dir_file):
proxy['status'] = True
else:
proxy['status'] = False
tmp.append(proxy)
return mw.returnJson(True, "ok", {"result": data, "count": len(data)})
# 设置 网站 反向代理列表
def setProxyApi(self):
_siteName = request.form.get('siteName', '')
_from = request.form.get('from', '')
_to = request.form.get('to', '')
_host = request.form.get('host', '')
_open_proxy = request.form.get('open_proxy', '')
if _siteName == "" or _from == "" or _to == "" or _host == "":
return mw.returnJson(False, "必填项不能为空")
data_path = self.getProxytDataPath(_siteName)
data_content = mw.readFile(
data_path) if os.path.exists(data_path) else ""
data = json.loads(data_content) if data_content != "" else []
rep = "http(s)?\:\/\/([a-zA-Z0-9][-a-zA-Z0-9]{0,62}\.)+([a-zA-Z0-9][a-zA-Z0-9]{0,62})+.?"
if not re.match(rep, _to):
return mw.returnJson(False, "错误的目标地址!")
# get host from url
try:
if _host == "$host":
host_tmp = urlparse(_to)
_host = host_tmp.netloc
except:
return mw.returnJson(False, "错误的目标地址")
tpl = """
# PROXY-START/
location ~* \.(gif|png|jpg|css|js|woff|woff2)$
{
proxy_pass {to};
proxy_set_header Host {host};
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header REMOTE-HOST $remote_addr;
expires 12h;
}
location ~* ^{from}(.*)$ {
proxy_pass {to};
proxy_set_header Host {host};
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header REMOTE-HOST $remote_addr;
add_header X-Cache $upstream_cache_status;
proxy_ignore_headers Set-Cookie Cache-Control expires;
add_header Cache-Control no-cache;
}
# PROXY-END/
"""
# replace
if _from[0] != '/':
_from = '/' + _from
tpl = tpl.replace("{from}", _from, 999)
tpl = tpl.replace("{to}", _to)
tpl = tpl.replace("{host}", _host, 999)
_id = mw.md5("{}+{}+{}".format(_from, _to, _siteName))
for item in data:
if item["id"] == _id:
return mw.returnJson(False, "已存在该规则!")
if item["from"] == _from:
return mw.returnJson(False, "代理目录已存在!")
data.append({
"from": _from,
"to": _to,
"host": _host,
"id": _id
})
conf_file = "{}/{}.conf".format(self.getProxyPath(_siteName), _id)
if _open_proxy != 'on':
conf_file = "{}/{}.conf.txt".format(
self.getProxyPath(_siteName), _id)
mw.writeFile(data_path, json.dumps(data))
mw.writeFile(conf_file, tpl)
self.operateProxyConf(_siteName, 'start')
mw.restartWeb()
return mw.returnJson(True, "ok", {"hash": _id})
def delProxyApi(self):
_siteName = request.form.get("siteName", '')
_id = request.form.get("id", '')
if _id == '' or _siteName == '':
return mw.returnJson(False, "必填项不能为空!")
try:
data_path = self.getProxytDataPath(_siteName)
data_content = mw.readFile(
data_path) if os.path.exists(data_path) else ""
data = json.loads(data_content) if data_content != "" else []
for item in data:
if item["id"] == _id:
data.remove(item)
break
# write database
mw.writeFile(data_path, json.dumps(data))
# data is empty,should stop
if len(data) == 0:
self.operateProxyConf(_siteName, 'stop')
# remove conf file
cmd = "rm -rf {}/{}.conf*".format(
self.getProxyPath(_siteName), _id)
mw.execShell(cmd)
except:
return mw.returnJson(False, "删除失败!")
mw.restartWeb()
return mw.returnJson(True, "删除成功!")
def getSiteTypesApi(self):
# 取网站分类
@@ -1508,7 +1789,13 @@ class site_api:
return "{}/{}/data.json".format(self.redirectPath, siteName)
def getRedirectPath(self, siteName):
return "{}/{}/".format(self.redirectPath, siteName)
return "{}/{}".format(self.redirectPath, siteName)
def getProxytDataPath(self, siteName):
return "{}/{}/data.json".format(self.proxyPath, siteName)
def getProxyPath(self, siteName):
return "{}/{}".format(self.proxyPath, siteName)
def getDirBindRewrite(self, siteName, dirname):
return self.rewritePath + '/' + siteName + '_' + dirname + '.conf'
@@ -1527,6 +1814,12 @@ class site_api:
return mw.returnJson(False, '日志为空')
return mw.returnJson(True, mw.getNumLines(logPath, 100))
def getErrorLogs(self, siteName):
logPath = mw.getLogsDir() + '/' + siteName + '.error.log'
if not os.path.exists(logPath):
return mw.returnJson(False, '日志为空')
return mw.returnJson(True, mw.getNumLines(logPath, 100))
# 取日志状态
def getLogsStatus(self, siteName):
filename = self.getHostConf(siteName)
@@ -1716,7 +2009,7 @@ class site_api:
return 404;
}
}
#SECURITY-END
# SECURITY-END
include %s/enable-php-''' % (fix.strip().replace(',', '|'), domains.strip().replace(',', ' '), pre_path)
conf = re.sub(re_path, rconf, conf)
mw.writeLog('网站管理', '站点[' + name + ']已开启防盗链!')
@@ -1766,10 +2059,10 @@ class site_api:
def createRootDir(self, path):
if not os.path.exists(path):
os.makedirs(path)
if not mw.isAppleSystem():
mw.execShell('chown -R www:www ' + path)
mw.writeFile(path + '/index.html', 'Work has started!!!')
mw.execShell('chmod -R 755 ' + path)
if not mw.isAppleSystem():
mw.execShell('chown -R www:www ' + path)
mw.writeFile(path + '/index.html', 'Work has started!!!')
mw.execShell('chmod -R 755 ' + path)
def nginxAddDomain(self, webname, domain, port):
file = self.getHostConf(webname)
@@ -1807,7 +2100,8 @@ class site_api:
content = content.replace('{$PHP_DIR}', self.setupPath + '/php')
content = content.replace('{$PHPVER}', self.phpVersion)
content = content.replace('{$OR_REWRITE}', self.rewritePath)
content = content.replace('{$OR_REDIRECT}', self.redirectPath)
# content = content.replace('{$OR_REDIRECT}', self.redirectPath)
# content = content.replace('{$OR_PROXY}', self.proxyPath)
logsPath = mw.getLogsDir()
content = content.replace('{$LOGPATH}', logsPath)
@@ -1815,6 +2109,10 @@ class site_api:
rewrite_content = '''
location /{
if ($PHP_ENV != "1"){
break;
}
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php/$1 last;
break;
@@ -1869,18 +2167,28 @@ location /{
errLogPath = mw.getLogsDir() + '/' + webname + '.error.log'
confFile = self.setupPath + '/nginx/vhost/' + webname + '.conf'
rewriteFile = self.setupPath + '/nginx/rewrite/' + webname + '.conf'
rewriteFile = self.setupPath + '/nginx/pass/' + webname + '.conf'
passFile = self.setupPath + '/nginx/pass/' + webname + '.conf'
keyPath = self.sslDir + webname + '/privkey.pem'
certPath = self.sslDir + webname + '/fullchain.pem'
logs = [assLogPath,
errLogPath,
confFile,
rewriteFile,
passFile,
keyPath,
certPath]
for i in logs:
mw.deleteFile(i)
# 重定向目录
redirectDir = self.setupPath + '/nginx/redirect/' + webname
if os.path.exists(redirectDir):
mw.execShell('rm -rf ' + redirectDir)
# 代理目录
proxyDir = self.setupPath + '/nginx/proxy/' + webname
if os.path.exists(proxyDir):
mw.execShell('rm -rf ' + proxyDir)
def delete(self, sid, webname, path):
self.deleteWSLogs(webname)
if path == '1':
+22 -20
View File
@@ -243,13 +243,19 @@ class system_api:
mac_version += x.split("\t")[1] + ' '
return mac_version
version = mw.readFile('/etc/redhat-release')
if not version:
version = mw.readFile(
'/etc/issue').strip().split("\n")[0].replace('\\n', '').replace('\l', '').strip()
else:
redhat_series = '/etc/redhat-release'
if os.path.exists(redhat_series):
version = mw.readFile('/etc/redhat-release')
version = version.replace('release ', '').strip()
return version
return version
os_series = '/etc/os-release'
if os.path.exists(os_series):
version = mw.execShell(
"cat /etc/*-release | grep PRETTY_NAME | awk -F = '{print $2}' | awk -F '\"' '{print $2}'")
return version[0].strip()
return '未识别系统信息'
def getBootTime(self):
# 取系统启动时间
@@ -312,8 +318,11 @@ class system_api:
except Exception as ex:
return 1
def getDiskInfo(self, get=None):
return self.getDiskInfo2()
def getDiskInfo(self):
info = self.getDiskInfo2()
if len(info) != 0:
return info
# 取磁盘分区信息
diskIo = psutil.disk_partitions()
diskInfo = []
@@ -325,7 +334,9 @@ class system_api:
continue
tmp = {}
tmp['path'] = disk[1]
tmp['size'] = psutil.disk_usage(disk[1])
size_tmp = psutil.disk_usage(disk[1])
tmp['size'] = [mw.toSize(size_tmp[0]), mw.toSize(
size_tmp[1]), mw.toSize(size_tmp[2]), str(size_tmp[3]) + '%']
diskInfo.append(tmp)
return diskInfo
@@ -340,7 +351,7 @@ class system_api:
diskInfo = []
n = 0
cuts = ['/mnt/cdrom', '/boot', '/boot/efi', '/dev',
'/dev/shm', '/run/lock', '/run', '/run/shm', '/run/user']
'/dev/shm', '/zroot', '/run/lock', '/run', '/run/shm', '/run/user']
for tmp in temp1:
n += 1
inodes = tempInodes1[n - 1].split()
@@ -360,16 +371,7 @@ class system_api:
tmp1 = [disk[1], disk[2], disk[3], disk[4]]
arr['size'] = tmp1
arr['inodes'] = [inodes[1], inodes[2], inodes[3], inodes[4]]
if disk[5] == '/':
bootLog = os.getcwd() + '/tmp/panelBoot.pl'
if disk[2].find('M') != -1:
if os.path.exists(bootLog):
os.system('rm -f ' + bootLog)
else:
if not os.path.exists(bootLog):
pass
if inodes[2] != '0':
diskInfo.append(arr)
diskInfo.append(arr)
return diskInfo
# 清理系统垃圾
+32 -3
View File
@@ -11,14 +11,37 @@ fi
# export LC_ALL="en_US.UTF-8"
mw_start_task()
{
isStart=$(ps aux |grep 'task.py'|grep -v grep|awk '{print $2}')
if [ "$isStart" == '' ];then
echo -e "Starting mw-tasks... \c"
cd $DIR && python3 task.py >> ${DIR}/logs/task.log 2>&1 &
sleep 0.3
isStart=$(ps aux |grep 'task.py'|grep -v grep|awk '{print $2}')
if [ "$isStart" == '' ];then
echo -e "\033[31mfailed\033[0m"
echo '------------------------------------------------------'
tail -n 20 $DIR/logs/task.log
echo '------------------------------------------------------'
echo -e "\033[31mError: mw-tasks service startup failed.\033[0m"
return;
fi
echo -e "\033[32mdone\033[0m"
else
echo "Starting mw-tasks... mw-tasks (pid $(echo $isStart)) already running"
fi
}
mw_start(){
gunicorn -c setting.py app:app
python3 task.py >> $DIR/logs/task.log 2>&1 &
#安全启动
mw_start_task
}
mw_start_debug(){
python3 task.py >> $DIR/logs/task.log 2>&1 &
gunicorn -b :7200 -k gevent -w 1 app:app
}
@@ -36,7 +59,13 @@ mw_stop()
do
kill -9 $i
done
ps -ef|grep task.py |grep -v grep|awk '{print $2}'|xargs kill -9
pids=`ps -ef|grep task.py | grep -v grep |awk '{print $2}'`
arr=($pids)
for p in ${arr[@]}
do
kill -9 $p
done
}
case "$1" in
+65
View File
@@ -0,0 +1,65 @@
### 兼容性测试报告
- 暂时不具有指导意见
快速测试命令
```
cd /www/server/mdserver-web/scripts/quick && bash debug.sh
cd /www/server/mdserver-web/plugins/php && bash all_test.sh
```
| 系统名称 | 面板 | OpenResty |
| ----------------- |---------------|---------------|
| CentOS 7.9 |✅ |✅ |
| CentOS 8.4 |✅ |✅ |
| CentOS 8 Stream |✅ |✅ |
| CentOS 9 Stream |✅ |✅ |
| Debian 10.3 |✅ |✅ |
| Debian 11.3 |✅ |✅ |
| Ubuntu 10.04 |✅ |✅ |
| Ubuntu 11.3 |✅ |✅ |
| Fedora 31 |✅ |✅ |
| Fedora 32 |✅ |✅ |
| AlmaLinix 9 |✅ |✅ |
| RockyLinux 8.6 |✅ |✅ |
| openSUSE 15.4 |:x: |:x: |
| 系统名称 | PHP52 |PHP53 |PHP54 |PHP55 |PHP56 |PHP70 |PHP71 |PHP72 |PHP73 |PHP74 |PHP80 |PHP81 |
| ----------------- |-------|-------|-------|-------|-------|-------|-------|-------|-------|-------|-------|-------|
| CentOS 7.9 |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |
| CentOS 8.4 |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |
| CentOS 8 Stream |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |
| CentOS 9 Stream |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |
| Debian 10.3 |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |
| Debian 11.3 |:x: |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |
| Ubuntu 10.04 |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |
| Ubuntu 11.3 |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |
| Fedora 31 |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |
| Fedora 32 |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |
| AlmaLinix 9 |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |
| RockyLinux 8.6 |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |✅ |
| openSUSE 15.4 |:x: |:x: |:x: |:x: |:x: |:x: |:x: |:x: |:x: |:x: |:x: |:x: |
| 系统名称 | MySQL55 |MySQL56 |MySQL57 |MySQL80 |
| ----------------- |-----------|-----------|-----------|-----------|
| CentOS 7.9 |✅ |✅ |✅ |:x: |
| CentOS 8.4 |:x: |✅ |✅ |✅ |
| CentOS 8 Stream |✅ |✅ |✅ |✅ |
| CentOS 9 Stream |✅ |✅ |✅ |✅ |
| Debian 10.3 |✅ |✅ |✅ |✅ |
| Debian 11.3 |✅ |✅ |✅ |✅ |
| Ubuntu 10.04 |✅ |✅ |✅ |✅ |
| Ubuntu 11.3 |✅ |✅ |✅ |✅ |
| Fedora 31 |✅ |✅ |✅ |✅ |
| Fedora 32 |✅ |✅ |✅ |✅ |
| AlmaLinix 9 |✅ |✅ |✅ |✅ |
| RockyLinux 8.6 |✅ |✅ |✅ |✅ |
| openSUSE 15.4 |:x: |:x: |:x: |:x: |
+5 -4
View File
@@ -8,6 +8,10 @@ server
#SSL-START
#error_page 404/404.html;
#SSL-END
#301-START
#PROXY-START
#ERROR-PAGE-START
error_page 404 /404.html;
@@ -21,10 +25,7 @@ server
#REWRITE-START
include {$OR_REWRITE}/{$SERVER_NAME}.conf;
#REWRITE-END
#301-START
include {$OR_REDIRECT}/{$SERVER_NAME}/*.conf;
##301-END
#禁止访问的文件或目录
location ~ ^/(\.user.ini|\.htaccess|\.git|\.svn|\.project|LICENSE|README.md)
-34
View File
@@ -1,34 +0,0 @@
#!/bin/bash
export LC_ALL=en_US.UTF-8
export LC_CTYPE=zh_CN.UTF-8
REPOS="$1"
REV="$2"
TXN_NAME="$3"
if [ ! -d {$PROJECT_DIR}/csvn ]; then
sudo mkdir -p {$PROJECT_DIR}/csvn
sudo chown -R csvn:csvn {$PROJECT_DIR}/csvn
fi
SAVE_PATH={$PROJECT_DIR}/csvn/$REPOS
SVN_PATH=http://127.0.0.1:{$PORT}/svn/$REPOS
if [ ! -d $SAVE_PATH ]; then
svn co $SVN_PATH $SAVE_PATH \
--username={$CSVN_USER} \
--password={$CSVN_PWD} \
--no-auth-cache \
--non-interactive
fi
cd $SAVE_PATH && svn update --username={$CSVN_USER} --password={$CSVN_PWD} --no-auth-cache --non-interactive
WEB_PATH={$PROJECT_DIR}/wwwroot/$REPOS
sudo mkdir -p $WEB_PATH
sudo rsync -vauP --delete --exclude=".*" $SAVE_PATH/ $WEB_PATH
sudo chown -R www:www $WEB_PATH
-11
View File
@@ -1,11 +0,0 @@
#!/bin/bash
REPOS="$1"
REV="$2"
TXN_NAME="$3"
REPOS_NAME=${REPOS##*/}
sh -x $REPOS/hooks/commit $REPOS_NAME $REV $TXN_NAME 2>$REPOS/sh.log
Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

-41
View File
@@ -1,41 +0,0 @@
<style type="text/css">
.outline_no {
outline:none;
}
</style>
<div class="bt-form">
<div class="bt-w-main">
<div class="bt-w-menu">
<p class="bgw" onclick="pluginService('csvn');">服务</p>
<p onclick="pluginInitD('csvn');">自启动</p>
<p onclick="csvnEdit();">手动编辑</p>
<p onclick="csvnUserList(1);">用户管理</p>
<p onclick="csvnProjectList(1);">项目管理</p>
<p onclick="csvnReadme();">使用说明</p>
</div>
<div class="bt-w-con pd15">
<div class="soft-man-con"></div>
</div>
</div>
</div>
<script type="text/javascript">
resetPluginWinWidth(700);
$.getScript( "/plugins/file?name=csvn&f=js/csvn.js");
function csvnReadme(){
var readme = '<ul class="help-info-text c7">';
readme += '<li>注意:在启动时会比较慢,需要耐心等待一会</li>';
readme += '<li>注意:csvn需要java环境,在安装会自动检查并安装</li>';
readme += '<li>注意:默认后台密码admin:admin,最好马上修改</li>';
readme += '<li>注意:牢记admin的密码,在后csvn的管理后台和这里不同步</li>';
readme += '<li>注意:在这里添加用户和csvn后台并不同步</li>';
readme += '<li>注意:项目管理的地址一般是正确的,但在特殊环境下,地址可能不一致</li>';
readme += '<li>注意:脚本内使用sudo名,需要注释(vi /etc/sudoers)[#Default requiretty]</li>';
readme += '</ul>';
$('.bt-w-main .soft-man-con').html(readme);
}
</script>
-711
View File
@@ -1,711 +0,0 @@
# coding: utf-8
import time
import random
import os
import urllib
import binascii
import json
import re
import sys
import subprocess
sys.path.append(os.getcwd() + "/class/core")
import mw
app_debug = False
if mw.isAppleSystem():
app_debug = True
def getPluginName():
return 'csvn'
def getPluginDir():
return mw.getPluginDir() + '/' + getPluginName()
def getServerDir():
return mw.getServerDir() + '/' + getPluginName()
def getInitDFile():
if app_debug:
return '/tmp/' + getPluginName()
return '/etc/init.d/' + getPluginName()
def getArgs():
args = sys.argv[2:]
tmp = {}
args_len = len(args)
if args_len == 1:
t = args[0].strip('{').strip('}')
t = t.split(':')
tmp[t[0]] = t[1]
elif args_len > 1:
for i in range(len(args)):
t = args[i].split(':')
tmp[t[0]] = t[1]
return tmp
def initDreplace():
initd_file = getInitDFile()
if not os.path.exists(initd_file):
return getServerDir()
return initd_file
def status():
data = mw.execShell(
"ps -ef|grep " + getPluginName() + " |grep -v grep | grep -v python | awk '{print $2}'")
if data[0] == '':
return 'stop'
return 'start'
def csvnOp(method):
if app_debug:
os_name = mw.getOs()
if os_name == 'darwin':
return "Apple Computer does not support"
_initd_csvn = '/etc/init.d/csvn'
_initd_csvn_httpd = '/etc/init.d/csvn-httpd'
#_csvn = getServerDir() + '/bin/csvn'
#_csvn_httpd = getServerDir() + '/bin/csvn-httpd'
ret_csvn_httpd = mw.execShell(_initd_csvn_httpd + ' ' + method)
# ret_csvn = mw.execShell(_initd_csvn + ' ' + method)
subprocess.Popen(_initd_csvn + ' ' + method,
stdout=subprocess.PIPE, shell=True)
if ret_csvn_httpd[1] == '':
return 'ok'
return 'fail'
def start():
if not os.path.exists("/etc/init.d/csvn"):
return "先在自启动安装!"
return csvnOp('start')
def stop():
return csvnOp('stop')
def restart():
return csvnOp('restart')
def reload():
return csvnOp('reload')
def initdStatus():
if not app_debug:
if mw.isAppleSystem():
return "Apple Computer does not support"
_initd_csvn = '/etc/init.d/csvn'
_initd_csvn_httpd = '/etc/init.d/csvn-httpd'
if os.path.exists(_initd_csvn) and os.path.exists(_initd_csvn_httpd):
return 'ok'
return 'fail'
def initdInstall():
import shutil
if not app_debug:
if mw.isAppleSystem():
return "Apple Computer does not support"
_csvn = getServerDir() + '/bin/csvn'
_csvn_httpd = getServerDir() + '/bin/csvn-httpd'
ret_csvn = mw.execShell(_csvn + ' install')
ret_csvn_httpd = mw.execShell(_csvn_httpd + ' install')
if ret_csvn[1] == '' and ret_csvn_httpd[1] == '':
return 'ok'
return 'fail'
def initdUinstall():
if not app_debug:
if mw.isAppleSystem():
return "Apple Computer does not support"
_csvn = getServerDir() + '/bin/csvn'
_csvn_httpd = getServerDir() + '/bin/csvn-httpd'
ret_csvn = mw.execShell(_csvn + ' remove')
ret_csvn_httpd = mw.execShell(_csvn_httpd + ' remove')
return 'ok'
def csvnEdit():
data = {}
data['svn_access_file'] = getServerDir() + '/data/conf/svn_access_file'
data['commit_tpl'] = getPluginDir() + '/hook/commit.tpl'
data['post_commit_tpl'] = getPluginDir() + '/hook/post-commit.tpl'
return mw.getJson(data)
def userAdd():
args = getArgs()
if not 'username' in args:
return 'name missing'
if not 'password' in args:
return 'password missing'
htpasswd = getServerDir() + "/bin/htpasswd"
svn_auth_file = getServerDir() + "/data/conf/svn_auth_file"
cmd = htpasswd + ' -b ' + svn_auth_file + ' ' + \
args['username'] + ' ' + args['password']
data = mw.execShell(cmd)
# print data
if data[0] == '':
return 'ok'
return 'fail'
def userDel():
args = getArgs()
if not 'username' in args:
return 'name missing'
htpasswd = getServerDir() + "/bin/htpasswd"
svn_auth_file = getServerDir() + "/data/conf/svn_auth_file"
cmd = htpasswd + ' -D ' + svn_auth_file + ' ' + args['username']
data = mw.execShell(cmd)
if data[0] == '':
return 'ok'
return 'fail'
def getAllUser(search=''):
svn_auth_file = getServerDir() + '/data/conf/svn_auth_file'
if not os.path.exists(svn_auth_file):
return mw.getJson([])
auth = mw.readFile(svn_auth_file)
auth = auth.strip()
auth_list = auth.split("\n")
ulist = []
for x in range(len(auth_list)):
tmp = auth_list[x].split(':')
if search != '':
if tmp[0].find(search) != -1:
ulist.append(tmp[0])
else:
ulist.append(tmp[0])
return ulist
def userList():
import math
args = getArgs()
page = 1
page_size = 10
search = ''
if 'page' in args:
page = int(args['page'])
if 'page_size' in args:
page_size = int(args['page_size'])
if 'search' in args:
search = args['search']
ulist = getAllUser(search)
ulist_sum = len(ulist)
page_info = {'count': ulist_sum, 'p': page,
'row': 10, 'tojs': 'csvnUserList'}
data = {}
data['list'] = mw.getPage(page_info)
data['page'] = page
data['page_size'] = page_size
data['page_count'] = int(math.ceil(ulist_sum / page_size))
start = (page - 1) * page_size
data['data'] = ulist[start:start + page_size]
return mw.getJson(data)
def projectAdd():
args = getArgs()
if not 'name' in args:
return 'project name missing'
path = getServerDir() + '/bin/svnadmin'
dest = getServerDir() + '/data/repositories/' + args['name']
cmd = path + ' create ' + dest
data = mw.execShell(cmd)
if data[1] == '':
mw.execShell('chown -R csvn:csvn ' + dest)
return 'ok'
return 'fail'
def projectDel():
args = getArgs()
if not 'name' in args:
return 'project name missing'
dest = getServerDir() + '/data/repositories/' + args['name']
cmd = 'rm -rf ' + dest
data = mw.execShell(cmd)
if data[0] == '':
return 'ok'
return 'fail'
def getHttpPort():
http_main_conf = getServerDir() + '/data/conf/csvn_main_httpd.conf'
try:
if os.path.exists(http_main_conf):
content = mw.readFile(http_main_conf)
return re.search('Listen\s(\d+)', content).groups()[0]
except Exception as e:
pass # print e
return '80'
def getCsvnPort():
http_main_conf = getServerDir() + '/data/conf/csvn-wrapper.conf'
try:
if os.path.exists(http_main_conf):
content = mw.readFile(http_main_conf)
return re.search('wrapper.java.additional.3=-Djetty.port=(\d+)', content).groups()[0]
except Exception as e:
pass # print e
return '3343'
def getALlProjectList(search=''):
path = getServerDir() + '/data/repositories'
dlist = []
if os.path.exists(path):
for filename in os.listdir(path):
tmp = {}
filePath = path + '/' + filename
if os.path.isdir(filePath):
if search == '':
tmp['name'] = filename
dlist.append(tmp)
else:
if filename.find(search) != -1:
tmp['name'] = filename
dlist.append(tmp)
return dlist
def checkProjectListIsHasScript(data):
dlen = len(data)
for x in range(dlen):
path = getServerDir() + '/data/repositories/' + \
data[x]['name'] + '/hooks/post-commit'
if os.path.exists(path):
data[x]['has_hook'] = True
else:
data[x]['has_hook'] = False
return data
def projectList():
import math
args = getArgs()
page = 1
page_size = 10
search = ''
if 'page' in args:
page = int(args['page'])
if 'page_size' in args:
page_size = int(args['page_size'])
if 'search' in args:
search = args['search']
dlist = getALlProjectList(search)
dlist_sum = len(dlist)
start = (page - 1) * page_size
ret_data = dlist[start:start + page_size]
ret_data = checkProjectListIsHasScript(ret_data)
data = {}
data['data'] = ret_data
data['list'] = mw.getPage(
{'count': dlist_sum, 'p': page, 'row': 10, 'tojs': 'csvnProjectList'})
data['ip'] = mw.getLocalIp()
data['port'] = getHttpPort()
data['csvn_port'] = getCsvnPort()
return mw.getJson(data)
def getAllAclList():
svn_access_file = getServerDir() + '/data/conf/svn_access_file'
aData = mw.readFile(svn_access_file)
aData = re.sub('#.*', '', aData)
aData = aData.strip().split('[')[1:]
allAcl = {}
for i in range(len(aData)):
oData = aData[i].strip().split(']')
name = oData[0].strip('/').strip(':')
if oData[1] == '':
allAcl[name] = []
else:
user = oData[1].strip().split('\n')
userAll = []
for iu in range(len(user)):
ulist = user[iu].split('=')
utmp = {}
utmp['user'] = ulist[0].strip()
utmp['acl'] = ulist[1].strip()
userAll.append(utmp)
allAcl[name] = userAll
return allAcl
def makeAclFile(content):
# print content
svn_access_file = getServerDir() + '/data/conf/svn_access_file'
tmp = "\n"
for k, v in content.items():
if k == '':
tmp += "[/]\n"
else:
tmp += "[" + k + ":/]\n"
for iv in range(len(v)):
tmp += v[iv]['user'] + ' = ' + v[iv]['acl'] + "\n"
tmp += "\n"
# svn_tmp_path = getServerDir() + '/data/conf/svn_access_file.log'
return mw.writeFile(svn_access_file, tmp)
def projectAclList():
args = getArgs()
if not 'name' in args:
return 'name missing!'
name = args['name']
acl = getAllAclList()
if name in acl:
return mw.getJson(acl[name])
else:
return 'fail'
def projectAclAdd():
args = getArgs()
if not 'uname' in args:
return 'username missing'
if not 'pname' in args:
return 'project name missing'
uname = args['uname']
pname = args['pname']
ulist = getAllUser()
if not uname in ulist:
return uname + " user not exists!"
acl = getAllAclList()
tmp_acl = {'user': uname, 'acl': 'rw'}
if not pname in acl:
acl[pname] = [tmp_acl]
makeAclFile(acl)
return 'ok'
tmp = acl[pname]
tmp_len = len(tmp)
if tmp_len == 0:
acl[pname] = [tmp_acl]
else:
is_have = False
for x in range(tmp_len):
if tmp[x]['user'] == uname:
is_have = True
return uname + ' users already exist!'
if not is_have:
tmp.append(tmp_acl)
acl[pname] = tmp
makeAclFile(acl)
return 'ok'
def projectAclDel():
args = getArgs()
if not 'uname' in args:
return 'username missing'
if not 'pname' in args:
return 'project name missing'
uname = args['uname']
pname = args['pname']
ulist = getAllUser()
if not uname in ulist:
return uname + " user not exists!"
acl = getAllAclList()
if not pname in acl:
return 'project not exists!'
tmp = acl[pname]
tmp_len = len(tmp)
if tmp_len == 0:
return 'project no have user:' + uname
else:
is_have = False
rtmp = []
for x in range(tmp_len):
if tmp[x]['user'] != uname:
rtmp.append(tmp[x])
acl[pname] = rtmp
makeAclFile(acl)
return 'ok'
def projectAclSet():
args = getArgs()
if not 'uname' in args:
return 'username missing'
if not 'pname' in args:
return 'project name missing'
if not 'acl' in args:
return 'acl missing'
uname = args['uname']
pname = args['pname']
up_acl = args['acl']
ulist = getAllUser()
if not uname in ulist:
return uname + " user not exists!"
acl = getAllAclList()
if not pname in acl:
return 'project not exists!'
tmp = acl[pname]
tmp_len = len(tmp)
if tmp_len == 0:
return 'project no have user:' + uname
else:
is_have = False
for x in range(tmp_len):
if tmp[x]['user'] == uname:
tmp[x]['acl'] = up_acl
acl[pname] = tmp
makeAclFile(acl)
return 'ok'
def getCsvnUser():
user = 'admin_sync'
acl = getAllAclList()
if '' in acl:
tmp = acl['']
is_has = False
for data in tmp:
if data['user'] == user:
is_has = True
if not is_has:
tmp.append({'user': user, 'acl': 'r'})
acl[''] = tmp
makeAclFile(acl)
return user
def getCsvnPwd(user):
if app_debug:
return user + '123'
pwd_file = 'data/csvn_sync.pl'
if os.path.exists(pwd_file):
return mw.readFile(pwd_file).strip()
import time
cur_time = time.time()
rand_pwd = mw.md5(str(cur_time))
pwd = user + rand_pwd[:5]
htpasswd = getServerDir() + "/bin/htpasswd"
svn_auth_file = getServerDir() + "/data/conf/svn_auth_file"
cmd = htpasswd + ' -b ' + svn_auth_file + ' ' + user + ' ' + pwd
data = mw.execShell(cmd)
mw.writeFile(pwd_file, pwd)
return pwd
def projectScriptLoad():
args = getArgs()
if not 'pname' in args:
return 'project name missing'
post_commit_tpl = getPluginDir() + '/hook/post-commit.tpl'
hook_path = getServerDir() + '/data/repositories/' + \
args['pname'] + '/hooks'
post_commit_file = hook_path + '/post-commit'
pct_content = mw.readFile(post_commit_tpl)
mw.writeFile(post_commit_file, pct_content)
mw.execShell('chmod 777 ' + post_commit_file)
commit_tpl = getPluginDir() + '/hook/commit.tpl'
commit_file = hook_path + '/commit'
ct_content = mw.readFile(commit_tpl)
ct_content = ct_content.replace('{$PROJECT_DIR}', mw.getRootDir())
ct_content = ct_content.replace('{$PORT}', getHttpPort())
ct_content = ct_content.replace('{$CSVN_USER}', getCsvnUser())
ct_content = ct_content.replace('{$CSVN_PWD}', getCsvnPwd(getCsvnUser()))
mw.writeFile(commit_file, ct_content)
mw.execShell('chmod 777 ' + commit_file)
return 'ok'
def projectScriptUnload():
args = getArgs()
if not 'pname' in args:
return 'project name missing'
post_commit_file = getServerDir() + '/data/repositories/' + '/' + \
args['pname'] + '/hooks/post-commit'
mw.execShell('rm -f ' + post_commit_file)
commit_file = getServerDir() + '/data/repositories/' + '/' + \
args['pname'] + '/hooks/commit'
mw.execShell('rm -f ' + commit_file)
return 'ok'
def projectScriptEdit():
args = getArgs()
if not 'pname' in args:
return 'project name missing'
data = {}
commit_file = getServerDir() + '/data/repositories/' + \
args['pname'] + '/hooks/commit'
if os.path.exists(commit_file):
data['status'] = True
data['path'] = commit_file
else:
data['status'] = False
data['msg'] = 'file does not exist'
return mw.getJson(data)
def projectScriptDebug():
args = getArgs()
if not 'pname' in args:
return 'project name missing'
data = {}
commit_log = getServerDir() + '/data/repositories/' + \
args['pname'] + '/sh.log'
if os.path.exists(commit_log):
data['status'] = True
data['path'] = commit_log
else:
data['status'] = False
data['msg'] = 'file does not exist'
return mw.getJson(data)
def getTotalStatistics():
st = status()
data = {}
if st == 'start':
svn_path = getServerDir() + '/data/repositories'
data['status'] = True
data['count'] = len(os.listdir(svn_path))
data['ver'] = mw.readFile(getServerDir() + '/version.pl').strip()
return mw.returnJson(True, 'ok', data)
else:
data['status'] = False
data['count'] = 0
return mw.returnJson(False, 'fail', data)
if __name__ == "__main__":
func = sys.argv[1]
if func == 'status':
print(status())
elif func == 'start':
print(start())
elif func == 'stop':
print(stop())
elif func == 'restart':
print(restart())
elif func == 'reload':
print(reload())
elif func == 'initd_status':
print(initdStatus())
elif func == 'initd_install':
print(initdInstall())
elif func == 'initd_uninstall':
print(initdUinstall())
elif func == 'csvn_edit':
print(csvnEdit())
elif func == 'user_list':
print(userList())
elif func == 'user_add':
print(userAdd())
elif func == 'user_del':
print(userDel())
elif func == 'project_list':
print(projectList())
elif func == 'project_del':
print(projectDel())
elif func == 'project_add':
print(projectAdd())
elif func == 'project_acl_list':
print(projectAclList())
elif func == 'project_acl_add':
print(projectAclAdd())
elif func == 'project_acl_del':
print(projectAclDel())
elif func == 'project_acl_set':
print(projectAclSet())
elif func == 'project_script_load':
print(projectScriptLoad())
elif func == 'project_script_unload':
print(projectScriptUnload())
elif func == 'project_script_edit':
print(projectScriptEdit())
elif func == 'project_script_debug':
print(projectScriptDebug())
elif func == 'get_total_statistics':
print(getTotalStatistics())
else:
print('fail')
-17
View File
@@ -1,17 +0,0 @@
{
"sort": 7,
"ps": "最流行的SVN代码共享管理软件",
"shell": "install.sh",
"name": "csvn",
"title": "CSVN",
"versions": "5.1",
"updates":"5.1.4",
"tip": "soft",
"checks": "server/csvn",
"path":"server/csvn",
"author": "midoks",
"date": "2017-04-01",
"home": "https://www.collab.net",
"type": "SVN代码共享管理软件",
"pid": "3"
}
-107
View File
@@ -1,107 +0,0 @@
#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
# https://blog.csdn.net/akipa11/article/details/103455298
# https://blog.csdn.net/bbj12345678/article/details/122941395
curPath=`pwd`
rootPath=$(dirname "$curPath")
rootPath=$(dirname "$rootPath")
serverPath=$(dirname "$rootPath")
install_tmp=${rootPath}/tmp/mw_install.pl
sysName=`uname`
echo "use system: ${sysName}"
if [ ${sysName} == "Darwin" ]; then
OSNAME='macos'
elif grep -Eqi "CentOS" /etc/issue || grep -Eq "CentOS" /etc/*-release; then
OSNAME='centos'
elif grep -Eqi "Fedora" /etc/issue || grep -Eq "Fedora" /etc/*-release; then
OSNAME='fedora'
elif grep -Eqi "Debian" /etc/issue || grep -Eq "Debian" /etc/*-release; then
OSNAME='debian'
elif grep -Eqi "Ubuntu" /etc/issue || grep -Eq "Ubuntu" /etc/*-release; then
OSNAME='ubuntu'
elif grep -Eqi "Raspbian" /etc/issue || grep -Eq "Raspbian" /etc/*-release; then
OSNAME='raspbian'
else
OSNAME='unknow'
fi
CheckJAVA()
{
which "java" > /dev/null
if [ $? -eq 0 ]
then
echo 'java is exist'
elif [ "ubuntu" == "$OSNAME" ] || [ "debian" == "$OSNAME" ] ;then
echo 'java install...'
apt install -y default-jdk
export JAVA_HOME=/usr/lib/jvm/default-java
else
echo 'java install...'
yum install -y java
fi
}
# export JAVA_HOME=/usr/lib/jvm/default-java
#JAVA_BIN=/usr/lib/jvm/default-java/bin
#JRE_HOME=/usr/lib/jvm/default-java/jre
#PATH=$PATH:/usr/lib/jvm/default-java/bin:/usr/lib/jvm/default-java/jre/bin
#CLASSPATH=/usr/lib/jvm/default-java/jre/lib:/usr/lib/jvm/default-java/lib:/usr/lib/jvm/default-java/jre/lib/charsets.jar
Install_csvn()
{
CheckJAVA
mkdir -p $serverPath/source
echo '正在安装脚本文件...' > $install_tmp
CSVN_SOURCE='https://github.com/midoks/mdserver-web/releases/download/init/CollabNetSubversionEdge-5.1.4_linux-x86_64.tar.xz'
if [ ! -f $serverPath/source/csvn.tar.xz ];then
wget -O $serverPath/source/csvn.tar.xz ${CSVN_SOURCE}
fi
cd $serverPath/source && tar -Jxf $serverPath/source/csvn.tar.xz
mv $serverPath/source/csvn $serverPath/csvn
echo '5.1' > $serverPath/csvn/version.pl
if id -u csvn > /dev/null 2>&1; then
echo "csvn user exists"
else
groupadd csvn
useradd -g csvn csvn
cp /etc/sudoers{,.`date +"%Y-%m-%d_%H-%M-%S"`}
echo "csvn ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
fi
chown -R csvn:csvn $serverPath/csvn
$serverPath/csvn/bin/csvn install
$serverPath/csvn/bin/csvn-httpd install
echo '安装完成' > $install_tmp
}
Uninstall_csvn()
{
rm -rf $serverPath/csvn
}
action=$1
host=$2
if [ "${1}" == 'install' ];then
Install_csvn
else
Uninstall_csvn
fi
-500
View File
@@ -1,500 +0,0 @@
pluginService('csvn');
function csvnPost(method,args,callback){
var loadT = layer.msg('正在获取...', { icon: 16, time: 0, shade: 0.3 });
$.post('/plugins/run', {name:'csvn', func:method, args:JSON.stringify(args)}, function(data) {
layer.close(loadT);
if (!data.status){
layer.msg(data.msg,{icon:0,time:2000,shade: [0.3, '#000']});
return;
}
if(typeof(callback) == 'function'){
callback(data);
}
},'json');
}
function csvnEdit(){
csvnPost('csvn_edit',{} , function(data){
// console.log(data);
var rdata = $.parseJSON(data.data);
var edit = '<p class="status">通用的手动编辑:</p>';
edit +='<div class="sfm-opt">\
<button class="btn btn-default btn-sm" onclick="onlineEditFile(0,\''+rdata['svn_access_file']+'\');">权限编辑</button>\
<button class="btn btn-default btn-sm" onclick="onlineEditFile(0,\''+rdata['post_commit_tpl']+'\');">post_commit_tpl</button>\
<button class="btn btn-default btn-sm" onclick="onlineEditFile(0,\''+rdata['commit_tpl']+'\');">commit_tpl</button>\
</div>';
$(".soft-man-con").html(edit);
});
}
function csvnUserFind(){
var search = $('#csvn_find_user').val();
if (search==''){
layer.msg('搜索字符不能为空!',{icon:0,time:2000,shade: [0.3, '#000']});
return;
}
csvnUserList(1, search);
}
function csvnUserList(page, search) {
var _data = {};
if (typeof(page) =='undefined'){
var page = 1;
}
_data['page'] = page;
_data['page_size'] = 10;
if(typeof(search) != 'undefined'){
_data['search'] = search;
}
csvnPost('user_list', _data, function(data){
var rdata = $.parseJSON(data.data);
// console.log(rdata);
content = '<div class="finduser"><input class="bt-input-text mr5 outline_no" type="text" placeholder="查找用户名" id="csvn_find_user" style="height: 28px; border-radius: 3px;width: 505px;">';
content += '<button class="btn btn-success btn-sm" onclick="csvnUserFind();">查找</button></div>';
content += '<div class="divtable" style="margin-top:5px;"><table class="table table-hover" width="100%" cellspacing="0" cellpadding="0" border="0">';
content += '<thead><tr>';
content += '<th>用户名</th>';
content += '<th>操作(<a class="btlink" onclick="csvnAddUser();">添加</a>)</th>';
content += '</tr></thead>';
content += '<tbody>';
ulist = rdata.data;
for (i in ulist){
content += '<tr><td>'+ulist[i]+'</td><td>'+
'<a class="btlink" onclick="csvnDelUser(\''+ulist[i]+'\')">删除</a> | ' +
'<a class="btlink" onclick="csvnModPwdUser(\''+ulist[i]+'\')">改密</a></td></tr>';
}
content += '</tbody>';
content += '</table></div>';
page = '<div class="dataTables_paginate paging_bootstrap pagination" style="margin-top:0px;"><ul id="softPage" class="page"><div>';
page += rdata.list;
page += '</div></ul></div>';
content += page;
$(".soft-man-con").html(content);
});
}
function csvnDelUser(name){
var loadOpen = layer.open({
type: 1,
title: '删除用户',
area: '350px',
content:"<div class='bt-form pd20 pb70 c6'>\
<div class='version line'>你要确认要删除"+ name + "账户?</div>\
<div class='bt-form-submit-btn'>\
<button type='button' id='csvn_del_close' class='btn btn-danger btn-sm btn-title'>关闭</button>\
<button type='button' id='csvn_del_ok' class='btn btn-success btn-sm btn-title bi-btn'>确认</button>\
</div>\
</div>"
});
$('#csvn_del_close').click(function(){
layer.close(loadOpen);
});
$('#csvn_del_ok').click(function(){
_data = {};
_data['username'] = name;
var loadT = layer.msg('正在获取...', { icon: 16, time: 0, shade: 0.3 });
$.post('/plugins/run', {name:'csvn', func:'user_del', args:JSON.stringify(_data)}, function(data) {
layer.close(loadT);
if (!data.status){
layer.msg(data.data,{icon:0,time:2000,shade: [0.3, '#000']});
return;
}
if (data.data !='ok'){
layer.msg(data.data,{icon:2,time:2000,shade: [0.3, '#000']});
}
layer.close(loadOpen);
layer.msg("删除成功!",{icon:1,time:3000,shade: [0.3, '#000']});
},'json');
});
}
function csvnAddUser(username){
user_input = ''
if (typeof(username) == 'undefined'){
user_input = "<div><input class='bt-input-text mr5 outline_no' type='text' id='csvn_username' name='username' style='height: 28px; border-radius: 3px;width: 200px;' placeholder='输入用户名'></div>";
} else {
user_input = "<div><input value='"+ username +"' class='bt-input-text mr5 outline_no' type='text' id='csvn_username' name='username' style='height: 28px; border-radius: 3px;width: 200px;' disabled='true'></div>";
}
var loadOpen = layer.open({
type: 1,
title: '添加用户',
area: '240px',
content:"<div class='bt-form pd20 pb70 c6'>\
<div class='version line'>\
"+user_input+"\
<div style='padding-top:3px;'><input class='bt-input-text mr5 outline_no' type='text' id='csvn_password' name='password' style='height: 28px; border-radius: 3px;width: 200px;' placeholder='输入密码'></div>\
</div>\
<div class='bt-form-submit-btn'>\
<button type='button' id='csvn_add_close' class='btn btn-danger btn-sm btn-title'>关闭</button>\
<button type='button' id='csvn_add_ok' class='btn btn-success btn-sm btn-title bi-btn'>确认</button>\
</div>\
</div>"
});
$('#csvn_add_close').click(function(){
layer.close(loadOpen);
});
$('#csvn_add_ok').click(function(){
_data = {};
_data['username'] = $('#csvn_username').val();
_data['password'] = $('#csvn_password').val();
var loadT = layer.msg('正在获取...', { icon: 16, time: 0, shade: 0.3 });
$.post('/plugins/run', {name:'csvn', func:'user_add', args:JSON.stringify(_data)}, function(data) {
layer.close(loadT);
if (!data.status){
layer.msg(data.data,{icon:0,time:2000,shade: [0.3, '#000']});
return;
}
if (data.data !='ok'){
layer.msg(data.data,{icon:2,time:2000,shade: [0.3, '#000']});
}
csvnUserList();
layer.close(loadOpen);
layer.msg("操作成功!",{icon:1,time:3000,shade: [0.3, '#000']});
},'json');
});
}
function csvnModPwdUser(name){
csvnAddUser(name);
}
function csvnProjectFind(){
var search = $('#csvn_project_find').val();
if (search == ''){
layer.msg('查找字符不能为空!',{icon:0,time:2000,shade: [0.3, '#000']});
return;
}
csvnProjectList(1, search);
}
function csvnProjectList(page, search){
var _data = {};
_data['page_size'] = 10;
if (typeof(search) != 'undefined'){
_data['search'] = search;
}
if (typeof(page) != 'undefined'){
_data['page'] = page;
setCookie('csvnProjectListPage',page);
} else {
_data['page'] = 1;
cookie_page = getCookie('csvnProjectListPage')
if (cookie_page >0){
_data['page'] = cookie_page;
}
}
csvnPost('project_list', _data, function(data){
var rdata = $.parseJSON($.trim(data.data));
var csvn_mg = project_url = 'http://' +rdata['ip'] +(rdata['csvn_port'] == '80' ? '': ':'+rdata['csvn_port']);
content = '<div><input class="bt-input-text mr5" type="text" placeholder="查找项目" id="csvn_project_find" style="height: 28px; border-radius: 3px;width: 505px;">';
content += '<button class="btn btn-success btn-sm" onclick="csvnProjectFind();">查找</button></div>';
content += '<div class="divtable" style="margin-top:5px;"><table class="table table-hover" width="100%" cellspacing="0" cellpadding="0" border="0">';
content += '<thead><tr>';
content += '<th>项目名</th>';
content += '<th>地址</th>';
content += '<th>操作(<a class="btlink" onclick="csvnAddProject();">添加</a>) | <a class="btlink" target="_blank" href="'+csvn_mg+'">后台管理</a> </th>';
content += '</tr></thead>';
content += '<tbody>';
// console.log(rdata);
ulist = rdata.data;
for (i in ulist){
var project_url = 'http://' +rdata['ip'] +(rdata['port'] == '80' ? '': ':'+rdata['port'])+ '/svn/'+ulist[i]['name'];
var code_url = 'http://' +rdata['ip'] +(rdata['port'] == '80' ? '': ':'+rdata['port'])+ '/viewvc/'+ulist[i]['name'];
content += '<tr><td>'+ulist[i]['name']+'</td>'+
'<td>'+project_url+'</td><td>'+
'<a class="btlink" onclick="csvnDelProject(\''+ulist[i]['name']+'\')">删除</a> | ' +
'<a class="btlink" onclick="csvnAclProject(\''+ulist[i]['name']+'\')">权限</a> | ' +
'<a class="btlink" target="_blank" href="' + code_url +'">源码</a> | ' +
'<a class="btlink" onclick="csvnProjectScript(\''+ulist[i]['name']+'\','+ ulist[i]['has_hook']+')">脚本</a>' +
'</td></tr>';
}
content += '</tbody>';
content += '</table></div>';
page = '<div class="dataTables_paginate paging_bootstrap pagination" style="margin-top:0px;"><ul id="softPage" class="page"><div>';
page += rdata.list;
page += '</div></ul></div>';
content += page;
$(".soft-man-con").html(content);
});
}
function csvnDelProject(name){
var loadOpen = layer.open({
type: 1,
title: '删除用户',
area: '350px',
content:"<div class='bt-form pd20 pb70 c6'>\
<div class='version line'>你要确认要删除"+ name + "账户?</div>\
<div class='bt-form-submit-btn'>\
<button type='button' id='csvn_del_close' class='btn btn-danger btn-sm btn-title'>关闭</button>\
<button type='button' id='csvn_del_ok' class='btn btn-success btn-sm btn-title bi-btn'>确认</button>\
</div>\
</div>"
});
$('#csvn_del_close').click(function(){
layer.close(loadOpen);
});
$('#csvn_del_ok').click(function(){
var _data = {};
_data['name'] = name;
var loadT = layer.msg('正在获取...', { icon: 16, time: 0, shade: 0.3 });
$.post('/plugins/run', {name:'csvn', func:'project_del', args:JSON.stringify(_data)}, function(data) {
layer.close(loadT);
if (!data.status){
layer.msg(data.data,{icon:0,time:2000,shade: [0.3, '#000']});
return;
}
if (data.data !='ok'){
layer.msg(data.data,{icon:2,time:2000,shade: [0.3, '#000']});
return;
}
csvnProjectList();
layer.close(loadOpen);
layer.msg("删除成功!",{icon:1,time:3000,shade: [0.3, '#000']});
},'json');
});
}
function csvnAddProject(){
var loadOpen = layer.open({
type: 1,
title: '添加项目',
area: '240px',
content:"<div class='bt-form pd20 pb70 c6'>\
<div class='version line'>\
<div><input class='bt-input-text mr5 outline_no' type='text' id='csvn_name' name='username' style='height: 28px; border-radius: 3px;width: 200px;' placeholder='输入项目名'></div>\
</div>\
<div class='bt-form-submit-btn'>\
<button type='button' id='csvn_project_close' class='btn btn-danger btn-sm btn-title'>关闭</button>\
<button type='button' id='csvn_project_ok' class='btn btn-success btn-sm btn-title bi-btn'>确认</button>\
</div>\
</div>"
});
$('#csvn_project_close').click(function(){
layer.close(loadOpen);
});
$('#csvn_project_ok').click(function(){
var _data = {};
_data['name'] = $('#csvn_name').val();
csvnPost('project_add', _data, function(data){
if (data.data !='ok'){
layer.msg(data.data,{icon:2,time:2000,shade: [0.3, '#000']});
return;
}
csvnProjectList();
layer.close(loadOpen);
layer.msg("操作成功!",{icon:1,time:3000,shade: [0.3, '#000']});
});
});
}
function csvnProjectScript(pname, has_hook){
var html = '';
if (has_hook){
html += '<button onclick="csvnProjectScriptEdit(\''+pname+'\')" class="btn btn-default btn-sm">手动编辑</button>';
html += '<button onclick="csvnProjectScriptDebug(\''+pname+'\')" class="btn btn-default btn-sm">调试日志</button>';
html += '<button onclick="csvnProjectScriptLoad(\''+pname+'\')" class="btn btn-default btn-sm">重新加载</button>';
html += '<button onclick="csvnProjectScriptUnload(\''+pname+'\')" class="btn btn-default btn-sm">卸载脚本</button>';
} else {
html += '<button onclick="csvnProjectScriptLoad(\''+pname+'\')" class="btn btn-default btn-sm">加载脚本</button>';
}
var loadOpen = layer.open({
type: 1,
title: '脚本设置',
area: '240px',
content:'<div class="change-default pd20">'+html+'</div>'
});
}
function csvnProjectScriptLoad(pname){
csvnPost('project_script_load', {'pname':pname}, function(data){
if (data.data != 'ok'){
layer.msg(data.data,{icon:0,time:2000,shade: [0.3, '#000']});
return;
}
layer.msg('加载成功!',{icon:1,time:2000,shade: [0.3, '#000']});
setTimeout(function(){
csvnProjectList();
},2000);
});
}
function csvnProjectScriptUnload(pname){
csvnPost('project_script_unload', {'pname':pname}, function(data){
if (data.data != 'ok'){
layer.msg(data.data,{icon:0,time:2000,shade: [0.3, '#000']});
return;
}
layer.msg('卸载成功!',{icon:1,time:2000,shade: [0.3, '#000']});
setTimeout(function(){
csvnProjectList();
},2000);
});
}
function csvnProjectScriptEdit(pname){
csvnPost('project_script_edit', {'pname':pname}, function(data){
var rdata = $.parseJSON(data.data);
if (rdata['status']){
onlineEditFile(0, rdata['path']);
csvnProjectList();
} else {
layer.msg(rdata.msg,{icon:1,time:2000,shade: [0.3, '#000']});
}
});
}
function csvnProjectScriptDebug(pname){
csvnPost('project_script_debug', {'pname':pname}, function(data){
var rdata = $.parseJSON(data.data);
if (rdata['status']){
onlineEditFile(0, rdata['path']);
csvnProjectList();
} else {
layer.msg(rdata.msg,{icon:1,time:2000,shade: [0.3, '#000']});
}
});
}
function csvnAclAdd(pname){
var uname = $('#csvn_username').val();
if (uname == ''){
layer.msg('添加用户名不能为空!',{icon:0,time:2000,shade: [0.3, '#000']});
return;
}
csvnPost('project_acl_add', {'pname':pname,'uname':uname}, function(data){
if (data.data != 'ok'){
layer.msg(data.data,{icon:0,time:2000,shade: [0.3, '#000']});
return;
}
$('.layui-layer-close1').click();
csvnAclProject(pname);
});
}
function csvnAclDel(pname, uname){
csvnPost('project_acl_del', {'pname':pname,'uname':uname}, function(data){
if (data.data != 'ok'){
layer.msg(data.data,{icon:0,time:2000,shade: [0.3, '#000']});
return;
}
$('.layui-layer-close1').click();
csvnAclProject(pname);
});
}
function csvnAclSet(obj, pname, uname, acl, selected){
if (selected){
$(obj).prop('checked',true);
layer.msg('权限没有变化!',{icon:0,time:2000,shade: [0.3, '#000']});
return;
}
csvnPost('project_acl_set', {'pname':pname,'uname':uname, 'acl':acl}, function(data){
if (data.data != 'ok'){
layer.msg(data.data,{icon:0,time:2000,shade: [0.3, '#000']});
return;
}
$('.layui-layer-close1').click();
csvnAclProject(pname);
});
}
function csvnAclProject(pname){
csvnPost('project_acl_list', {'name':pname}, function(data){
var rdata = [];
try {
rdata = $.parseJSON(data.data);
} catch(e){}
var list = '';
for (i in rdata) {
var user = rdata[i]['user'];
var acl = '';
if (rdata[i]['acl'] == 'r'){
acl += '<input type="checkbox" onclick="csvnAclSet(this,\''+pname+'\',\''+user+'\',\'r\',true)" checked="true"> 只读 | <input type="checkbox" onclick="csvnAclSet(this,\''+pname+'\',\''+user+'\',\'rw\', false)"> 读写';
} else {
acl += '<input type="checkbox" onclick="csvnAclSet(this,\''+pname+'\',\''+user+'\',\'r\',false)"> 只读 | <input type="checkbox" onclick="csvnAclSet(this,\''+pname+'\',\''+user+'\',\'rw\',true)" checked="true"> 读写';
}
list += '<tr><td>'+user+'</td><td>' + acl +'</td>'+
'<td><a class="btlink" onclick="csvnAclDel(\''+pname+'\',\''+user+'\')">删除</a></td>'+'</tr>';
}
var loadOpen = layer.open({
type: 1,
title: '项目('+pname+')权限设置',
area: '300px',
content:"<div class='bt-form pd20 c6'>\
<div>\
<div><input class='bt-input-text mr5 outline_no' type='text' id='csvn_username' name='username' style='height: 28px; border-radius: 3px;width: 205px;' placeholder='用户名'>\
<button class='btn btn-success btn-sm' onclick='csvnAclAdd(\""+pname+"\");'>添加</button></div>\
<div class='divtable' style='margin-top:5px;'><table class='table table-hover'><thead><tr><th>用户</th><th>权限</th><th>操作</th></tr></thead>\
<tbody>"+list+"</tbody>\
</table></div>\
</div>\
</div>"
});
});
}
+1 -1
View File
@@ -157,7 +157,7 @@ def initDreplace():
# mw.writeFile(conf_bin, content)
# systemd
systemDir = '/lib/systemd/system'
systemDir = '/usr/lib/systemd/system'
systemService = systemDir + '/gogs.service'
systemServiceTpl = getPluginDir() + '/init.d/gogs.service.tpl'
if os.path.exists(systemDir) and not os.path.exists(systemService):
+2 -2
View File
@@ -79,10 +79,10 @@ Install_gogs()
Uninstall_gogs()
{
if [ -f /lib/systemd/system/gogs.service ];then
if [ -f /usr/lib/systemd/system/gogs.service ];then
systemctl stop gogs
systemctl disable gogs
rm -rf /lib/systemd/system/gogs.service
rm -rf /usr/lib/systemd/system/gogs.service
systemctl daemon-reload
fi
+1 -1
View File
@@ -104,7 +104,7 @@ def initDreplace():
mw.execShell('chmod +x ' + file_bin)
# systemd
systemDir = '/lib/systemd/system'
systemDir = '/usr/lib/systemd/system'
systemService = systemDir + '/memcached.service'
systemServiceTpl = getPluginDir() + '/init.d/memcached.service.tpl'
if os.path.exists(systemDir) and not os.path.exists(systemService):
+6 -3
View File
@@ -14,6 +14,7 @@ VERSION=1.6.15
Install_mem(){
mkdir -p $serverPath/source
# mkdir -p $serverPath/memcached
echo '正在安装脚本文件...' > $install_tmp
if [ ! -f $serverPath/source/memcached.tar.gz ];then
@@ -22,7 +23,7 @@ Install_mem(){
cd $serverPath/source && tar -zxvf memcached.tar.gz
mkdir -p $serverPath/memcached
echo "./configure --prefix=${serverPath}/memcached && make && make install"
cd $serverPath/source/memcached-${VERSION} && ./configure --prefix=$serverPath/memcached && make && make install
@@ -38,10 +39,10 @@ Install_mem(){
Uninstall_mem()
{
if [ -f /lib/systemd/system/memcached.service ];then
if [ -f /usr/lib/systemd/system/memcached.service ];then
systemctl stop memcached
systemctl disable memcached
rm -rf /lib/systemd/system/memcached.service
rm -rf /usr/lib/systemd/system/memcached.service
systemctl daemon-reload
fi
@@ -52,6 +53,8 @@ Uninstall_mem()
}
# /www/server/memcached/bin/memcached -d -p 11211 -u root -m 100 -c 100
action=$1
if [ "${1}" == 'install' ];then
Install_mem
+17 -77
View File
@@ -104,80 +104,41 @@ def initDreplace():
return file_bin
def start():
def mgOp(method):
file = initDreplace()
if mw.isAppleSystem():
file = initDreplace()
data = mw.execShell(file + ' start')
data = mw.execShell(file + ' ' + method)
if data[1] == '':
return 'ok'
return 'fail'
return data[1]
cmd = 'systemctl start mongod'
cmd = 'systemctl ' + method + ' mongod'
if os.path.exists("/usr/lib/systemd/system/mongodb.service"):
cmd = 'systemctl start mongodb'
cmd = 'systemctl ' + start + ' mongodb'
data = mw.execShell(cmd)
if data[1] == '':
return 'ok'
return 'fail'
return data[1]
def start():
return mgOp('start')
def stop():
if mw.isAppleSystem():
file = initDreplace()
data = mw.execShell(file + ' stop')
if data[1] == '':
return 'ok'
return 'fail'
cmd = 'systemctl stop mongod'
if os.path.exists("/usr/lib/systemd/system/mongodb.service"):
cmd = 'systemctl stop mongodb'
data = mw.execShell(cmd)
if data[1] == '':
return 'ok'
return 'fail'
return mgOp('stop')
def reload():
if os.path.exists("/tmp/mongodb-27017.sock"):
mw.execShell('rm -rf ' + "/tmp/mongodb-27017.sock")
if mw.isAppleSystem():
file = initDreplace()
data = mw.execShell(file + ' reload')
if data[1] == '':
return 'ok'
return 'fail'
cmd = 'systemctl reload mongod'
if os.path.exists("/usr/lib/systemd/system/mongodb.service"):
cmd = 'systemctl reload mongodb'
data = mw.execShell(cmd)
if data[1] == '':
return 'ok'
return 'fail'
return mgOp('reload')
def restart():
if os.path.exists("/tmp/mongodb-27017.sock"):
mw.execShell('rm -rf ' + "/tmp/mongodb-27017.sock")
if mw.isAppleSystem():
file = initDreplace()
data = mw.execShell(file + ' reload')
if data[1] == '':
return 'ok'
return 'fail'
cmd = 'systemctl reload mongod'
if os.path.exists("/usr/lib/systemd/system/mongodb.service"):
cmd = 'systemctl reload mongodb'
data = mw.execShell(cmd)
if data[1] == '':
return 'ok'
return 'fail'
return mgOp('restart')
def runInfo():
@@ -218,15 +179,8 @@ def runInfo():
def initdStatus():
if not app_debug:
if mw.isAppleSystem():
return "Apple Computer does not support"
if mw.isAppleSystem():
initd_bin = getInitDFile()
if os.path.exists(initd_bin):
return 'ok'
return 'fail'
return "Apple Computer does not support"
shell_cmd = 'systemctl status mongod | grep loaded | grep "enabled;"'
@@ -240,17 +194,8 @@ def initdStatus():
def initdInstall():
import shutil
if not app_debug:
if mw.isAppleSystem():
return "Apple Computer does not support"
if mw.isAppleSystem():
source_bin = initDreplace()
initd_bin = getInitDFile()
shutil.copyfile(source_bin, initd_bin)
mw.execShell('chmod +x ' + initd_bin)
mw.execShell('chkconfig --add ' + getPluginName())
return "Apple Computer does not support"
if os.path.exists("/usr/lib/systemd/system/mongodb.service"):
mw.execShell('systemctl enable mongodb')
@@ -260,13 +205,8 @@ def initdInstall():
def initdUinstall():
if not app_debug:
if mw.isAppleSystem():
return "Apple Computer does not support"
if mw.isAppleSystem():
mw.execShell('chkconfig --del ' + getPluginName())
initd_bin = getInitDFile()
os.remove(initd_bin)
return "Apple Computer does not support"
if os.path.exists("/usr/lib/systemd/system/mongodb.service"):
mw.execShell('systemctl disable mongodb')
+3 -3
View File
@@ -4,15 +4,15 @@
"name": "mongodb",
"title": "Mongodb",
"shell": "install.sh",
"versions":["4.4.14","5.0.4"],
"updates":["4.4.14","5.0.4"],
"versions":["4.4","5.0"],
"updates":["4.4","5.0"],
"tip": "soft",
"checks": "server/mongodb",
"path": "server/mongodb",
"display": 1,
"author": "mongodb",
"date": "2021-11-23",
"home": "https://www.mongodb.com/",
"home": "https://www.mongodb.com/docs/v4.4/installation/",
"type": 0,
"pid": "2"
}
+197 -14
View File
@@ -18,6 +18,8 @@ echo "use system: ${sysName}"
if [ ${sysName} == "Darwin" ]; then
OSNAME='macos'
elif grep -Eq "openSUSE" /etc/*-release; then
OSNAME='opensuse'
elif grep -Eqi "CentOS" /etc/issue || grep -Eq "CentOS" /etc/*-release; then
OSNAME='centos'
elif grep -Eqi "Fedora" /etc/issue || grep -Eq "Fedora" /etc/*-release; then
@@ -26,58 +28,239 @@ elif grep -Eqi "Debian" /etc/issue || grep -Eq "Debian" /etc/*-release; then
OSNAME='debian'
elif grep -Eqi "Ubuntu" /etc/issue || grep -Eq "Ubuntu" /etc/*-release; then
OSNAME='ubuntu'
elif grep -Eqi "Raspbian" /etc/issue || grep -Eq "Raspbian" /etc/*-release; then
OSNAME='raspbian'
else
OSNAME='unknow'
fi
SYS_VERSION_ID=`cat /etc/*-release | grep VERSION_ID | awk -F = '{print $2}' | awk -F "\"" '{print $2}'`
Install_app_mac()
{
if [ ! -f $serverPath/source/mongodb-macos-x86_64-${VERSION}.tgz ];then
wget -O $serverPath/source/mongodb-macos-x86_64-${VERSION}.tgz https://fastdl.mongodb.org/osx/mongodb-macos-x86_64-${VERSION}.tgz
fi
cd $serverPath/source && tar -zxvf mongodb-macos-x86_64-${VERSION}.tgz
cd mongodb-macos-x86_64-${VERSION} && mv ./* $serverPath/mongodb
}
Install_Linux_Ubuntu()
{
##################### Ubuntu start #####################
if [ "$SYS_VERSION_ID" == "22" ]; then
echo "Not yet supported"
exit 1
fi
if [ -f /usr/lib/systemd/system/mongod.service ];then
echo 'alreay exist!'
exit 0
fi
wget -qO - https://www.mongodb.org/static/pgp/server-${VERSION}.asc | sudo apt-key add -
sudo apt install gnupg
touch /etc/apt/sources.list.d/mongodb-org-${VERSION}.list
lsb_release -dc
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/${VERSION} multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-${VERSION}.list
apt update -y
apt install -y mongodb-org
##################### Ubuntu end #####################
}
Uninstall_Linux_Ubuntu()
{
systemctl stop mongod
apt purge -y mongodb-org*
apt autoremove -y
rm -r /var/log/mongodb
rm -r /var/lib/mongodb
}
Install_Linux_Debian()
{
##################### debian start #####################
if [ "$SYS_VERSION_ID" -ge "11" ]; then
echo "Not yet supported"
exit 1
fi
if [ -f /usr/lib/systemd/system/mongod.service ];then
echo 'alreay exist!'
exit 0
fi
wget -qO - https://www.mongodb.org/static/pgp/server-${VERSION}.asc | sudo apt-key add -
apt install -y gnupg
wget -qO - https://www.mongodb.org/static/pgp/server-${VERSION}.asc | sudo apt-key add -
echo "deb http://repo.mongodb.org/apt/debian buster/mongodb-org/${VERSION} main" | sudo tee /etc/apt/sources.list.d/mongodb-org-${VERSION}.list
apt update -y
apt install -y mongodb-org
echo "mongodb-org hold" | sudo dpkg --set-selections
echo "mongodb-org-server hold" | sudo dpkg --set-selections
echo "mongodb-org-shell hold" | sudo dpkg --set-selections
echo "mongodb-org-mongos hold" | sudo dpkg --set-selections
echo "mongodb-org-tools hold" | sudo dpkg --set-selections
##################### debian end #####################
}
Uninstall_Linux_Debian()
{
systemctl stop mongod
apt purge -y mongodb-org*
apt autoremove -y
rm -r /var/log/mongodb
rm -r /var/lib/mongodb
}
Install_Linux_Opensuse()
{
##################### opensuse start #####################
if [ "$SYS_VERSION_ID" -gt "15" ]; then
echo "Not yet supported"
exit 1
fi
if [ -f /usr/lib/systemd/system/mongod.service ];then
echo 'alreay exist!'
exit 0
fi
rpm --import https://www.mongodb.org/static/pgp/server-${VERSION}.asc
zypper addrepo --gpgcheck "https://repo.mongodb.org/zypper/suse/15/mongodb-org/${VERSION}/x86_64/" mongodb
zypper -n install mongodb-org
# zypper install mongodb-org-4.4.15 mongodb-org-server-4.4.15 mongodb-org-shell-4.4.15 mongodb-org-mongos-4.4.15 mongodb-org-tools-4.4.15
##################### opensuse end #####################
}
Uninstall_Linux_Opensuse()
{
systemctl stop mongod
zypper remove -y $(rpm -qa | grep mongodb-org)
rm -r /var/log/mongodb
rm -r /var/lib/mongo
}
# https://repo.mongodb.org/yum/redhat/7/mongodb-org/5.0/x86_64/RPMS/mongodb-org-server-5.0.4-1.el7.x86_64.rpm
Install_app_linux(){
if [ ! -f $serverPath/source/mongodb-org-server-${VERSION}-1.el7.x86_64.rpm ];then
wget -O $serverPath/source/mongodb-org-server-${VERSION}-1.el7.x86_64.rpm https://repo.mongodb.org/yum/redhat/7/mongodb-org/5.0/x86_64/RPMS/mongodb-org-server-${VERSION}-1.el7.x86_64.rpm
Install_Linux_CentOS()
{
if [ -f /usr/lib/systemd/system/mongod.service ];then
echo 'alreay exist!'
exit 0
fi
#清空mongo的repo源
rm -rf /etc/yum.repos.d/mongodb-org-*
##################### centos start #####################
echo "
[mongodb-org-${VERSION}]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/\$releasever/mongodb-org/${VERSION}/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-${VERSION}.asc
" > /etc/yum.repos.d/mongodb-org-${VERSION}.repo
yum install -y mongodb-org
##################### centos end #####################
}
Uninstall_Linux_CentOS()
{
systemctl stop mongod
yum erase -y $(rpm -qa | grep mongodb-org)
rm -r /var/log/mongodb
rm -r /var/lib/mongo
}
Install_app_linux()
{
if [ "$OSNAME" == "ubuntu" ];then
Install_Linux_Ubuntu
elif [ "$OSNAME" == "debian" ];then
Install_Linux_Debian
elif [ "$OSNAME" == "centos" ];then
Install_Linux_CentOS
elif [ "$OSNAME" == "opensuse" ];then
Install_Linux_Opensuse
else
echo "Not yet supported"
exit 1
fi
rpm -ivh $serverPath/source/mongodb-org-server-${VERSION}-1.el7.x86_64.rpm
}
Install_app()
{
pip3 install pymongo
echo '正在安装脚本文件...' > $install_tmp
mkdir -p $serverPath/source
mkdir -p $serverPath/mongodb
if [ "macos" == "$OSNAME" ];then
Install_app_mac
elif [ "ubuntu" == "$OSNAME" ] || [ "debian" == "$OSNAME" ] ;then
apt install -y mongodb
else
Install_app_linux
fi
echo "${VERSION}" > $serverPath/mongodb/version.pl
echo '安装完成' > $install_tmp
#初始化
cd ${rootPath} && python3 ${rootPath}/plugins/mongodb/index.py start
cd ${rootPath} && python3 ${rootPath}/plugins/mongodb/index.py initd_install
}
Uninstall_app_linux()
{
##################
if [ "$OSNAME" == "ubuntu" ];then
Uninstall_Linux_Ubuntu
elif [ "$OSNAME" == "debian" ];then
Uninstall_Linux_Debian
elif [ "$OSNAME" == "centos" ];then
Uninstall_Linux_CentOS
elif [ "$OSNAME" == "opensuse" ];then
Uninstall_Linux_Opensuse
else
echo "ok"
fi
##################
}
Uninstall_app()
{
# apt remove mongodb -y
if [ "macos" == "$OSNAME" ];then
echo 'mac'
else
Uninstall_app_linux
fi
rm -rf $serverPath/mongodb
echo "Uninstall_mongodb" > $install_tmp
}
+3
View File
@@ -52,7 +52,10 @@
</style>
<script type="text/javascript">
resetPluginWinWidth(800);
var loading = layer.msg("资源加载中...", { icon: 16, time: 0, shade: 0.3 });
$.getScript( "/plugins/file?name=mysql&f=js/mysql.js", function(){
layer.close(loading);
pluginService('mysql',$('.plugin_version').attr('version'));
});
</script>
+3 -3
View File
@@ -176,7 +176,7 @@ def initDreplace(version=''):
mw.writeFile(mysql_conf, content)
# systemd
systemDir = '/lib/systemd/system'
systemDir = '/usr/lib/systemd/system'
systemService = systemDir + '/mysql.service'
systemServiceTpl = getPluginDir() + '/init.d/mysql.service.tpl'
if os.path.exists(systemDir) and not os.path.exists(systemService):
@@ -572,7 +572,7 @@ def setMyPort():
def runInfo():
if status(version) == 'stop':
return mw.returnJson(false, 'MySQL未启动', [])
return mw.returnJson(False, 'MySQL未启动', [])
db = pMysqlDb()
data = db.query('show global status')
@@ -1470,7 +1470,7 @@ def setDbSlave(version):
def getMasterStatus(version=''):
if status(version) == 'stop':
return mw.returnJson(false, 'MySQL未启动,或正在启动中...!', [])
return mw.returnJson(False, 'MySQL未启动,或正在启动中...!', [])
conf = getConf()
con = mw.readFile(conf)
+2 -2
View File
@@ -26,10 +26,10 @@ fi
if [ "${action}" == "uninstall" ];then
if [ -f /lib/systemd/system/mysql.service ];then
if [ -f /usr/lib/systemd/system/mysql.service ];then
systemctl stop mysql
systemctl disable mysql
rm -rf /lib/systemd/system/mysql.service
rm -rf /usr/lib/systemd/system/mysql.service
systemctl daemon-reload
fi
fi
+2 -1
View File
@@ -34,7 +34,7 @@ Install_mysql()
fi
if [ ! -f ${mysqlDir}/mysql-5.5.62.tar.gz ];then
wget -O ${mysqlDir}/mysql-5.5.62.tar.gz https://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.62.tar.gz
wget -O ${mysqlDir}/mysql-5.5.62.tar.gz --tries=3 https://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.62.tar.gz
fi
if [ ! -d ${mysqlDir}/mysql-5.5.62 ];then
@@ -66,6 +66,7 @@ Install_mysql()
else
rm -rf ${mysqlDir}/mysql-5.5.62
echo '安装失败' > $install_tmp
exit 1
fi
fi
}
+17 -4
View File
@@ -38,13 +38,23 @@ Install_mysql()
if [ ! -f ${mysqlDir}/mysql-5.6.50.tar.gz ];then
wget -O ${mysqlDir}/mysql-5.6.50.tar.gz https://cdn.mysql.com/Downloads/MySQL-5.6/mysql-5.6.50.tar.gz
wget -O ${mysqlDir}/mysql-5.6.50.tar.gz --tries=3 https://cdn.mysql.com/Downloads/MySQL-5.6/mysql-5.6.50.tar.gz
fi
if [ ! -d ${mysqlDir}/mysql-5.6.50 ];then
cd ${mysqlDir} && tar -zxvf ${mysqlDir}/mysql-5.6.50.tar.gz
fi
OPTIONS=''
##check openssl version
OPENSSL_VERSION=`openssl version|awk '{print $2}'|awk -F '.' '{print $1}'`
if [ "${OPENSSL_VERSION}" -ge "3" ];then
#openssl version to high
cd $serverPath/mdserver-web/plugins/php/lib && /bin/bash openssl.sh
export PKG_CONFIG_PATH=$serverPath/lib/openssl/lib/pkgconfig
OPTIONS="-DWITH_SSL=${serverPath}/lib/openssl"
fi
if [ ! -d $serverPath/mysql ];then
cd ${mysqlDir}/mysql-5.6.50 && cmake \
@@ -59,9 +69,11 @@ Install_mysql()
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DEXTRA_CHARSETS=all \
-DDEFAULT_CHARSET=utf8mb4 \
-DDEFAULT_COLLATION=utf8mb4_general_ci \
$OPTIONS \
-DCMAKE_C_COMPILER=/usr/bin/gcc \
-DCMAKE_CXX_COMPILER=/usr/bin/g++ \
-DDEFAULT_COLLATION=utf8mb4_general_ci
-DCMAKE_CXX_COMPILER=/usr/bin/g++
make clean && make && make install && make clean
@@ -71,6 +83,7 @@ Install_mysql()
else
rm -rf ${mysqlDir}/mysql-5.6.50
echo '安装失败' > $install_tmp
exit 1
fi
fi
}
+14 -2
View File
@@ -40,7 +40,7 @@ Install_mysql()
if [ ! -f ${mysqlDir}/mysql-boost-${VERSION}.tar.gz ];then
wget -O ${mysqlDir}/mysql-boost-${VERSION}.tar.gz https://cdn.mysql.com/Downloads/MySQL-5.7/mysql-boost-${VERSION}.tar.gz
wget -O ${mysqlDir}/mysql-boost-${VERSION}.tar.gz --tries=3 https://cdn.mysql.com/Downloads/MySQL-5.7/mysql-boost-${VERSION}.tar.gz
fi
#检测文件是否损坏.
@@ -52,7 +52,7 @@ Install_mysql()
else
# 重新下载
rm -rf ${mysqlDir}/mysql-${VERSION}
wget -O ${mysqlDir}/mysql-boost-${VERSION}.tar.gz https://cdn.mysql.com/Downloads/MySQL-5.7/mysql-boost-${VERSION}.tar.gz
wget -O ${mysqlDir}/mysql-boost-${VERSION}.tar.gz --tries=3 https://cdn.mysql.com/Downloads/MySQL-5.7/mysql-boost-${VERSION}.tar.gz
fi
fi
@@ -60,6 +60,16 @@ Install_mysql()
cd ${mysqlDir} && tar -zxvf ${mysqlDir}/mysql-boost-${VERSION}.tar.gz
fi
OPTIONS=''
##check openssl version
OPENSSL_VERSION=`openssl version|awk '{print $2}'|awk -F '.' '{print $1}'`
if [ "${OPENSSL_VERSION}" -ge "3" ];then
#openssl version to high
cd $serverPath/mdserver-web/plugins/php/lib && /bin/bash openssl.sh
export PKG_CONFIG_PATH=$serverPath/lib/openssl/lib/pkgconfig
OPTIONS="-DWITH_SSL=${serverPath}/lib/openssl"
fi
if [ ! -d $serverPath/mysql ];then
cd ${mysqlDir}/mysql-${VERSION} && cmake \
-DCMAKE_INSTALL_PREFIX=$serverPath/mysql \
@@ -75,6 +85,7 @@ Install_mysql()
-DDEFAULT_CHARSET=utf8mb4 \
-DDEFAULT_COLLATION=utf8mb4_general_ci \
-DDOWNLOAD_BOOST=1 \
$OPTIONS \
-DCMAKE_C_COMPILER=/usr/bin/gcc \
-DCMAKE_CXX_COMPILER=/usr/bin/g++ \
-DWITH_BOOST=${mysqlDir}/mysql-${VERSION}/boost/
@@ -86,6 +97,7 @@ Install_mysql()
else
rm -rf ${mysqlDir}/mysql-${VERSION}
echo '安装失败' > $install_tmp
exit 1
fi
fi
}
+87 -17
View File
@@ -17,6 +17,50 @@ sysName=`uname`
install_tmp=${rootPath}/tmp/mw_install.pl
mysqlDir=${serverPath}/source/mysql
_os=`uname`
echo "use system: ${_os}"
if [ ${_os} == "Darwin" ]; then
OSNAME='macos'
elif grep -Eq "openSUSE" /etc/*-release; then
OSNAME='opensuse'
zypper refresh
elif grep -Eq "FreeBSD" /etc/*-release; then
OSNAME='freebsd'
pkg install -y wget unzip
elif grep -Eqi "Arch" /etc/issue || grep -Eq "Arch" /etc/*-release; then
OSNAME='arch'
echo y | pacman -Sy unzip
elif grep -Eqi "CentOS" /etc/issue || grep -Eq "CentOS" /etc/*-release; then
OSNAME='centos'
yum install -y wget zip unzip
elif grep -Eqi "Fedora" /etc/issue || grep -Eq "Fedora" /etc/*-release; then
OSNAME='fedora'
yum install -y wget zip unzip
elif grep -Eqi "Rocky" /etc/issue || grep -Eq "Rocky" /etc/*-release; then
OSNAME='rocky'
yum install -y wget zip unzip
elif grep -Eqi "AlmaLinux" /etc/issue || grep -Eq "AlmaLinux" /etc/*-release; then
OSNAME='alma'
yum install -y wget zip unzip
elif grep -Eqi "Debian" /etc/issue || grep -Eq "Debian" /etc/*-release; then
OSNAME='debian'
apt update -y
apt install -y devscripts
apt install -y wget zip unzip
elif grep -Eqi "Ubuntu" /etc/issue || grep -Eq "Ubuntu" /etc/*-release; then
OSNAME='ubuntu'
apt install -y wget zip unzip
else
OSNAME='unknow'
fi
VERSION_ID=`cat /etc/*-release | grep VERSION_ID | awk -F = '{print $2}' | awk -F "\"" '{print $2}'`
VERSION=8.0.29
Install_mysql()
{
mkdir -p ${mysqlDir}
@@ -32,36 +76,60 @@ Install_mysql()
fi
INSTALL_CMD=cmake
if [ "$sysName" != "Darwin" ];then
# check cmake version
CMAKE_VERSION=`cmake -version | grep version | awk '{print $3}' | awk -F '.' '{print $1}'`
if [ "$CMAKE_VERSION" -eq "2" ];then
mkdir -p /var/log/mariadb
touch /var/log/mariadb/mariadb.log
INSTALL_CMD=cmake
fi
INSTALL_CMD=cmake3
fi
if [ ! -f ${mysqlDir}/mysql-boost-8.0.25.tar.gz ];then
wget -O ${mysqlDir}/mysql-boost-8.0.25.tar.gz --tries=3 https://cdn.mysql.com/archives/mysql-8.0/mysql-boost-8.0.25.tar.gz
if [ ! -f ${mysqlDir}/mysql-boost-${VERSION}.tar.gz ];then
wget -O ${mysqlDir}/mysql-boost-${VERSION}.tar.gz --tries=3 https://cdn.mysql.com/Downloads/MySQL-8.0/mysql-boost-${VERSION}.tar.gz
fi
#检测文件是否损坏.
md5_mysql_ok=e142c2058313b4646c36fa9bb1b38493
if [ -f ${mysqlDir}/mysql-boost-8.0.25.tar.gz ];then
md5_mysql=`md5sum ${mysqlDir}/mysql-boost-8.0.25.tar.gz | awk '{print $1}'`
md5_mysql_ok=42fbfe0569089c20f9aa457b3f367d50
if [ -f ${mysqlDir}/mysql-boost-${VERSION}.tar.gz ];then
md5_mysql=`md5sum ${mysqlDir}/mysql-boost-${VERSION}.tar.gz | awk '{print $1}'`
if [ "${md5_mysql_ok}" == "${md5_mysql}" ]; then
echo "mysql8.0 file check ok"
else
# 重新下载
rm -rf ${mysqlDir}/mysql-8.0.25
wget -O ${mysqlDir}/mysql-boost-8.0.25.tar.gz --tries=3 https://cdn.mysql.com/archives/mysql-8.0/mysql-boost-8.0.25.tar.gz
rm -rf ${mysqlDir}/mysql-${VERSION}
wget -O ${mysqlDir}/mysql-boost-${VERSION}.tar.gz --tries=3 https://cdn.mysql.com/Downloads/MySQL-8.0/mysql-boost-${VERSION}.tar.gz
fi
fi
if [ ! -d ${mysqlDir}/mysql-8.0.25 ];then
cd ${mysqlDir} && tar -zxvf ${mysqlDir}/mysql-boost-8.0.25.tar.gz
if [ ! -d ${mysqlDir}/mysql-${VERSION} ];then
cd ${mysqlDir} && tar -zxvf ${mysqlDir}/mysql-boost-${VERSION}.tar.gz
fi
OPTIONS=''
##check openssl version
OPENSSL_VERSION=`openssl version|awk '{print $2}'|awk -F '.' '{print $1}'`
if [ "${OPENSSL_VERSION}" -ge "3" ];then
#openssl version to high
cd $serverPath/mdserver-web/plugins/php/lib && /bin/bash openssl.sh
export PKG_CONFIG_PATH=$serverPath/lib/openssl/lib/pkgconfig
OPTIONS="-DWITH_SSL=${serverPath}/lib/openssl"
fi
WHERE_DIR_GCC=/usr/bin/gcc
WHERE_DIR_GPP=/usr/bin/g++
if [ "$OSNAME" == "centos" ] && [ "$VERSION_ID" == "7" ];then
yum install centos-release-scl -y
yum install devtoolset-7 -y
# scl enable devtoolset-7 bash
gcc --version
WHERE_DIR_GCC=/opt/rh/devtoolset-7/root/usr/bin/gcc
WHERE_DIR_GPP=/opt/rh/devtoolset-7/root/usr/bin/g++
echo $WHERE_DIR_GCC
echo $WHERE_DIR_GPP
fi
if [ ! -d $serverPath/mysql ];then
cd ${mysqlDir}/mysql-8.0.25 && ${INSTALL_CMD} \
cd ${mysqlDir}/mysql-${VERSION} && ${INSTALL_CMD} \
-DCMAKE_INSTALL_PREFIX=$serverPath/mysql \
-DMYSQL_USER=mysql \
-DMYSQL_TCP_PORT=3306 \
@@ -76,17 +144,19 @@ Install_mysql()
-DDEFAULT_COLLATION=utf8mb4_general_ci \
-DDOWNLOAD_BOOST=1 \
-DFORCE_INSOURCE_BUILD=1 \
-DCMAKE_C_COMPILER=/usr/bin/gcc \
-DCMAKE_CXX_COMPILER=/usr/bin/g++ \
-DWITH_BOOST=${mysqlDir}/mysql-8.0.25/boost/
$OPTIONS \
-DCMAKE_C_COMPILER=$WHERE_DIR_GCC \
-DCMAKE_CXX_COMPILER=$WHERE_DIR_GPP \
-DWITH_BOOST=${mysqlDir}/mysql-${VERSION}/boost/
make clean && make && make install && make clean
if [ -d $serverPath/mysql ];then
echo '8.0' > $serverPath/mysql/version.pl
echo '安装完成' > $install_tmp
else
rm -rf ${mysqlDir}/mysql-8.0.25
rm -rf ${mysqlDir}/mysql-${VERSION}
echo '安装失败' > $install_tmp
exit 1
fi
fi
}
+3 -3
View File
@@ -132,7 +132,7 @@ def confReplace():
mw.execShell('mkdir -p ' + php_conf)
static_conf = mw.getServerDir() + '/web_conf/php/conf/enable-php-00.conf'
if not os.path.exists(static_conf):
mw.writeFile(static_conf, '')
mw.writeFile(static_conf, 'set $PHP_ENV 0;')
# give nginx root permission
ng_exe_bin = getServerDir() + "/nginx/sbin/nginx"
@@ -174,7 +174,7 @@ def initDreplace():
confReplace()
# systemd
systemDir = '/lib/systemd/system'
systemDir = '/usr/lib/systemd/system'
systemService = systemDir + '/openresty.service'
systemServiceTpl = getPluginDir() + '/init.d/openresty.service.tpl'
if os.path.exists(systemDir) and not os.path.exists(systemService):
@@ -188,7 +188,7 @@ def initDreplace():
def status():
data = mw.execShell(
"ps -ef|grep nginx |grep -v grep | grep -v python | awk '{print $2}'")
"ps -ef|grep openresty |grep -v grep | grep -v python | awk '{print $2}'")
if data[0] == '':
return 'stop'
return 'start'
+2 -2
View File
@@ -11,6 +11,6 @@
"home":"http://openresty.org",
"date":"2017-11-24",
"pid": "1",
"versions": ["1.11.2.5", "1.13.6.2","1.15.8.3","1.19.3.1","1.21.4.1"],
"updates": ["1.11.2.5", "1.13.6.2","1.15.8.3","1.19.3.1","1.21.4.1"]
"versions": ["1.15.8.3","1.17.8.2","1.19.3.1","1.21.4.1"],
"updates": ["1.15.8.3","1.17.8.2","1.19.3.1","1.21.4.1"]
}
+3 -3
View File
@@ -51,7 +51,7 @@ Install_openresty()
echo "${VERSION}" > $serverPath/openresty/version.pl
mkdir -p $serverPath/web_conf/php/conf
echo "" > $serverPath/web_conf/php/conf/enable-php-00.conf
echo 'set $PHP_ENV 0;' > $serverPath/web_conf/php/conf/enable-php-00.conf
#初始化
cd ${rootPath} && python3 ${rootPath}/plugins/openresty/index.py start
@@ -63,9 +63,9 @@ Install_openresty()
Uninstall_openresty()
{
if [ -f /lib/systemd/system/openresty.service ];then
if [ -f /usr/lib/systemd/system/openresty.service ];then
systemctl stop openresty
rm -rf /lib/systemd/system/openresty.service
rm -rf /usr/systemd/system/openresty.service
systemctl daemon-reload
fi
+15 -5
View File
@@ -3,9 +3,19 @@ export PATH=$PATH:/opt/local/bin:/opt/local/sbin:/opt/local/share/man:/usr/local
DIR=$(cd "$(dirname "$0")"; pwd)
# cd /www/server/mdserver-web/scripts/quick && bash debug.sh
# cd /www/server/mdserver-web/plugins/php && bash all_test.sh
PHP_VER=53
# cd /www/server/mdserver-web/plugins/php && bash install.sh install 71
# cd /www/server/mdserver-web/plugins/php/versions/52/ && bash gd.sh install 52
# cd /www/server/mdserver-web/plugins/php/versions/52/ && bash openssl.sh install 52
# cd /www/server/mdserver-web/plugins/php/versions/81/ && bash imagemagick.sh install 81
# cd /www/server/mdserver-web/plugins/php/versions/70/ && bash imagemagick.sh install 70
PHP_VER=52
echo "php${PHP_VER} -- start"
cmd_ext=$(ls -l $DIR/versions/$PHP_VER/ |awk '{print $9}')
cd $DIR && /bin/bash install.sh install $PHP_VER
@@ -20,19 +30,19 @@ done
echo "php${PHP_VER} -- end"
PHP_VER_LIST=(54 55 56 71 72 73 74 80 81)
PHP_VER_LIST=(53 54 55 56 70 71 72 73 74 80 81)
# PHP_VER_LIST=(81)
for PHP_VER in ${PHP_VER_LIST[@]}; do
echo "php${PHP_VER} -- start"
if [ -d /www/server/php/${PHP_VER} ];then
cmd_ext=$(ls -l $DIR/versions/$PHP_VER/ |awk '{print $9}')
for ii in cmd_ext
for ii in $cmd_ext
do
echo "${ii}"
if [ "install.sh" == "$ii" ];then
echo '' > /tmp/t.log
else
cd $DIR/versions/$PHP_VER && bash $ii install ${PHP_VER}
cd $DIR/versions/$PHP_VER/ && bash $ii install ${PHP_VER}
fi
done
fi
+1
View File
@@ -1,3 +1,4 @@
set $PHP_ENV 1;
location ~ [^/]\.php(/|$)
{
try_files $uri =404;
+3 -3
View File
@@ -6,10 +6,10 @@
<section name="global_options">
Pid file
<value name="pid_file">/www/server/php/52/logs/php-fpm.pid</value>
<value name="pid_file">/www/server/php/52/var/run/php-fpm.pid</value>
Error log file
<value name="error_log">/www/server/php/52/logs/php-fpm.log</value>
<value name="error_log">/www/server/php/52/var/log/php-fpm.log</value>
Log level
<value name="log_level">notice</value>
@@ -107,7 +107,7 @@
<value name="request_slowlog_timeout">0s</value>
The log file for slow requests
<value name="slowlog">logs/slow.log</value>
<value name="slowlog">var/log/www-slow.log</value>
Set open file desc rlimit
<value name="rlimit_files">1024</value>
+1 -1
View File
@@ -12,7 +12,7 @@ zend.enable_gc = On
expose_php = On
max_execution_time = 30
max_input_time = 60
max_input_var = 1000
max_input_vars = 1000
memory_limit = 128M
error_reporting = E_ALL
display_errors = On
+1 -1
View File
@@ -12,7 +12,7 @@ zend.enable_gc = On
expose_php = On
max_execution_time = 30
max_input_time = 60
max_input_var = 1000
max_input_vars = 1000
memory_limit = 128M
error_reporting = E_ALL
display_errors = On
+1 -1
View File
@@ -12,7 +12,7 @@ zend.enable_gc = On
expose_php = On
max_execution_time = 30
max_input_time = 60
max_input_var = 1000
max_input_vars = 1000
memory_limit = 128M
error_reporting = E_ALL
display_errors = On
+1 -1
View File
@@ -1,4 +1,4 @@
location /{$PHP_VERSION} {
root {$ROOT_PATH}/phpinfo;
include enable-php-{$PHP_VERSION}.conf;
include {$SERVER_PATH}/web_conf/php/conf/enable-php-{$PHP_VERSION}.conf;
}
+44 -29
View File
@@ -152,7 +152,7 @@ def makeOpenrestyConf():
dfile = sdir + '/web_conf/php/conf/enable-php-' + x + '.conf'
if not os.path.exists(dfile):
if x == '00':
mw.writeFile(dfile, '')
mw.writeFile(dfile, 'set $PHP_ENV 0;')
else:
w_content = contentReplace(tpl_content, x)
mw.writeFile(dfile, w_content)
@@ -253,7 +253,7 @@ def initReplace(version):
mw.execShell('chown -R www:www ' + upload_path)
# systemd
systemDir = '/lib/systemd/system'
systemDir = '/usr/lib/systemd/system'
systemService = systemDir + '/php' + version + '.service'
systemServiceTpl = getPluginDir() + '/init.d/php.service.tpl'
if os.path.exists(systemDir) and not os.path.exists(systemService):
@@ -274,7 +274,7 @@ def phpOp(version, method):
data = mw.execShell('systemctl ' + method + ' php' + version)
if data[1] == '':
return 'ok'
return 'fail'
return data[1]
data = mw.execShell(file + ' ' + method)
if data[1] == '':
@@ -287,7 +287,14 @@ def start(version):
def stop(version):
return phpOp(version, 'stop')
status = phpOp(version, 'stop')
if version == '52':
file = initReplace(version)
data = mw.execShell(file + ' ' + 'stop')
if data[1] == '':
return 'ok'
return status
def restart(version):
@@ -295,7 +302,7 @@ def restart(version):
def reload(version):
return phpOp(version, 'reload')
return phpOp(version, 'restart')
def initdStatus(version):
@@ -339,7 +346,7 @@ def getPhpConf(version):
{'name': 'asp_tags', 'type': 1, 'ps': 'ASP标签支持'},
{'name': 'max_execution_time', 'type': 2, 'ps': '最大脚本运行时间'},
{'name': 'max_input_time', 'type': 2, 'ps': '最大输入时间'},
{'name': 'max_input_var', 'type': 2, 'ps': '最大输入数量'},
{'name': 'max_input_vars', 'type': 2, 'ps': '最大输入数量'},
{'name': 'memory_limit', 'type': 2, 'ps': '脚本内存限制'},
{'name': 'post_max_size', 'type': 2, 'ps': 'POST数据最大尺寸'},
{'name': 'file_uploads', 'type': 1, 'ps': '是否允许上传文件'},
@@ -365,7 +372,7 @@ def getPhpConf(version):
def submitPhpConf(version):
gets = ['display_errors', 'cgi.fix_pathinfo', 'date.timezone', 'short_open_tag',
'asp_tags', 'max_execution_time', 'max_input_time', 'memory_limit',
'asp_tags', 'max_execution_time', 'max_input_time', 'max_input_vars', 'memory_limit',
'post_max_size', 'file_uploads', 'upload_max_filesize', 'max_file_uploads',
'default_socket_timeout', 'error_reporting']
args = getArgs()
@@ -377,7 +384,8 @@ def submitPhpConf(version):
val = g + ' = ' + args[g] + '\n'
phpini = re.sub(rep, val, phpini)
mw.writeFile(filename, phpini)
mw.execShell(getServerDir() + '/init.d/php' + version + ' reload')
# mw.execShell(getServerDir() + '/init.d/php' + version + ' reload')
reload(version)
return mw.returnJson(True, '设置成功')
@@ -445,21 +453,23 @@ def setMaxTime(version):
def setMaxSize(version):
args = getArgs()
if not 'max' in args:
return 'missing time args!'
max = args['max']
if int(max) < 2:
data = checkArgs(args, ['max'])
if not data[0]:
return data[1]
maxVal = args['max']
if int(maxVal) < 2:
return mw.returnJson(False, '上传大小限制不能小于2MB!')
path = getServerDir() + '/' + version + '/etc/php.ini'
conf = mw.readFile(path)
rep = u"\nupload_max_filesize\s*=\s*[0-9]+M"
conf = re.sub(rep, u'\nupload_max_filesize = ' + max + 'M', conf)
conf = re.sub(rep, u'\nupload_max_filesize = ' + maxVal + 'M', conf)
rep = u"\npost_max_size\s*=\s*[0-9]+M"
conf = re.sub(rep, u'\npost_max_size = ' + max + 'M', conf)
conf = re.sub(rep, u'\npost_max_size = ' + maxVal + 'M', conf)
mw.writeFile(path, conf)
msg = mw.getInfo('设置PHP-{1}最大上传大小为[{2}MB]!', (version, max,))
msg = mw.getInfo('设置PHP-{1}最大上传大小为[{2}MB]!', (version, maxVal,))
mw.writeLog('插件管理[PHP]', msg)
return mw.returnJson(True, '设置成功!')
@@ -547,21 +557,23 @@ def checkFpmStatusFile(version):
def getFpmStatus(version):
checkFpmStatusFile(version)
if version == '52':
return mw.returnJson(False, 'PHP[' + version + ']不支持!!!')
checkFpmStatusFile(version)
stat = status(version)
if stat == 'stop':
return mw.returnJson(False, 'PHP[' + version + ']未启动!!!')
try:
url = 'http://' + mw.getHostAddr() + '/phpfpm_status_' + version + '?json'
result = mw.httpGet(url)
result = mw.httpGet(url, 1)
data = json.loads(result)
fTime = time.localtime(int(data['start time']))
data['start time'] = time.strftime('%Y-%m-%d %H:%M:%S', fTime)
except Exception as e:
url = 'http://127.0.0.1/phpfpm_status_' + version + '?json'
result = mw.httpGet(url)
result = mw.httpGet(url, 1)
data = json.loads(result)
fTime = time.localtime(int(data['start time']))
data['start time'] = time.strftime('%Y-%m-%d %H:%M:%S', fTime)
@@ -605,20 +617,20 @@ def setDisableFunc(version):
def checkPhpinfoFile(v):
if mw.isInstalledWeb():
sdir = mw.getServerDir()
dfile = sdir + '/openresty/nginx/conf/php_status/phpinfo_' + v + '.conf'
if not os.path.exists(dfile):
tpl = getPluginDir() + '/conf/phpinfo.conf'
content = mw.readFile(tpl)
content = contentReplace(content, v)
mw.writeFile(dfile, content)
mw.restartWeb()
sdir = mw.getServerDir()
dfile = sdir + '/web_conf/php/status/phpinfo_' + v + '.conf'
if not os.path.exists(dfile):
tpl = getPluginDir() + '/conf/phpinfo.conf'
content = mw.readFile(tpl)
content = contentReplace(content, v)
mw.writeFile(dfile, content)
mw.restartWeb()
def getPhpinfo(v):
checkPhpinfoFile(v)
sPath = mw.getRootDir() + '/phpinfo/' + v
mw.execShell("rm -rf " + mw.getRootDir() + '/phpinfo')
mw.execShell("mkdir -p " + sPath)
mw.writeFile(sPath + '/phpinfo.php', '<?php phpinfo(); ?>')
@@ -629,6 +641,8 @@ def getPhpinfo(v):
def get_php_info(args):
if not mw.isInstalledWeb():
return "openresty is not running!!!"
return getPhpinfo(args['version'])
@@ -675,7 +689,7 @@ def installLib(version):
name + '.sh' + ' install ' + version
rettime = time.strftime('%Y-%m-%d %H:%M:%S')
insert_info = (None, '安装[' + name + '-' + version + ']',
insert_info = (None, '安装[' + name + '-PHP' + version + ']',
'execshell', '0', rettime, execstr)
mw.M('tasks').add('id,name,type,status,addtime,execstr', insert_info)
@@ -694,7 +708,8 @@ def uninstallLib(version):
name + '.sh' + ' uninstall ' + version
data = mw.execShell(execstr)
if data[0] == '' and data[1] == '':
# data[0] == '' and
if data[1] == '':
return mw.returnJson(True, '已经卸载成功!')
else:
return mw.returnJson(False, '卸载信息![通道0]:' + data[0] + "[通道0]:" + data[1])
+1 -1
View File
@@ -2,7 +2,7 @@
php_fpm_BIN=/www/server/php/52/bin/php-cgi
php_fpm_CONF=/www/server/php/52/etc/php-fpm.conf
php_fpm_PID=/www/server/php/52/logs/php-fpm.pid
php_fpm_PID=/www/server/php/52/var/run/php-fpm.pid
php_opts="--fpm-config $php_fpm_CONF"
+2 -2
View File
@@ -33,10 +33,10 @@ fi
if [ "${action}" == "uninstall" ];then
if [ -f /lib/systemd/system/php${type}.service ];then
if [ -f /usr/lib/systemd/system/php${type}.service ];then
systemctl stop php${type}
systemctl disable php${type}
rm -rf /lib/systemd/system/php${type}.service
rm -rf /usr/lib/systemd/system/php${type}.service
systemctl daemon-reload
fi
fi
+2
View File
@@ -111,6 +111,7 @@ function submitConf(version) {
safe_mode: $("select[name='safe_mode']").val(),
max_execution_time: $("input[name='max_execution_time']").val(),
max_input_time: $("input[name='max_input_time']").val(),
max_input_vars: $("input[name='max_input_vars']").val(),
memory_limit: $("input[name='memory_limit']").val(),
post_max_size: $("input[name='post_max_size']").val(),
file_uploads: $("select[name='file_uploads']").val(),
@@ -501,6 +502,7 @@ function phpLibConfig(version){
<li>请按实际需求安装扩展,不要安装不必要的PHP扩展,这会影响PHP执行效率,甚至出现异常</li>\
<li>Redis扩展只允许在1个PHP版本中使用,安装到其它PHP版本请在[软件管理]重装Redis</li>\
<li>opcache/xcache/apc等脚本缓存扩展,请只安装其中1个,否则可能导致您的站点程序异常</li>\
<li>ioncube要在ZendGuardLoader/opcache前安装,否则可能导致您的站点程序异常</li>\
</ul>';
$('.soft-man-con').html(con);
});
+28
View File
@@ -0,0 +1,28 @@
#!/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")
rootPath=$(dirname "$rootPath")
rootPath=$(dirname "$rootPath")
# echo $rootPath
# cd /www/server/mdserver-web/plugins/php/lib && /bin/bash libmemcached.sh
SERVER_ROOT=$rootPath/lib
SOURCE_ROOT=$rootPath/source/lib
#----------------------------- libmemcached start -------------------------#
if [ ! -d ${SERVER_ROOT}/libmemcached ];then
cd ${SOURCE_ROOT}
if [ ! -f ${SOURCE_ROOT}/libmemcached-1.0.4.tar.gz ];then
wget -O libmemcached-1.0.4.tar.gz https://launchpad.net/libmemcached/1.0/1.0.4/+download/libmemcached-1.0.4.tar.gz -T 20
fi
tar -zxf libmemcached-1.0.4.tar.gz
cd libmemcached-1.0.4
./configure --prefix=${SERVER_ROOT}/libmemcached -with-memcached && make && make install
fi
#----------------------------- libmemcached end -------------------------#
+38
View File
@@ -0,0 +1,38 @@
#!/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")
rootPath=$(dirname "$rootPath")
rootPath=$(dirname "$rootPath")
# echo $rootPath
SERVER_ROOT=$rootPath/lib
SOURCE_ROOT=$rootPath/source/lib
# if [ ! -d ${SERVER_ROOT}/openssl ];then
# cd ${SOURCE_ROOT}
# if [ ! -f ${SOURCE_ROOT}/openssl-1.0.2q.tar.gz ];then
# wget https://github.com/midoks/mdserver-web/releases/download/init/openssl-1.0.2q.tar.gz -T 20
# fi
# tar -zxf openssl-1.0.2q.tar.gz
# cd openssl-1.0.2q
# ./config --openssldir=${SERVER_ROOT}/openssl zlib-dynamic shared
# make && make install
# fi
if [ ! -d ${SERVER_ROOT}/openssl ];then
cd ${SOURCE_ROOT}
if [ ! -f ${SOURCE_ROOT}/openssl-1.1.1p.tar.gz ];then
wget -O ${SOURCE_ROOT}/openssl-1.1.1p.tar.gz https://www.openssl.org/source/openssl-1.1.1p.tar.gz
fi
tar -zxvf openssl-1.1.1p.tar.gz
cd openssl-1.1.1p
./config --prefix=${SERVER_ROOT}/openssl zlib-dynamic shared
make && make install
fi
+27
View File
@@ -0,0 +1,27 @@
#!/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")
rootPath=$(dirname "$rootPath")
rootPath=$(dirname "$rootPath")
# echo $rootPath
SERVER_ROOT=$rootPath/lib
SOURCE_ROOT=$rootPath/source/lib
if [ ! -d ${SERVER_ROOT}/openssl10 ];then
cd ${SOURCE_ROOT}
if [ ! -f ${SOURCE_ROOT}/openssl-1.0.2q.tar.gz ];then
wget https://github.com/midoks/mdserver-web/releases/download/init/openssl-1.0.2q.tar.gz -T 20
fi
tar -zxf openssl-1.0.2q.tar.gz
cd openssl-1.0.2q
./config --openssldir=${SERVER_ROOT}/openssl10 zlib-dynamic shared
make && make install
fi
+4 -2
View File
@@ -77,7 +77,8 @@ Install_lib()
echo "${LIBNAME}.allowed_admin_path=/www/wwwroot/you_project_dir" >> $serverPath/php/$version/etc/php.ini
$serverPath/php/init.d/php$version reload
bash ${rootPath}/plugins/php/versions/lib.sh $version restart
echo '==========================================================='
echo 'successful!'
}
@@ -100,7 +101,8 @@ Uninstall_lib()
sed -i $BAK "/${LIBNAME}/d" $serverPath/php/$version/etc/php.ini
rm -f $extFile
$serverPath/php/init.d/php$version reload
bash ${rootPath}/plugins/php/versions/lib.sh $version restart
echo '==============================================='
echo 'successful!'
}
+3 -2
View File
@@ -68,7 +68,7 @@ Install_lib()
echo "[${LIBNAME}]" >> $serverPath/php/$version/etc/php.ini
echo "extension=${LIBNAME}.so" >> $serverPath/php/$version/etc/php.ini
$serverPath/php/init.d/php$version reload
bash ${rootPath}/plugins/php/versions/lib.sh $version restart
echo '==========================================================='
echo 'successful!'
}
@@ -91,7 +91,8 @@ Uninstall_lib()
sed -i $BAK "/${LIBNAME}/d" $serverPath/php/$version/etc/php.ini
rm -f $extFile
$serverPath/php/init.d/php$version reload
bash ${rootPath}/plugins/php/versions/lib.sh $version restart
echo '==============================================='
echo 'successful!'
}
+30 -7
View File
@@ -27,6 +27,26 @@ else
BAK=''
fi
sysName=`uname`
echo "use system: ${sysName}"
if [ ${sysName} == "Darwin" ]; then
OSNAME='macos'
elif grep -Eqi "CentOS" /etc/issue || grep -Eq "CentOS" /etc/*-release; then
OSNAME='centos'
elif grep -Eqi "Fedora" /etc/issue || grep -Eq "Fedora" /etc/*-release; then
OSNAME='fedora'
elif grep -Eqi "Debian" /etc/issue || grep -Eq "Debian" /etc/*-release; then
OSNAME='debian'
elif grep -Eqi "Ubuntu" /etc/issue || grep -Eq "Ubuntu" /etc/*-release; then
OSNAME='ubuntu'
elif grep -Eqi "Raspbian" /etc/issue || grep -Eq "Raspbian" /etc/*-release; then
OSNAME='raspbian'
else
OSNAME='unknow'
fi
Install_lib()
{
@@ -36,9 +56,12 @@ Install_lib()
return
fi
ln -s /usr/lib64/libjpeg.so /usr/lib/libjpeg.so
ln -s /usr/lib64/libpng.so /usr/lib/
cp -frp /usr/lib64/libldap* /usr/lib/
if [ "$OSNAME" == "debian" ] && [ "$OSNAME" == "ubuntu" ];then
ln -s /usr/lib64/libjpeg.so /usr/lib/libjpeg.so
ln -s /usr/lib64/libpng.so /usr/lib/
cp -frp /usr/lib64/libldap* /usr/lib/
fi
if [ ! -f "$extFile" ];then
@@ -54,8 +77,7 @@ Install_lib()
--with-gd \
--with-jpeg-dir=/usr/lib \
--with-freetype-dir=${serverPath}/lib/freetype_old \
--enable-gd-native-ttf \
--enable-gd-jis-conv
--enable-gd-native-ttf
make clean && make && make install && make clean
@@ -70,7 +92,7 @@ Install_lib()
echo "[${LIBNAME}]" >> $serverPath/php/$version/etc/php.ini
echo "extension=${LIBNAME}.so" >> $serverPath/php/$version/etc/php.ini
$serverPath/php/init.d/php${version} restart
bash ${rootPath}/plugins/php/versions/lib.sh $version restart
echo '==========================================================='
echo 'successful!'
}
@@ -93,7 +115,8 @@ Uninstall_lib()
sed -i $BAK "/${LIBNAME}/d" $serverPath/php/$version/etc/php.ini
rm -f $extFile
$serverPath/php/init.d/php$version reload
bash ${rootPath}/plugins/php/versions/lib.sh $version restart
echo '==============================================='
echo 'successful!'
}
+7
View File
@@ -161,6 +161,13 @@ if [ ! -d $serverPath/php/${PHP_VER}/lib/php/extensions/no-debug-non-zts-2006061
mkdir -p $serverPath/php/${PHP_VER}/lib/php/extensions/no-debug-non-zts-20060613
fi
# ps -ef|grep php/52 |grep -v grep |awk '{print $2}'|xargs kill
# /www/server/php/init.d/php52 start
# /www/server/php/52/sbin/php-fpm start
# cd /www/server/mdserver-web && python3 /www/server/mdserver-web/plugins/php/index.py start 52
mkdir -p $serverPath/php/${PHP_VER}/var/log
mkdir -p $serverPath/php/${PHP_VER}/var/run
#------------------------ install end ------------------------------------#
}
+9 -6
View File
@@ -35,19 +35,21 @@ Install_lib()
return
fi
cd $serverPath/mdserver-web/plugins/php/lib && /bin/bash icu.sh
if [ ! -f "$extFile" ];then
php_lib=$sourcePath/php_lib
mkdir -p $php_lib
wget -O $php_lib/${LIBNAME}-${LIBV}.tgz http://pecl.php.net/get/${LIBNAME}-${LIBV}.tgz
cd $php_lib && tar xvf ${LIBNAME}-${LIBV}.tgz
cd ${LIBNAME}-${LIBV}
$serverPath/php/$version/bin/phpize
./configure --with-php-config=$serverPath/php/$version/bin/php-config
make && make install && make clean
./configure --with-php-config=$serverPath/php/$version/bin/php-config \
--with-icu-dir=${serverPath}/lib/icu
make clean && make && make install && make clean
fi
@@ -60,7 +62,7 @@ Install_lib()
echo "[${LIBNAME}]" >> $serverPath/php/$version/etc/php.ini
echo "extension=${LIBNAME}.so" >> $serverPath/php/$version/etc/php.ini
$serverPath/php/init.d/php$version reload
bash ${rootPath}/plugins/php/versions/lib.sh $version restart
echo '==========================================================='
echo 'successful!'
}
@@ -83,7 +85,8 @@ Uninstall_lib()
sed -i $BAK "/${LIBNAME}/d" $serverPath/php/$version/etc/php.ini
rm -f $extFile
$serverPath/php/init.d/php$version reload
bash ${rootPath}/plugins/php/versions/lib.sh $version restart
echo '==============================================='
echo 'successful!'
}
+3 -2
View File
@@ -60,7 +60,7 @@ Install_lib()
echo "[${LIBNAME}]" >> $serverPath/php/$version/etc/php.ini
echo "zend_extension=${LIBNAME}.so" >> $serverPath/php/$version/etc/php.ini
$serverPath/php/init.d/php$version reload
bash ${rootPath}/plugins/php/versions/lib.sh $version restart
echo '==========================================================='
echo 'successful!'
}
@@ -83,7 +83,8 @@ Uninstall_lib()
sed -i $BAK "/${LIBNAME}/d" $serverPath/php/$version/etc/php.ini
rm -f $extFile
$serverPath/php/init.d/php$version reload
bash ${rootPath}/plugins/php/versions/lib.sh $version restart
echo '==============================================='
echo 'successful!'
}
+2 -2
View File
@@ -58,7 +58,7 @@ Install_lib()
echo "extension=${LIBNAME}.so" >> $serverPath/php/$version/etc/php.ini
$serverPath/php/init.d/php$version reload
bash ${rootPath}/plugins/php/versions/lib.sh $version restart
echo '==========================================================='
echo 'successful!'
}
@@ -81,7 +81,7 @@ Uninstall_lib()
sed -i $BAK "/${LIBNAME}/d" $serverPath/php/$version/etc/php.ini
rm -f $extFile
$serverPath/php/init.d/php$version reload
bash ${rootPath}/plugins/php/versions/lib.sh $version restart
echo '==============================================='
echo 'successful!'
}
+105
View File
@@ -0,0 +1,105 @@
#!/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")
rootPath=$(dirname "$rootPath")
rootPath=$(dirname "$rootPath")
serverPath=$(dirname "$rootPath")
sourcePath=${serverPath}/source/php
actionType=$1
version=$2
LIBNAME=openssl
LIBV=0
NON_ZTS_FILENAME=`ls $serverPath/php/${version}/lib/php/extensions | grep no-debug-non-zts`
extFile=$serverPath/php/${version}/lib/php/extensions/${NON_ZTS_FILENAME}/${LIBNAME}.so
sysName=`uname`
if [ "$sysName" == "Darwin" ];then
BAK='_bak'
else
BAK=''
fi
Install_lib()
{
isInstall=`cat $serverPath/php/$version/etc/php.ini|grep "${LIBNAME}.so"`
if [ "${isInstall}" != "" ];then
echo "php-$version 已安装${LIBNAME},请选择其它版本!"
return
fi
cd $serverPath/mdserver-web/plugins/php/lib && /bin/bash openssl_10.sh
if [ ! -f "$extFile" ];then
if [ ! -d $sourcePath/php${version}/ext ];then
cd $serverPath/mdserver-web/plugins/php && /bin/bash install.sh install ${version}
fi
cd $sourcePath/php${version}/ext/${LIBNAME}
if [ ! -f "config.m4" ];then
mv config0.m4 config.m4
fi
export PKG_CONFIG_PATH=$serverPath/lib/openssl10/lib/pkgconfig
$serverPath/php/$version/bin/phpize
./configure --with-php-config=$serverPath/php/$version/bin/php-config \
--with-openssl
make clean && make && make install && make clean
fi
if [ ! -f "$extFile" ];then
echo "ERROR!"
return
fi
echo "" >> $serverPath/php/$version/etc/php.ini
echo "[${LIBNAME}]" >> $serverPath/php/$version/etc/php.ini
echo "extension=${LIBNAME}.so" >> $serverPath/php/$version/etc/php.ini
bash ${rootPath}/plugins/php/versions/lib.sh $version restart
echo '==========================================================='
echo 'successful!'
}
Uninstall_lib()
{
if [ ! -f "$serverPath/php/$version/bin/php-config" ];then
echo "php-$version 未安装,请选择其它版本!"
return
fi
if [ ! -f "$extFile" ];then
echo "php-$version 未安装${LIBNAME},请选择其它版本!"
return
fi
echo $serverPath/php/$version/etc/php.ini
sed -i $BAK "/${LIBNAME}.so/d" $serverPath/php/$version/etc/php.ini
sed -i $BAK "/${LIBNAME}/d" $serverPath/php/$version/etc/php.ini
rm -f $extFile
bash ${rootPath}/plugins/php/versions/lib.sh $version restart
echo '==============================================='
echo 'successful!'
}
if [ "$actionType" == 'install' ];then
Install_lib
elif [ "$actionType" == 'uninstall' ];then
Uninstall_lib
fi
+3 -2
View File
@@ -59,7 +59,7 @@ Install_lib()
echo "[${LIBNAME}]" >> $serverPath/php/$version/etc/php.ini
echo "extension=${LIBNAME}.so" >> $serverPath/php/$version/etc/php.ini
$serverPath/php/init.d/php$version reload
bash ${rootPath}/plugins/php/versions/lib.sh $version restart
echo '==========================================================='
echo 'successful!'
}
@@ -82,7 +82,8 @@ Uninstall_lib()
sed -i $BAK "/${LIBNAME}/d" $serverPath/php/$version/etc/php.ini
rm -f $extFile
$serverPath/php/init.d/php$version reload
bash ${rootPath}/plugins/php/versions/lib.sh $version restart
echo '==============================================='
echo 'successful!'
}
+3 -2
View File
@@ -61,7 +61,7 @@ Install_lib()
echo "[${LIBNAME}]" >> $serverPath/php/$version/etc/php.ini
echo "extension=${LIBNAME}.so" >> $serverPath/php/$version/etc/php.ini
$serverPath/php/init.d/php$version reload
bash ${rootPath}/plugins/php/versions/lib.sh $version restart
echo '==========================================================='
echo 'successful!'
}
@@ -85,7 +85,8 @@ Uninstall_lib()
sed -i $BAK "/${LIBNAME}/d" $serverPath/php/$version/etc/php.ini
rm -f $extFile
$serverPath/php/init.d/php$version reload
bash ${rootPath}/plugins/php/versions/lib.sh $version restart
echo '==============================================='
echo 'successful!'
}
+2 -2
View File
@@ -66,7 +66,7 @@ Install_lib()
echo "${LIBNAME}.output_dir=/tmp/xhprof" >> $serverPath/php/$version/etc/php.ini
$serverPath/php/init.d/php$version reload
bash ${rootPath}/plugins/php/versions/lib.sh $version restart
echo '==========================================================='
echo 'successful!'
}
@@ -90,7 +90,7 @@ Uninstall_lib()
rm -f $extFile
$serverPath/php/init.d/php$version reload
bash ${rootPath}/plugins/php/versions/lib.sh $version restart
echo '==============================================='
echo 'successful!'
}
+2 -2
View File
@@ -67,7 +67,7 @@ Install_lib()
echo "zend_loader.obfuscation_level_support=3" >> $serverPath/php/$version/etc/php.ini
echo "zend_loader.license_path=" >> $serverPath/php/$version/etc/php.ini
$serverPath/php/init.d/php$version reload
bash ${rootPath}/plugins/php/versions/lib.sh $version restart
echo '==========================================================='
echo 'successful!'
}
@@ -90,7 +90,7 @@ Uninstall_lib()
sed -i $BAK "/\[Zend ZendGuard Loader\]/d" $serverPath/php/$version/etc/php.ini
rm -f $extFile
$serverPath/php/init.d/php$version reload
bash ${rootPath}/plugins/php/versions/lib.sh $version restart
echo '==============================================='
echo 'successful!'
}
+2 -2
View File
@@ -61,7 +61,7 @@ Install_lib()
echo "[${LIBNAME}]" >> $serverPath/php/$version/etc/php.ini
echo "extension=${LIBNAME}.so" >> $serverPath/php/$version/etc/php.ini
$serverPath/php/init.d/php$version reload
bash ${rootPath}/plugins/php/versions/lib.sh $version restart
echo '==========================================================='
echo 'successful!'
}
@@ -85,7 +85,7 @@ Uninstall_lib()
sed -i $BAK "/${LIBNAME}/d" $serverPath/php/$version/etc/php.ini
rm -f $extFile
$serverPath/php/init.d/php$version reload
bash ${rootPath}/plugins/php/versions/lib.sh $version restart
echo '==============================================='
echo 'successful!'
}
+2 -2
View File
@@ -67,7 +67,7 @@ Install_lib()
echo "[${LIBNAME}]" >> $serverPath/php/$version/etc/php.ini
echo "extension=${LIBNAME}.so" >> $serverPath/php/$version/etc/php.ini
$serverPath/php/init.d/php$version reload
bash ${rootPath}/plugins/php/versions/lib.sh $version restart
echo '==========================================================='
echo 'successful!'
}
@@ -90,7 +90,7 @@ Uninstall_lib()
sed -i $BAK "/${LIBNAME}/d" $serverPath/php/$version/etc/php.ini
rm -f $extFile
$serverPath/php/init.d/php$version reload
bash ${rootPath}/plugins/php/versions/lib.sh $version restart
echo '==============================================='
echo 'successful!'
}
+105
View File
@@ -0,0 +1,105 @@
#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
curPath=`pwd`
appPath=$(dirname "$curPath")
rootPath=$(dirname "$curPath")
rootPath=$(dirname "$rootPath")
rootPath=$(dirname "$rootPath")
rootPath=$(dirname "$rootPath")
serverPath=$(dirname "$rootPath")
sourcePath=${serverPath}/source/php
actionType=$1
version=$2
LIBNAME=exif
LIBV=0
NON_ZTS_FILENAME=`ls $serverPath/php/${version}/lib/php/extensions | grep no-debug-non-zts`
extFile=$serverPath/php/${version}/lib/php/extensions/${NON_ZTS_FILENAME}/${LIBNAME}.so
sysName=`uname`
if [ "$sysName" == "Darwin" ];then
BAK='_bak'
else
BAK=''
fi
Install_lib()
{
isInstall=`cat $serverPath/php/$version/etc/php.ini|grep "${LIBNAME}.so"`
if [ "${isInstall}" != "" ];then
echo "php-$version 已安装${LIBNAME},请选择其它版本!"
return
fi
if [ ! -f "$extFile" ];then
if [ ! -d $sourcePath/php${version}/ext ];then
cd $serverPath/mdserver-web/plugins/php && /bin/bash install.sh install ${version}
fi
cd $sourcePath/php${version}/ext/${LIBNAME}
$serverPath/php/$version/bin/phpize
./configure --with-php-config=$serverPath/php/$version/bin/php-config
FIND_C99=`cat Makefile|grep c99`
if [ "$FIND_C99" == "" ];then
sed -i $BAK 's/CFLAGS \=/CFLAGS \= -std=c99/g' Makefile
fi
make && make install && make clean
fi
if [ ! -f "$extFile" ];then
echo "ERROR!"
return
fi
echo "" >> $serverPath/php/$version/etc/php.ini
echo "[${LIBNAME}]" >> $serverPath/php/$version/etc/php.ini
echo "extension=${LIBNAME}.so" >> $serverPath/php/$version/etc/php.ini
bash ${rootPath}/plugins/php/versions/lib.sh $version restart
echo '==========================================================='
echo 'successful!'
}
Uninstall_lib()
{
if [ ! -f "$serverPath/php/$version/bin/php-config" ];then
echo "php-$version 未安装,请选择其它版本!"
return
fi
if [ ! -f "$extFile" ];then
echo "php-$version 未安装${LIBNAME},请选择其它版本!"
return
fi
echo $serverPath/php/$version/etc/php.ini
sed -i $BAK "/${LIBNAME}.so/d" $serverPath/php/$version/etc/php.ini
sed -i $BAK "/${LIBNAME}/d" $serverPath/php/$version/etc/php.ini
rm -f $extFile
bash ${rootPath}/plugins/php/versions/lib.sh $version restart
echo '==============================================='
echo 'successful!'
}
if [ "$actionType" == 'install' ];then
Install_lib
elif [ "$actionType" == 'uninstall' ];then
Uninstall_lib
fi
+4 -2
View File
@@ -66,7 +66,7 @@ Install_lib()
echo "[${LIBNAME}]" >> $serverPath/php/$version/etc/php.ini
echo "extension=${LIBNAME}.so" >> $serverPath/php/$version/etc/php.ini
$serverPath/php/init.d/php$version reload
bash ${rootPath}/plugins/php/versions/lib.sh $version restart
echo '==========================================================='
echo 'successful!'
}
@@ -89,7 +89,9 @@ Uninstall_lib()
sed -i $BAK "/${LIBNAME}/d" $serverPath/php/$version/etc/php.ini
rm -f $extFile
$serverPath/php/init.d/php$version reload
bash ${rootPath}/plugins/php/versions/lib.sh $version restart
echo '==============================================='
echo 'successful!'
}
+2 -2
View File
@@ -63,7 +63,7 @@ Install_lib()
echo "[${LIBNAME}]" >> $serverPath/php/$version/etc/php.ini
echo "extension=${LIBNAME}.so" >> $serverPath/php/$version/etc/php.ini
$serverPath/php/init.d/php$version reload
bash ${rootPath}/plugins/php/versions/lib.sh $version restart
echo '==========================================================='
echo 'successful!'
}
@@ -86,7 +86,7 @@ Uninstall_lib()
sed -i $BAK "/${LIBNAME}/d" $serverPath/php/$version/etc/php.ini
rm -f $extFile
$serverPath/php/init.d/php$version reload
bash ${rootPath}/plugins/php/versions/lib.sh $version restart
echo '==============================================='
echo 'successful!'
}
+2 -2
View File
@@ -60,7 +60,7 @@ Install_lib()
echo "[${LIBNAME}]" >> $serverPath/php/$version/etc/php.ini
echo "zend_extension=${LIBNAME}.so" >> $serverPath/php/$version/etc/php.ini
$serverPath/php/init.d/php$version reload
bash ${rootPath}/plugins/php/versions/lib.sh $version restart
echo '==========================================================='
echo 'successful!'
}
@@ -83,7 +83,7 @@ Uninstall_lib()
sed -i $BAK "/${LIBNAME}/d" $serverPath/php/$version/etc/php.ini
rm -f $extFile
$serverPath/php/init.d/php$version reload
bash ${rootPath}/plugins/php/versions/lib.sh $version restart
echo '==============================================='
echo 'successful!'
}
+2 -2
View File
@@ -57,7 +57,7 @@ Install_lib()
echo "extension=${LIBNAME}.so" >> $serverPath/php/$version/etc/php.ini
$serverPath/php/init.d/php$version reload
bash ${rootPath}/plugins/php/versions/lib.sh $version restart
echo '==========================================================='
echo 'successful!'
}
@@ -80,7 +80,7 @@ Uninstall_lib()
sed -i $BAK "/${LIBNAME}/d" $serverPath/php/$version/etc/php.ini
rm -f $extFile
$serverPath/php/init.d/php$version reload
bash ${rootPath}/plugins/php/versions/lib.sh $version restart
echo '==============================================='
echo 'successful!'
}
+2 -2
View File
@@ -61,7 +61,7 @@ Install_lib()
echo "[${LIBNAME}]" >> $serverPath/php/$version/etc/php.ini
echo "extension=${LIBNAME}.so" >> $serverPath/php/$version/etc/php.ini
$serverPath/php/init.d/php$version reload
bash ${rootPath}/plugins/php/versions/lib.sh $version restart
echo '==========================================================='
echo 'successful!'
}
@@ -84,7 +84,7 @@ Uninstall_lib()
sed -i $BAK "/${LIBNAME}/d" $serverPath/php/$version/etc/php.ini
rm -f $extFile
$serverPath/php/init.d/php$version reload
bash ${rootPath}/plugins/php/versions/lib.sh $version restart
echo '==============================================='
echo 'successful!'
}
+3 -2
View File
@@ -68,7 +68,7 @@ Install_lib()
echo "[${LIBNAME}]" >> $serverPath/php/$version/etc/php.ini
echo "extension=${LIBNAME}.so" >> $serverPath/php/$version/etc/php.ini
$serverPath/php/init.d/php$version reload
bash ${rootPath}/plugins/php/versions/lib.sh $version restart
echo '==========================================================='
echo 'successful!'
}
@@ -91,7 +91,8 @@ Uninstall_lib()
sed -i $BAK "/${LIBNAME}/d" $serverPath/php/$version/etc/php.ini
rm -f $extFile
$serverPath/php/init.d/php$version reload
bash ${rootPath}/plugins/php/versions/lib.sh $version restart
echo '==============================================='
echo 'successful!'
}
+2 -2
View File
@@ -72,7 +72,7 @@ Install_lib()
echo "opcache.fast_shutdown=1" >> $serverPath/php/$version/etc/php.ini
echo "opcache.enable_cli=1" >> $serverPath/php/$version/etc/php.ini
$serverPath/php/init.d/php$version reload
bash ${rootPath}/plugins/php/versions/lib.sh $version restart
echo '==========================================================='
echo 'successful!'
}
@@ -96,7 +96,7 @@ Uninstall_lib()
rm -f $extFile
$serverPath/php/init.d/php$version reload
bash ${rootPath}/plugins/php/versions/lib.sh $version restart
echo '==============================================='
echo 'successful!'
}
+104
View File
@@ -0,0 +1,104 @@
#!/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")
rootPath=$(dirname "$rootPath")
rootPath=$(dirname "$rootPath")
serverPath=$(dirname "$rootPath")
sourcePath=${serverPath}/source/php
actionType=$1
version=$2
LIBNAME=openssl
LIBV=0
NON_ZTS_FILENAME=`ls $serverPath/php/${version}/lib/php/extensions | grep no-debug-non-zts`
extFile=$serverPath/php/${version}/lib/php/extensions/${NON_ZTS_FILENAME}/${LIBNAME}.so
sysName=`uname`
if [ "$sysName" == "Darwin" ];then
BAK='_bak'
else
BAK=''
fi
Install_lib()
{
isInstall=`cat $serverPath/php/$version/etc/php.ini|grep "${LIBNAME}.so"`
if [ "${isInstall}" != "" ];then
echo "php-$version 已安装${LIBNAME},请选择其它版本!"
return
fi
cd $serverPath/mdserver-web/plugins/php/lib && /bin/bash openssl_10.sh
if [ ! -f "$extFile" ];then
if [ ! -d $sourcePath/php${version}/ext ];then
cd $serverPath/mdserver-web/plugins/php && /bin/bash install.sh install ${version}
fi
cd $sourcePath/php${version}/ext/${LIBNAME}
if [ ! -f "config.m4" ];then
mv config0.m4 config.m4
fi
export PKG_CONFIG_PATH=$serverPath/lib/openssl10/lib/pkgconfig
$serverPath/php/$version/bin/phpize
./configure --with-php-config=$serverPath/php/$version/bin/php-config \
--with-openssl
make clean && make && make install && make clean
fi
if [ ! -f "$extFile" ];then
echo "ERROR!"
return
fi
echo "" >> $serverPath/php/$version/etc/php.ini
echo "[${LIBNAME}]" >> $serverPath/php/$version/etc/php.ini
echo "extension=${LIBNAME}.so" >> $serverPath/php/$version/etc/php.ini
bash ${rootPath}/plugins/php/versions/lib.sh $version restart
echo '==========================================================='
echo 'successful!'
}
Uninstall_lib()
{
if [ ! -f "$serverPath/php/$version/bin/php-config" ];then
echo "php-$version 未安装,请选择其它版本!"
return
fi
if [ ! -f "$extFile" ];then
echo "php-$version 未安装${LIBNAME},请选择其它版本!"
return
fi
echo $serverPath/php/$version/etc/php.ini
sed -i $BAK "/${LIBNAME}.so/d" $serverPath/php/$version/etc/php.ini
sed -i $BAK "/${LIBNAME}/d" $serverPath/php/$version/etc/php.ini
rm -f $extFile
bash ${rootPath}/plugins/php/versions/lib.sh $version restart
echo '==============================================='
echo 'successful!'
}
if [ "$actionType" == 'install' ];then
Install_lib
elif [ "$actionType" == 'uninstall' ];then
Uninstall_lib
fi
+2 -2
View File
@@ -59,7 +59,7 @@ Install_lib()
echo "[${LIBNAME}]" >> $serverPath/php/$version/etc/php.ini
echo "extension=${LIBNAME}.so" >> $serverPath/php/$version/etc/php.ini
$serverPath/php/init.d/php$version reload
bash ${rootPath}/plugins/php/versions/lib.sh $version restart
echo '==========================================================='
echo 'successful!'
}
@@ -82,7 +82,7 @@ Uninstall_lib()
sed -i $BAK "/${LIBNAME}/d" $serverPath/php/$version/etc/php.ini
rm -f $extFile
$serverPath/php/init.d/php$version reload
bash ${rootPath}/plugins/php/versions/lib.sh $version restart
echo '==============================================='
echo 'successful!'
}
+2 -2
View File
@@ -62,7 +62,7 @@ Install_lib()
echo "[${LIBNAME}]" >> $serverPath/php/$version/etc/php.ini
echo "extension=${LIBNAME}.so" >> $serverPath/php/$version/etc/php.ini
$serverPath/php/init.d/php$version reload
bash ${rootPath}/plugins/php/versions/lib.sh $version restart
echo '==========================================================='
echo 'successful!'
}
@@ -86,7 +86,7 @@ Uninstall_lib()
sed -i $BAK "/${LIBNAME}/d" $serverPath/php/$version/etc/php.ini
rm -f $extFile
$serverPath/php/init.d/php$version reload
bash ${rootPath}/plugins/php/versions/lib.sh $version restart
echo '==============================================='
echo 'successful!'
}
+2 -2
View File
@@ -69,7 +69,7 @@ Install_lib()
echo "[${_LIBNAME}]" >> $serverPath/php/$version/etc/php.ini
echo "extension=${_LIBNAME}.so" >> $serverPath/php/$version/etc/php.ini
$serverPath/php/init.d/php$version reload
bash ${rootPath}/plugins/php/versions/lib.sh $version restart
echo '==========================================================='
echo 'successful!'
}
@@ -93,7 +93,7 @@ Uninstall_lib()
sed -i $BAK "/${_LIBNAME}/d" $serverPath/php/$version/etc/php.ini
rm -f $extFile
$serverPath/php/init.d/php$version reload
bash ${rootPath}/plugins/php/versions/lib.sh $version restart
echo '==============================================='
echo 'successful!'
}
+2 -2
View File
@@ -67,7 +67,7 @@ Install_lib()
echo "[${LIBNAME}]" >> $serverPath/php/$version/etc/php.ini
echo "extension=${LIBNAME}.so" >> $serverPath/php/$version/etc/php.ini
$serverPath/php/init.d/php$version reload
bash ${rootPath}/plugins/php/versions/lib.sh $version restart
echo '==========================================================='
echo 'successful!'
}
@@ -91,7 +91,7 @@ Uninstall_lib()
sed -i $BAK "/${LIBNAME}/d" $serverPath/php/$version/etc/php.ini
rm -f $extFile
$serverPath/php/init.d/php$version reload
bash ${rootPath}/plugins/php/versions/lib.sh $version restart
echo '==============================================='
echo 'successful!'
}
+2 -2
View File
@@ -79,7 +79,7 @@ Install_lib()
echo "[${LIBNAME}]" >> $serverPath/php/$version/etc/php.ini
echo "extension=${LIBNAME}.so" >> $serverPath/php/$version/etc/php.ini
$serverPath/php/init.d/php$version reload
bash ${rootPath}/plugins/php/versions/lib.sh $version restart
echo '==========================================================='
echo 'successful!'
}
@@ -103,7 +103,7 @@ Uninstall_lib()
sed -i $BAK "/${LIBNAME}/d" $serverPath/php/$version/etc/php.ini
rm -f $extFile
$serverPath/php/init.d/php$version reload
bash ${rootPath}/plugins/php/versions/lib.sh $version restart
echo '==============================================='
echo 'successful!'
}
+3 -3
View File
@@ -60,9 +60,9 @@ Install_lib()
echo "" >> $serverPath/php/$version/etc/php.ini
echo "[${LIBNAME}]" >> $serverPath/php/$version/etc/php.ini
echo "extension=${LIBNAME}.so" >> $serverPath/php/$version/etc/php.ini
echo "zend_extension=${LIBNAME}.so" >> $serverPath/php/$version/etc/php.ini
$serverPath/php/init.d/php$version reload
bash ${rootPath}/plugins/php/versions/lib.sh $version restart
echo '==========================================================='
echo 'successful!'
}
@@ -85,7 +85,7 @@ Uninstall_lib()
sed -i $BAK "/${LIBNAME}/d" $serverPath/php/$version/etc/php.ini
rm -f $extFile
$serverPath/php/init.d/php$version reload
bash ${rootPath}/plugins/php/versions/lib.sh $version restart
echo '==============================================='
echo 'successful!'
}
+2 -2
View File
@@ -66,7 +66,7 @@ Install_lib()
echo "${LIBNAME}.output_dir=/tmp/xhprof" >> $serverPath/php/$version/etc/php.ini
$serverPath/php/init.d/php$version reload
bash ${rootPath}/plugins/php/versions/lib.sh $version restart
echo '==========================================================='
echo 'successful!'
}
@@ -90,7 +90,7 @@ Uninstall_lib()
rm -f $extFile
$serverPath/php/init.d/php$version reload
bash ${rootPath}/plugins/php/versions/lib.sh $version restart
echo '==============================================='
echo 'successful!'
}
+2 -2
View File
@@ -67,7 +67,7 @@ Install_lib()
echo "extension=${LIBNAME}.so" >> $serverPath/php/$version/etc/php.ini
echo "yaf.use_namespace=1" >> $serverPath/php/$version/etc/php.ini
$serverPath/php/init.d/php$version reload
bash ${rootPath}/plugins/php/versions/lib.sh $version restart
echo '==========================================================='
echo 'successful!'
}
@@ -92,7 +92,7 @@ Uninstall_lib()
sed -i $BAK "/\[yaf\]/d" $serverPath/php/$version/etc/php.ini
rm -f $extFile
$serverPath/php/init.d/php$version reload
bash ${rootPath}/plugins/php/versions/lib.sh $version restart
echo '==============================================='
echo 'successful!'
}
+2 -2
View File
@@ -69,7 +69,7 @@ Install_lib()
echo "extension=${LIBNAME}.so" >> $serverPath/php/$version/etc/php.ini
echo "${LIBNAME}.expose_info=false" >> $serverPath/php/$version/etc/php.ini
$serverPath/php/init.d/php$version reload
bash ${rootPath}/plugins/php/versions/lib.sh $version restart
echo '==========================================================='
echo 'successful!'
}
@@ -94,7 +94,7 @@ Uninstall_lib()
sed -i $BAK "/\[${LIBNAME}\]/d" $serverPath/php/$version/etc/php.ini
rm -f $extFile
$serverPath/php/init.d/php$version reload
bash ${rootPath}/plugins/php/versions/lib.sh $version restart
echo '==============================================='
echo 'successful!'
}
+2 -2
View File
@@ -66,7 +66,7 @@ Install_lib()
echo "zend_loader.obfuscation_level_support=3" >> $serverPath/php/$version/etc/php.ini
echo "zend_loader.license_path=" >> $serverPath/php/$version/etc/php.ini
$serverPath/php/init.d/php$version reload
bash ${rootPath}/plugins/php/versions/lib.sh $version restart
echo '==========================================================='
echo 'successful!'
}
@@ -89,7 +89,7 @@ Uninstall_lib()
sed -i $BAK "/\[Zend ZendGuard Loader\]/d" $serverPath/php/$version/etc/php.ini
rm -f $extFile
$serverPath/php/init.d/php$version reload
bash ${rootPath}/plugins/php/versions/lib.sh $version restart
echo '==============================================='
echo 'successful!'
}
+2 -2
View File
@@ -59,7 +59,7 @@ Install_lib()
echo "[${LIBNAME}]" >> $serverPath/php/$version/etc/php.ini
echo "extension=${LIBNAME}.so" >> $serverPath/php/$version/etc/php.ini
$serverPath/php/init.d/php$version reload
bash ${rootPath}/plugins/php/versions/lib.sh $version restart
echo '==========================================================='
echo 'successful!'
}
@@ -83,7 +83,7 @@ Uninstall_lib()
sed -i $BAK "/${LIBNAME}/d" $serverPath/php/$version/etc/php.ini
rm -f $extFile
$serverPath/php/init.d/php$version reload
bash ${rootPath}/plugins/php/versions/lib.sh $version restart
echo '==============================================='
echo 'successful!'
}
+3 -2
View File
@@ -68,7 +68,7 @@ Install_lib()
echo "[${LIBNAME}]" >> $serverPath/php/$version/etc/php.ini
echo "extension=${LIBNAME}.so" >> $serverPath/php/$version/etc/php.ini
$serverPath/php/init.d/php$version reload
bash ${rootPath}/plugins/php/versions/lib.sh $version restart
echo '==========================================================='
echo 'successful!'
}
@@ -91,7 +91,8 @@ Uninstall_lib()
sed -i $BAK "/${LIBNAME}/d" $serverPath/php/$version/etc/php.ini
rm -f $extFile
$serverPath/php/init.d/php$version reload
bash ${rootPath}/plugins/php/versions/lib.sh $version restart
echo '==============================================='
echo 'successful!'
}
+2 -2
View File
@@ -66,7 +66,7 @@ Install_lib()
echo "[${LIBNAME}]" >> $serverPath/php/$version/etc/php.ini
echo "extension=${LIBNAME}.so" >> $serverPath/php/$version/etc/php.ini
$serverPath/php/init.d/php$version reload
bash ${rootPath}/plugins/php/versions/lib.sh $version restart
echo '==========================================================='
echo 'successful!'
}
@@ -89,7 +89,7 @@ Uninstall_lib()
sed -i $BAK "/${LIBNAME}/d" $serverPath/php/$version/etc/php.ini
rm -f $extFile
$serverPath/php/init.d/php$version reload
bash ${rootPath}/plugins/php/versions/lib.sh $version restart
echo '==============================================='
echo 'successful!'
}
+2 -2
View File
@@ -60,7 +60,7 @@ Install_lib()
echo "[${LIBNAME}]" >> $serverPath/php/$version/etc/php.ini
echo "extension=${LIBNAME}.so" >> $serverPath/php/$version/etc/php.ini
$serverPath/php/init.d/php$version reload
bash ${rootPath}/plugins/php/versions/lib.sh $version restart
echo '==========================================================='
echo 'successful!'
}
@@ -83,7 +83,7 @@ Uninstall_lib()
sed -i $BAK "/${LIBNAME}/d" $serverPath/php/$version/etc/php.ini
rm -f $extFile
$serverPath/php/init.d/php$version reload
bash ${rootPath}/plugins/php/versions/lib.sh $version restart
echo '==============================================='
echo 'successful!'
}
+2 -2
View File
@@ -64,7 +64,7 @@ Install_lib()
echo "[${LIBNAME}]" >> $serverPath/php/$version/etc/php.ini
echo "extension=${LIBNAME}.so" >> $serverPath/php/$version/etc/php.ini
$serverPath/php/init.d/php$version reload
bash ${rootPath}/plugins/php/versions/lib.sh $version restart
echo '==========================================================='
echo 'successful!'
}
@@ -87,7 +87,7 @@ Uninstall_lib()
sed -i $BAK "/${LIBNAME}/d" $serverPath/php/$version/etc/php.ini
rm -f $extFile
$serverPath/php/init.d/php$version reload
bash ${rootPath}/plugins/php/versions/lib.sh $version restart
echo '==============================================='
echo 'successful!'
}
+2 -2
View File
@@ -60,7 +60,7 @@ Install_lib()
echo "[${LIBNAME}]" >> $serverPath/php/$version/etc/php.ini
echo "zend_extension=${LIBNAME}.so" >> $serverPath/php/$version/etc/php.ini
$serverPath/php/init.d/php$version reload
bash ${rootPath}/plugins/php/versions/lib.sh $version restart
echo '==========================================================='
echo 'successful!'
}
@@ -83,7 +83,7 @@ Uninstall_lib()
sed -i $BAK "/${LIBNAME}/d" $serverPath/php/$version/etc/php.ini
rm -f $extFile
$serverPath/php/init.d/php$version reload
bash ${rootPath}/plugins/php/versions/lib.sh $version restart
echo '==============================================='
echo 'successful!'
}
+2 -2
View File
@@ -61,7 +61,7 @@ Install_lib()
echo "[${LIBNAME}]" >> $serverPath/php/$version/etc/php.ini
echo "extension=${LIBNAME}.so" >> $serverPath/php/$version/etc/php.ini
$serverPath/php/init.d/php$version reload
bash ${rootPath}/plugins/php/versions/lib.sh $version restart
echo '==========================================================='
echo 'successful!'
}
@@ -84,7 +84,7 @@ Uninstall_lib()
sed -i $BAK "/${LIBNAME}/d" $serverPath/php/$version/etc/php.ini
rm -f $extFile
$serverPath/php/init.d/php$version reload
bash ${rootPath}/plugins/php/versions/lib.sh $version restart
echo '==============================================='
echo 'successful!'
}
+2 -2
View File
@@ -61,7 +61,7 @@ Install_lib()
echo "[${LIBNAME}]" >> $serverPath/php/$version/etc/php.ini
echo "extension=${LIBNAME}.so" >> $serverPath/php/$version/etc/php.ini
$serverPath/php/init.d/php$version reload
bash ${rootPath}/plugins/php/versions/lib.sh $version restart
echo '==========================================================='
echo 'successful!'
}
@@ -84,7 +84,7 @@ Uninstall_lib()
sed -i $BAK "/${LIBNAME}/d" $serverPath/php/$version/etc/php.ini
rm -f $extFile
$serverPath/php/init.d/php$version reload
bash ${rootPath}/plugins/php/versions/lib.sh $version restart
echo '==============================================='
echo 'successful!'
}
+2 -2
View File
@@ -67,7 +67,7 @@ Install_lib()
echo "[${LIBNAME}]" >> $serverPath/php/$version/etc/php.ini
echo "extension=${LIBNAME}.so" >> $serverPath/php/$version/etc/php.ini
$serverPath/php/init.d/php$version reload
bash ${rootPath}/plugins/php/versions/lib.sh $version restart
echo '==========================================================='
echo 'successful!'
}
@@ -90,7 +90,7 @@ Uninstall_lib()
sed -i $BAK "/${LIBNAME}/d" $serverPath/php/$version/etc/php.ini
rm -f $extFile
$serverPath/php/init.d/php$version reload
bash ${rootPath}/plugins/php/versions/lib.sh $version restart
echo '==============================================='
echo 'successful!'
}
+2 -2
View File
@@ -71,7 +71,7 @@ Install_lib()
echo "opcache.fast_shutdown=1" >> $serverPath/php/$version/etc/php.ini
echo "opcache.enable_cli=1" >> $serverPath/php/$version/etc/php.ini
$serverPath/php/init.d/php$version reload
bash ${rootPath}/plugins/php/versions/lib.sh $version restart
echo '==========================================================='
echo 'successful!'
}
@@ -95,7 +95,7 @@ Uninstall_lib()
rm -f $extFile
$serverPath/php/init.d/php$version reload
bash ${rootPath}/plugins/php/versions/lib.sh $version restart
echo '==============================================='
echo 'successful!'
}
+104
View File
@@ -0,0 +1,104 @@
#!/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")
rootPath=$(dirname "$rootPath")
rootPath=$(dirname "$rootPath")
serverPath=$(dirname "$rootPath")
sourcePath=${serverPath}/source/php
actionType=$1
version=$2
LIBNAME=openssl
LIBV=0
NON_ZTS_FILENAME=`ls $serverPath/php/${version}/lib/php/extensions | grep no-debug-non-zts`
extFile=$serverPath/php/${version}/lib/php/extensions/${NON_ZTS_FILENAME}/${LIBNAME}.so
sysName=`uname`
if [ "$sysName" == "Darwin" ];then
BAK='_bak'
else
BAK=''
fi
Install_lib()
{
isInstall=`cat $serverPath/php/$version/etc/php.ini|grep "${LIBNAME}.so"`
if [ "${isInstall}" != "" ];then
echo "php-$version 已安装${LIBNAME},请选择其它版本!"
return
fi
cd $serverPath/mdserver-web/plugins/php/lib && /bin/bash openssl_10.sh
if [ ! -f "$extFile" ];then
if [ ! -d $sourcePath/php${version}/ext ];then
cd $serverPath/mdserver-web/plugins/php && /bin/bash install.sh install ${version}
fi
cd $sourcePath/php${version}/ext/${LIBNAME}
if [ ! -f "config.m4" ];then
mv config0.m4 config.m4
fi
export PKG_CONFIG_PATH=$serverPath/lib/openssl10/lib/pkgconfig
$serverPath/php/$version/bin/phpize
./configure --with-php-config=$serverPath/php/$version/bin/php-config \
--with-openssl
make clean && make && make install && make clean
fi
if [ ! -f "$extFile" ];then
echo "ERROR!"
return
fi
echo "" >> $serverPath/php/$version/etc/php.ini
echo "[${LIBNAME}]" >> $serverPath/php/$version/etc/php.ini
echo "extension=${LIBNAME}.so" >> $serverPath/php/$version/etc/php.ini
bash ${rootPath}/plugins/php/versions/lib.sh $version restart
echo '==========================================================='
echo 'successful!'
}
Uninstall_lib()
{
if [ ! -f "$serverPath/php/$version/bin/php-config" ];then
echo "php-$version 未安装,请选择其它版本!"
return
fi
if [ ! -f "$extFile" ];then
echo "php-$version 未安装${LIBNAME},请选择其它版本!"
return
fi
echo $serverPath/php/$version/etc/php.ini
sed -i $BAK "/${LIBNAME}.so/d" $serverPath/php/$version/etc/php.ini
sed -i $BAK "/${LIBNAME}/d" $serverPath/php/$version/etc/php.ini
rm -f $extFile
bash ${rootPath}/plugins/php/versions/lib.sh $version restart
echo '==============================================='
echo 'successful!'
}
if [ "$actionType" == 'install' ];then
Install_lib
elif [ "$actionType" == 'uninstall' ];then
Uninstall_lib
fi
+2 -2
View File
@@ -59,7 +59,7 @@ Install_lib()
echo "[${LIBNAME}]" >> $serverPath/php/$version/etc/php.ini
echo "extension=${LIBNAME}.so" >> $serverPath/php/$version/etc/php.ini
$serverPath/php/init.d/php$version reload
bash ${rootPath}/plugins/php/versions/lib.sh $version restart
echo '==========================================================='
echo 'successful!'
}
@@ -82,7 +82,7 @@ Uninstall_lib()
sed -i $BAK "/${LIBNAME}/d" $serverPath/php/$version/etc/php.ini
rm -f $extFile
$serverPath/php/init.d/php$version reload
bash ${rootPath}/plugins/php/versions/lib.sh $version restart
echo '==============================================='
echo 'successful!'
}

Some files were not shown because too many files have changed in this diff Show More