This commit is contained in:
hiCasper
2022-12-13 13:05:22 +08:00
24 changed files with 499 additions and 187 deletions
+9 -10
View File
@@ -2,6 +2,7 @@
<img alt="logo" src="https://cdn.jsdelivr.net/gh/midoks/mdserver-web@latest/route/static/logo.png" height="140" />
<h3 align="center">mdserver-web</h3>
<p align="center">一款简单Linux面板服务</p>
<p align="center">强烈推荐系统:debian</p>
</p>
### 简介
@@ -10,10 +11,11 @@
复制了后台管理界面,按照自己想要的方式写了一版。
![CentOS](https://img.shields.io/badge/LINUX-CentOS-blue?style=for-the-badge&logo=CentOS)
![Ubuntu](https://img.shields.io/badge/LINUX-Ubuntu-blue?style=for-the-badge&logo=Ubuntu)
![Debian](https://img.shields.io/badge/LINUX-Debian-blue?style=for-the-badge&logo=Debian)
![Ubuntu](https://img.shields.io/badge/LINUX-Ubuntu-blue?style=for-the-badge&logo=Ubuntu)
![Fedora](https://img.shields.io/badge/LINUX-Fedora-blue?style=for-the-badge&logo=Fedora)
![CentOS](https://img.shields.io/badge/LINUX-CentOS-blue?style=for-the-badge&logo=CentOS)
[![Wiki](https://img.shields.io/badge/MW-Wiki-red?style=for-the-badge&logo=wiki)](https://github.com/midoks/mdserver-web/wiki)
[![](https://data.jsdelivr.com/v1/package/gh/midoks/mdserver-web/badge?style=for-the-badge)](https://www.jsdelivr.com/package/gh/midoks/mdserver-web)
@@ -90,15 +92,12 @@ docker run -itd --name mw-server --privileged=true -p 7200:7200 -p 80:80 -p 443:
```
### 版本更新 0.11.2
### 版本更新 0.11.4
* redis安全强化。
* 添加php命令行设置。
* 域名绑定。
* Gitea优化。
* 网站统计优化。
* centos9下php-gd安装优化。
* php82rc7测试版。
* PHP82正式释出。
* PHP-fileinfo扩展优化。
* 删除任务时删除日志。
* 优化修改密码后的显示问题(#288)。
### JSDelivr安装地址
+128 -27
View File
@@ -27,7 +27,7 @@ from flask import request
class config_api:
__version = '0.11.2'
__version = '0.11.4'
__api_addr = 'data/api.json'
def __init__(self):
@@ -89,21 +89,6 @@ class config_api:
return mw.returnJson(True, '修改成功!')
return mw.returnJson(False, '修改失败!')
def setPanelDomainApi(self):
domain = request.form.get('domain', '')
cfg_domain = 'data/bind_domain.pl'
if domain == '':
os.remove(cfg_domain)
return mw.returnJson(True, '清空域名成功!')
reg = r"^([\w\-\*]{1,100}\.){1,4}(\w{1,10}|\w{1,10}\.\w{1,10})$"
if not re.match(reg, domain):
return mw.returnJson(False, '主域名格式不正确')
mw.writeFile(cfg_domain, domain)
return mw.returnJson(True, '设置域名成功!')
def syncDateApi(self):
if mw.isAppleSystem():
return mw.returnJson(True, '开发系统不必同步时间!')
@@ -150,7 +135,8 @@ class config_api:
import system_api
import firewall_api
if os.path.exists("/lib/systemd/system/firewalld.service"):
sysCfgDir = mw.systemdCfgDir()
if os.path.exists(sysCfgDir + "/firewalld.service"):
if not firewall_api.firewall_api().getFwStatus():
return mw.returnJson(False, 'firewalld必须先启动!')
@@ -257,7 +243,8 @@ class config_api:
import system_api
import firewall_api
if os.path.exists("/lib/systemd/system/firewalld.service"):
sysCfgDir = mw.systemdCfgDir()
if os.path.exists(sysCfgDir + "/firewalld.service"):
if not firewall_api.firewall_api().getFwStatus():
return mw.returnJson(False, 'firewalld必须先启动!')
@@ -355,24 +342,32 @@ class config_api:
def getPanelSslApi(self):
cert = {}
if not os.path.exists('ssl/certificate.pem'):
keyPath = 'ssl/private.pem'
certPath = 'ssl/cert.pem'
if not os.path.exists(certPath):
mw.createSSL()
cert['privateKey'] = mw.readFile('ssl/privateKey.pem')
cert['certPem'] = mw.readFile('ssl/certificate.pem')
cert['privateKey'] = mw.readFile(keyPath)
cert['certPem'] = mw.readFile(certPath)
cert['rep'] = os.path.exists('ssl/input.pl')
cert['info'] = mw.getCertName('ssl/certificate.pem')
cert['info'] = mw.getCertName(certPath)
return mw.getJson(cert)
# 保存面板证书
def savePanelSslApi(self):
keyPath = 'ssl/privateKey.pem'
certPath = 'ssl/certificate.pem'
keyPath = 'ssl/private.pem'
certPath = 'ssl/cert.pem'
checkCert = '/tmp/cert.pl'
certPem = request.form.get('certPem', '').strip()
privateKey = request.form.get('privateKey', '').strip()
if(privateKey.find('KEY') == -1):
return mw.returnJson(False, '秘钥错误,请检查!')
if(certPem.find('CERTIFICATE') == -1):
return mw.returnJson(False, '证书错误,请检查!')
mw.writeFile(checkCert, certPem)
if privateKey:
mw.writeFile(keyPath, privateKey)
@@ -383,22 +378,128 @@ class config_api:
mw.writeFile('ssl/input.pl', 'True')
return mw.returnJson(True, '证书已保存!')
def setPanelDomainApi(self):
domain = request.form.get('domain', '')
panel_tpl = mw.getRunDir() + "/data/tpl/nginx_panel.conf"
dst_panel_path = mw.getServerDir() + "/web_conf/nginx/vhost/panel.conf"
cfg_domain = 'data/bind_domain.pl'
if domain == '':
os.remove(cfg_domain)
os.remove(dst_panel_path)
mw.restartWeb()
return mw.returnJson(True, '清空域名成功!')
reg = r"^([\w\-\*]{1,100}\.){1,4}(\w{1,10}|\w{1,10}\.\w{1,10})$"
if not re.match(reg, domain):
return mw.returnJson(False, '主域名格式不正确')
op_dir = mw.getServerDir() + "/openresty"
if not os.path.exists(op_dir):
return mw.returnJson(False, '依赖OpenResty,先安装启动它!')
content = mw.readFile(panel_tpl)
content = content.replace("{$PORT}", "80")
content = content.replace("{$SERVER_NAME}", domain)
content = content.replace("{$PANAL_PORT}", mw.readFile('data/port.pl'))
content = content.replace("{$LOGPATH}", mw.getRunDir() + '/logs')
content = content.replace("{$PANAL_ADDR}", mw.getRunDir())
mw.writeFile(dst_panel_path, content)
mw.restartWeb()
mw.writeFile(cfg_domain, domain)
return mw.returnJson(True, '设置域名成功!')
# 设置面板SSL
def setPanelSslApi(self):
sslConf = mw.getRunDir() + '/data/ssl.pl'
panel_tpl = mw.getRunDir() + "/data/tpl/nginx_panel.conf"
dst_panel_path = mw.getServerDir() + "/web_conf/nginx/vhost/panel.conf"
if os.path.exists(sslConf):
os.system('rm -f ' + sslConf)
mw.restartMw()
conf = mw.readFile(dst_panel_path)
if conf:
rep = "\s+ssl_certificate\s+.+;\s+ssl_certificate_key\s+.+;"
conf = re.sub(rep, '', conf)
rep = "\s+ssl_protocols\s+.+;\n"
conf = re.sub(rep, '', conf)
rep = "\s+ssl_ciphers\s+.+;\n"
conf = re.sub(rep, '', conf)
rep = "\s+ssl_prefer_server_ciphers\s+.+;\n"
conf = re.sub(rep, '', conf)
rep = "\s+ssl_session_cache\s+.+;\n"
conf = re.sub(rep, '', conf)
rep = "\s+ssl_session_timeout\s+.+;\n"
conf = re.sub(rep, '', conf)
rep = "\s+ssl_ecdh_curve\s+.+;\n"
conf = re.sub(rep, '', conf)
rep = "\s+ssl_session_tickets\s+.+;\n"
conf = re.sub(rep, '', conf)
rep = "\s+ssl_stapling\s+.+;\n"
conf = re.sub(rep, '', conf)
rep = "\s+ssl_stapling_verify\s+.+;\n"
conf = re.sub(rep, '', conf)
rep = "\s+ssl\s+on;"
conf = re.sub(rep, '', conf)
rep = "\s+error_page\s497.+;"
conf = re.sub(rep, '', conf)
rep = "\s+if.+server_port.+\n.+\n\s+\s*}"
conf = re.sub(rep, '', conf)
rep = "\s+listen\s+443.*;"
conf = re.sub(rep, '', conf)
rep = "\s+listen\s+\[\:\:\]\:443.*;"
conf = re.sub(rep, '', conf)
mw.writeFile(dst_panel_path, conf)
mw.writeLog('面板配置', '面板SSL关闭成功!')
mw.restartWeb()
return mw.returnJson(True, 'SSL已关闭,请使用http协议访问面板!')
else:
try:
if not os.path.exists('ssl/input.ssl'):
mw.createSSL()
mw.writeFile(sslConf, 'True')
keyPath = mw.getRunDir() + '/ssl/private.pem'
certPath = mw.getRunDir() + '/ssl/cert.pem'
conf = mw.readFile(dst_panel_path)
if conf:
if conf.find('ssl_certificate') == -1:
sslStr = """#error_page 404/404.html;
ssl_certificate %s;
ssl_certificate_key %s;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
ssl_prefer_server_ciphers on;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;
error_page 497 https://$host$request_uri;""" % (certPath, keyPath)
if(conf.find('ssl_certificate') != -1):
return mw.returnJson(True, 'SSL开启成功!')
conf = conf.replace('#error_page 404/404.html;', sslStr)
rep = "listen\s+([0-9]+)\s*[default_server]*;"
tmp = re.findall(rep, conf)
if not mw.inArray(tmp, '443'):
listen = re.search(rep, conf).group()
http_ssl = "\n\tlisten 443 ssl http2;"
http_ssl = http_ssl + "\n\tlisten [::]:443 ssl http2;"
conf = conf.replace(listen, listen + http_ssl)
mw.backFile(dst_panel_path)
mw.writeFile(dst_panel_path, conf)
isError = mw.checkWebConfig()
if(isError != True):
mw.restoreFile(dst_panel_path)
return mw.returnJson(False, '证书错误: <br><a style="color:red;">' + isError.replace("\n", '<br>') + '</a>')
except Exception as ex:
return mw.returnJson(False, '开启失败:' + str(ex))
mw.restartMw()
mw.restartWeb()
return mw.returnJson(True, '开启成功,请使用https协议访问面板!')
def getApi(self):
+8 -3
View File
@@ -97,11 +97,11 @@ class files_api:
import shutil
try:
shutil.move(sfile, dfile)
msg = mw.getInfo('移动文件或目录[{1}]到[{2}]成功!', (sfile, dfile,))
msg = mw.getInfo('移动或重名命文件[{1}]到[{2}]成功!', (sfile, dfile,))
mw.writeLog('文件管理', msg)
return mw.returnJson(True, '移动文件或目录成功!')
return mw.returnJson(True, '移动或重名命文件成功!')
except:
return mw.returnJson(False, '移动文件或目录失败!')
return mw.returnJson(False, '移动或重名命文件失败!')
def deleteApi(self):
path = request.form.get('path', '')
@@ -240,6 +240,11 @@ class files_api:
system_api.system_api().restartTask()
except:
system_api.system_api().restartTask()
# 删除日志
task_log = mw.getRunDir() + "/tmp/panelTask.pl"
if os.path.exists(task_log):
os.remove(task_log)
return mw.returnJson(True, '任务已删除!')
# 上传文件
+12 -3
View File
@@ -920,13 +920,22 @@ def checkDomainPanel():
tmp = getHost()
domain = readFile('data/bind_domain.pl')
port = readFile('data/port.pl').strip()
npid = getServerDir() + "/openresty/nginx/logs/nginx.pid"
if not os.path.exists(npid):
return False
nconf = getServerDir() + "/web_conf/nginx/vhost/panel.conf"
if os.path.exists(nconf):
port = "80"
if domain:
client_ip = getClientIp()
if client_ip in ['127.0.0.1', 'localhost', '::1']:
return False
if tmp.strip().lower() != domain.strip().lower():
from flask import Flask, redirect, request, url_for
to = "http://" + domain + ":" + port
to = "http://" + domain + ":" + str(port)
return redirect(to, code=302)
return False
@@ -1371,8 +1380,8 @@ def createSSL():
private_key = OpenSSL.crypto.dump_privatekey(
OpenSSL.crypto.FILETYPE_PEM, key)
if len(cert_ca) > 100 and len(private_key) > 100:
writeFile('ssl/certificate.pem', cert_ca, 'wb+')
writeFile('ssl/privateKey.pem', private_key, 'wb+')
writeFile('ssl/cert.pem', cert_ca, 'wb+')
writeFile('ssl/private.pem', private_key, 'wb+')
return True
return False
+4
View File
@@ -140,6 +140,10 @@ class site_api:
return mw.getJson(data)
def getCliPhpVersionApi(self):
php_dir = mw.getServerDir() + '/php'
if not os.path.exists(php_dir):
return mw.returnJson(False, '未安装PHP,无法设置')
php_bin = '/usr/bin/php'
php_versions = self.getPhpVersion()
php_versions = php_versions[1:]
+9 -14
View File
@@ -2,27 +2,22 @@ server
{
listen {$PORT};
listen [::]:{$PORT};
server_name {$SERVER_NAME};
index index.php index.html index.htm default.php default.htm default.html;
root {$ROOT_DIR};
#SSL-START
#error_page 404/404.html;
#SSL-END
#禁止访问的文件或目录
location ~ ^/(\.user.ini|\.htaccess|\.git|\.svn|\.project|LICENSE|README.md)
{
return 404;
#PROXY-START
location ^~ / {
proxy_pass http://0.0.0.0:{$PANAL_PORT}/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
}
#一键申请SSL证书验证目录相关设置
location ~ \.well-known{
allow all;
}
access_log {$LOGPATH}/{$SERVER_NAME}.log main;
#PROXY-END
error_log {$LOGPATH}/{$SERVER_NAME}.error.log;
}
+9 -3
View File
@@ -32,9 +32,9 @@ if [ ! -d $curPath/versions/$2 ];then
fi
if [ "${action}" == "install" ] && [ -d $serverPath/php/${type} ];then
exit 0
fi
# if [ "${action}" == "install" ] && [ -d $serverPath/php/${type} ];then
# exit 0
# fi
if [ "${action}" == "uninstall" ];then
@@ -71,6 +71,12 @@ if [ "${action}" == "install" ] && [ -d ${serverPath}/php/${type} ];then
cd ${rootPath}/plugins/php/versions/common && bash gettext.sh install ${type}
cd ${rootPath}/plugins/php/versions/common && bash redis.sh install ${type}
cd ${rootPath}/plugins/php/versions/common && bash memcached.sh install ${type}
cd ${rootPath}/plugins/php/versions/common && bash zlib.sh install ${type}
if [ "${type}" -gt "72" ];then
cd ${rootPath}/plugins/php/versions/common && bash zip.sh install ${type}
fi
echo "install PHP${type} extend end"
fi
+2 -3
View File
@@ -16,7 +16,7 @@ function version_lt() { test "$(echo "$@" | tr " " "\n" | sort -rV | head -n 1)"
function version_ge() { test "$(echo "$@" | tr " " "\n" | sort -rV | head -n 1)" == "$1"; }
version=8.2.0RC7
version=8.2.0
PHP_VER=82
Install_php()
{
@@ -32,8 +32,7 @@ cd ${rootPath}/plugins/php/lib && /bin/bash zlib.sh
if [ ! -d $sourcePath/php/php${PHP_VER} ];then
if [ ! -f $sourcePath/php/php-${version}.tar.xz ];then
# wget --no-check-certificate -O $sourcePath/php/php-${version}.tar.xz https://downloads.php.net/~pierrick/php-${version}.tar.xz
wget --no-check-certificate -O $sourcePath/php/php-${version}.tar.xz https://downloads.php.net/~pierrick/php-${version}.tar.xz
wget --no-check-certificate -O $sourcePath/php/php-${version}.tar.xz https://www.php.net/distributions/php-${version}.tar.xz
fi
cd $sourcePath/php && tar -Jxf $sourcePath/php/php-${version}.tar.xz
+17 -2
View File
@@ -49,6 +49,7 @@ Install_lib()
if [ ! -f "$extFile" ];then
if [ ! -d $sourcePath/php${version}/ext ];then
echo "cd ${rootPath}/plugins/php && /bin/bash install.sh install ${version}"
cd ${rootPath}/plugins/php && /bin/bash install.sh install ${version}
fi
@@ -57,9 +58,23 @@ Install_lib()
$serverPath/php/$version/bin/phpize
./configure --with-php-config=$serverPath/php/$version/bin/php-config
# It is considered as a temporary bug
if [ "$version" == "81" ] || [ "$version" == "82" ];then
bash ${rootPath}/scripts/getos.sh
OSNAME=`cat ${rootPath}/data/osname.pl`
if [ "$OSNAME" == 'centos' ];then
FILE_softmagic=$sourcePath/php${version}/ext/${LIBNAME}/libmagic/softmagic.c
FIND_UNDEF_STRNDUP=`cat $FILE_softmagic|grep '#undef strndup'`
if [ "$version" -gt "74" ] && [ "$FIND_UNDEF_STRNDUP" == "" ];then
sed -i $BAK "s/char \*strndup/#undef strndup\nchar \*strndup/g" $FILE_softmagic
fi
fi
fi
FIND_C99=`cat Makefile|grep c99`
if [ "$FIND_C99" == "" ];then
sed -i $BAK 's/CFLAGS \=/CFLAGS \= -std=c99/g' Makefile
if [ "$version" -gt "74" ] && [ "$FIND_C99" == "" ];then
sed -i $BAK 's/CFLAGS \=/CFLAGS \= -std=gnu99/g' Makefile
fi
make clean && make && make install && make clean
+1 -3
View File
@@ -20,12 +20,10 @@ LIBV=4.1.2
if [ "$version" -lt "73" ];then
echo "not support!"
exit 1
else
fi
if [ "$version" -gt "74" ];then
LIBV=5.1.2
else
echo "not support!"
fi
LIB_PATH_NAME=lib/php
+2
View File
@@ -21,6 +21,8 @@ if [ "$version" == "52" ];then
LIBV=2.2.7
elif [ "$version" -lt "70" ];then
LIBV=4.2.0
elif [ "$version" -gt "74" ];then
LIBV=5.3.5
else
echo 'ok'
fi
-5
View File
@@ -31,11 +31,6 @@ if [ "$version" -eq "72" ] || [ "$version" -eq "73" ];then
LIBV=3.2.5
fi
if [ "$version" -eq "82" ];then
echo "not need"
exit 1
fi
LIB_PATH_NAME=lib/php
if [ -d $serverPath/php/${version}/lib64 ];then
-6
View File
@@ -21,12 +21,6 @@ if [ "$version" -lt "70" ];then
LIBV=1.2.5
fi
if [ "$version" -eq "82" ];then
echo "wait php82 release"
exit 0
fi
LIB_PATH_NAME=lib/php
if [ -d $serverPath/php/${version}/lib64 ];then
LIB_PATH_NAME=lib64
+2 -4
View File
@@ -520,8 +520,7 @@
"73",
"74",
"80",
"81",
"82"
"81"
],
"type": "框架",
"msg": "Yaf是一个C语言编写的PHP框架",
@@ -541,8 +540,7 @@
"73",
"74",
"80",
"81",
"82"
"81"
],
"type": "框架",
"msg": "Yar是一个RPC框架",
+16
View File
@@ -0,0 +1,16 @@
location / {
set $replace 'tmplate_replace';
set $spider_request '0';
if ($http_user_agent ~* '(baiduspider|360sipder|Sogou Orion spider|Sogou News Spider|Sogou blog|Sogou spider2|Sogou inst spider|Sogou web spider|Sogou spider|trendiction|Yahoo|semrush|Toutiao|Google|qihoobot|Googlebot|Googlebot-Mobile|Googlebot-Image|Mediapartners-Google|Adsbot-Google|Feedfetcher-Google|Yahoo! Slurp|Yahoo! Slurp China|YoudaoBot|Sosospider|MSNBot|ia_archiver|Tomato Bot)') {
set $spider_request '1';
}
if ($spider_request = '0' ) {
set $replace 'tmplate_replace';
}
sub_filter 'tmplate_replace' $replace;
sub_filter_once on;
sub_filter_types *;
}
+6 -2
View File
@@ -1103,7 +1103,7 @@ function reName(type, fileName) {
closeBtn: 1,
area: '320px',
title: '重命名',
btn:["确定","保存"],
btn:["确定","取消"],
content: '<div class="bt-form pd20">\
<div class="line">\
<input type="text" class="bt-input-text" name="Name" id="newFileName" value="' + fileName + '" placeholder="文件名" style="width:100%" />\
@@ -1615,10 +1615,13 @@ function getPathSize(){
$("body").not(".def-log").click(function(){
$("#rmenu").hide()
});
//指定路径
$("#DirPathPlace input").keyup(function(e){
if(e.keyCode == 13) {
getFiles($(this).val());
var fpath = $(this).val();
fpath = filterPath(fpath);
getFiles(fpath);
}
});
@@ -1662,6 +1665,7 @@ function pathLeft(){
$("#PathPlaceBtn ul").css("left",0);
}
}
//路径快捷点击
$("#PathPlaceBtn").on("click", function(e){
if($("#DirPathPlace").is(":hidden")){
+13
View File
@@ -100,6 +100,19 @@ function isContains(str, substr) {
return str.indexOf(substr) >= 0;
}
function filterPath(path){
var path_arr = path.split('/');
var path_new = [];
for (var i = 0; i < path_arr.length; i++) {
if (path_arr[i]!=''){
path_new.push(path_arr[i]);
}
}
var rdata = "/"+path_new.join('/');
return rdata;
}
function msgTpl(msg, args){
if (typeof args == 'string'){
return msg.replace('{1}', args);
+2 -1
View File
@@ -331,7 +331,8 @@ case "$1" in
echo -e "=================================================================="
echo -e "$address"
echo -e `python3 $mw_path/tools.py username`
echo -e "password: $password"
echo -e `python3 $mw_path/tools.py password`
# echo -e "password: $password"
echo -e "\033[33mWarning:\033[0m"
echo -e "\033[33mIf you cannot access the panel. \033[0m"
echo -e "\033[33mrelease the following port (${show_panel_ip}888|80|443|22) in the security group.\033[0m"
+1 -1
View File
@@ -48,7 +48,7 @@ elif grep -Eqi "Debian" /etc/issue || grep -Eq "Debian" /etc/os-release; then
apt update -y
apt install -y wget curl zip unzip tar cron
elif grep -Eqi "Ubuntu" /etc/issue || grep -Eq "Ubuntu" /etc/os-release; then
OSNAME='debian'
OSNAME='ubuntu'
apt update -y
apt install -y wget curl zip unzip tar cron
else
+162
View File
@@ -0,0 +1,162 @@
#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
export LANG=en_US.UTF-8
export DEBIAN_FRONTEND=noninteractive
DISTRO=''
if grep -Eqi "Debian" /etc/issue || grep -Eq "Debian" /etc/*-release; then
DISTRO='debian'
elif grep -Eqi "Ubuntu" /etc/issue || grep -Eq "Ubuntu" /etc/*-release; then
DISTRO='ubuntu'
fi
VERSION_ID=`cat /etc/*-release | grep VERSION_ID | awk -F = '{print $2}' | awk -F "\"" '{print $2}'`
cn=$(curl -fsSL -m 10 http://ipinfo.io/json | grep "\"country\": \"CN\"")
NTPHOST='time.nist.gov'
if [ ! -z "$cn" ];then
NTPHOST='ntp1.aliyun.com'
fi
ln -sf /bin/bash /bin/sh
__GET_BIT=`getconf LONG_BIT`
if [ "$__GET_BIT" == "32" ];then
# install rust | 32bit need
# curl https://sh.rustup.rs -sSf | sh
apt install -y rustc
fi
# synchronize time first
apt-get install ntpdate -y
ntpdate $NTPHOST | logger -t NTP
apt-get update -y
apt install -y wget curl lsof unzip tar cron expect locate
apt install -y python3-pip python3-dev python3-venv
locale-gen en_US.UTF-8
localedef -v -c -i en_US -f UTF-8 en_US.UTF-8
if [ -f /usr/sbin/ufw ];then
ufw allow 22/tcp
ufw allow 80/tcp
ufw allow 443/tcp
ufw allow 888/tcp
# ufw allow 7200/tcp
# ufw allow 3306/tcp
# ufw allow 30000:40000/tcp
fi
if [ -f /usr/sbin/ufw ];then
ufw disable
fi
if [ ! -f /usr/sbin/ufw ];then
apt install -y firewalld
systemctl enable firewalld
systemctl start firewalld
firewall-cmd --permanent --zone=public --add-port=22/tcp
firewall-cmd --permanent --zone=public --add-port=80/tcp
firewall-cmd --permanent --zone=public --add-port=443/tcp
firewall-cmd --permanent --zone=public --add-port=888/tcp
# firewall-cmd --permanent --zone=public --add-port=7200/tcp
# firewall-cmd --permanent --zone=public --add-port=3306/tcp
# firewall-cmd --permanent --zone=public --add-port=30000-40000/tcp
# fix:debian10 firewalld faq
# https://kawsing.gitbook.io/opensystem/andoid-shou-ji/untitled/fang-huo-qiang#debian-10-firewalld-0.6.3-error-commandfailed-usrsbinip6tablesrestorewn-failed-ip6tablesrestore-v1.8
sed -i 's#IndividualCalls=no#IndividualCalls=yes#g' /etc/firewalld/firewalld.conf
firewall-cmd --reload
fi
#安装时不开启
systemctl stop firewalld
if [ "$DISTRO" == 'debian' ]; then
#fix zlib1g-dev fail
echo -e "\e[0;32mfix zlib1g-dev install question start\e[0m"
Install_TmpFile=/tmp/debian-fix-zlib1g-dev.txt
apt install -y zlib1g-dev > ${Install_TmpFile}
if [ "$?" != "0" ];then
ZLIB1G_BASE_VER=$(cat ${Install_TmpFile} | grep zlib1g | awk -F "=" '{print $2}' | awk -F ")" '{print $1}')
ZLIB1G_BASE_VER=`echo ${ZLIB1G_BASE_VER} | sed "s/^[ \s]\{1,\}//g;s/[ \s]\{1,\}$//g"`
# echo "1${ZLIB1G_BASE_VER}1"
echo -e "\e[1;31mapt install zlib1g=${ZLIB1G_BASE_VER} zlib1g-dev\e[0m"
echo "Y" | apt install zlib1g=${ZLIB1G_BASE_VER} zlib1g-dev
fi
rm -rf ${Install_TmpFile}
echo -e "\e[0;32mfix zlib1g-dev install question end\e[0m"
#fix libunwind-dev fail
echo -e "\e[0;32mfix libunwind-dev install question start\e[0m"
Install_TmpFile=/tmp/debian-fix-libunwind-dev.txt
apt install -y libunwind-dev > ${Install_TmpFile}
if [ "$?" != "0" ];then
liblzma5_BASE_VER=$(cat ${Install_TmpFile} | grep liblzma-dev | awk -F "=" '{print $2}' | awk -F ")" '{print $1}')
liblzma5_BASE_VER=`echo ${liblzma5_BASE_VER} | sed "s/^[ \s]\{1,\}//g;s/[ \s]\{1,\}$//g"`
echo -e "\e[1;31mapt install liblzma5=${liblzma5_BASE_VER} libunwind-dev\e[0m"
echo "Y" | apt install liblzma5=${liblzma5_BASE_VER} libunwind-dev
fi
rm -rf ${Install_TmpFile}
echo -e "\e[0;32mfix libunwind-dev install question end\e[0m"
apt install -y libvpx-dev
apt install -y libxpm-dev
apt install -y libwebp-dev
apt install -y libfreetype6-dev
localedef -i en_US -f UTF-8 en_US.UTF-8
if [ "$VERSION_ID" == "9" ];then
sed "s/flask==2.0.3/flask==1.1.1/g" -i /www/server/mdserver-web/requirements.txt
sed "s/cryptography==3.3.2/cryptography==2.5/g" -i /www/server/mdserver-web/requirements.txt
sed "s/configparser==5.2.0/configparser==4.0.2/g" -i /www/server/mdserver-web/requirements.txt
sed "s/flask-socketio==5.2.0/flask-socketio==4.2.0/g" -i /www/server/mdserver-web/requirements.txt
sed "s/python-engineio==4.3.2/python-engineio==3.9.0/g" -i /www/server/mdserver-web/requirements.txt
# pip3 install -r /www/server/mdserver-web/requirements.txt
fi
fi
apt install -y build-essential devscripts
apt install --ignore-missing -y autoconf automake cmake curl dia gcc imagemagick libbz2-dev libcurl4-gnutls-dev\
libcurl4-openssl-dev libevent-dev libffi-dev libfreetype6 libfreetype6-dev libgmp-dev libgmp3-dev libicu-dev \
libjpeg-dev libjpeg62-turbo-dev libldap2-dev libmagickwand-dev libmcrypt-dev libmemcached-dev libncurses5-dev \
libpcre3 libpcre3-dev libpng-dev libpspell-dev libreadline-dev librecode-dev libsasl2-dev libssl-dev \
libunwind-dev libwebp-dev libxml2 libxml2-dev libxpm-dev libzip-dev lzma lzma-dev make net-tools openssl \
pkg-config python3-dev scons webp zlib1g-dev
#https://blog.csdn.net/qq_36228377/article/details/123154344
# ln -s /usr/include/x86_64-linux-gnu/curl /usr/include/curl
if [ ! -d /usr/include/curl ];then
ln -s /usr/include/x86_64-linux-gnu/curl /usr/include/curl
fi
apt install -y graphviz bison re2c flex libsqlite3-dev libonig-dev perl g++ libtool libxslt1-dev
apt install -y libmariadb-dev libmariadb-dev-compat
#apt install -y libmysqlclient-dev
#apt install -y libmariadbclient-dev
if [ "$DISTRO" == 'ubuntu' ] && [ "${VERSION_ID}" == "22.04" ]; then
apt install -y patchelf
apt install -y python3-cffi
pip3 install -U --force-reinstall --no-binary :all: gevent
fi
cd /www/server/mdserver-web/scripts && bash lib.sh
chmod 755 /www/server/mdserver-web/data
if [ "$DISTRO" == 'ubuntu' ] && [ "${VERSION_ID}" == "22.04" ]; then
apt install -y patchelf
apt install -y python3-cffi
pip3 install -U --force-reinstall --no-binary :all: gevent
fi
+77 -96
View File
@@ -4,21 +4,9 @@ export PATH
export LANG=en_US.UTF-8
export DEBIAN_FRONTEND=noninteractive
DISTRO=''
if grep -Eqi "Debian" /etc/issue || grep -Eq "Debian" /etc/*-release; then
DISTRO='debian'
elif grep -Eqi "Ubuntu" /etc/issue || grep -Eq "Ubuntu" /etc/*-release; then
DISTRO='ubuntu'
if grep -Eq "Debian" /etc/*-release; then
ln -sf /bin/bash /bin/sh
fi
VERSION_ID=`cat /etc/*-release | grep VERSION_ID | awk -F = '{print $2}' | awk -F "\"" '{print $2}'`
cn=$(curl -fsSL -m 10 http://ipinfo.io/json | grep "\"country\": \"CN\"")
NTPHOST='time.nist.gov'
if [ ! -z "$cn" ];then
NTPHOST='ntp1.aliyun.com'
fi
ln -sf /bin/bash /bin/sh
__GET_BIT=`getconf LONG_BIT`
if [ "$__GET_BIT" == "32" ];then
@@ -29,24 +17,27 @@ fi
# synchronize time first
apt-get install ntpdate -y
ntpdate $NTPHOST | logger -t NTP
ntpdate time.nist.gov | logger -t NTP
if [ ! -f /usr/sbin/locale-gen ];then
apt install -y locales
sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen
locale-gen en_US.UTF-8
localedef -v -c -i en_US -f UTF-8 en_US.UTF-8
dpkg-reconfigure --frontend=noninteractive locales
update-locale LANG=en_US.UTF-8
else
locale-gen en_US.UTF-8
localedef -v -c -i en_US -f UTF-8 en_US.UTF-8
apt update -y
apt-get update -y
apt install -y wget curl lsof unzip
apt install -y python3-pip
apt install -y python3-dev
apt install -y python3-venv
apt install -y cron
apt install -y expect
apt install -y locate
locale-gen en_US.UTF-8
localedef -v -c -i en_US -f UTF-8 en_US.UTF-8
if [ ! -d /root/.acme.sh ];then
curl https://get.acme.sh | sh
fi
apt-get update -y
apt install -y wget curl lsof unzip tar cron expect locate
apt install -y python3-pip python3-dev python3-venv
if [ -f /usr/sbin/ufw ];then
ufw allow 22/tcp
@@ -60,9 +51,12 @@ if [ -f /usr/sbin/ufw ];then
fi
if [ -f /usr/sbin/ufw ];then
ufw disable
fi
if [ ! -f /usr/sbin/ufw ];then
apt install -y firewalld
systemctl enable firewalld
@@ -86,57 +80,56 @@ fi
#安装时不开启
systemctl stop firewalld
if [ "$DISTRO" == 'debian' ]; then
#fix zlib1g-dev fail
echo -e "\e[0;32mfix zlib1g-dev install question start\e[0m"
Install_TmpFile=/tmp/debian-fix-zlib1g-dev.txt
apt install -y zlib1g-dev > ${Install_TmpFile}
if [ "$?" != "0" ];then
ZLIB1G_BASE_VER=$(cat ${Install_TmpFile} | grep zlib1g | awk -F "=" '{print $2}' | awk -F ")" '{print $1}')
ZLIB1G_BASE_VER=`echo ${ZLIB1G_BASE_VER} | sed "s/^[ \s]\{1,\}//g;s/[ \s]\{1,\}$//g"`
# echo "1${ZLIB1G_BASE_VER}1"
echo -e "\e[1;31mapt install zlib1g=${ZLIB1G_BASE_VER} zlib1g-dev\e[0m"
echo "Y" | apt install zlib1g=${ZLIB1G_BASE_VER} zlib1g-dev
fi
rm -rf ${Install_TmpFile}
echo -e "\e[0;32mfix zlib1g-dev install question end\e[0m"
#fix zlib1g-dev fail
echo -e "\e[0;32mfix zlib1g-dev install question start\e[0m"
Install_TmpFile=/tmp/debian-fix-zlib1g-dev.txt
apt install -y zlib1g-dev > ${Install_TmpFile}
if [ "$?" != "0" ];then
ZLIB1G_BASE_VER=$(cat ${Install_TmpFile} | grep zlib1g | awk -F "=" '{print $2}' | awk -F ")" '{print $1}')
ZLIB1G_BASE_VER=`echo ${ZLIB1G_BASE_VER} | sed "s/^[ \s]\{1,\}//g;s/[ \s]\{1,\}$//g"`
# echo "1${ZLIB1G_BASE_VER}1"
echo -e "\e[1;31mapt install zlib1g=${ZLIB1G_BASE_VER} zlib1g-dev\e[0m"
echo "Y" | apt install zlib1g=${ZLIB1G_BASE_VER} zlib1g-dev
fi
rm -rf ${Install_TmpFile}
echo -e "\e[0;32mfix zlib1g-dev install question end\e[0m"
#fix libunwind-dev fail
echo -e "\e[0;32mfix libunwind-dev install question start\e[0m"
Install_TmpFile=/tmp/debian-fix-libunwind-dev.txt
apt install -y libunwind-dev > ${Install_TmpFile}
if [ "$?" != "0" ];then
liblzma5_BASE_VER=$(cat ${Install_TmpFile} | grep liblzma-dev | awk -F "=" '{print $2}' | awk -F ")" '{print $1}')
liblzma5_BASE_VER=`echo ${liblzma5_BASE_VER} | sed "s/^[ \s]\{1,\}//g;s/[ \s]\{1,\}$//g"`
echo -e "\e[1;31mapt install liblzma5=${liblzma5_BASE_VER} libunwind-dev\e[0m"
echo "Y" | apt install liblzma5=${liblzma5_BASE_VER} libunwind-dev
fi
rm -rf ${Install_TmpFile}
echo -e "\e[0;32mfix libunwind-dev install question end\e[0m"
#fix libunwind-dev fail
echo -e "\e[0;32mfix libunwind-dev install question start\e[0m"
Install_TmpFile=/tmp/debian-fix-libunwind-dev.txt
apt install -y libunwind-dev > ${Install_TmpFile}
if [ "$?" != "0" ];then
liblzma5_BASE_VER=$(cat ${Install_TmpFile} | grep liblzma-dev | awk -F "=" '{print $2}' | awk -F ")" '{print $1}')
liblzma5_BASE_VER=`echo ${liblzma5_BASE_VER} | sed "s/^[ \s]\{1,\}//g;s/[ \s]\{1,\}$//g"`
echo -e "\e[1;31mapt install liblzma5=${liblzma5_BASE_VER} libunwind-dev\e[0m"
echo "Y" | apt install liblzma5=${liblzma5_BASE_VER} libunwind-dev
fi
rm -rf ${Install_TmpFile}
echo -e "\e[0;32mfix libunwind-dev install question end\e[0m"
apt install -y libvpx-dev
apt install -y libxpm-dev
apt install -y libwebp-dev
apt install -y libfreetype6-dev
apt install -y libvpx-dev
apt install -y libxpm-dev
apt install -y libwebp-dev
apt install -y libfreetype6-dev
localedef -i en_US -f UTF-8 en_US.UTF-8
sudo localedef -i en_US -f UTF-8 en_US.UTF-8
if [ "$VERSION_ID" == "9" ];then
sed "s/flask==2.0.3/flask==1.1.1/g" -i /www/server/mdserver-web/requirements.txt
sed "s/cryptography==3.3.2/cryptography==2.5/g" -i /www/server/mdserver-web/requirements.txt
sed "s/configparser==5.2.0/configparser==4.0.2/g" -i /www/server/mdserver-web/requirements.txt
sed "s/flask-socketio==5.2.0/flask-socketio==4.2.0/g" -i /www/server/mdserver-web/requirements.txt
sed "s/python-engineio==4.3.2/python-engineio==3.9.0/g" -i /www/server/mdserver-web/requirements.txt
# pip3 install -r /www/server/mdserver-web/requirements.txt
fi
VERSION_ID=`cat /etc/*-release | grep VERSION_ID | awk -F = '{print $2}' | awk -F "\"" '{print $2}'`
if [ "$VERSION_ID" == "9" ];then
sed "s/flask==2.0.3/flask==1.1.1/g" -i /www/server/mdserver-web/requirements.txt
sed "s/cryptography==3.3.2/cryptography==2.5/g" -i /www/server/mdserver-web/requirements.txt
sed "s/configparser==5.2.0/configparser==4.0.2/g" -i /www/server/mdserver-web/requirements.txt
sed "s/flask-socketio==5.2.0/flask-socketio==4.2.0/g" -i /www/server/mdserver-web/requirements.txt
sed "s/python-engineio==4.3.2/python-engineio==3.9.0/g" -i /www/server/mdserver-web/requirements.txt
# pip3 install -r /www/server/mdserver-web/requirements.txt
fi
apt install -y build-essential
apt install -y devscripts
apt install -y net-tools
apt install -y python3-dev
apt install -y autoconf
apt install -y gcc
@@ -163,47 +156,35 @@ apt install -y dia pkg-config
apt install -y zlib1g-dev
apt install -y libjpeg-dev libpng-dev
apt install -y libfreetype6
apt install -y libjpeg62-turbo-dev
apt install -y libfreetype6-dev
apt install -y libevent-dev libncurses5-dev libldap2-dev
apt install -y libzip-dev
apt install -y libicu-dev
apt install -y build-essential
apt install -y libcurl4-openssl-dev
apt install -y curl libcurl4-gnutls-dev
# Disabled due to dependency issues
#apt install --ignore-missing -y autoconf automake cmake curl dia gcc imagemagick libbz2-dev libcurl4-gnutls-dev\
# libcurl4-openssl-dev libevent-dev libffi-dev libfreetype6 libfreetype6-dev libgmp-dev libgmp3-dev libicu-dev \
# libjpeg-dev libldap2-dev libmagickwand-dev libmcrypt-dev libmemcached-dev libncurses5-dev \
# libpcre3 libpcre3-dev libpng-dev libpspell-dev libreadline-dev librecode-dev libsasl2-dev libssl-dev \
# libunwind-dev libwebp-dev libxml2 libxml2-dev libxpm-dev libzip-dev lzma lzma-dev make net-tools openssl \
# pkg-config python3-dev scons webp zlib1g-dev
if [ "$DISTRO" == 'debian' ] && [ "$VERSION_ID" != "9" ]; then
apt install -y libjpeg62-turbo-dev
fi
#https://blog.csdn.net/qq_36228377/article/details/123154344
# ln -s /usr/include/x86_64-linux-gnu/curl /usr/include/curl
if [ ! -d /usr/include/curl ];then
ln -s /usr/include/x86_64-linux-gnu/curl /usr/include/curl
fi
apt install -y graphviz bison re2c flex libsqlite3-dev libonig-dev perl g++ libtool libxslt1-dev
apt install -y libmariadb-dev libmariadb-dev-compat
#apt install -y libmysqlclient-dev
apt install -y graphviz bison re2c flex
apt install -y libsqlite3-dev
apt install -y libonig-dev
apt install -y perl g++ libtool
apt install -y libxslt1-dev
apt install -y libmariadb-dev
#apt install -y libmysqlclient-dev
apt install -y libmariadb-dev-compat
#apt install -y libmariadbclient-dev
if [ "$DISTRO" == 'ubuntu' ] && [ "${VERSION_ID}" == "22.04" ]; then
apt install -y patchelf
apt install -y python3-cffi
pip3 install -U --force-reinstall --no-binary :all: gevent
fi
cd /www/server/mdserver-web/scripts && bash lib.sh
chmod 755 /www/server/mdserver-web/data
if [ "$DISTRO" == 'ubuntu' ] && [ "${VERSION_ID}" == "22.04" ]; then
pip3 install -U --force-reinstall --no-binary :all: gevent
fi
+1 -1
View File
@@ -47,7 +47,7 @@ elif grep -Eqi "Debian" /etc/issue || grep -Eq "Debian" /etc/*-release; then
apt install -y devscripts
apt install -y wget zip unzip
elif grep -Eqi "Ubuntu" /etc/issue || grep -Eq "Ubuntu" /etc/*-release; then
OSNAME='debian'
OSNAME='ubuntu'
apt install -y wget zip unzip
else
OSNAME='unknow'
-3
View File
@@ -82,6 +82,3 @@ loglevel = 'info'
errorlog = log_dir + '/error.log'
accesslog = log_dir + '/access.log'
pidfile = log_dir + '/mw.pid'
# if os.path.exists(os.getcwd() + '/data/ssl.pl'):
# certfile = 'ssl/certificate.pem'
# keyfile = 'ssl/privateKey.pem'
+18
View File
@@ -132,6 +132,22 @@ def set_panel_pwd(password, ncli=False):
print(username)
def show_panel_pwd():
# 设置面板密码
import db
sql = db.Sql()
password = sql.table('users').where('id=?', (1,)).getField('password')
file_pwd = ''
if os.path.exists('data/default.pl'):
file_pwd = mw.readFile('data/default.pl').strip()
if mw.md5(file_pwd) == password:
print('password: ' + file_pwd)
return
print("the password has been changed!")
def set_panel_username(username=None):
# 随机面板用户名
import db
@@ -171,6 +187,8 @@ if __name__ == "__main__":
set_panel_username(sys.argv[2])
else:
set_panel_username()
elif method == 'password':
show_panel_pwd()
elif method == 'getServerIp':
getServerIp()
elif method == "cli":