From 98bc816b21ac938e21c15a6236036004ebe454bf Mon Sep 17 00:00:00 2001 From: midoks Date: Tue, 13 Sep 2022 21:02:55 +0800 Subject: [PATCH 01/59] up --- plugins/mail/ico.png | Bin 0 -> 4184 bytes plugins/mail/index.html | 54 ++++++ plugins/mail/index.py | 241 +++++++++++++++++++++++++ plugins/mail/info.json | 18 ++ plugins/mail/install.sh | 25 +++ plugins/mail/versions/1.0/install.sh | 77 ++++++++ plugins/php/versions/common/gettext.sh | 113 ++++++++++++ plugins/php/versions/phplib.conf | 22 +++ 8 files changed, 550 insertions(+) create mode 100755 plugins/mail/ico.png create mode 100755 plugins/mail/index.html create mode 100755 plugins/mail/index.py create mode 100755 plugins/mail/info.json create mode 100755 plugins/mail/install.sh create mode 100755 plugins/mail/versions/1.0/install.sh create mode 100755 plugins/php/versions/common/gettext.sh diff --git a/plugins/mail/ico.png b/plugins/mail/ico.png new file mode 100755 index 0000000000000000000000000000000000000000..fd5d7fad16f9db45782ca31657cd58e52f0a7286 GIT binary patch literal 4184 zcmd5<3se(l77j%Ld1!rGS+_%IeeNVPlSw9tqCx@!3ZjDIYSGEeB#b1PI5R*16;Oo2 zy1Qz{cU62px)yQkS|4pHTCG~qsw?Y?;-gkwU2s>Fb#3iG0Rr^E(X*%LY;(@M?tkC+ z`|p2KoDe@Q$bX=}OePD8i8f9KPXt^;{d~avU{Tgw@aX1_3FX9L{`cnH;b4SCJ&bk zLdkInkb&bFNUhMo6pE`MLZ?7ADqN@g4TK@6R*7hps0v0kdK}SX7}Wfe18Y2O)=xG@ zHQNGTVe(W_bm*1J%*;$hrb@x_7A30F>68ej#4s3ez(ST?B%QEb2yM||WCV(59U{xw zAxR@?;?l)1IqqU;Z8j+`H@6^0W&q)4H#+1N60;nP zaxx=u={&_mW-xX!v{igE(;CHVhy!+yFim+3JJNZpJ9?T@GFHY0YzV+r)Z?ckl@mE3 zm2-GR+8OgKyW?x|PGrrUI47;NV`ZFdC#=#+J63?0j-6;puVfz7KyT!zbSaV;V+*Qi zj$&!O$5}mvYSkJXGs6U>qG5!@aac!E6pZ2sslwGbO5@rVZ83I1B<&OyD9j*?3C4981M5(XfVH$52iU}Ln#5Ysbbw3r$u$JCm()Cr8;(w>|k)f?5mW~w8W>S0 zqM&yWdYl-6X!QufX;ZV`HtYRacTW-zq8naFm4NrKjzP&1{5X%&saxCzt1S_)Ca6rwXBW|a;nO(4Nd zN;6X#si5t`R$+Qv*Ahz;o4}dHOp<59EnqjbG-5YGq>ca?3{vCOK||w6inU8^Vpxj- zDwVWb7;p+G<;uE{0G*%F-_q8XlTlf1TOJU&1_r@>d&ipD4nhBG=?P2gG>$4CuKni&LU%nX5;aGjb! zO)aVXMbzq*5s?f*Qm9T16DA6Qaax1IS`|sd6ppGG+^oTI8uY2o(bsM#{W8$^3cN{> zY;Db*qWty2_w(3$Wu;#4?E3#yN-51%O-)ew)Bf1>ZEV`hQBr#lL@?FpJL-k6i$+Nv z%m$um0oYK`;Cz4G{VBG9h?HAwWHigv9g{v`YKY}Bz9=S z&Cq6=1)AL?Fd|E@p4l9Hc&2;C4w^X+X7_==Em$m*c|VIWh9@R3ezYdd+9zp1;l_(6 z4g_pltmr>u`P67-f@1PDb*xpr`Q2XYR$Xq)AY<71?Tc^!asT)o+M07`?V0c0{$N7Jx%DdH zI-$Dp?8EhaC&!xB983-HD_u<>3Ww>xgV$nb1+MgY&{Ln4USqs#@|N7X@aW3E2@~%` z`(${X%T6?r;WJBPQHxifpY4DlE%}>I{R=K`>KYCyMngeB)+G4+M z`%1?D{k#ep9TD-7>5Aruk?GKYGb(a{zjbxcZ5uV>-pSzdm)Mg)*RFFHP6lUtUk-R@ zR!V+_P+XLuLM+gsZanqOHTLs^=F5o{jDGt6>Gf^Aq@f5A3`Bdn>Nix&B~w z{^hOVcaJ^&^o_$`5H_t3zx-ycYWX#K=*S*LdKWP}>0fXDzNS82bt(PWhI!8UD-SKm zIbZ#Kp$QsmT3_p$Qa@?W))z-=vlSoB3;d?n*Tp{fKJU?xvU5&>)@#Tr*Ve|eAGG8{ z-O7ptc5m&!hm_s*e`qZ{kRohMtb^v|#8o^Gyt5;s=697R)_uVbgku-g`MYYm&IlWR z(0AP2koZD1m|&h(F!NMF-pBm{PJb7DAiH+I=H6jq-jXiYQijg0%qzG(-c>sA!P%1Xq+6f- zZQ-us`jx>4oSXLN?yNhN{?+aqWtV;5oxZfR&)(^kbnR29&r5%37rgY(*B4&4Y`XI*gDhLq}~$Z4O?>_vm(%CX+D6K9qxf3jxb zTN%}V?Q(r|_2E<5{y|^4wg))M2km~lXqCmabzI@Ii7|Pb$0aRIOIu#!qujPAG<@3) zOK$#_s_?=Skw@+is1I^|)BAjF=|kaI$&%cX-1_>W1YeLFUrN zjf~kbzrWSmW!$JlrEEv#)vaE4cZ^Ni@chnjrR&76ojDsGs0Q9G47xNkY0rtxc=ASX zUGE^p)Toe}?xk5vR|Q_~U$)J6&W5S`s4fPd&l;x;`iGF%fFC-KmDKo*z(S}u9@_JX zU?^wvzMRO}!nFOW{sD)N%B#;^`|$l(wCX*Zq003s0Cwym3F4LD?R1Jnd*=X#sI X3+b8nanE?^zkf_*ym4>D?1eu9Gr#88 literal 0 HcmV?d00001 diff --git a/plugins/mail/index.html b/plugins/mail/index.html new file mode 100755 index 0000000000..dfa65bf45a --- /dev/null +++ b/plugins/mail/index.html @@ -0,0 +1,54 @@ +
+
+
+

服务

+

自启动

+

配置修改

+

负载状态

+

日志

+
+
+
+
+
+
+ \ No newline at end of file diff --git a/plugins/mail/index.py b/plugins/mail/index.py new file mode 100755 index 0000000000..37ffe8ffc5 --- /dev/null +++ b/plugins/mail/index.py @@ -0,0 +1,241 @@ +# coding:utf-8 + +import sys +import io +import os +import time + +sys.path.append(os.getcwd() + "/class/core") +import mw + +app_debug = False +if mw.isAppleSystem(): + app_debug = True + + +def getPluginName(): + return 'mail' + + +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 getConf(): + path = getServerDir() + "/redis.conf" + return path + + +def getConfTpl(): + path = getPluginDir() + "/config/redis.conf" + return path + + +def getInitDTpl(): + path = getPluginDir() + "/init.d/" + getPluginName() + ".tpl" + return path + + +def getArgs(): + args = sys.argv[2:] + tmp = {} + args_len = len(args) + + if args_len == 1: + t = args[0].strip('{').strip('}') + 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 status(): + data = mw.execShell( + "ps -ef|grep redis |grep -v grep | grep -v python | grep -v mdserver-web | awk '{print $2}'") + + if data[0] == '': + return 'stop' + return 'start' + + +def initDreplace(): + + file_tpl = getInitDTpl() + service_path = os.path.dirname(os.getcwd()) + + initD_path = getServerDir() + '/init.d' + if not os.path.exists(initD_path): + os.mkdir(initD_path) + file_bin = initD_path + '/' + getPluginName() + + # initd replace + if not os.path.exists(file_bin): + content = mw.readFile(file_tpl) + content = content.replace('{$SERVER_PATH}', service_path) + mw.writeFile(file_bin, content) + mw.execShell('chmod +x ' + file_bin) + + # log + dataLog = getServerDir() + '/data' + if not os.path.exists(dataLog): + mw.execShell('chmod +x ' + file_bin) + + # config replace + dst_conf = getServerDir() + '/redis.conf' + dst_conf_init = getServerDir() + '/init.pl' + if not os.path.exists(dst_conf_init): + conf_content = mw.readFile(getConfTpl()) + conf_content = conf_content.replace('{$SERVER_PATH}', service_path) + mw.writeFile(dst_conf, conf_content) + mw.writeFile(dst_conf_init, 'ok') + + # systemd + systemDir = mw.systemdCfgDir() + systemService = systemDir + '/redis.service' + systemServiceTpl = getPluginDir() + '/init.d/redis.service.tpl' + if os.path.exists(systemDir) and not os.path.exists(systemService): + service_path = mw.getServerDir() + se_content = mw.readFile(systemServiceTpl) + se_content = se_content.replace('{$SERVER_PATH}', service_path) + mw.writeFile(systemService, se_content) + mw.execShell('systemctl daemon-reload') + + return file_bin + + +def redisOp(method): + file = initDreplace() + + if not mw.isAppleSystem(): + data = mw.execShell('systemctl ' + method + ' redis') + if data[1] == '': + return 'ok' + return 'fail' + + data = mw.execShell(file + ' start') + if data[1] == '': + return 'ok' + return 'fail' + + +def start(): + return redisOp('start') + + +def stop(): + return redisOp('stop') + + +def restart(): + status = redisOp('restart') + + log_file = runLog() + mw.execShell("echo '' > " + log_file) + return status + + +def reload(): + return redisOp('reload') + + +def runInfo(): + cmd = getServerDir() + "/bin/redis-cli info" + data = mw.execShell(cmd)[0] + res = [ + 'tcp_port', + 'uptime_in_days', # 已运行天数 + 'connected_clients', # 连接的客户端数量 + 'used_memory', # Redis已分配的内存总量 + 'used_memory_rss', # Redis占用的系统内存总量 + 'used_memory_peak', # Redis所用内存的高峰值 + 'mem_fragmentation_ratio', # 内存碎片比率 + 'total_connections_received', # 运行以来连接过的客户端的总数量 + 'total_commands_processed', # 运行以来执行过的命令的总数量 + 'instantaneous_ops_per_sec', # 服务器每秒钟执行的命令数量 + 'keyspace_hits', # 查找数据库键成功的次数 + 'keyspace_misses', # 查找数据库键失败的次数 + 'latest_fork_usec' # 最近一次 fork() 操作耗费的毫秒数 + ] + data = data.split("\n") + result = {} + for d in data: + if len(d) < 3: + continue + t = d.strip().split(':') + if not t[0] in res: + continue + result[t[0]] = t[1] + return mw.getJson(result) + + +def initdStatus(): + if mw.isAppleSystem(): + return "Apple Computer does not support" + + shell_cmd = 'systemctl status redis | grep loaded | grep "enabled;"' + data = mw.execShell(shell_cmd) + if data[0] == '': + return 'fail' + return 'ok' + + +def initdInstall(): + if mw.isAppleSystem(): + return "Apple Computer does not support" + + mw.execShell('systemctl enable redis') + return 'ok' + + +def initdUinstall(): + + if mw.isAppleSystem(): + return "Apple Computer does not support" + + mw.execShell('systemctl disable redis') + return 'ok' + + +def runLog(): + return getServerDir() + '/data/redis.log' + +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 == 'run_info': + print(runInfo()) + elif func == 'conf': + print(getConf()) + elif func == 'run_log': + print(runLog()) + else: + print('error') diff --git a/plugins/mail/info.json b/plugins/mail/info.json new file mode 100755 index 0000000000..b8dd1eace9 --- /dev/null +++ b/plugins/mail/info.json @@ -0,0 +1,18 @@ +{ + "sort": 7, + "ps": "简单邮件服务[DEV]", + "name": "mail", + "title": "mail", + "shell": "install.sh", + "versions":["1.0"], + "updates":["1.0"], + "tip": "soft", + "checks": "server/mail", + "path": "server/mail", + "display": 1, + "author": "midoks", + "date": "2022-09-13", + "home": "https://github.com/midoks/mdserver-web", + "type": 0, + "pid": "2" +} \ No newline at end of file diff --git a/plugins/mail/install.sh b/plugins/mail/install.sh new file mode 100755 index 0000000000..04a563fe97 --- /dev/null +++ b/plugins/mail/install.sh @@ -0,0 +1,25 @@ +#!/bin/bash +PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin +export PATH + +curPath=`pwd` +rootPath=$(dirname "$curPath") +rootPath=$(dirname "$rootPath") +serverPath=$(dirname "$rootPath") + +install_tmp=${rootPath}/tmp/mw_install.pl + +action=$1 +type=$2 + +if [ "${2}" == "" ];then + echo '缺少安装脚本...' > $install_tmp + exit 0 +fi + +if [ ! -d $curPath/versions/$2 ];then + echo '缺少安装脚本2...' > $install_tmp + exit 0 +fi + +sh -x $curPath/versions/$2/install.sh $1 diff --git a/plugins/mail/versions/1.0/install.sh b/plugins/mail/versions/1.0/install.sh new file mode 100755 index 0000000000..7ec7a436ec --- /dev/null +++ b/plugins/mail/versions/1.0/install.sh @@ -0,0 +1,77 @@ +#!/bin/bash +PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin +export PATH + +curPath=`pwd` +rootPath=$(dirname "$curPath") +rootPath=$(dirname "$rootPath") +serverPath=$(dirname "$rootPath") + +install_tmp=${rootPath}/tmp/mw_install.pl +VERSION=$2 + +cpu_arch=`arch` +if [[ $cpu_arch != "x86_64" ]];then + echo 'Does not support non-x86 system installation' + exit 0 +fi + +# if [ -f "/usr/bin/apt-get" ];then +# systemver='ubuntu' +# elif [ -f "/etc/redhat-release" ];then +# systemver=`cat /etc/redhat-release|sed -r 's/.* ([0-9]+)\..*/\1/'` +# postfixver=`postconf mail_version|sed -r 's/.* ([0-9\.]+)$/\1/'` +# else +# echo 'Unsupported system version' +# exit 0 +# fi + +bash ${rootPath}/scripts/getos.sh +OSNAME=`cat ${rootPath}/data/osname.pl` +OSNAME_ID=`cat /etc/*-release | grep VERSION_ID | awk -F = '{print $2}' | awk -F "\"" '{print $2}'` + + + +Install_debain(){ + +} + +Install_App() +{ + echo '正在安装脚本文件...' > $install_tmp + mkdir -p $serverPath/source + + if [[ $OSNAME = "centos" ]]; then + + if [[ $OSNAME_ID == "7" ]];then + Install_centos7 + fi + + if [[ $OSNAME_ID == "8" ]];then + Install_centos8 + fi + + elif [[ $OSNAME = "debian" ]]; then + Install_debain + else + Install_ubuntu + fi +} + +Uninstall_App() +{ + + if [ -f $serverPath/mail/initd/mail ];then + $serverPath/mail/initd/mail stop + fi + + rm -rf $serverPath/mail + echo "Uninstall_Mail" > $install_tmp +} + +action=$1 +if [ "${1}" == 'install' ];then + Install_App +else + Uninstall_App +fi diff --git a/plugins/php/versions/common/gettext.sh b/plugins/php/versions/common/gettext.sh new file mode 100755 index 0000000000..6026714133 --- /dev/null +++ b/plugins/php/versions/common/gettext.sh @@ -0,0 +1,113 @@ +#!/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=gettext +LIBV=0 + +# if [ "$version" == "53" ];then +# echo "i wont support it" +# exit +# fi + +LIB_PATH_NAME=lib/php +if [ -d $serverPath/php/${version}/lib64 ];then + LIB_PATH_NAME=lib64 +fi + +NON_ZTS_FILENAME=`ls $serverPath/php/${version}/${LIB_PATH_NAME}/extensions | grep no-debug-non-zts` +extFile=$serverPath/php/${version}/${LIB_PATH_NAME}/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 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 \ No newline at end of file diff --git a/plugins/php/versions/phplib.conf b/plugins/php/versions/phplib.conf index 7651635859..3862c4a685 100755 --- a/plugins/php/versions/phplib.conf +++ b/plugins/php/versions/phplib.conf @@ -219,6 +219,28 @@ "shell": "igbinary.sh", "check": "igbinary.so" }, + { + "name": "gettext", + "versions": [ + "52", + "53", + "54", + "55", + "56", + "70", + "71", + "72", + "73", + "74", + "80", + "81", + "82" + ], + "type": "通用扩展", + "msg": "国际化与本地化!", + "shell": "gettext.sh", + "check": "gettext.so" + }, { "name": "gd", "versions": [ From eb1c0efda12b17121ca1fb4a43e8b4948e545ad0 Mon Sep 17 00:00:00 2001 From: midoks Date: Tue, 13 Sep 2022 21:06:11 +0800 Subject: [PATCH 02/59] Update gettext.sh --- plugins/php/versions/common/gettext.sh | 5 ----- 1 file changed, 5 deletions(-) diff --git a/plugins/php/versions/common/gettext.sh b/plugins/php/versions/common/gettext.sh index 6026714133..6a1e7bef77 100755 --- a/plugins/php/versions/common/gettext.sh +++ b/plugins/php/versions/common/gettext.sh @@ -17,11 +17,6 @@ version=$2 LIBNAME=gettext LIBV=0 -# if [ "$version" == "53" ];then -# echo "i wont support it" -# exit -# fi - LIB_PATH_NAME=lib/php if [ -d $serverPath/php/${version}/lib64 ];then LIB_PATH_NAME=lib64 From 6ae6e5fafc88c42a43390e572dccf73c8d81ef71 Mon Sep 17 00:00:00 2001 From: midoks Date: Tue, 13 Sep 2022 21:53:30 +0800 Subject: [PATCH 03/59] Update info.json --- plugins/mail/info.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/mail/info.json b/plugins/mail/info.json index b8dd1eace9..36c3336478 100755 --- a/plugins/mail/info.json +++ b/plugins/mail/info.json @@ -14,5 +14,5 @@ "date": "2022-09-13", "home": "https://github.com/midoks/mdserver-web", "type": 0, - "pid": "2" + "pid": "5" } \ No newline at end of file From 565d011191396532e32f235580ee08832340b29d Mon Sep 17 00:00:00 2001 From: midoks Date: Tue, 13 Sep 2022 22:04:18 +0800 Subject: [PATCH 04/59] Update index.html --- plugins/mail/index.html | 46 ++++------------------------------------- 1 file changed, 4 insertions(+), 42 deletions(-) diff --git a/plugins/mail/index.html b/plugins/mail/index.html index dfa65bf45a..b257f933f2 100755 --- a/plugins/mail/index.html +++ b/plugins/mail/index.html @@ -1,11 +1,10 @@
-

服务

-

自启动

-

配置修改

-

负载状态

-

日志

+

服务

+

自启动

+

配置修改

+

日志

@@ -14,41 +13,4 @@
\ No newline at end of file From d9e46f1065607d80017a7fdb79348a49b79dde54 Mon Sep 17 00:00:00 2001 From: midoks Date: Tue, 13 Sep 2022 23:34:37 +0800 Subject: [PATCH 05/59] Update install.sh --- plugins/mail/versions/1.0/install.sh | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/plugins/mail/versions/1.0/install.sh b/plugins/mail/versions/1.0/install.sh index 7ec7a436ec..ed2fa62451 100755 --- a/plugins/mail/versions/1.0/install.sh +++ b/plugins/mail/versions/1.0/install.sh @@ -26,6 +26,9 @@ fi # exit 0 # fi +## debug: +## cd /www/server/mdserver-web/plugins/mail && bash install.sh install 1.0 + bash ${rootPath}/scripts/getos.sh OSNAME=`cat ${rootPath}/data/osname.pl` OSNAME_ID=`cat /etc/*-release | grep VERSION_ID | awk -F = '{print $2}' | awk -F "\"" '{print $2}'` @@ -33,7 +36,19 @@ OSNAME_ID=`cat /etc/*-release | grep VERSION_ID | awk -F = '{print $2}' | awk -F Install_debain(){ - + hostname=`hostname` + # 安装postfix和postfix-sqlite + debconf-set-selections <<< "postfix postfix/mailname string ${hostname}" + debconf-set-selections <<< "postfix postfix/main_mailer_type string 'Internet Site'" + apt install postfix -y + apt install postfix-sqlite -y + apt install sqlite -y + # 安装dovecot和dovecot-sieve + apt install dovecot-core dovecot-pop3d dovecot-imapd dovecot-lmtpd dovecot-sqlite dovecot-sieve -y + + apt install rspamd -y + + apt install cyrus-sasl-plain -y } Install_App() From 598f964e91317839cf74794144e5401afe82ebc9 Mon Sep 17 00:00:00 2001 From: midoks Date: Tue, 13 Sep 2022 23:41:34 +0800 Subject: [PATCH 06/59] Update install.sh --- plugins/mail/versions/1.0/install.sh | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/plugins/mail/versions/1.0/install.sh b/plugins/mail/versions/1.0/install.sh index ed2fa62451..95d025a984 100755 --- a/plugins/mail/versions/1.0/install.sh +++ b/plugins/mail/versions/1.0/install.sh @@ -26,6 +26,7 @@ fi # exit 0 # fi +## curl -fsSL https://raw.githubusercontent.com/midoks/mdserver-web/dev/scripts/update_dev.sh | bash ## debug: ## cd /www/server/mdserver-web/plugins/mail && bash install.sh install 1.0 @@ -43,11 +44,12 @@ Install_debain(){ apt install postfix -y apt install postfix-sqlite -y apt install sqlite -y + # 安装dovecot和dovecot-sieve apt install dovecot-core dovecot-pop3d dovecot-imapd dovecot-lmtpd dovecot-sqlite dovecot-sieve -y apt install rspamd -y - + apt install cyrus-sasl-plain -y } @@ -71,6 +73,13 @@ Install_App() else Install_ubuntu fi + + filesize=`ls -l /etc/dovecot/dh.pem | awk '{print $5}'` + echo $filesize + + if [ ! -f "/etc/dovecot/dh.pem" ] || [ $filesize -lt 300 ]; then + openssl dhparam 2048 > /etc/dovecot/dh.pem + fi } Uninstall_App() From fb3aac37ec486a8a4ae29ac9dce4cff8498f34c9 Mon Sep 17 00:00:00 2001 From: midoks Date: Tue, 13 Sep 2022 23:42:54 +0800 Subject: [PATCH 07/59] Update install.sh --- plugins/mail/versions/1.0/install.sh | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/plugins/mail/versions/1.0/install.sh b/plugins/mail/versions/1.0/install.sh index 95d025a984..b9158d662c 100755 --- a/plugins/mail/versions/1.0/install.sh +++ b/plugins/mail/versions/1.0/install.sh @@ -74,6 +74,26 @@ Install_App() Install_ubuntu fi + if [ ! -f /etc/dovecot/conf.d/90-sieve.conf ];then + if [ -f "/usr/bin/apt-get" ];then + apt install dovecot-sieve -y + else + rm -rf /etc/dovecot_back + cp -a /etc/dovecot /etc/dovecot_back + yum remove dovecot -y + yum install dovecot-pigeonhole -y + if [ ! -f /usr/sbin/dovecot ]; then + yum install dovecot -y + fi + \cp -a /etc/dovecot_back/* /etc/dovecot + chown -R vmail:dovecot /etc/dovecot + chmod -R o-rwx /etc/dovecot + + systemctl enable dovecot + systemctl restart dovecot + fi + fi + filesize=`ls -l /etc/dovecot/dh.pem | awk '{print $5}'` echo $filesize From 1ad9546ae476cd78c8bc1d1f7bd076eb231badba Mon Sep 17 00:00:00 2001 From: midoks Date: Tue, 13 Sep 2022 23:48:01 +0800 Subject: [PATCH 08/59] Update install.sh --- plugins/mail/versions/1.0/install.sh | 34 ++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/plugins/mail/versions/1.0/install.sh b/plugins/mail/versions/1.0/install.sh index b9158d662c..f4b4aa575e 100755 --- a/plugins/mail/versions/1.0/install.sh +++ b/plugins/mail/versions/1.0/install.sh @@ -35,7 +35,6 @@ OSNAME=`cat ${rootPath}/data/osname.pl` OSNAME_ID=`cat /etc/*-release | grep VERSION_ID | awk -F = '{print $2}' | awk -F "\"" '{print $2}'` - Install_debain(){ hostname=`hostname` # 安装postfix和postfix-sqlite @@ -53,6 +52,19 @@ Install_debain(){ apt install cyrus-sasl-plain -y } +Uninstall_debain(){ + apt remove postfix postfix-sqlite -y && rm -rf /etc/postfix + dpkg -P postfix postfix-sqlite + apt remove dovecot-core dovecot-imapd dovecot-lmtpd dovecot-pop3d dovecot-sqlite dovecot-sieve -y + dpkg -P dovecot-core dovecot-imapd dovecot-lmtpd dovecot-pop3d dovecot-sqlite dovecot-sieve + apt remove opendkim opendkim-tools -y + dpkg -P opendkim opendkim-tools + apt remove rspamd -y + dpkg -P rspamd +} + + + Install_App() { echo '正在安装脚本文件...' > $install_tmp @@ -104,12 +116,30 @@ Install_App() Uninstall_App() { + if [[ $OSNAME = "centos" ]]; then + + if [[ $OSNAME_ID == "7" ]];then + Install_centos7 + fi + + if [[ $OSNAME_ID == "8" ]];then + Install_centos8 + fi + + elif [[ $OSNAME = "debian" ]]; then + Uninstall_debain + else + Install_ubuntu + fi if [ -f $serverPath/mail/initd/mail ];then $serverPath/mail/initd/mail stop fi - rm -rf $serverPath/mail + rm -rf /etc/postfix + rm -rf /etc/dovecot + rm -rf /etc/opendkim + rm -rf /usr/share/rspamd/www/rspamd echo "Uninstall_Mail" > $install_tmp } From b616854baafc03d78a3f40281229d50c1988826e Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 14 Sep 2022 20:50:32 +0800 Subject: [PATCH 09/59] =?UTF-8?q?redis=20=E6=B7=BB=E5=8A=A0=E6=80=A7?= =?UTF-8?q?=E8=83=BD=E8=B0=83=E6=95=B4=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/mail/index.html | 2 +- plugins/redis/config/redis.conf | 3 + plugins/redis/index.html | 45 ++-------- plugins/redis/index.py | 83 +++++++++++++++++- plugins/redis/js/redis.js | 149 ++++++++++++++++++++++++++++++++ 5 files changed, 240 insertions(+), 42 deletions(-) create mode 100755 plugins/redis/js/redis.js diff --git a/plugins/mail/index.html b/plugins/mail/index.html index b257f933f2..7804682f85 100755 --- a/plugins/mail/index.html +++ b/plugins/mail/index.html @@ -12,5 +12,5 @@
\ No newline at end of file diff --git a/plugins/redis/config/redis.conf b/plugins/redis/config/redis.conf index 30c63fff0f..fae7a8a768 100644 --- a/plugins/redis/config/redis.conf +++ b/plugins/redis/config/redis.conf @@ -1,6 +1,9 @@ daemonize yes pidfile {$SERVER_PATH}/redis/redis_6379.pid + +bind 127.0.0.1 port 6379 +requirepass admin timeout 0 tcp-keepalive 0 diff --git a/plugins/redis/index.html b/plugins/redis/index.html index dfa65bf45a..f7eb39a90e 100755 --- a/plugins/redis/index.html +++ b/plugins/redis/index.html @@ -1,10 +1,12 @@
+

服务

自启动

配置修改

-

负载状态

+

性能调整

+

负载状态

日志

@@ -13,42 +15,7 @@
\ No newline at end of file diff --git a/plugins/redis/index.py b/plugins/redis/index.py index 671d9b98d9..f3664256f1 100755 --- a/plugins/redis/index.py +++ b/plugins/redis/index.py @@ -4,6 +4,7 @@ import io import os import time +import re sys.path.append(os.getcwd() + "/class/core") import mw @@ -47,7 +48,7 @@ def getInitDTpl(): def getArgs(): - args = sys.argv[2:] + args = sys.argv[3:] tmp = {} args_len = len(args) @@ -153,7 +154,19 @@ def reload(): def runInfo(): + requirepass = "" + + conf = getServerDir() + '/redis.conf' + content = mw.readFile(conf) + rep = "^(requirepass" + ')\s*([.0-9A-Za-z_& ~]+)' + tmp = re.search(rep, content, re.M) + if tmp: + requirepass = tmp.groups()[1] + cmd = getServerDir() + "/bin/redis-cli info" + if requirepass != "": + cmd = getServerDir() + '/bin/redis-cli -a "' + requirepass + '" info' + data = mw.execShell(cmd)[0] res = [ 'tcp_port', @@ -202,7 +215,6 @@ def initdInstall(): def initdUinstall(): - if mw.isAppleSystem(): return "Apple Computer does not support" @@ -213,6 +225,69 @@ def initdUinstall(): def runLog(): return getServerDir() + '/data/redis.log' + +def getRedisConfInfo(): + conf = getServerDir() + '/redis.conf' + content = mw.readFile(conf) + + gets = [ + {'name': 'bind', 'type': 2, 'ps': '绑定IP(修改绑定IP可能会存在安全隐患)'}, + {'name': 'port', 'type': 2, 'ps': '绑定端口'}, + {'name': 'timeout', 'type': 2, 'ps': '空闲链接超时时间,0表示不断开'}, + {'name': 'maxclients', 'type': 2, 'ps': '最大输入时间'}, + {'name': 'databases', 'type': 2, 'ps': '数据库数量'}, + {'name': 'requirepass', 'type': 2, 'ps': 'redis密码,留空代表没有设置密码'}, + {'name': 'maxmemory', 'type': 2, 'ps': 'MB,最大使用内存,0表示不限制'} + ] + content = mw.readFile(conf) + + result = [] + for g in gets: + rep = "^(" + g['name'] + ')\s*([.0-9A-Za-z_& ~]+)' + tmp = re.search(rep, content, re.M) + if not tmp: + g['value'] = '' + result.append(g) + continue + g['value'] = tmp.groups()[1] + if g['name'] == 'maxmemory': + g['value'] = g['value'].strip("mb") + result.append(g) + + return result + + +def getRedisConf(): + data = getRedisConfInfo() + return mw.getJson(data) + + +def submitRedisConf(): + gets = ['bind', 'port', 'timeout', 'maxclients', + 'databases', 'requirepass', 'maxmemory'] + args = getArgs() + conf = getServerDir() + '/redis.conf' + content = mw.readFile(conf) + for g in gets: + if g in args: + rep = g + '\s*([.0-9A-Za-z_& ~]+)' + val = g + ' ' + args[g] + + if g == 'maxmemory': + val = g + ' ' + args[g] + "mb" + + if g == 'requirepass' and args[g] == '': + content = re.sub('requirepass', '#requirepass', content) + if g == 'requirepass' and args[g] != '': + content = re.sub('#requirepass', 'requirepass', content) + content = re.sub(rep, val, content) + + if g != 'requirepass': + content = re.sub(rep, val, content) + mw.writeFile(conf, content) + reload() + return mw.returnJson(True, '设置成功') + if __name__ == "__main__": func = sys.argv[1] if func == 'status': @@ -237,5 +312,9 @@ def runLog(): print(getConf()) elif func == 'run_log': print(runLog()) + elif func == 'get_redis_conf': + print(getRedisConf()) + elif func == 'submit_redis_conf': + print(submitRedisConf()) else: print('error') diff --git a/plugins/redis/js/redis.js b/plugins/redis/js/redis.js new file mode 100755 index 0000000000..63b3d73e09 --- /dev/null +++ b/plugins/redis/js/redis.js @@ -0,0 +1,149 @@ + +function str2Obj(str){ + var data = {}; + kv = str.split('&'); + for(i in kv){ + v = kv[i].split('='); + data[v[0]] = v[1]; + } + return data; +} + +function redisPost(method, version, args,callback){ + var loadT = layer.msg('正在获取...', { icon: 16, time: 0, shade: 0.3 }); + + var req_data = {}; + req_data['name'] = 'redis'; + req_data['func'] = method; + req_data['version'] = version; + + if (typeof(args) == 'string'){ + req_data['args'] = JSON.stringify(str2Obj(args)); + } else { + req_data['args'] = JSON.stringify(args); + } + + $.post('/plugins/run', req_data, function(data) { + layer.close(loadT); + if (!data.status){ + //错误展示10S + layer.msg(data.msg,{icon:0,time:2000,shade: [10, '#000']}); + return; + } + + if(typeof(callback) == 'function'){ + callback(data); + } + },'json'); +} + +function redisPostCallbak(method, version, args,callback){ + var loadT = layer.msg('正在获取...', { icon: 16, time: 0, shade: 0.3 }); + + var req_data = {}; + req_data['name'] = 'redis'; + req_data['func'] = method; + args['version'] = version; + + if (typeof(args) == 'string'){ + req_data['args'] = JSON.stringify(str2Obj(args)); + } else { + req_data['args'] = JSON.stringify(args); + } + + $.post('/plugins/callback', req_data, function(data) { + layer.close(loadT); + if (!data.status){ + layer.msg(data.msg,{icon:0,time:2000,shade: [0.3, '#000']}); + return; + } + + if(typeof(callback) == 'function'){ + callback(data); + } + },'json'); +} + +//redis负载状态 start +function redisStatus(version) { + + redisPost('run_info',version, {},function(data){ + var rdata = $.parseJSON(data.data); + hit = (parseInt(rdata.keyspace_hits) / (parseInt(rdata.keyspace_hits) + parseInt(rdata.keyspace_misses)) * 100).toFixed(2); + var con = '
\ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ +
字段当前值说明
uptime_in_days' + rdata.uptime_in_days + '已运行天数
tcp_port' + rdata.tcp_port + '当前监听端口
connected_clients' + rdata.connected_clients + '连接的客户端数量
used_memory_rss' + toSize(rdata.used_memory_rss) + 'Redis当前占用的系统内存总量
used_memory' + toSize(rdata.used_memory) + 'Redis当前已分配的内存总量
used_memory_peak' + toSize(rdata.used_memory_peak) + 'Redis历史分配内存的峰值
mem_fragmentation_ratio' + rdata.mem_fragmentation_ratio + '%内存碎片比率
total_connections_received' + rdata.total_connections_received + '运行以来连接过的客户端的总数量
total_commands_processed' + rdata.total_commands_processed + '运行以来执行过的命令的总数量
instantaneous_ops_per_sec' + rdata.instantaneous_ops_per_sec + '服务器每秒钟执行的命令数量
keyspace_hits' + rdata.keyspace_hits + '查找数据库键成功的次数
keyspace_misses' + rdata.keyspace_misses + '查找数据库键失败的次数
hit' + hit + '%查找数据库键命中率
latest_fork_usec' + rdata.latest_fork_usec + '最近一次 fork() 操作耗费的微秒数
'; + $(".soft-man-con").html(con); + }); +} +//redis负载状态 end + +//配置修改 +function getRedisConfig(version) { + redisPost('get_redis_conf', version,'',function(data){ + // console.log(data); + var rdata = $.parseJSON(data.data); + // console.log(rdata); + var mlist = ''; + for (var i = 0; i < rdata.length; i++) { + var w = '70' + if (rdata[i].name == 'error_reporting') w = '250'; + var ibody = ''; + switch (rdata[i].type) { + case 0: + var selected_1 = (rdata[i].value == 1) ? 'selected' : ''; + var selected_0 = (rdata[i].value == 0) ? 'selected' : ''; + ibody = '' + break; + case 1: + var selected_1 = (rdata[i].value == 'On') ? 'selected' : ''; + var selected_0 = (rdata[i].value == 'Off') ? 'selected' : ''; + ibody = '' + break; + } + mlist += '

' + rdata[i].name + '' + ibody + ', ' + rdata[i].ps + '

' + } + var phpCon = '
' + mlist + '\ +
\ +
\ +
' + $(".soft-man-con").html(phpCon); + }); +} + +//提交PHP配置 +function submitConf(version) { + var data = { + version: version, + bind: $("input[name='bind']").val(), + 'port': $("input[name='port']").val(), + 'timeout': $("input[name='timeout']").val(), + maxclients: $("input[name='maxclients']").val(), + databases: $("input[name='databases']").val(), + requirepass: $("input[name='requirepass']").val(), + maxmemory: $("input[name='maxmemory']").val(), + }; + + redisPost('submit_redis_conf', version, data, function(ret_data){ + var rdata = $.parseJSON(ret_data.data); + layer.msg(rdata.msg, { icon: rdata.status ? 1 : 2 }); + }); +} + From c0e1512195cdd79fc841bfebbfaa428656a7504c Mon Sep 17 00:00:00 2001 From: midoks Date: Thu, 15 Sep 2022 00:16:08 +0800 Subject: [PATCH 10/59] init --- plugins/mail/index.html | 7 +- plugins/mail/index.py | 5 +- plugins/mail/js/mail.js | 66 +++++++++++ plugins/mail/versions/1.0/install.sh | 33 +++--- plugins/mail/versions/1.0/install_centos.sh | 118 ++++++++++++++++++++ 5 files changed, 206 insertions(+), 23 deletions(-) create mode 100755 plugins/mail/js/mail.js create mode 100644 plugins/mail/versions/1.0/install_centos.sh diff --git a/plugins/mail/index.html b/plugins/mail/index.html index 7804682f85..aa6ab36a23 100755 --- a/plugins/mail/index.html +++ b/plugins/mail/index.html @@ -1,9 +1,10 @@
-

服务

+

域名列表

自启动

配置修改

+

服务状态

日志

@@ -12,5 +13,7 @@
\ No newline at end of file diff --git a/plugins/mail/index.py b/plugins/mail/index.py index 37ffe8ffc5..69359867ec 100755 --- a/plugins/mail/index.py +++ b/plugins/mail/index.py @@ -211,7 +211,10 @@ def initdUinstall(): def runLog(): - return getServerDir() + '/data/redis.log' + path = '/var/log/maillog' + # if "ubuntu" in: + # path = '/var/log/mail.log' + return path if __name__ == "__main__": func = sys.argv[1] diff --git a/plugins/mail/js/mail.js b/plugins/mail/js/mail.js new file mode 100755 index 0000000000..5f5ce730d0 --- /dev/null +++ b/plugins/mail/js/mail.js @@ -0,0 +1,66 @@ + +function str2Obj(str){ + var data = {}; + kv = str.split('&'); + for(i in kv){ + v = kv[i].split('='); + data[v[0]] = v[1]; + } + return data; +} + +function mailPost(method, version, args,callback){ + var loadT = layer.msg('正在获取...', { icon: 16, time: 0, shade: 0.3 }); + + var req_data = {}; + req_data['name'] = 'mail'; + req_data['func'] = method; + req_data['version'] = version; + + if (typeof(args) == 'string'){ + req_data['args'] = JSON.stringify(str2Obj(args)); + } else { + req_data['args'] = JSON.stringify(args); + } + + $.post('/plugins/run', req_data, function(data) { + layer.close(loadT); + if (!data.status){ + //错误展示10S + layer.msg(data.msg,{icon:0,time:2000,shade: [10, '#000']}); + return; + } + + if(typeof(callback) == 'function'){ + callback(data); + } + },'json'); +} + +function mailPostCallbak(method, version, args,callback){ + var loadT = layer.msg('正在获取...', { icon: 16, time: 0, shade: 0.3 }); + + var req_data = {}; + req_data['name'] = 'mail'; + req_data['func'] = method; + args['version'] = version; + + if (typeof(args) == 'string'){ + req_data['args'] = JSON.stringify(str2Obj(args)); + } else { + req_data['args'] = JSON.stringify(args); + } + + $.post('/plugins/callback', req_data, function(data) { + layer.close(loadT); + if (!data.status){ + layer.msg(data.msg,{icon:0,time:2000,shade: [0.3, '#000']}); + return; + } + + if(typeof(callback) == 'function'){ + callback(data); + } + },'json'); +} + diff --git a/plugins/mail/versions/1.0/install.sh b/plugins/mail/versions/1.0/install.sh index f4b4aa575e..57b7798ffe 100755 --- a/plugins/mail/versions/1.0/install.sh +++ b/plugins/mail/versions/1.0/install.sh @@ -63,23 +63,23 @@ Uninstall_debain(){ dpkg -P rspamd } +Install_ubuntu(){ + Install_debain +} +Uninstall_ubuntu(){ + Uninstall_debain +} Install_App() { echo '正在安装脚本文件...' > $install_tmp mkdir -p $serverPath/source - if [[ $OSNAME = "centos" ]]; then - - if [[ $OSNAME_ID == "7" ]];then - Install_centos7 - fi - - if [[ $OSNAME_ID == "8" ]];then - Install_centos8 - fi + runScript=$curPath/install_$OSNAME.sh + if [[ -f $runScript ]]; then + sh -x $runScript install elif [[ $OSNAME = "debian" ]]; then Install_debain else @@ -116,20 +116,13 @@ Install_App() Uninstall_App() { - if [[ $OSNAME = "centos" ]]; then - - if [[ $OSNAME_ID == "7" ]];then - Install_centos7 - fi - - if [[ $OSNAME_ID == "8" ]];then - Install_centos8 - fi - + runScript=$curPath/install_$OSNAME.sh + if [[ -f $runScript ]]; then + sh -x $runScript uninstall elif [[ $OSNAME = "debian" ]]; then Uninstall_debain else - Install_ubuntu + Uninstall_ubuntu fi if [ -f $serverPath/mail/initd/mail ];then diff --git a/plugins/mail/versions/1.0/install_centos.sh b/plugins/mail/versions/1.0/install_centos.sh new file mode 100644 index 0000000000..181c8db234 --- /dev/null +++ b/plugins/mail/versions/1.0/install_centos.sh @@ -0,0 +1,118 @@ +#!/bin/bash +PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin +export PATH + +curPath=`pwd` +rootPath=$(dirname "$curPath") +rootPath=$(dirname "$rootPath") +serverPath=$(dirname "$rootPath") + +cpu_arch=`arch` +if [[ $cpu_arch != "x86_64" ]];then + echo 'Does not support non-x86 system installation' + exit 0 +fi + + +OSNAME_ID=`cat /etc/*-release | grep VERSION_ID | awk -F = '{print $2}' | awk -F "\"" '{print $2}'` + +Install_centos8() +{ + yum install epel-release -y + # 卸载系统自带的postfix + if [[ $cpu_arch = "x86_64" && $postfixver != "3.4.9" ]];then + yum remove postfix -y + rm -rf /etc/postfix + fi + # 安装postfix和postfix-sqlite + yum localinstall $pluginPath/rpm/postfix3-3.4.9-1.gf.el8.x86_64.rpm -y + yum localinstall $pluginPath/rpm/postfix3-sqlite-3.4.9-1.gf.el8.x86_64.rpm -y + if [[ ! -f "/usr/sbin/postfix" ]]; then + yum install postfix -y + yum install postfix-sqlite -y + fi + # 安装dovecot和dovecot-sieve + yum install dovecot-pigeonhole -y + if [[ ! -f "/usr/sbin/dovecot" ]]; then + yum install dovecot -y + fi + # 安装opendkim +# 安装rspamd + + install_rspamd + yum install cyrus-sasl-plain -y +} + +Install_centos7() { + + yum install epel-release -y + # 卸载系统自带的postfix + if [[ $cpu_arch = "x86_64" && $postfixver != "3.4.7" ]];then + yum remove postfix -y + rm -rf /etc/postfix + fi + # 安装postfix和postfix-sqlite + yum localinstall $pluginPath/rpm/postfix3-3.4.7-1.gf.el7.x86_64.rpm -y + yum localinstall $pluginPath/rpm/postfix3-sqlite-3.4.7-1.gf.el7.x86_64.rpm -y + if [[ ! -f "/usr/sbin/postfix" ]]; then + yum install postfix -y + yum install postfix-sqlite -y + fi + # 安装dovecot和dovecot-sieve + yum install dovecot-pigeonhole -y + if [[ ! -f "/usr/sbin/dovecot" ]]; then + yum install dovecot -y + fi + #安装rspamd + install_rspamd + yum install cyrus-sasl-plain -y + +} + +install_rspamd() { + if [[ $systemver = "7" ]];then + wget -O /etc/yum.repos.d/rspamd.repo https://rspamd.com/rpm-stable/centos-7/rspamd.repo + rpm --import https://rspamd.com/rpm-stable/gpg.key + yum makecache + yum install rspamd -y + elif [ $systemver = "8" ]; then + wget -O /etc/yum.repos.d/rspamd.repo https://rspamd.com/rpm-stable/centos-8/rspamd.repo + rpm --import https://rspamd.com/rpm-stable/gpg.key + yum makecache + yum install rspamd -y + else + CODENAME=`lsb_release -c -s` + mkdir -p /etc/apt/keyrings + wget -O- https://rspamd.com/apt-stable/gpg.key | gpg --dearmor | tee /etc/apt/keyrings/rspamd.gpg > /dev/null + echo "deb [arch=amd64 signed-by=/etc/apt/keyrings/rspamd.gpg] http://rspamd.com/apt-stable/ $CODENAME main" | tee /etc/apt/sources.list.d/rspamd.list + echo "deb-src [arch=amd64 signed-by=/etc/apt/keyrings/rspamd.gpg] http://rspamd.com/apt-stable/ $CODENAME main" | tee -a /etc/apt/sources.list.d/rspamd.list + apt-get update + export DEBIAN_FRONTEND=noninteractive + apt-get --no-install-recommends install rspamd -y + fi +} + +Install_App() { + if [ "$OSNAME_ID" == "7" ];then + Install_centos7 + elif [ "$OSNAME_ID" == "8" ];then + Install_centos8 + fi +} + +Uninstall_App() +{ + yum remove postfix -y + yum remove dovecot -y + yum remove opendkim -y + yum remove rspamd -y + yum remove dovecot-pigeonhole -y +} + + +action=$1 +if [ "${1}" == 'install' ];then + Install_App +else + Uninstall_App +fi \ No newline at end of file From 38f8fe9a3897c679edbe1ed3af03a4b2059d068f Mon Sep 17 00:00:00 2001 From: midoks Date: Thu, 15 Sep 2022 17:59:37 +0800 Subject: [PATCH 11/59] =?UTF-8?q?=E7=94=BB=E4=B8=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/mail/index.html | 9 +- plugins/mail/index.py | 171 +------------------- plugins/mail/info.json | 2 +- plugins/mail/js/mail.js | 126 +++++++++++++++ plugins/mail/versions/1.0/install.sh | 4 + plugins/mail/versions/1.0/install_centos.sh | 4 +- 6 files changed, 138 insertions(+), 178 deletions(-) diff --git a/plugins/mail/index.html b/plugins/mail/index.html index aa6ab36a23..a8c3a2e599 100755 --- a/plugins/mail/index.html +++ b/plugins/mail/index.html @@ -1,10 +1,8 @@
-

域名列表

-

自启动

-

配置修改

-

服务状态

+

域名列表

+

服务状态

日志

@@ -13,7 +11,8 @@
\ No newline at end of file diff --git a/plugins/mail/index.py b/plugins/mail/index.py index 69359867ec..81c8295c44 100755 --- a/plugins/mail/index.py +++ b/plugins/mail/index.py @@ -31,23 +31,8 @@ def getInitDFile(): return '/etc/init.d/' + getPluginName() -def getConf(): - path = getServerDir() + "/redis.conf" - return path - - -def getConfTpl(): - path = getPluginDir() + "/config/redis.conf" - return path - - -def getInitDTpl(): - path = getPluginDir() + "/init.d/" + getPluginName() + ".tpl" - return path - - def getArgs(): - args = sys.argv[2:] + args = sys.argv[3:] tmp = {} args_len = len(args) @@ -72,144 +57,6 @@ def status(): return 'start' -def initDreplace(): - - file_tpl = getInitDTpl() - service_path = os.path.dirname(os.getcwd()) - - initD_path = getServerDir() + '/init.d' - if not os.path.exists(initD_path): - os.mkdir(initD_path) - file_bin = initD_path + '/' + getPluginName() - - # initd replace - if not os.path.exists(file_bin): - content = mw.readFile(file_tpl) - content = content.replace('{$SERVER_PATH}', service_path) - mw.writeFile(file_bin, content) - mw.execShell('chmod +x ' + file_bin) - - # log - dataLog = getServerDir() + '/data' - if not os.path.exists(dataLog): - mw.execShell('chmod +x ' + file_bin) - - # config replace - dst_conf = getServerDir() + '/redis.conf' - dst_conf_init = getServerDir() + '/init.pl' - if not os.path.exists(dst_conf_init): - conf_content = mw.readFile(getConfTpl()) - conf_content = conf_content.replace('{$SERVER_PATH}', service_path) - mw.writeFile(dst_conf, conf_content) - mw.writeFile(dst_conf_init, 'ok') - - # systemd - systemDir = mw.systemdCfgDir() - systemService = systemDir + '/redis.service' - systemServiceTpl = getPluginDir() + '/init.d/redis.service.tpl' - if os.path.exists(systemDir) and not os.path.exists(systemService): - service_path = mw.getServerDir() - se_content = mw.readFile(systemServiceTpl) - se_content = se_content.replace('{$SERVER_PATH}', service_path) - mw.writeFile(systemService, se_content) - mw.execShell('systemctl daemon-reload') - - return file_bin - - -def redisOp(method): - file = initDreplace() - - if not mw.isAppleSystem(): - data = mw.execShell('systemctl ' + method + ' redis') - if data[1] == '': - return 'ok' - return 'fail' - - data = mw.execShell(file + ' start') - if data[1] == '': - return 'ok' - return 'fail' - - -def start(): - return redisOp('start') - - -def stop(): - return redisOp('stop') - - -def restart(): - status = redisOp('restart') - - log_file = runLog() - mw.execShell("echo '' > " + log_file) - return status - - -def reload(): - return redisOp('reload') - - -def runInfo(): - cmd = getServerDir() + "/bin/redis-cli info" - data = mw.execShell(cmd)[0] - res = [ - 'tcp_port', - 'uptime_in_days', # 已运行天数 - 'connected_clients', # 连接的客户端数量 - 'used_memory', # Redis已分配的内存总量 - 'used_memory_rss', # Redis占用的系统内存总量 - 'used_memory_peak', # Redis所用内存的高峰值 - 'mem_fragmentation_ratio', # 内存碎片比率 - 'total_connections_received', # 运行以来连接过的客户端的总数量 - 'total_commands_processed', # 运行以来执行过的命令的总数量 - 'instantaneous_ops_per_sec', # 服务器每秒钟执行的命令数量 - 'keyspace_hits', # 查找数据库键成功的次数 - 'keyspace_misses', # 查找数据库键失败的次数 - 'latest_fork_usec' # 最近一次 fork() 操作耗费的毫秒数 - ] - data = data.split("\n") - result = {} - for d in data: - if len(d) < 3: - continue - t = d.strip().split(':') - if not t[0] in res: - continue - result[t[0]] = t[1] - return mw.getJson(result) - - -def initdStatus(): - if mw.isAppleSystem(): - return "Apple Computer does not support" - - shell_cmd = 'systemctl status redis | grep loaded | grep "enabled;"' - data = mw.execShell(shell_cmd) - if data[0] == '': - return 'fail' - return 'ok' - - -def initdInstall(): - if mw.isAppleSystem(): - return "Apple Computer does not support" - - mw.execShell('systemctl enable redis') - return 'ok' - - -def initdUinstall(): - - if mw.isAppleSystem(): - return "Apple Computer does not support" - - mw.execShell('systemctl disable redis') - return 'ok' - - def runLog(): path = '/var/log/maillog' # if "ubuntu" in: @@ -220,22 +67,6 @@ def runLog(): 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 == 'run_info': - print(runInfo()) elif func == 'conf': print(getConf()) elif func == 'run_log': diff --git a/plugins/mail/info.json b/plugins/mail/info.json index 36c3336478..222e411ca5 100755 --- a/plugins/mail/info.json +++ b/plugins/mail/info.json @@ -2,7 +2,7 @@ "sort": 7, "ps": "简单邮件服务[DEV]", "name": "mail", - "title": "mail", + "title": "邮件服务", "shell": "install.sh", "versions":["1.0"], "updates":["1.0"], diff --git a/plugins/mail/js/mail.js b/plugins/mail/js/mail.js index 5f5ce730d0..f72218f982 100755 --- a/plugins/mail/js/mail.js +++ b/plugins/mail/js/mail.js @@ -64,3 +64,129 @@ function mailPostCallbak(method, version, args,callback){ },'json'); } + +function domainList(){ + var con = '
\ + \ + \ + \ +
\ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ +
邮箱域名MX记录A记录SPF记录DKIM记录DMARC记录CatchAllSSL操作
\ +
\ +
\ +
    \ +
  • \ + 添加域名后,需要添加MX记录(用于邮箱服务)和TXT记录(用于邮箱反垃圾服务)才能正常使用邮箱服务。\ +
  • \ +
  • \ + 提示: 部分云厂商(如:阿里云,腾讯云)默认关闭25端口,需联系厂商开通25端口后才能正常使用邮局服务\ +
  • \ +
  • 该自建邮局版本为基础版本,仅提供基础功能,更多功能请耐心等候开发进度。
  • \ +
\ +
'; + + $(".soft-man-con").html(con); +} + + + +function serviceStatus(){ + var con = '
\ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ +
服务名称服务状态操作
Dovecot获取中...\ + 启动\ + 停止 | \ + 重启 | \ + 修复 | \ + 获取中...\ + 启动\ + 停止 | \ + 重启 | \ + 修复 | \ + 配置文件\ +
Rspamd获取中...\ + 启动\ + 停止 | \ + 重启 | \ + 修复 | \ + 配置文件\ +
Postfix获取中...\ + 启动\ + 停止 | \ + 重启 | \ + 修复 | \ + 配置文件\ +
\ +
'; + $(".soft-man-con").html(con); +} + diff --git a/plugins/mail/versions/1.0/install.sh b/plugins/mail/versions/1.0/install.sh index 57b7798ffe..337d179605 100755 --- a/plugins/mail/versions/1.0/install.sh +++ b/plugins/mail/versions/1.0/install.sh @@ -112,6 +112,10 @@ Install_App() if [ ! -f "/etc/dovecot/dh.pem" ] || [ $filesize -lt 300 ]; then openssl dhparam 2048 > /etc/dovecot/dh.pem fi + + mkdir -p $serverPath/mail + echo '1.0' > $serverPath/mail/version.pl + echo '安装完成' > $install_tmp } Uninstall_App() diff --git a/plugins/mail/versions/1.0/install_centos.sh b/plugins/mail/versions/1.0/install_centos.sh index 181c8db234..e30a78a16f 100644 --- a/plugins/mail/versions/1.0/install_centos.sh +++ b/plugins/mail/versions/1.0/install_centos.sh @@ -70,12 +70,12 @@ Install_centos7() { } install_rspamd() { - if [[ $systemver = "7" ]];then + if [[ $OSNAME_ID = "7" ]];then wget -O /etc/yum.repos.d/rspamd.repo https://rspamd.com/rpm-stable/centos-7/rspamd.repo rpm --import https://rspamd.com/rpm-stable/gpg.key yum makecache yum install rspamd -y - elif [ $systemver = "8" ]; then + elif [ $OSNAME_ID = "8" ]; then wget -O /etc/yum.repos.d/rspamd.repo https://rspamd.com/rpm-stable/centos-8/rspamd.repo rpm --import https://rspamd.com/rpm-stable/gpg.key yum makecache From b314ebeed33c1479ef2b073798d2b660ebdf5337 Mon Sep 17 00:00:00 2001 From: midoks Date: Fri, 16 Sep 2022 11:49:20 +0800 Subject: [PATCH 12/59] =?UTF-8?q?cpu=20tips=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit gogs 统计优化 --- class/core/mw.py | 15 ++++++++++-- class/core/system_api.py | 19 +++++++++++---- plugins/gogs/index.py | 7 +----- route/static/app/index.js | 37 +++++++++++++++++++++--------- route/templates/default/index.html | 2 +- 5 files changed, 55 insertions(+), 25 deletions(-) diff --git a/class/core/mw.py b/class/core/mw.py index c4cb1d603d..1711b0d226 100755 --- a/class/core/mw.py +++ b/class/core/mw.py @@ -714,13 +714,24 @@ def getStrBetween(startStr, endStr, srcStr): def getCpuType(): + cpuType = '' + if isAppleSystem(): + cmd = "system_profiler SPHardwareDataType | grep 'Processor Name' | awk -F ':' '{print $2}'" + cpuinfo = execShell(cmd) + return cpuinfo[0].strip() + # 取CPU类型 cpuinfo = open('/proc/cpuinfo', 'r').read() rep = "model\s+name\s+:\s+(.+)" - tmp = re.search(rep, cpuinfo) - cpuType = None + tmp = re.search(rep, cpuinfo, re.I) if tmp: cpuType = tmp.groups()[0] + else: + cpuinfo = execShell('LANG="en_US.UTF-8" && lscpu')[0] + rep = "Model\s+name:\s+(.+)" + tmp = re.search(rep, cpuinfo, re.I) + if tmp: + cpuType = tmp.groups()[0] return cpuType diff --git a/class/core/system_api.py b/class/core/system_api.py index f176642bed..80c4930485 100755 --- a/class/core/system_api.py +++ b/class/core/system_api.py @@ -162,7 +162,7 @@ def getPanelInfo(self, get=None): except: port = mw.readFile('data/port.pl') except: - port = '8888' + port = '7200' domain = '' if os.path.exists('data/domain.conf'): domain = mw.readFile('data/domain.conf') @@ -201,9 +201,9 @@ def getSystemTotal(self, interval=1): def getLoadAverage(self): c = os.getloadavg() data = {} - data['one'] = float(c[0]) - data['five'] = float(c[1]) - data['fifteen'] = float(c[2]) + data['one'] = round(float(c[0]), 2) + data['five'] = round(float(c[1]), 2) + data['fifteen'] = round(float(c[2]), 2) data['max'] = psutil.cpu_count() * 2 data['limit'] = data['max'] data['safe'] = data['max'] * 0.75 @@ -276,8 +276,17 @@ def getBootTime(self): def getCpuInfo(self, interval=1): # 取CPU信息 cpuCount = psutil.cpu_count() + cpuLogicalNum = psutil.cpu_count(logical=False) used = psutil.cpu_percent(interval=interval) - return used, cpuCount + + if os.path.exists('/proc/cpuinfo'): + c_tmp = public.readFile('/proc/cpuinfo') + d_tmp = re.findall("physical id.+", c_tmp) + cpuLogicalNum = len(set(d_tmp)) + + used_all = psutil.cpu_percent(percpu=True) + cpu_name = mw.getCpuType() + " * {}".format(cpuLogicalNum) + return used, cpuCount, used_all, cpu_name, cpuCount, cpuLogicalNum def getMemInfo(self): # 取内存信息 diff --git a/plugins/gogs/index.py b/plugins/gogs/index.py index 8985144773..e494d29e0b 100755 --- a/plugins/gogs/index.py +++ b/plugins/gogs/index.py @@ -681,12 +681,7 @@ def getTotalStatistics(): data = {} if st.strip() == 'start': list_count = pQuery('select count(id) as num from repository') - - if list_count.find("error") > -1: - data['status'] = False - data['count'] = 0 - return mw.returnJson(False, 'fail', data) - + count = list_count[0]["num"] data['status'] = True data['count'] = count data['ver'] = mw.readFile(getServerDir() + '/version.pl').strip() diff --git a/route/static/app/index.js b/route/static/app/index.js index 50140ad5ff..d14e1cf901 100755 --- a/route/static/app/index.js +++ b/route/static/app/index.js @@ -65,6 +65,7 @@ function getLoad(data) { $('#LoadList .circle').click(function() { getNet(); }); + $('#LoadList .mask').hover(function() { var one, five, fifteen; var that = this; @@ -78,6 +79,25 @@ $('#LoadList .mask').hover(function() { }); +function showCpuTips(rdata){ + $('#cpuChart .mask').hover(function() { + var cpuText = ''; + for (var i = 1; i < rdata.cpu[2].length + 1; i++) { + var cpuUse = parseFloat(rdata.cpu[2][i - 1] == 0 ? 0 : rdata.cpu[2][i - 1]).toFixed(1) + if (i % 2 != 0) { + cpuText += 'CPU-' + i + ':' + cpuUse + '% | ' + } else { + cpuText += 'CPU-' + i + ':' + cpuUse + '%' + cpuText += '\n' + } + } + layer.tips(rdata.cpu[3] + "
" + rdata.cpu[5] + "个物理CPU," + (rdata.cpu[4]) + "个物理核心," + rdata.cpu[1] + "个逻辑核心
" + cpuText, this, { time: 0, tips: [1, '#999'] }); + }, function() { + layer.closeAll('tips'); + }); +} + + function rocket(sum, m) { var n = sum - m; $(".mem-release").find(".mask span").text(n); @@ -249,9 +269,11 @@ function setcolor(pre, s, s1, s2, s3) { co.parent('.circle').css("background", LoadColor); } + + + function getNet() { - var up; - var down; + var up, down; $.get("/system/network", function(net) { $("#InterfaceSpeed").html(lan.index.interfacespeed + ": 1.0Gbps"); $("#upSpeed").html(net.up + ' KB'); @@ -269,6 +291,8 @@ function getNet() { // setMemImg(net.mem); setImg(); + + showCpuTips(net); },'json'); } @@ -478,16 +502,7 @@ setTimeout(function() { $('#toUpdate a').css("position","relative"); return; } - // $.get('/system?action=ReWeb', function() {}); - // layer.msg(rdata.msg, { icon: 1 }); - // setTimeout(function() { - // window.location.reload(); - // }, 3000); },'json').error(function() { - // $.get('/system?action=ReWeb', function() {}); - // setTimeout(function() { - // window.location.reload(); - // }, 3000); }); }, 3000); diff --git a/route/templates/default/index.html b/route/templates/default/index.html index 6b8b4b3bf8..9146b09a73 100755 --- a/route/templates/default/index.html +++ b/route/templates/default/index.html @@ -38,7 +38,7 @@

负载状态获取中...

-
  • +
  • CPU使用率

    From 9f020927886ebe02ff26c757a120c98fdeb5234e Mon Sep 17 00:00:00 2001 From: midoks Date: Fri, 16 Sep 2022 11:52:20 +0800 Subject: [PATCH 13/59] Update system_api.py --- class/core/system_api.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/class/core/system_api.py b/class/core/system_api.py index 80c4930485..2cc71f1416 100755 --- a/class/core/system_api.py +++ b/class/core/system_api.py @@ -280,7 +280,7 @@ def getCpuInfo(self, interval=1): used = psutil.cpu_percent(interval=interval) if os.path.exists('/proc/cpuinfo'): - c_tmp = public.readFile('/proc/cpuinfo') + c_tmp = mw.readFile('/proc/cpuinfo') d_tmp = re.findall("physical id.+", c_tmp) cpuLogicalNum = len(set(d_tmp)) From daf6c9bff86b57ce091dcdf95ba5d1445ec57426 Mon Sep 17 00:00:00 2001 From: midoks Date: Fri, 16 Sep 2022 12:05:50 +0800 Subject: [PATCH 14/59] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- route/static/app/index.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/route/static/app/index.js b/route/static/app/index.js index d14e1cf901..7bcc851cd1 100755 --- a/route/static/app/index.js +++ b/route/static/app/index.js @@ -80,6 +80,7 @@ $('#LoadList .mask').hover(function() { function showCpuTips(rdata){ + $('#cpuChart .mask').unbind(); $('#cpuChart .mask').hover(function() { var cpuText = ''; for (var i = 1; i < rdata.cpu[2].length + 1; i++) { @@ -481,6 +482,8 @@ function setImg() { $(this).find('.left').css('transform', "rotate(" + (num - 180) + "deg)"); }; }); + + $('.diskbox .mask').unbind(); $('.diskbox .mask').hover(function() { layer.closeAll('tips'); var that = this; From ef6adfd82d6f8d203ff1bfebcd9250000a468f9c Mon Sep 17 00:00:00 2001 From: midoks Date: Fri, 16 Sep 2022 12:11:09 +0800 Subject: [PATCH 15/59] Update index.js --- route/static/app/index.js | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/route/static/app/index.js b/route/static/app/index.js index 7bcc851cd1..578b516e38 100755 --- a/route/static/app/index.js +++ b/route/static/app/index.js @@ -83,14 +83,19 @@ function showCpuTips(rdata){ $('#cpuChart .mask').unbind(); $('#cpuChart .mask').hover(function() { var cpuText = ''; - for (var i = 1; i < rdata.cpu[2].length + 1; i++) { - var cpuUse = parseFloat(rdata.cpu[2][i - 1] == 0 ? 0 : rdata.cpu[2][i - 1]).toFixed(1) - if (i % 2 != 0) { - cpuText += 'CPU-' + i + ':' + cpuUse + '% | ' - } else { - cpuText += 'CPU-' + i + ':' + cpuUse + '%' - cpuText += '\n' - } + + if (rdata.cpu[2].length == 1){ + cpuText += 'CPU-1:' + cpuUse + '%' + } else{ + for (var i = 1; i < rdata.cpu[2].length + 1; i++) { + var cpuUse = parseFloat(rdata.cpu[2][i - 1] == 0 ? 0 : rdata.cpu[2][i - 1]).toFixed(1) + if (i % 2 != 0) { + cpuText += 'CPU-' + i + ':' + cpuUse + '% | ' + } else { + cpuText += 'CPU-' + i + ':' + cpuUse + '%' + cpuText += '\n' + } + } } layer.tips(rdata.cpu[3] + "
    " + rdata.cpu[5] + "个物理CPU," + (rdata.cpu[4]) + "个物理核心," + rdata.cpu[1] + "个逻辑核心
    " + cpuText, this, { time: 0, tips: [1, '#999'] }); }, function() { @@ -482,7 +487,7 @@ function setImg() { $(this).find('.left').css('transform', "rotate(" + (num - 180) + "deg)"); }; }); - + $('.diskbox .mask').unbind(); $('.diskbox .mask').hover(function() { layer.closeAll('tips'); From e7174a211187f30b4eb363dd1f86310d2e116dfc Mon Sep 17 00:00:00 2001 From: midoks Date: Fri, 16 Sep 2022 12:13:34 +0800 Subject: [PATCH 16/59] Update index.js --- route/static/app/index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/route/static/app/index.js b/route/static/app/index.js index 578b516e38..0abe8a0fa6 100755 --- a/route/static/app/index.js +++ b/route/static/app/index.js @@ -85,6 +85,7 @@ function showCpuTips(rdata){ var cpuText = ''; if (rdata.cpu[2].length == 1){ + var cpuUse = parseFloat(rdata.cpu[2][0] == 0 ? 0 : rdata.cpu[2][0]).toFixed(1) cpuText += 'CPU-1:' + cpuUse + '%' } else{ for (var i = 1; i < rdata.cpu[2].length + 1; i++) { From cc80ec7839ac3213b530ef5e4592eccf41b3c592 Mon Sep 17 00:00:00 2001 From: midoks Date: Fri, 16 Sep 2022 12:14:07 +0800 Subject: [PATCH 17/59] Update index.js --- route/static/app/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/route/static/app/index.js b/route/static/app/index.js index 0abe8a0fa6..bb1d7e5d8e 100755 --- a/route/static/app/index.js +++ b/route/static/app/index.js @@ -85,11 +85,11 @@ function showCpuTips(rdata){ var cpuText = ''; if (rdata.cpu[2].length == 1){ - var cpuUse = parseFloat(rdata.cpu[2][0] == 0 ? 0 : rdata.cpu[2][0]).toFixed(1) + var cpuUse = parseFloat(rdata.cpu[2][0] == 0 ? 0 : rdata.cpu[2][0]).toFixed(1); cpuText += 'CPU-1:' + cpuUse + '%' } else{ for (var i = 1; i < rdata.cpu[2].length + 1; i++) { - var cpuUse = parseFloat(rdata.cpu[2][i - 1] == 0 ? 0 : rdata.cpu[2][i - 1]).toFixed(1) + var cpuUse = parseFloat(rdata.cpu[2][i - 1] == 0 ? 0 : rdata.cpu[2][i - 1]).toFixed(1); if (i % 2 != 0) { cpuText += 'CPU-' + i + ':' + cpuUse + '% | ' } else { From 9ee570e3bb610914f1c2ca659cf37f26dae10cf1 Mon Sep 17 00:00:00 2001 From: midoks Date: Fri, 16 Sep 2022 12:15:39 +0800 Subject: [PATCH 18/59] Update config_api.py --- class/core/config_api.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/class/core/config_api.py b/class/core/config_api.py index 72197f5c9d..0e09a4b457 100755 --- a/class/core/config_api.py +++ b/class/core/config_api.py @@ -15,7 +15,7 @@ class config_api: - __version = '0.9.9' + __version = '0.10.0.1' def __init__(self): pass From e45ebc5f11d32b0d75dc72dcb296d532e0cab4fd Mon Sep 17 00:00:00 2001 From: midoks Date: Fri, 16 Sep 2022 13:47:57 +0800 Subject: [PATCH 19/59] Update index.py --- plugins/mail/index.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/plugins/mail/index.py b/plugins/mail/index.py index 81c8295c44..1d10438007 100755 --- a/plugins/mail/index.py +++ b/plugins/mail/index.py @@ -49,11 +49,6 @@ def getArgs(): def status(): - data = mw.execShell( - "ps -ef|grep redis |grep -v grep | grep -v python | grep -v mdserver-web | awk '{print $2}'") - - if data[0] == '': - return 'stop' return 'start' From 47f67275d5bc76b0a6e099f3e732438865013ab1 Mon Sep 17 00:00:00 2001 From: midoks Date: Sat, 17 Sep 2022 21:09:53 +0800 Subject: [PATCH 20/59] up --- plugins/mail/conf/postfixadmin.sql | 42 ++ plugins/mail/index.html | 1035 +++++++++++++++++++++++++++- plugins/mail/index.py | 28 + plugins/mail/js/mail.js | 488 ++++++++----- 4 files changed, 1411 insertions(+), 182 deletions(-) create mode 100644 plugins/mail/conf/postfixadmin.sql diff --git a/plugins/mail/conf/postfixadmin.sql b/plugins/mail/conf/postfixadmin.sql new file mode 100644 index 0000000000..dc984f2f44 --- /dev/null +++ b/plugins/mail/conf/postfixadmin.sql @@ -0,0 +1,42 @@ +CREATE TABLE IF NOT EXISTS `domain` ( + `domain` varchar(255) NOT NULL, + `a_record` TEXT DEFAULT "", + `created` datetime NOT NULL, + `active` tinyint(1) NOT NULL DEFAULT 1, + PRIMARY KEY (`domain`) +); + +CREATE TABLE IF NOT EXISTS `mailbox` ( + `username` varchar(255) NOT NULL, + `password` varchar(255) NOT NULL, + `password_encode` varchar(255) NOT NULL, + `full_name` varchar(255) NOT NULL, + `is_admin` tinyint(1) NOT NULL DEFAULT 0, + `maildir` varchar(255) NOT NULL, + `quota` bigint(20) NOT NULL DEFAULT 0, + `local_part` varchar(255) NOT NULL, + `domain` varchar(255) NOT NULL, + `created` datetime NOT NULL, + `modified` datetime NOT NULL, + `active` tinyint(1) NOT NULL DEFAULT 1, + PRIMARY KEY (`username`) +); + +CREATE TABLE IF NOT EXISTS `alias` ( + `address` varchar(255) NOT NULL, + `goto` text NOT NULL, + `domain` varchar(255) NOT NULL, + `created` datetime NOT NULL, + `modified` datetime NOT NULL, + `active` tinyint(1) NOT NULL DEFAULT 1, + PRIMARY KEY (`address`) +); + +CREATE TABLE IF NOT EXISTS `alias_domain` ( + `alias_domain` varchar(255) NOT NULL, + `target_domain` varchar(255) NOT NULL, + `created` datetime NOT NULL, + `modified` datetime NOT NULL, + `active` tinyint(1) NOT NULL DEFAULT 1, + PRIMARY KEY (`alias_domain`) +); \ No newline at end of file diff --git a/plugins/mail/index.html b/plugins/mail/index.html index a8c3a2e599..7c19113530 100755 --- a/plugins/mail/index.html +++ b/plugins/mail/index.html @@ -1,18 +1,1041 @@ + +
    +
    -

    域名列表

    -

    服务状态

    -

    日志

    +

    域名列表

    +

    邮件秘抄

    +

    邮件中继

    +

    邮件转发

    +

    邮件备份

    +

    收件箱

    +

    垃圾箱

    +

    已发送

    +

    发送邮件

    +

    服务状态

    +

    日志

    -
    +
    + +
    + + + +
    + + + + + + + + + + + + + + + +
    邮箱域名MX记录A记录SPF记录DKIM记录DMARC记录CatchAllSSL操作
    +
    +
    +
      +
    • 添加域名后,需要添加MX记录(用于邮箱服务)和TXT记录(用于邮箱反垃圾服务)才能正常使用邮箱服务。
    • +
    • 提示: 部分云厂商(如:阿里云,腾讯云)默认关闭25端口,需联系厂商开通25端口后才能正常使用邮局服务
    • +
    • 该自建邮局版本为基础版本,仅提供基础功能,更多功能请耐心等候开发进度。
    • +
    +
    + + + +
    + + + + + + + + + + + + + + + + +
    \ No newline at end of file diff --git a/plugins/mail/index.py b/plugins/mail/index.py index 1d10438007..b6ff50b037 100755 --- a/plugins/mail/index.py +++ b/plugins/mail/index.py @@ -52,6 +52,32 @@ def status(): return 'start' +def pSqliteDb(dbname='domain'): + file = getServerDir() + '/postfixadmin.db' + name = 'mail' + if not os.path.exists(file): + conn = mw.M(dbname).dbPos(getServerDir(), name) + csql = mw.readFile(getPluginDir() + '/conf/postfixadmin.sql') + csql_list = csql.split(';') + for index in range(len(csql_list)): + conn.execute(csql_list[index], ()) + else: + # 现有run + # conn = mw.M(dbname).dbPos(getServerDir(), name) + # csql = mw.readFile(getPluginDir() + '/conf/mysql.sql') + # csql_list = csql.split(';') + # for index in range(len(csql_list)): + # conn.execute(csql_list[index], ()) + conn = mw.M(dbname).dbPos(getServerDir(), name) + return conn + + +def addDomain(): + args = getArgs() + + return mw.returnJson(False, 'OK') + + def runLog(): path = '/var/log/maillog' # if "ubuntu" in: @@ -66,5 +92,7 @@ def runLog(): print(getConf()) elif func == 'run_log': print(runLog()) + elif func == 'add_domain': + print(addDomain()) else: print('error') diff --git a/plugins/mail/js/mail.js b/plugins/mail/js/mail.js index f72218f982..254492a25c 100755 --- a/plugins/mail/js/mail.js +++ b/plugins/mail/js/mail.js @@ -1,192 +1,328 @@ +var mail = { + plugin_name: 'mail', + init: function () { + var _this = this; -function str2Obj(str){ - var data = {}; - kv = str.split('&'); - for(i in kv){ - v = kv[i].split('='); - data[v[0]] = v[1]; - } - return data; -} + this.event(); + }, + event: function () { + var _this = this; -function mailPost(method, version, args,callback){ - var loadT = layer.msg('正在获取...', { icon: 16, time: 0, shade: 0.3 }); - - var req_data = {}; - req_data['name'] = 'mail'; - req_data['func'] = method; - req_data['version'] = version; - - if (typeof(args) == 'string'){ - req_data['args'] = JSON.stringify(str2Obj(args)); - } else { - req_data['args'] = JSON.stringify(args); - } + $('.bt-w-main .bt-w-menu p').click(function () { + var index = $(this).index(); + $(this).addClass('on').siblings().removeClass('on'); + $('.soft-man-con .task_block').eq(index).show().siblings().hide(); + console.log(index); + }); - $.post('/plugins/run', req_data, function(data) { - layer.close(loadT); - if (!data.status){ - //错误展示10S - layer.msg(data.msg,{icon:0,time:2000,shade: [10, '#000']}); - return; - } + console.log(_this); + }, - if(typeof(callback) == 'function'){ - callback(data); + // 编辑添加邮箱用户视图-方法 + edit_domain_view: function (type, obj) { + var _this = this; + if (obj == undefined) { + obj = { + domain: '', + company_name: '', + admin_name: '', + admin_phone: '' + } } - },'json'); -} + + layer.open({ + type: 1, + title: type ? '添加邮箱域名' : '编辑邮箱域名', + area: '500px', + closeBtn: 1, + btn: [type ? '提交' : '保存', '取消'], + content: "
    \ +
    \ + 邮箱域名\ +
    \ + \ +
    \ +
    \ +
    \ + A记录\ +
    \ + \ +
    \ +
    \ +
    \ +
      \ +
    • 当前邮箱域名仅支持一级域名
    • \ +
    • A记录解析参数[主机记录:mail或其他字符]、[记录值:当前服务器IP]
    • \ +
    • A记录需要解析当前域名A记录,A记录=主机记录值+当前域名
    • \ +
    \ +
    \ +
    ", + yes: function (index, layers) { + var array = [ + ['domain', '邮箱域名不能为空!', 'a_record', 'A记录值不能为空!'] + ], + _form = {}, + tel_reg = /^[1][3,4,5,6,7,8,9][0-9]{9}$/; + for (var i = 0; i < array.length; i++) { + if ($('[name="' + array[i][0] + '"]').val() == '') { + layer.msg(array[i][1], { + icon: 2 + }); + return false; + } else if (array[i][0] == 'admin_phone' && !tel_reg.test($('[name="' + array[i] + [0] + '"]').val())) { + layer.msg('管理手机号码格式错误,请重试!', { + icon: 2 + }); + return false; + } + _form[array[i][0]] = $('[name="' + array[i][0] + '"]').val(); + _form[array[i][2]] = $('[name="' + array[i][2] + '"]').val(); + } + if (type) { + _this.add_domain(_form, function (res) { + _this.create_domain_list({ + page: 1, + size: 10 + }, function (res) { + var rdata = res.msg.data, + hostname = rdata; + for (var i = 0; i < rdata.length; i++) { + if (rdata[i].domain == _form['domain']) hostname = + rdata[i]['domain'] + } + layer.close(index); + }); + }); + } else { + _form['active'] = obj.active; + _this.update_domain(_form, function (res) { + _this.create_domain_list({ + page: 1, + size: 10 + }, function (res) { + layer.msg(res.msg, { + icon: 1 + }); + layer.close(index); + }); + }); + } + } + }) + }, -function mailPostCallbak(method, version, args,callback){ - var loadT = layer.msg('正在获取...', { icon: 16, time: 0, shade: 0.3 }); - - var req_data = {}; - req_data['name'] = 'mail'; - req_data['func'] = method; - args['version'] = version; - - if (typeof(args) == 'string'){ - req_data['args'] = JSON.stringify(str2Obj(args)); - } else { - req_data['args'] = JSON.stringify(args); - } + // 添加域名_请求 + add_domain: function (obj, callback) { + this.send({ + tips: '正在添加域名,请稍候...', + method: 'add_domain', + data: { + domain: obj.domain, + a_record: obj.a_record, + company_name: obj.company_name, + admin_name: obj.admin_name, + admin_phone: obj.admin_phone + }, + success: function (res) { + if (callback) callback(res); + } + }); + }, + // 获取域名列表_请求 + get_domain_list: function (obj, callback) { + this.send({ + tips: '正在获取域名列表,请稍候....', + method: 'get_domains', + data: { + p: obj.page, + size: obj.size + }, + success: function (res) { + if (callback) callback(res); + } + }) + }, - $.post('/plugins/callback', req_data, function(data) { - layer.close(loadT); - if (!data.status){ - layer.msg(data.msg,{icon:0,time:2000,shade: [0.3, '#000']}); - return; + // 创建域名列表-方法 + create_domain_list: function (obj, callback) { + if (obj == undefined) obj = { + page: 1, + size: 10 + } + var _this = this; + this.get_domain_list(obj, function (res) { + var _tbody = '', + rdata = res.msg.data; + _this.domain_list = rdata + if (rdata.length > 0) { + for (var i = 0; i < rdata.length; i++) { + _tbody += '\ + ' + rdata[i].domain + '\ + ' + (rdata[i].mx_status ? + '
    已设置
    ' : + '') + '\ + ' + (rdata[i].a_status ? + '
    已设置
    ' : + '') + '\ + ' + (rdata[i].spf_status ? + '
    已设置
    ' : + '') + '\ + ' + (rdata[i].dkim_status ? + '
    已设置
    ' : + '') + '\ + ' + (rdata[i].dmarc_status ? + '
    已设置
    ' : + '') + '\ +
    \ + '+(rdata[i].ssl_status?('到期时间: '+rdata[i].ssl_info.notAfter):'添加证书')+'\ + ' + (rdata[i].mx_status ? ( + '用户管理') : ( + '添加记录值')) + ' | \ + 删除\ + \ + '; + }; + } + $('#domain_list').html(_tbody); + $('#domain_page').html(res.msg.page); + $('#domain_page a').click(function (e) { + _this.create_domain_list({ + page: $(this).attr('href').split('p=')[1], + size: 10 + }) + e.stopPropagation(); + e.preventDefault(); + }) + $('#flush_domain_record').unbind().on('click',function(e){ + _this.flush_domain_record('all',function(res){ + layer.msg(res.msg, { icon: res.status ? 1 : 2 }); + }); + }) + $('.add_certificate').unbind().on('click',function(){ + var index = $(this).attr('data-index') + _this.open_certificate_view(rdata[index].ssl_status, rdata[index].domain, rdata[index].ssl_info.dns, index) + }) + $('.catch_all').click(function (e) { + e.preventDefault(); + var _catch = $(this), + _status = $(this).prop('checked'), + _html = _status ? '
    邮件转寄
    ' : '确认关闭此功能?', + loadT = layer.confirm(_html, {title:'CatchAll设置', closeBtn: 2, area: '500'},function(){ + var _email = _status ? $(".catchall").val() : '', + loadS = bt.load(); + _this.enable_catchall({domain:_catch.attr('id'), email: _email},function(res){ + loadS.close(); + if(res.status) _catch.prop('checked', _status); + layer.msg(res.msg, { icon: res.status ? 1 : 2 }); + loadT.close(); + }) + }); + }); + if (callback) callback(res); + }); + }, + + str2Obj:function(str){ + var data = {}; + kv = str.split('&'); + for(i in kv){ + v = kv[i].split('='); + data[v[0]] = v[1]; } + return data; + }, + + send:function(info){ + var tips = info['tips']; + var method = info['method']; + var args = info['data']; + var callback = info['callback']; + + var loadT = layer.msg(tips, { icon: 16, time: 0, shade: 0.3 }); - if(typeof(callback) == 'function'){ - callback(data); + var data = {}; + data['name'] = 'mail'; + data['func'] = method; + data['version'] = $('.plugin_version').attr('version'); + + if (typeof(args) == 'string'){ + data['args'] = JSON.stringify(this.str2Obj(args)); + } else { + data['args'] = JSON.stringify(args); } - },'json'); -} + $.post('/plugins/run', data, function(res) { -function domainList(){ - var con = '
    \ - \ - \ - \ -
    \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ -
    邮箱域名MX记录A记录SPF记录DKIM记录DMARC记录CatchAllSSL操作
    \ -
    \ -
    \ -
      \ -
    • \ - 添加域名后,需要添加MX记录(用于邮箱服务)和TXT记录(用于邮箱反垃圾服务)才能正常使用邮箱服务。\ -
    • \ -
    • \ - 提示: 部分云厂商(如:阿里云,腾讯云)默认关闭25端口,需联系厂商开通25端口后才能正常使用邮局服务\ -
    • \ -
    • 该自建邮局版本为基础版本,仅提供基础功能,更多功能请耐心等候开发进度。
    • \ -
    \ -
    '; - - $(".soft-man-con").html(con); -} + layer.close(loadT); + if (!res.status){ + layer.msg(res.msg,{icon:2,time:10000}); + return; + } + var ret_data = $.parseJSON(res.data); + if (!ret_data.status){ + layer.msg(ret_data.msg,{icon:2,time:2000}); + return; + } + if(typeof(callback) == 'function'){ + callback(res); + } + },'json'); + }, + postCallback:function(info){ + var tips = info['tips']; + var method = info['method']; + var args = info['data']; + var callback = info['callback']; + + var loadT = layer.msg(tips, { icon: 16, time: 0, shade: 0.3 }); -function serviceStatus(){ - var con = '
    \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ -
    服务名称服务状态操作
    Dovecot获取中...\ - 启动\ - 停止 | \ - 重启 | \ - 修复 | \ - 获取中...\ - 启动\ - 停止 | \ - 重启 | \ - 修复 | \ - 配置文件\ -
    Rspamd获取中...\ - 启动\ - 停止 | \ - 重启 | \ - 修复 | \ - 配置文件\ -
    Postfix获取中...\ - 启动\ - 停止 | \ - 重启 | \ - 修复 | \ - 配置文件\ -
    \ -
    '; - $(".soft-man-con").html(con); -} + var data = {}; + data['name'] = 'mail'; + data['func'] = method; + data['version'] = $('.plugin_version').attr('version'); + + if (typeof(args) == 'string'){ + data['args'] = JSON.stringify(this.str2Obj(args)); + } else { + data['args'] = JSON.stringify(args); + } + + $.post('/plugins/callback', data, function(res) { + layer.close(loadT); + if (!res.status){ + layer.msg(res.msg,{icon:2,time:10000}); + return; + } + + var ret_data = $.parseJSON(res.data); + if (!ret_data.status){ + layer.msg(ret_data.msg,{icon:2,time:2000}); + return; + } + + if(typeof(callback) == 'function'){ + callback(res); + } + },'json'); + } +} From 33faf1e54cb2b87008913eff89328f5bf9dc5945 Mon Sep 17 00:00:00 2001 From: midoks Date: Sat, 17 Sep 2022 22:39:42 +0800 Subject: [PATCH 21/59] Update index.html --- plugins/mail/index.html | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/mail/index.html b/plugins/mail/index.html index 7c19113530..e3778027bb 100755 --- a/plugins/mail/index.html +++ b/plugins/mail/index.html @@ -511,7 +511,8 @@
    -
    + +

    域名列表

    邮件秘抄

    From 372dbc8995128c785f8b29a55ab3391e33446dc0 Mon Sep 17 00:00:00 2001 From: midoks Date: Sun, 18 Sep 2022 00:05:45 +0800 Subject: [PATCH 22/59] =?UTF-8?q?mail=20=20=E6=B7=BB=E5=8A=A0=E5=9F=9F?= =?UTF-8?q?=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/mail/index.py | 80 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 79 insertions(+), 1 deletion(-) diff --git a/plugins/mail/index.py b/plugins/mail/index.py index b6ff50b037..d7f8470baf 100755 --- a/plugins/mail/index.py +++ b/plugins/mail/index.py @@ -5,7 +5,20 @@ import os import time +from datetime import datetime + +try: + import dns.resolver +except: + if os.path.exists(os.getcwd() + '/bin'): + mw.mw(os.getcwd() + '/bin/pip install dnspython') + else: + mw.execShell('pip install dnspython') + import dns.resolver + + sys.path.append(os.getcwd() + "/class/core") + import mw app_debug = False @@ -52,7 +65,7 @@ def status(): return 'start' -def pSqliteDb(dbname='domain'): +def M(dbname='domain'): file = getServerDir() + '/postfixadmin.db' name = 'mail' if not os.path.exists(file): @@ -72,9 +85,74 @@ def pSqliteDb(dbname='domain'): return conn +def __check_a(hostname): + key = '{0}:{1}'.format(hostname, 'A') + now = int(time.time()) + + value = "" + error_ip = "" + + ipaddress = mw.getLocalIp() + if not ipaddress: + return False, {"status": 0, "v_time": now, "value": error_ip} + + try: + resolver = dns.resolver.Resolver() + resolver.timeout = 1 + try: + result = resolver.resolve(hostname, 'A') + except: + result = resolver.query(hostname, 'A') + + for i in result.response.answer: + for j in i.items: + error_ip = j + if str(j).strip() in ipaddress: + value = str(j).strip() + + if value: + return True, {"status": 1, "v_time": now, "value": value} + return False, {"status": 0, "v_time": now, "value": error_ip} + except Exception as e: + raise e + return False, {"status": 0, "v_time": now, "value": error_ip} + + def addDomain(): args = getArgs() + if 'domain' not in args: + return mw.returnJson(False, '请传入域名') + + domain = args['domain'] + a_record = args['a_record'] + + if not a_record.endswith(domain): + return mw.returnJson(False, 'A记录 [{}] 不属于该域名'.format(a_record)) + + if not mw.isDebugMode(): + check = __check_a(a_record) + if not check[0]: + return mw.returnJson(False, 'A记录解析失败
    域名:{}
    IP:{}'.format(a_record, check[1]['value'])) + + if M('domain').where("domain=?", (domain,)).count() > 0: + return mw.returnJson(False, '该域名已存在') + + cur_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S') + try: + M('domain').add('domain,a_record,created', + (domain, a_record, cur_time)) + except: + return mw.returnJson(False, '邮局没有初始化成功!
    ' + '请尝试重新初始化,
    ' + '如果以下端口没访问将无法初始化
    port 25 [outbound direction]
    ' + '你可以尝试执行以下命令测试端口是否开启:

    [ telnet gmail-smtp-in.l.google.com 25 ]
    ') + + # 在虚拟用户家目录创建对应域名的目录 + if os.path.exists('/www/vmail'): + if not os.path.exists('/www/vmail/{0}'.format(domain)): + os.makedirs('/www/vmail/{0}'.format(domain)) + mw.execShell('chown -R vmail:mail /www/vmail/{0}'.format(domain)) return mw.returnJson(False, 'OK') From e0ebed3080a25b32cab42db50438cf601561b4b7 Mon Sep 17 00:00:00 2001 From: midoks Date: Sun, 18 Sep 2022 20:00:23 +0800 Subject: [PATCH 23/59] up --- plugins/mail/index.html | 9 +- plugins/mail/index.py | 520 ++++++++++++++++++++++++++++++---------- plugins/mail/js/mail.js | 44 +++- 3 files changed, 430 insertions(+), 143 deletions(-) diff --git a/plugins/mail/index.html b/plugins/mail/index.html index e3778027bb..7907280541 100755 --- a/plugins/mail/index.html +++ b/plugins/mail/index.html @@ -95,9 +95,10 @@ height: 34px; } +/* .domain_table { - height: 220px; -} + height: auto; +}*/ .tasklist .tab-nav span.on { background-color: #fff; @@ -514,7 +515,7 @@
    -

    域名列表

    +

    域名列表

    邮件秘抄

    邮件中继

    邮件转发

    @@ -1035,7 +1036,7 @@
    \ No newline at end of file diff --git a/plugins/mail/index.py b/plugins/mail/index.py deleted file mode 100755 index be1122a128..0000000000 --- a/plugins/mail/index.py +++ /dev/null @@ -1,489 +0,0 @@ -# coding:utf-8 - -import sys -import io -import os -import time -import re -import socket - -from datetime import datetime - -try: - import dns.resolver -except: - if os.path.exists(os.getcwd() + '/bin'): - mw.mw(os.getcwd() + '/bin/pip install dnspython') - else: - mw.execShell('pip install dnspython') - import dns.resolver - - -sys.path.append(os.getcwd() + "/class/core") - -import mw -app_debug = False -if mw.isAppleSystem(): - app_debug = True - -import mail_init as mi - - -class App: - __setupPath = '/www/server/mail' - __session_conf = __setupPath + '/session.json' - - _check_time = 86400 - - def __init__(self): - self.__setupPath = self.getServerDir() - self._session = self.__get_session() - - def getArgs(self): - args = sys.argv[3:] - 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 check_mail_sys(self): - args = self.getArgs() - - if os.path.exists('/etc/postfix/sqlite_virtual_domains_maps.cf'): - mw.execShell( - '/sbin/postconf -e "message_size_limit = 102400000"') - # 修改postfix mydestination配置项 - result = mw.readFile(self.postfix_main_cf) - if not result: - return mw.returnJson(False, "找不到postfix配置文件") - result = re.search(r"\n*mydestination\s*=(.+)", result) - if not result: - return mw.returnJson(False, "postfix配置文件中找不到mydestination配置项") - result = result.group(1) - if 'localhost' in result or '$myhostname' in result or '$mydomain' in result: - mw.execShell( - '/sbin/postconf -e "mydestination =" && systemctl restart postfix') - # 修改dovecot配置 - dovecot_conf = public.readFile("/etc/dovecot/dovecot.conf") - if not dovecot_conf or not re.search(r"\n*protocol\s*imap", dovecot_conf): - return mw.returnJson(False, '配置dovecot失败') - # 修复之前版本未安装opendkim的问题 - # if not (os.path.exists("/usr/sbin/opendkim") and os.path.exists("/etc/opendkim.conf") and os.path.exists("/etc/opendkim")): - # if not self.setup_opendkim(): - # return public.returnMsg(False, 'Failed to configure opendkim 1') - - return mw.returnJson(True, '邮局系统已经存在,重装之前请先卸载!') - else: - return mw.returnJson(False, '之前没有安装过邮局系统,请放心安装!') - - def __get_session(self): - session = mw.readFile(self.__session_conf) - if session: - session = json.loads(session) - else: - session = {} - return session - - def __get_dkim_value(self, domain): - ''' - 解析/etc/opendkim/keys/domain/default.txt得到域名要设置的dkim记录值 - :param domain: - :return: - ''' - if not os.path.exists("/www/server/dkim/{}".format(domain)): - os.makedirs("/www/server/dkim/{}".format(domain)) - rspamd_pub_file = '/www/server/dkim/{}/default.pub'.format(domain) - opendkim_pub_file = '/etc/opendkim/keys/{0}/default.txt'.format(domain) - if os.path.exists(opendkim_pub_file) and not os.path.exists(rspamd_pub_file): - opendkim_pub = mw.readFile(opendkim_pub_file) - mw.writeFile(rspamd_pub_file, opendkim_pub) - - rspamd_pri_file = '/www/server/dkim/{}/default.private'.format( - domain) - opendkim_pri_file = '/etc/opendkim/keys/{}/default.private'.format( - domain) - opendkim_pri = mw.readFile(opendkim_pri_file) - mw.writeFile(rspamd_pri_file, opendkim_pri) - - if not os.path.exists(rspamd_pub_file): - return '' - file_body = mw.readFile(rspamd_pub_file).replace( - ' ', '').replace('\n', '').split('"') - value = file_body[1] + file_body[3] - return value - - def __check_mx(self, domain): - ''' - 检测域名是否有mx记录 - :param domain: - :return: - ''' - a_record = self.M('domain').where( - 'domain=?', (domain,)).field('a_record').find()['a_record'] - key = '{0}:{1}'.format(domain, 'MX') - now = int(time.time()) - try: - value = "" - if key in self._session and self._session[key]["status"] != 0: - v_time = now - int(self._session[key]["v_time"]) - if v_time < self._check_time: - value = self._session[key]["value"] - if '' == value: - resolver = dns.resolver.Resolver() - resolver.timeout = 1 - try: - result = resolver.resolve(domain, 'MX') - except: - result = resolver.query(domain, 'MX') - - value = str(result[0].exchange).strip('.') - if not a_record: - a_record = value - self.M('domain').where('domain=?', (domain,)).save( - 'a_record', (a_record,)) - if value == a_record: - self._session[key] = {"status": 1, - "v_time": now, "value": value} - return True - self._session[key] = {"status": 0, "v_time": now, "value": value} - return False - except: - # print(public.get_error_info()) - self._session[key] = {"status": 0, "v_time": now, - "value": "None of DNS query names exist:{}".format(domain)} - return False - - def __check_spf(self, domain): - ''' - 检测域名是否有spf记录 - :param domain: - :return: - ''' - key = '{0}:{1}'.format(domain, 'TXT') - now = int(time.time()) - try: - value = "" - if key in self._session and self._session[key]["status"] != 0: - v_time = now - int(self._session[key]["v_time"]) - if v_time < self._check_time: - value = self._session[key]["value"] - if '' == value: - resolver = dns.resolver.Resolver() - resolver.timeout = 1 - # try: - result = resolver.resolve(domain, 'TXT') - # except: - # result = resolver.query(domain, 'TXT') - - for i in result.response.answer: - for j in i.items: - value += str(j).strip() - if 'v=spf1' in value.lower(): - self._session[key] = {"status": 1, - "v_time": now, "value": value} - return True - self._session[key] = {"status": 0, "v_time": now, "value": value} - return False - except: - # print(public.get_error_info()) - self._session[key] = {"status": 0, "v_time": now, - "value": "None of DNS query spf exist:{}".format(domain)} - return False - - def __check_dkim(self, domain): - ''' - 检测域名是否有dkim记录 - :param domain: - :return: - ''' - origin_domain = domain - domain = 'default._domainkey.{0}'.format(domain) - key = '{0}:{1}'.format(domain, 'TXT') - now = int(time.time()) - try: - value = "" - if key in self._session and self._session[key]["status"] != 0: - v_time = now - int(self._session[key]["v_time"]) - if v_time < self._check_time: - value = self._session[key]["value"] - if '' == value: - resolver = dns.resolver.Resolver() - resolver.timeout = 1 - result = resolver.resolve(domain, 'TXT') - for i in result.response.answer: - for j in i.items: - value += str(j).strip() - new_v = self._get_dkim_value(origin_domain) - if new_v and new_v in value: - self._session[key] = {"status": 1, - "v_time": now, "value": value} - return True - self._session[key] = {"status": 0, "v_time": now, "value": value} - return False - except: - # print(public.get_error_info()) - self._session[key] = {"status": 0, "v_time": now, - "value": "None of DNS query names exist:{}".format(domain)} - return False - - def __check_dmarc(self, domain): - ''' - 检测域名是否有dmarc记录 - :param domain: - :return: - ''' - domain = '_dmarc.{0}'.format(domain) - key = '{0}:{1}'.format(domain, 'TXT') - now = int(time.time()) - try: - value = "" - if key in self._session and self._session[key]["status"] != 0: - v_time = now - int(self._session[key]["v_time"]) - if v_time < self._check_time: - value = self._session[key]["value"] - if '' == value: - resolver = dns.resolver.Resolver() - resolver.timeout = 1 - - result = resolver.resolve(domain, 'TXT') - - for i in result.response.answer: - for j in i.items: - value += str(j).strip() - if 'v=dmarc1' in value.lower(): - self._session[key] = {"status": 1, - "v_time": now, "value": value} - return True - self._session[key] = {"status": 0, "v_time": now, "value": value} - return False - except: - # print(public.get_error_info()) - self._session[key] = {"status": 0, "v_time": now, - "value": "None of DNS query names exist:{}".format(domain)} - return False - - def __gevent_jobs(self, domain, a_record): - from gevent import monkey - # monkey.patch_all() - import gevent - gevent.joinall([ - gevent.spawn(self.__check_mx, domain), - gevent.spawn(self.__check_spf, domain), - gevent.spawn(self.__check_dkim, domain), - gevent.spawn(self.__check_dmarc, domain), - gevent.spawn(self.__check_a, a_record), - ]) - - return True - - def getInitDFile(self): - if app_debug: - return '/tmp/' + getPluginName() - return '/etc/init.d/' + getPluginName() - - def getPluginName(self): - return 'mail' - - def getPluginDir(self): - return mw.getPluginDir() + '/' + self.getPluginName() - - def getServerDir(self): - return mw.getServerDir() + '/' + self.getPluginName() - - def M(self, dbname='domain'): - file = self.getServerDir() + '/postfixadmin.db' - name = 'mail' - if not os.path.exists(file): - conn = mw.M(dbname).dbPos(self.getServerDir(), name) - csql = mw.readFile(self.getPluginDir() + '/conf/postfixadmin.sql') - csql_list = csql.split(';') - for index in range(len(csql_list)): - conn.execute(csql_list[index], ()) - else: - # 现有run - # conn = mw.M(dbname).dbPos(getServerDir(), name) - # csql = mw.readFile(getPluginDir() + '/conf/mysql.sql') - # csql_list = csql.split(';') - # for index in range(len(csql_list)): - # conn.execute(csql_list[index], ()) - conn = mw.M(dbname).dbPos(self.getServerDir(), name) - return conn - - def status(self): - return 'start' - - def get_domains(self): - args = self.getArgs() - - p = int(args['p']) if 'p' in args else 1 - rows = int(args['size']) if 'size' in args else 10 - callback = args['callback'] if 'callback' in args else '' - count = self.M('domain').count() - - data = {} - # 获取分页数据 - _page = {} - _page['count'] = count - _page['p'] = p - _page['row'] = rows - _page['tojs'] = callback - data['page'] = mw.getPage(_page) - - start_pos = (_page['p'] - 1) * _page['row'] - - data_list = self.M('domain').order('created desc').limit( - str(start_pos) + ',' + str(_page['row'])).field('domain,a_record,created,active').select() - - # print(data) - # print(data_list) - - return mw.returnJson(True, 'ok', {'data': data_list, 'page': data['page']}) - - def runLog(self): - path = '/var/log/maillog' - # if "ubuntu" in: - # path = '/var/log/mail.log' - return path - - def add_domain(self): - args = self.getArgs() - - if 'domain' not in args: - return mw.returnJson(False, '请传入域名') - - domain = args['domain'] - a_record = args['a_record'] - - if not a_record.endswith(domain): - return mw.returnJson(False, 'A记录 [{}] 不属于该域名'.format(a_record)) - - if not mw.isDebugMode(): - check = self.__check_a(a_record) - if not check[0]: - return mw.returnJson(False, 'A记录解析失败
    域名:{}
    IP:{}'.format(a_record, check[1]['value'])) - - if self.M('domain').where("domain=?", (domain,)).count() > 0: - return mw.returnJson(False, '该域名已存在') - - cur_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S') - try: - self.M('domain').add('domain,a_record,created', - (domain, a_record, cur_time)) - except: - return mw.returnJson(False, '邮局没有初始化成功!
    ' - '请尝试重新初始化,
    ' - '如果以下端口没访问将无法初始化
    port 25 [outbound direction]
    ' - '你可以尝试执行以下命令测试端口是否开启:

    [ telnet gmail-smtp-in.l.google.com 25 ]
    ') - - # 在虚拟用户家目录创建对应域名的目录 - if os.path.exists('/www/vmail'): - if not os.path.exists('/www/vmail/{0}'.format(domain)): - os.makedirs('/www/vmail/{0}'.format(domain)) - mw.execShell('chown -R vmail:mail /www/vmail/{0}'.format(domain)) - return mw.returnJson(False, 'OK') - - def __check_a(self, hostname): - key = '{0}:{1}'.format(hostname, 'A') - now = int(time.time()) - - value = "" - error_ip = "" - - ipaddress = mw.getLocalIp() - if not ipaddress: - return False, {"status": 0, "v_time": now, "value": error_ip} - - try: - resolver = dns.resolver.Resolver() - resolver.timeout = 1 - try: - result = resolver.resolve(hostname, 'A') - except: - result = resolver.query(hostname, 'A') - - for i in result.response.answer: - for j in i.items: - error_ip = j - if str(j).strip() in ipaddress: - value = str(j).strip() - - if value: - return True, {"status": 1, "v_time": now, "value": value} - return False, {"status": 0, "v_time": now, "value": error_ip} - except Exception as e: - raise e - return False, {"status": 0, "v_time": now, "value": error_ip} - - def flush_domain_record(self): - ''' - 手动刷新域名记录 - domain all/specify.com - :param args: - :return: - ''' - args = self.getArgs() - - if args['domain'] == 'all': - data_list = self.M('domain').order('created desc').field( - 'domain,a_record,created,active').select() - for item in data_list: - # try: - # if os.path.exists("/usr/bin/rspamd"): - # self.set_rspamd_dkim_key(item['domain']) - # if os.path.exists("/usr/sbin/opendkim"): - # self._gen_dkim_key(item['domain']) - # except: - # return mw.returnJson(False, '请检查Rspamd服务器是否已经启动!') - self.__gevent_jobs(item['domain'], item['a_record']) - # else: - # try: - # if os.path.exists("/usr/bin/rspamd"): - # self.set_rspamd_dkim_key(args.domain) - # if os.path.exists("/usr/sbin/opendkim"): - # self._gen_dkim_key(args.domain) - # except: - # return mw.returnJson(False, '请检查Rspamd服务器是否已经启动!') - # self._gevent_jobs(args['domain'], None) # 不需要验证A记录 - - # mw.writeFile(self._session_conf, json.dumps(self._session)) - - return mw.returnJson(True, '刷新成功!') - - def check_mail_env(self): - data = mi.mail_init().check_env() - return mw.returnJson(True, 'ok', data) - - def change_hostname(self): - ''' - mac - sudo scutil --set HostName mac_hostname.vm - ''' - args = self.getArgs() - hostname = args['hostname'] - rep_domain = "^(?=^.{3,255}$)[a-zA-Z0-9\_\-][a-zA-Z0-9\_\-]{0,62}(\.[a-zA-Z0-9\_\-][a-zA-Z0-9\_\-]{0,62})+$" - if not re.search(rep_domain, hostname): - return mw.returnJson(False, "请输入完整域名,例如 mail.bt.com),") - mw.execShell('hostnamectl set-hostname --static {}'.format(hostname)) - h = socket.gethostname() - if h == hostname: - return mw.returnJson(True, "设置成功!") - return mw.returnJson(False, "设置失败!") - - -if __name__ == "__main__": - func = sys.argv[1] - classApp = App() - try: - data = eval("classApp." + func + "()") - print(data) - except Exception as e: - print('error:' + str(e)) diff --git a/plugins/mail/info.json b/plugins/mail/info.json deleted file mode 100755 index 222e411ca5..0000000000 --- a/plugins/mail/info.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "sort": 7, - "ps": "简单邮件服务[DEV]", - "name": "mail", - "title": "邮件服务", - "shell": "install.sh", - "versions":["1.0"], - "updates":["1.0"], - "tip": "soft", - "checks": "server/mail", - "path": "server/mail", - "display": 1, - "author": "midoks", - "date": "2022-09-13", - "home": "https://github.com/midoks/mdserver-web", - "type": 0, - "pid": "5" -} \ No newline at end of file diff --git a/plugins/mail/install.sh b/plugins/mail/install.sh deleted file mode 100755 index 83537d0d26..0000000000 --- a/plugins/mail/install.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/bash -PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin -export PATH - -curPath=`pwd` -rootPath=$(dirname "$curPath") -rootPath=$(dirname "$rootPath") -serverPath=$(dirname "$rootPath") - -install_tmp=${rootPath}/tmp/mw_install.pl - -pip install dnspython - -if [ -f ${rootPath}/bin/activate ];then - source ${rootPath}/bin/activate - pip install dnspython -fi - - -action=$1 -type=$2 - -if [ "${2}" == "" ];then - echo '缺少安装脚本...' > $install_tmp - exit 0 -fi - -if [ ! -d $curPath/versions/$2 ];then - echo '缺少安装脚本2...' > $install_tmp - exit 0 -fi - -sh -x $curPath/versions/$2/install.sh $1 diff --git a/plugins/mail/js/mail.js b/plugins/mail/js/mail.js deleted file mode 100755 index b83c597acd..0000000000 --- a/plugins/mail/js/mail.js +++ /dev/null @@ -1,626 +0,0 @@ -var mail = { - plugin_name: 'mail', - post_env_list:['HostName','Postfix-Version','Postfix-install','Sqlite-support','Dovecot-install','Redis-install','Redis-Passwd','Rspamd-install','SElinux'], - post_env_text:['主机名','Postfix版本','Postfix安装','Sqlite支持','Dovecot安装','Redis安装','Redis密码','Rspamd','SElinux'], - init: function () { - var _this = this; - - this.event(); - - $('.layui-layer-page').hide(); - - setTimeout(function () { - var win = $(window), - layer = $('.layui-layer-page'); - layer.show(); - layer.css({ - 'width':'1080px', - 'top':((win.height()-layer.height())/2)+'px', - 'left':((win.width()-1000)/2)+'px', - 'zIndex':'999' - }); - $('.layui-layer-shade').css('zIndex', '998'); - }, 200); - - - _this.check_mail_sys({ - tips: '正在检查邮局服务是否正常,请稍后....', - hostname: '' - }, function (res) { - console.log("aaaa",res); - if (res.status == false && res.msg == '之前没有安装过邮局系统,请放心安装!') { - layer.confirm('当前未设置邮局服务,是否现在设置?', { - icon: 0, - title: '邮局初始化', - btn: ['设置', '取消'], //按钮 - cancel: function () { - layer.closeAll(); - } - }, function (index) { - _this.check_post_env('setup_mail_sys'); - }, function () { - layer.closeAll(); - }); - } else { - // _this.create_domain_list(); - $('.tasklist .tab-nav span:first').click(); // 初始化 - _this.loadScript('/static/ckeditor/ckeditor.js', function () { - CKEDITOR.replace('editor1', { - customConfig: '/static/ckeditor/config.js?v1.0' - }) - }); - } - }); - - // _this.create_domain_list(); - }, - event: function () { - var _this = this; - - $('.bt-w-main .bt-w-menu p').click(function () { - var index = $(this).index(); - $(this).addClass('on').siblings().removeClass('on'); - $('.soft-man-con .task_block').eq(index).show().siblings().hide(); - console.log(index); - - - switch (index) { - case 0: - _this.create_domain_list(); - // _this.get_mailSSL_status(function (res) { - // $('#certificateSSL').prop("checked", res); - // }); - break; - } - }); - - - - - console.log(_this); - }, - - // 编辑添加邮箱用户视图-方法 - edit_domain_view: function (type, obj) { - var _this = this; - if (obj == undefined) { - obj = { - domain: '', - company_name: '', - admin_name: '', - admin_phone: '' - } - } - - layer.open({ - type: 1, - title: type ? '添加邮箱域名' : '编辑邮箱域名', - area: '500px', - closeBtn: 1, - btn: [type ? '提交' : '保存', '取消'], - content: "
    \ -
    \ - 邮箱域名\ -
    \ - \ -
    \ -
    \ -
    \ - A记录\ -
    \ - \ -
    \ -
    \ -
    \ -
      \ -
    • 当前邮箱域名仅支持一级域名
    • \ -
    • A记录解析参数[主机记录:mail或其他字符]、[记录值:当前服务器IP]
    • \ -
    • A记录需要解析当前域名A记录,A记录=主机记录值+当前域名
    • \ -
    \ -
    \ -
    ", - yes: function (index, layers) { - var array = [ - ['domain', '邮箱域名不能为空!', 'a_record', 'A记录值不能为空!'] - ], - _form = {}, - tel_reg = /^[1][3,4,5,6,7,8,9][0-9]{9}$/; - for (var i = 0; i < array.length; i++) { - if ($('[name="' + array[i][0] + '"]').val() == '') { - layer.msg(array[i][1], { - icon: 2 - }); - return false; - } else if (array[i][0] == 'admin_phone' && !tel_reg.test($('[name="' + array[i] - [0] + '"]').val())) { - layer.msg('管理手机号码格式错误,请重试!', { - icon: 2 - }); - return false; - } - _form[array[i][0]] = $('[name="' + array[i][0] + '"]').val(); - _form[array[i][2]] = $('[name="' + array[i][2] + '"]').val(); - } - if (type) { - _this.add_domain(_form, function (res) { - console.log(res); - _this.create_domain_list({ - page: 1, - size: 10 - }, function (res) { - var rdata = res.msg.data, - hostname = rdata; - for (var i = 0; i < rdata.length; i++) { - if (rdata[i].domain == _form['domain']) hostname = - rdata[i]['domain'] - } - layer.close(index); - }); - }); - } else { - _form['active'] = obj.active; - _this.update_domain(_form, function (res) { - _this.create_domain_list({ - page: 1, - size: 10 - }, function (res) { - layer.msg(res.msg, { - icon: 1 - }); - layer.close(index); - }); - }); - } - } - }) - }, - - // 添加域名_请求 - add_domain: function (obj, callback) { - this.send({ - tips: '正在添加域名,请稍候...', - method: 'add_domain', - data: { - domain: obj.domain, - a_record: obj.a_record, - company_name: obj.company_name, - admin_name: obj.admin_name, - admin_phone: obj.admin_phone - }, - success: function (res) { - if (callback) callback(res); - } - }); - }, - // 获取域名列表_请求 - get_domain_list: function (obj, callback) { - this.send({ - tips: '正在获取域名列表,请稍候....', - method: 'get_domains', - data: { - p: obj.page, - size: obj.size - }, - success: function (res) { - if (callback) callback(res); - } - }) - }, - - flush_domain_record: function(obj,callback){ - var _this = this; - this.send({ - tips: obj == 'all'?'正在刷新所有域名记录,刷新时间视域名数量而定,请稍后...':'Refresh domain record, please wait...', - method: 'flush_domain_record', - data: { - domain: obj - }, - success: function (res) { - console.log(res); - if(res.status) _this.create_domain_list(); - if (callback) callback(res); - } - }); - }, - - // 创建域名列表-方法 - create_domain_list: function (obj, callback) { - if (obj == undefined) obj = { - page: 1, - size: 10 - } - var _this = this; - this.get_domain_list(obj, function (res) { - console.log(res); - var _tbody = '', - rdata = res.data.data; - _this.domain_list = rdata - if (rdata.length > 0) { - for (var i = 0; i < rdata.length; i++) { - _tbody += '\ - ' + rdata[i].domain + '\ - ' + (rdata[i].mx_status ? - '
    已设置
    ' : - '') + '\ - ' + (rdata[i].a_status ? - '
    已设置
    ' : - '') + '\ - ' + (rdata[i].spf_status ? - '
    已设置
    ' : - '') + '\ - ' + (rdata[i].dkim_status ? - '
    已设置
    ' : - '') + '\ - ' + (rdata[i].dmarc_status ? - '
    已设置
    ' : - '') + '\ -
    \ - '+(rdata[i].ssl_status?('到期时间: '+rdata[i].ssl_info.notAfter):'添加证书')+'\ - ' + (rdata[i].mx_status ? ( - '用户管理') : ( - '添加记录值')) + ' | \ - 删除\ - \ - '; - }; - } - $('#domain_list').html(_tbody); - $('#domain_page').html(res.page); - $('#domain_page a').click(function (e) { - _this.create_domain_list({ - page: $(this).attr('href').split('p=')[1], - size: 10 - }) - e.stopPropagation(); - e.preventDefault(); - }) - $('#flush_domain_record').unbind().on('click',function(e){ - _this.flush_domain_record('all',function(res){ - layer.msg(res.msg, { icon: res.status ? 1 : 2 }); - }); - }) - $('.add_certificate').unbind().on('click',function(){ - var index = $(this).attr('data-index') - _this.open_certificate_view(rdata[index].ssl_status, rdata[index].domain, rdata[index].ssl_info.dns, index) - }) - $('.catch_all').click(function (e) { - e.preventDefault(); - var _catch = $(this), - _status = $(this).prop('checked'), - _html = _status ? '
    邮件转寄
    ' : '确认关闭此功能?', - loadT = layer.confirm(_html, {title:'CatchAll设置', closeBtn: 2, area: '500'},function(){ - var _email = _status ? $(".catchall").val() : '', - loadS = bt.load(); - _this.enable_catchall({domain:_catch.attr('id'), email: _email},function(res){ - loadS.close(); - if(res.status) _catch.prop('checked', _status); - layer.msg(res.msg, { icon: res.status ? 1 : 2 }); - loadT.close(); - }) - }); - }); - if (callback) callback(res); - }); - }, - - // 获取邮箱服务是否正常_请求 - check_mail_sys: function (obj, callback) { - this.send({ - tips: obj.tips, - method: 'check_mail_sys', - data: { - hostname: obj.hostname - }, - check: true, - success: function (res) { - if (callback) callback(res); - } - }) - }, - - // 检查邮箱环境 - check_mail_env:function(callback){ - this.send({ - tips: '正在检查邮局环境,请稍候...', - method: 'check_mail_env', - success: function (res) { - if (callback) callback(res); - } - }) - }, - - //检查邮局环境 - check_post_env:function (name) { - var _this = this; - var layerE = layer.open({ - skin:"", - type: 1, - closeBtn:1, - title:'检查邮局环境', - area: ['600px','520px'], //宽高 - btn: ['提交','取消','刷新列表'], - content:'\ -
    \ -
    \ -
    \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ -
    环境详情操作
    \ -
    \ -
    \ -
      \ -
    • 如果邮局环境异常,请先排除故障。 请在所有异常修复完成后执行下一步操作
    • \ -
    \ -
    ', - success:function(index){ - _this.create_post_env_table(); - }, - cancel:function(){ - layer.closeAll(); - }, - yes:function(){ - if($('#checkPostEnv').find('.set_mail_key').length > 0){ - layer.msg('请修复好所有的异常再提交'); - }else{ - switch (name){ - case 'setup_mail_sys': - _this.setup_mail_sys({tips:'正在初始化邮局...'},function(res){ - layer.close(layerE) - layer.msg(res.msg,{icon:res.status?1:2}); - _this.create_domain_list(); - }); - break; - case 'change_to_rspamd': - _this.change_to_rspamd(function(res){ - layer.close(layerE) - layer.msg(res.msg,{icon:res.status?1:2}); - _this.create_server_status_table() - }) - break; - } - } - }, - btn3: function(index, layero){ - _this.create_post_env_table(); - return false; - }, - btn2: function(index, layero){ - name == 'change_to_rspamd'?layer.close(layerE):layer.closeAll(); - }, - - }) - }, - - //创建邮局环境列表 - create_post_env_table:function (callback){ - var _this = this; - _this.check_mail_env(function(rdata){ - var res = rdata.data; - $('#checkPostEnv tbody').empty(); - $.each(_this.post_env_list,function(index,item){ - var list = []; - var noOperList = ['Redis-install', 'Redis-Passwd', 'SElinux']; - if(res[item].msg && noOperList.includes(item)){ - $('#checkPostEnv tbody').append($(''+_this.post_env_text[index] +''+(res[item].status?"就绪":(res[item].msg.toString().length>30?res[item].msg.toString().substring(0,30)+'...':res[item].msg.toString()))+'无操作')) - }else{ - $('#checkPostEnv tbody').append($(``+_this.post_env_text[index] +`${(res[item].status?"就绪":(res[item].msg !=''?(res[item].msg.toString().length>30?res[item].msg.toString().substring(0,30)+'...':res[item].msg.toString()):"异常"))}${(res[item].status?"无操作":"修复")}`)) - } - $('#checkPostEnv .divtable').removeClass('mtb10'); - }); - }); - - $('#checkPostEnv').unbind().on('click','a',function(){ - var key = $(this).attr('data-keys'); - var confirmA = layer.confirm('是否修复邮局环境?', { - title: '修复邮局环境', - icon: 3, - closeBtn:2, - btn: ['确定', '取消'], - },function(index, layero){ - _this.repair_mail_env(key); - }); - }) - if(callback) callback() - }, - - //修复邮局环境 - repair_mail_env: function (key) { - var _this = this,_key; - switch(key) { - case 'Postfix-Version': - case 'Postfix-install': - case 'Sqlite-support': - _key = 'repair_postfix'; - break; - case 'Rspamd-install': - _key = 'install_rspamd'; - break; - case 'Dovecot-install': - _key = 'repair_dovecot'; - break; - case 'HostName': - _key = 'repair_host_name'; - break; - } - if (key == 'HostName'){ - this.repair_host_name(); - return; - } - - this.send({ - tips: '正在修复' + key + ',请稍候...', - method: _key, - success: function (res) { - layer.msg(res.msg, { icon: res.status?1:2 }); - _this.create_post_env_table(); - } - }) - }, - - // 修复hostname - repair_host_name: function () { - var _this = this; - layer.open({ - type: 1, - shift: 5, - closeBtn: 1, - shadeClose: false, - title: '修复【主机名】', - btn: ['确定', '取消'], - area: "400px", - content: '\ -
    \ -
    \ - 域名\ -
    \ - \ -
    \ -
    \ -
      \ -
    • 请输入你的完整域名,如:mail.mw.cn
    • \ -
    \ -
    ', - success: function ($layer, index) { - }, - yes: function(index){ - var hostname = $('input[name="hostname"]').val().trim(); - if (hostname === '') { - layer.msg('请输入你的完整域名', { icon: 2, closeBtn: true }); - return - } - _this.change_hostname({ - hostname: hostname, - }, function (res) { - layer.close(index); - _this.create_post_env_table(); - layer.msg(res.msg, { icon: res.status ? 1 : 5 }); - }); - } - }); - }, - - // 一键修复主机名 - change_hostname: function(data, callback){ - this.send({ - tips: '正在获取修复主机名, 请稍候...', - method: 'change_hostname', - data: data, - success: function (res) { - if (callback) callback(res); - } - }); - }, - - str2Obj:function(str){ - var data = {}; - kv = str.split('&'); - for(i in kv){ - v = kv[i].split('='); - data[v[0]] = v[1]; - } - return data; - }, - - send:function(info){ - var tips = info['tips']; - var method = info['method']; - var args = info['data']; - var callback = info['success']; - - var loadT = layer.msg(tips, { icon: 16, time: 0, shade: 0.3 }); - - var data = {}; - data['name'] = 'mail'; - data['func'] = method; - data['version'] = $('.plugin_version').attr('version'); - - if (typeof(args) == 'string'){ - data['args'] = JSON.stringify(this.str2Obj(args)); - } else { - data['args'] = JSON.stringify(args); - } - - $.post('/plugins/run', data, function(res) { - layer.close(loadT); - if (!res.status){ - layer.msg(res.msg,{icon:2,time:10000}); - return; - } - - var ret_data = $.parseJSON(res.data); - console.log("send:",ret_data); - // if (!ret_data.status){ - // layer.msg(ret_data.msg,{icon:2,time:2000}); - // return; - // } - - // console.log("send2:",ret_data); - - if(typeof(callback) == 'function'){ - callback(ret_data); - } - },'json'); - }, - postCallback:function(info){ - var tips = info['tips']; - var method = info['method']; - var args = info['data']; - var callback = info['success']; - - var loadT = layer.msg(tips, { icon: 16, time: 0, shade: 0.3 }); - - var data = {}; - data['name'] = 'mail'; - data['func'] = method; - data['version'] = $('.plugin_version').attr('version'); - - if (typeof(args) == 'string'){ - data['args'] = JSON.stringify(this.str2Obj(args)); - } else { - data['args'] = JSON.stringify(args); - } - - $.post('/plugins/callback', data, function(res) { - - layer.close(loadT); - if (!res.status){ - layer.msg(res.msg,{icon:2,time:10000}); - return; - } - - var ret_data = $.parseJSON(res.data); - if (!ret_data.status){ - layer.msg(ret_data.msg,{icon:2,time:2000}); - return; - } - - if(typeof(callback) == 'function'){ - callback(res); - } - },'json'); - } -} diff --git a/plugins/mail/mail_init.py b/plugins/mail/mail_init.py deleted file mode 100644 index 413e71ae35..0000000000 --- a/plugins/mail/mail_init.py +++ /dev/null @@ -1,69 +0,0 @@ -# coding:utf-8 - -import sys -import io -import os -import time -import re - - -sys.path.append(os.getcwd() + "/class/core") - -import mw -app_debug = False -if mw.isAppleSystem(): - app_debug = True - - -class mail_init: - - def __init__(self): - self.logfile = '/tmp/mail_init.log' - - def check_env(self): - data = {} - data['HostName'] = self.check_hostname() - data['Postfix-install'] = {"status": True, "msg": "Postfix已经安装"} if os.path.exists( - '/usr/sbin/postfix') else {"status": False, "msg": "Postfix未安装,请点击修复按钮"} - data['Dovecot-install'] = {"status": True, "msg": "Deovecot已经安装"} if os.path.exists( - '/usr/sbin/dovecot') else {"status": False, "msg": "Dovecot未安装,请点击修复按钮"} - data['Postfix-Version'] = self.check_postfix_ver() - data['Redis-install'] = {"status": True, "msg": "Redis已经安装"} if os.path.exists( - mw.getServerDir() + '/redis/bin/redis-server') else {"status": False, "msg": "请到软件商店内安装Redis"} - data['Redis-Passwd'] = self.check_redis_passwd(data['Redis-install']) - data['Rspamd-install'] = {"status": True, "msg": "Rspamd已经安装"} if os.path.exists( - '/usr/bin/rspamd') else {"status": False, "msg": "Rspamd未安装,请点击修复按钮"} - data['Sqlite-support'] = self.check_sqlite() - data['SElinux'] = {"status": True, "msg": "SElinux已经禁用"} if not 'enforcing' in mw.execShell( - 'getenforce')[0].lower() else {"status": False, "msg": "请先禁用SElinux"} - return data - - def check_hostname(self): - import socket - rep = '^(?!:\/\/)(?=.{1,255}$)((.{1,63}\.){1,127}(?![0-9]*$)[a-z0-9-]+\.?)$' - hostname = socket.gethostname() - if re.search(rep, hostname): - return mw.returnData(True, 'success') - return mw.returnData(False, '你的主机名 ({}) 不合规定, 需要是完整域名' - '你可以通过以下命令修复你的主机名 ' - '在ssh终端执行 \'hostnamectl set-hostname --static mail.example.com\''.format(hostname)) - - def check_postfix_ver(self): - postfix_version = mw.execShell( - r"postconf mail_version|sed -r 's/.* ([0-9\.]+)$/\1/'")[0].strip() - if postfix_version.startswith('3'): - return mw.returnData(True, postfix_version) - else: - return mw.returnData(False, "当前版本不支持或Postfix没有安装成功:{}".format(postfix_version)) - - def check_redis_passwd(self, redis_install): - redis_conf = mw.readFile(mw.getServerDir() + '/redis/redis.conf') - if redis_install['status']: - if re.search('\n\s*requirepass', redis_conf): - return mw.returnData(True, "Redis已经设置密码") - return mw.returnData(False, "请到Redis管理器设置密码!") - - def check_sqlite(self): - if not mw.execShell('postconf -m | grep sqlite')[0].strip(): - return mw.returnData(False, "Postfix不支持Sqlite") - return mw.returnData(True, "Postfix已支持Sqlite") diff --git a/plugins/mail/versions/1.0/install.sh b/plugins/mail/versions/1.0/install.sh deleted file mode 100755 index 337d179605..0000000000 --- a/plugins/mail/versions/1.0/install.sh +++ /dev/null @@ -1,148 +0,0 @@ -#!/bin/bash -PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin -export PATH - -curPath=`pwd` -rootPath=$(dirname "$curPath") -rootPath=$(dirname "$rootPath") -serverPath=$(dirname "$rootPath") - -install_tmp=${rootPath}/tmp/mw_install.pl -VERSION=$2 - -cpu_arch=`arch` -if [[ $cpu_arch != "x86_64" ]];then - echo 'Does not support non-x86 system installation' - exit 0 -fi - -# if [ -f "/usr/bin/apt-get" ];then -# systemver='ubuntu' -# elif [ -f "/etc/redhat-release" ];then -# systemver=`cat /etc/redhat-release|sed -r 's/.* ([0-9]+)\..*/\1/'` -# postfixver=`postconf mail_version|sed -r 's/.* ([0-9\.]+)$/\1/'` -# else -# echo 'Unsupported system version' -# exit 0 -# fi - -## curl -fsSL https://raw.githubusercontent.com/midoks/mdserver-web/dev/scripts/update_dev.sh | bash -## debug: -## cd /www/server/mdserver-web/plugins/mail && bash install.sh install 1.0 - -bash ${rootPath}/scripts/getos.sh -OSNAME=`cat ${rootPath}/data/osname.pl` -OSNAME_ID=`cat /etc/*-release | grep VERSION_ID | awk -F = '{print $2}' | awk -F "\"" '{print $2}'` - - -Install_debain(){ - hostname=`hostname` - # 安装postfix和postfix-sqlite - debconf-set-selections <<< "postfix postfix/mailname string ${hostname}" - debconf-set-selections <<< "postfix postfix/main_mailer_type string 'Internet Site'" - apt install postfix -y - apt install postfix-sqlite -y - apt install sqlite -y - - # 安装dovecot和dovecot-sieve - apt install dovecot-core dovecot-pop3d dovecot-imapd dovecot-lmtpd dovecot-sqlite dovecot-sieve -y - - apt install rspamd -y - - apt install cyrus-sasl-plain -y -} - -Uninstall_debain(){ - apt remove postfix postfix-sqlite -y && rm -rf /etc/postfix - dpkg -P postfix postfix-sqlite - apt remove dovecot-core dovecot-imapd dovecot-lmtpd dovecot-pop3d dovecot-sqlite dovecot-sieve -y - dpkg -P dovecot-core dovecot-imapd dovecot-lmtpd dovecot-pop3d dovecot-sqlite dovecot-sieve - apt remove opendkim opendkim-tools -y - dpkg -P opendkim opendkim-tools - apt remove rspamd -y - dpkg -P rspamd -} - -Install_ubuntu(){ - Install_debain -} - -Uninstall_ubuntu(){ - Uninstall_debain -} - -Install_App() -{ - echo '正在安装脚本文件...' > $install_tmp - mkdir -p $serverPath/source - - runScript=$curPath/install_$OSNAME.sh - - if [[ -f $runScript ]]; then - sh -x $runScript install - elif [[ $OSNAME = "debian" ]]; then - Install_debain - else - Install_ubuntu - fi - - if [ ! -f /etc/dovecot/conf.d/90-sieve.conf ];then - if [ -f "/usr/bin/apt-get" ];then - apt install dovecot-sieve -y - else - rm -rf /etc/dovecot_back - cp -a /etc/dovecot /etc/dovecot_back - yum remove dovecot -y - yum install dovecot-pigeonhole -y - if [ ! -f /usr/sbin/dovecot ]; then - yum install dovecot -y - fi - \cp -a /etc/dovecot_back/* /etc/dovecot - chown -R vmail:dovecot /etc/dovecot - chmod -R o-rwx /etc/dovecot - - systemctl enable dovecot - systemctl restart dovecot - fi - fi - - filesize=`ls -l /etc/dovecot/dh.pem | awk '{print $5}'` - echo $filesize - - if [ ! -f "/etc/dovecot/dh.pem" ] || [ $filesize -lt 300 ]; then - openssl dhparam 2048 > /etc/dovecot/dh.pem - fi - - mkdir -p $serverPath/mail - echo '1.0' > $serverPath/mail/version.pl - echo '安装完成' > $install_tmp -} - -Uninstall_App() -{ - runScript=$curPath/install_$OSNAME.sh - if [[ -f $runScript ]]; then - sh -x $runScript uninstall - elif [[ $OSNAME = "debian" ]]; then - Uninstall_debain - else - Uninstall_ubuntu - fi - - if [ -f $serverPath/mail/initd/mail ];then - $serverPath/mail/initd/mail stop - fi - - rm -rf /etc/postfix - rm -rf /etc/dovecot - rm -rf /etc/opendkim - rm -rf /usr/share/rspamd/www/rspamd - echo "Uninstall_Mail" > $install_tmp -} - -action=$1 -if [ "${1}" == 'install' ];then - Install_App -else - Uninstall_App -fi diff --git a/plugins/mail/versions/1.0/install_centos.sh b/plugins/mail/versions/1.0/install_centos.sh deleted file mode 100644 index e30a78a16f..0000000000 --- a/plugins/mail/versions/1.0/install_centos.sh +++ /dev/null @@ -1,118 +0,0 @@ -#!/bin/bash -PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin -export PATH - -curPath=`pwd` -rootPath=$(dirname "$curPath") -rootPath=$(dirname "$rootPath") -serverPath=$(dirname "$rootPath") - -cpu_arch=`arch` -if [[ $cpu_arch != "x86_64" ]];then - echo 'Does not support non-x86 system installation' - exit 0 -fi - - -OSNAME_ID=`cat /etc/*-release | grep VERSION_ID | awk -F = '{print $2}' | awk -F "\"" '{print $2}'` - -Install_centos8() -{ - yum install epel-release -y - # 卸载系统自带的postfix - if [[ $cpu_arch = "x86_64" && $postfixver != "3.4.9" ]];then - yum remove postfix -y - rm -rf /etc/postfix - fi - # 安装postfix和postfix-sqlite - yum localinstall $pluginPath/rpm/postfix3-3.4.9-1.gf.el8.x86_64.rpm -y - yum localinstall $pluginPath/rpm/postfix3-sqlite-3.4.9-1.gf.el8.x86_64.rpm -y - if [[ ! -f "/usr/sbin/postfix" ]]; then - yum install postfix -y - yum install postfix-sqlite -y - fi - # 安装dovecot和dovecot-sieve - yum install dovecot-pigeonhole -y - if [[ ! -f "/usr/sbin/dovecot" ]]; then - yum install dovecot -y - fi - # 安装opendkim -# 安装rspamd - - install_rspamd - yum install cyrus-sasl-plain -y -} - -Install_centos7() { - - yum install epel-release -y - # 卸载系统自带的postfix - if [[ $cpu_arch = "x86_64" && $postfixver != "3.4.7" ]];then - yum remove postfix -y - rm -rf /etc/postfix - fi - # 安装postfix和postfix-sqlite - yum localinstall $pluginPath/rpm/postfix3-3.4.7-1.gf.el7.x86_64.rpm -y - yum localinstall $pluginPath/rpm/postfix3-sqlite-3.4.7-1.gf.el7.x86_64.rpm -y - if [[ ! -f "/usr/sbin/postfix" ]]; then - yum install postfix -y - yum install postfix-sqlite -y - fi - # 安装dovecot和dovecot-sieve - yum install dovecot-pigeonhole -y - if [[ ! -f "/usr/sbin/dovecot" ]]; then - yum install dovecot -y - fi - #安装rspamd - install_rspamd - yum install cyrus-sasl-plain -y - -} - -install_rspamd() { - if [[ $OSNAME_ID = "7" ]];then - wget -O /etc/yum.repos.d/rspamd.repo https://rspamd.com/rpm-stable/centos-7/rspamd.repo - rpm --import https://rspamd.com/rpm-stable/gpg.key - yum makecache - yum install rspamd -y - elif [ $OSNAME_ID = "8" ]; then - wget -O /etc/yum.repos.d/rspamd.repo https://rspamd.com/rpm-stable/centos-8/rspamd.repo - rpm --import https://rspamd.com/rpm-stable/gpg.key - yum makecache - yum install rspamd -y - else - CODENAME=`lsb_release -c -s` - mkdir -p /etc/apt/keyrings - wget -O- https://rspamd.com/apt-stable/gpg.key | gpg --dearmor | tee /etc/apt/keyrings/rspamd.gpg > /dev/null - echo "deb [arch=amd64 signed-by=/etc/apt/keyrings/rspamd.gpg] http://rspamd.com/apt-stable/ $CODENAME main" | tee /etc/apt/sources.list.d/rspamd.list - echo "deb-src [arch=amd64 signed-by=/etc/apt/keyrings/rspamd.gpg] http://rspamd.com/apt-stable/ $CODENAME main" | tee -a /etc/apt/sources.list.d/rspamd.list - apt-get update - export DEBIAN_FRONTEND=noninteractive - apt-get --no-install-recommends install rspamd -y - fi -} - -Install_App() { - if [ "$OSNAME_ID" == "7" ];then - Install_centos7 - elif [ "$OSNAME_ID" == "8" ];then - Install_centos8 - fi -} - -Uninstall_App() -{ - yum remove postfix -y - yum remove dovecot -y - yum remove opendkim -y - yum remove rspamd -y - yum remove dovecot-pigeonhole -y -} - - -action=$1 -if [ "${1}" == 'install' ];then - Install_App -else - Uninstall_App -fi \ No newline at end of file From b5195ba6854bc0c2e3b1c992a80d5dde4c7eec79 Mon Sep 17 00:00:00 2001 From: midoks Date: Mon, 19 Sep 2022 20:07:34 +0800 Subject: [PATCH 34/59] =?UTF-8?q?mail=20=E5=BC=80=E5=8F=91=E9=98=B6?= =?UTF-8?q?=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 2e8c4a2406..d09f3ecf62 100644 --- a/.gitignore +++ b/.gitignore @@ -151,6 +151,7 @@ plugins/gdrive plugins/mtproxy plugins/zimg plugins/bk_demo +plugins/mail debug.out From 5a93b07968440bb7a99b93f265d6a22402db229b Mon Sep 17 00:00:00 2001 From: midoks Date: Mon, 19 Sep 2022 20:47:12 +0800 Subject: [PATCH 35/59] =?UTF-8?q?=E5=8A=A0=E5=85=A5=E5=BC=80=E5=8F=91?= =?UTF-8?q?=E6=A8=A1=E5=BC=8F=E5=BC=80=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + class/core/config_api.py | 16 +++++++++++++++- route/static/app/config.js | 15 ++++++++++++++- route/templates/default/config.html | 8 ++++++++ 4 files changed, 38 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index d09f3ecf62..1bce393138 100644 --- a/.gitignore +++ b/.gitignore @@ -122,6 +122,7 @@ data/datadir.pl data/502Task.pl data/default.pl data/backup.pl +data/debug.pl data/default_site.pl lib/python* diff --git a/class/core/config_api.py b/class/core/config_api.py index 0e09a4b457..72821da45c 100755 --- a/class/core/config_api.py +++ b/class/core/config_api.py @@ -207,6 +207,14 @@ def closePanelApi(self): mw.execShell("chown root.root " + filename) return mw.returnJson(True, '面板已关闭!') + def openDebugApi(self): + filename = 'data/debug.pl' + if os.path.exists(filename): + os.remove(filename) + return mw.returnJson(True, '开发模式关闭!') + mw.writeFile(filename, 'True') + return mw.returnJson(True, '开发模式开启!') + def setIpv6StatusApi(self): ipv6_file = 'data/ipv6.pl' if os.path.exists('data/ipv6.pl'): @@ -316,11 +324,17 @@ def get(self): data['admin_path'] = mw.readFile(admin_path_file) ipv6_file = 'data/ipv6.pl' - if os.path.exists('data/ipv6.pl'): + if os.path.exists(ipv6_file): data['ipv6'] = 'checked' else: data['ipv6'] = '' + debug_file = 'data/debug.pl' + if os.path.exists(debug_file): + data['debug'] = 'checked' + else: + data['debug'] = '' + ssl_file = 'data/ssl.pl' if os.path.exists('data/ssl.pl'): data['ssl'] = 'checked' diff --git a/route/static/app/config.js b/route/static/app/config.js index a9137eb535..61feae9f17 100755 --- a/route/static/app/config.js +++ b/route/static/app/config.js @@ -26,13 +26,26 @@ function closePanel(){ }}, function() { $.post('/config/close_panel','',function(rdata){ layer.msg(rdata.msg,{icon:rdata.status?1:2}); - setTimeout(function(){window.location.reload();},1000); + setTimeout(function(){ + window.location.reload(); + },1000); },'json'); },function(){ $("#closePl").prop("checked",false); }); } +//开发模式 +function debugMode(){ + var loadT = layer.msg('正在发送请求,请稍候...', { icon: 16, time: 0, shade: [0.3, '#000'] }); + $.post('/config/open_debug', {}, function (rdata) { + layer.close(loadT); + showMsg(rdata.msg, function(){ + window.location.reload(); + } ,{icon:rdata.status?1:2}, 1000); + },'json'); +} + function modifyAuthPath() { var auth_path = $("#admin_path").val(); diff --git a/route/templates/default/config.html b/route/templates/default/config.html index 8ada07c7a5..e6b068a458 100755 --- a/route/templates/default/config.html +++ b/route/templates/default/config.html @@ -18,6 +18,14 @@
    +
    + 开发模式 +
    + + +
    +
    +
    监听IPv6
    From 2eeef4d8bd9bb0e56c71dec3a161823f7b0bde85 Mon Sep 17 00:00:00 2001 From: midoks Date: Tue, 20 Sep 2022 00:22:11 +0800 Subject: [PATCH 36/59] Update mw.py --- class/core/mw.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/class/core/mw.py b/class/core/mw.py index 1711b0d226..5e87be7621 100755 --- a/class/core/mw.py +++ b/class/core/mw.py @@ -609,7 +609,7 @@ def getNumLines(path, num, p=1): break fp.close() except Exception as e: - return '' + return str(e) return "\n".join(data) From 5583db0c70d32526b7ac2f3aa5657a7d76b7d1dd Mon Sep 17 00:00:00 2001 From: midoks Date: Tue, 20 Sep 2022 00:24:40 +0800 Subject: [PATCH 37/59] Update crontab_api.py --- class/core/crontab_api.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/class/core/crontab_api.py b/class/core/crontab_api.py index a07fd0058a..66362cf8f4 100755 --- a/class/core/crontab_api.py +++ b/class/core/crontab_api.py @@ -167,7 +167,7 @@ def logsApi(self): logFile = mw.getServerDir() + '/cron/' + echo['echo'] + '.log' if not os.path.exists(logFile): return mw.returnJson(False, '当前日志为空!') - log = mw.getNumLines(logFile, 500) + log = mw.getLastLine(logFile, 500) return mw.returnJson(True, log) def addApi(self): From 2c0231155d0f982d1acdb172e389d5628a9b906b Mon Sep 17 00:00:00 2001 From: midoks Date: Tue, 20 Sep 2022 11:30:04 +0800 Subject: [PATCH 38/59] =?UTF-8?q?=E4=BC=98=E5=8C=96=20=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E8=AF=BB=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- class/core/files_api.py | 2 +- class/core/site_api.py | 4 ++-- plugins/mariadb/index.py | 2 +- plugins/mysql/index.py | 2 +- plugins/supervisor/index.py | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/class/core/files_api.py b/class/core/files_api.py index bc97a1482a..63a73783c6 100755 --- a/class/core/files_api.py +++ b/class/core/files_api.py @@ -36,7 +36,7 @@ def getLastBodyApi(self): return mw.returnJson(False, '文件不存在', (path,)) try: - data = mw.getNumLines(path, int(line)) + data = mw.getLastLine(path, int(line)) return mw.returnJson(True, 'OK', data) except Exception as ex: return mw.returnJson(False, u'无法正确读取文件!' + str(ex)) diff --git a/class/core/site_api.py b/class/core/site_api.py index 40f1ac30d4..c91e8749df 100755 --- a/class/core/site_api.py +++ b/class/core/site_api.py @@ -1829,13 +1829,13 @@ def getLogs(self, siteName): logPath = mw.getLogsDir() + '/' + siteName + '.log' if not os.path.exists(logPath): return mw.returnJson(False, '日志为空') - return mw.returnJson(True, mw.getNumLines(logPath, 100)) + return mw.returnJson(True, mw.getLastLine(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)) + return mw.returnJson(True, mw.getLastLine(logPath, 100)) # 取日志状态 def getLogsStatus(self, siteName): diff --git a/plugins/mariadb/index.py b/plugins/mariadb/index.py index 4d3e9a8c17..279e288134 100755 --- a/plugins/mariadb/index.py +++ b/plugins/mariadb/index.py @@ -304,7 +304,7 @@ def getErrorLog(): if 'close' in args: mw.writeFile(filename, '') return mw.returnJson(False, '日志已清空') - info = mw.getNumLines(filename, 18) + info = mw.getLastLine(filename, 18) return mw.returnJson(True, 'OK', info) diff --git a/plugins/mysql/index.py b/plugins/mysql/index.py index d6fd083ed7..d4f9cf8ed5 100755 --- a/plugins/mysql/index.py +++ b/plugins/mysql/index.py @@ -333,7 +333,7 @@ def getErrorLog(): if 'close' in args: mw.writeFile(filename, '') return mw.returnJson(False, '日志已清空') - info = mw.getNumLines(filename, 18) + info = mw.getLastLine(filename, 18) return mw.returnJson(True, 'OK', info) diff --git a/plugins/supervisor/index.py b/plugins/supervisor/index.py index 1d7c067583..7172170fe7 100755 --- a/plugins/supervisor/index.py +++ b/plugins/supervisor/index.py @@ -472,7 +472,7 @@ def readConfigLogTpl(): stdout_logfile = line.strip().split('=')[1] if stdout_logfile != '': - data = mw.getNumLines(stdout_logfile, int(line_log)) + data = mw.getLastLine(stdout_logfile, int(line_log)) return mw.returnJson(True, 'OK', data) return mw.returnJson(False, 'OK', '') @@ -494,7 +494,7 @@ def readConfigLogErrorTpl(): stderr_logfile = line.strip().split('=')[1] if stderr_logfile != '': - data = mw.getNumLines(stderr_logfile, int(line_log)) + data = mw.getLastLine(stderr_logfile, int(line_log)) return mw.returnJson(True, 'OK', data) return mw.returnJson(False, 'OK', '') From 0cdc23a096e7e6dd80bae61ae59c8d0ba1c671d8 Mon Sep 17 00:00:00 2001 From: midoks Date: Tue, 20 Sep 2022 11:55:32 +0800 Subject: [PATCH 39/59] Update install.sh --- plugins/php/versions/82/install.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/php/versions/82/install.sh b/plugins/php/versions/82/install.sh index 83aaa89908..5b541f8117 100755 --- a/plugins/php/versions/82/install.sh +++ b/plugins/php/versions/82/install.sh @@ -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.0beta3 +version=8.2.0RC2 PHP_VER=82 Install_php() { @@ -32,7 +32,7 @@ cd $serverPath/mdserver-web/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-8.2.0alpha2.tar.xz + wget --no-check-certificate -O $sourcePath/php/php-${version}.tar.xz https://downloads.php.net/~pierrick/php-${version}.tar.xz fi cd $sourcePath/php && tar -Jxf $sourcePath/php/php-${version}.tar.xz From e873ea8639c1d01c962658beed9897763b46b1f6 Mon Sep 17 00:00:00 2001 From: midoks Date: Tue, 20 Sep 2022 12:01:02 +0800 Subject: [PATCH 40/59] Update install.sh --- plugins/php/versions/82/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/php/versions/82/install.sh b/plugins/php/versions/82/install.sh index 5b541f8117..0e03fff589 100755 --- a/plugins/php/versions/82/install.sh +++ b/plugins/php/versions/82/install.sh @@ -32,7 +32,7 @@ cd $serverPath/mdserver-web/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/~sergey/php-${version}.tar.xz fi cd $sourcePath/php && tar -Jxf $sourcePath/php/php-${version}.tar.xz From e266d85c91c5783b87492cb1b19b2bb71e579516 Mon Sep 17 00:00:00 2001 From: midoks Date: Tue, 20 Sep 2022 12:10:27 +0800 Subject: [PATCH 41/59] ip --- plugins/php/versions/80/install.sh | 2 +- plugins/php/versions/81/install.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/php/versions/80/install.sh b/plugins/php/versions/80/install.sh index 4079c71a7b..815d1d9774 100755 --- a/plugins/php/versions/80/install.sh +++ b/plugins/php/versions/80/install.sh @@ -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.0.22 +version=8.0.23 PHP_VER=80 Install_php() { diff --git a/plugins/php/versions/81/install.sh b/plugins/php/versions/81/install.sh index 33f4a8460c..1ac0438243 100755 --- a/plugins/php/versions/81/install.sh +++ b/plugins/php/versions/81/install.sh @@ -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.1.9 +version=8.1.10 PHP_VER=81 Install_php() { From cafff1d522354c839b45fdb8c514581d9d089028 Mon Sep 17 00:00:00 2001 From: midoks Date: Tue, 20 Sep 2022 14:29:46 +0800 Subject: [PATCH 42/59] up --- plugins/mysql/versions/5.6/install.sh | 2 +- plugins/mysql/versions/5.7/install.sh | 4 ++-- plugins/mysql/versions/8.0/install.sh | 4 ++-- plugins/php/versions/52/install.sh | 2 +- plugins/php/versions/53/install.sh | 2 +- plugins/php/versions/54/install.sh | 2 +- plugins/php/versions/55/install.sh | 4 ++-- plugins/php/versions/56/install.sh | 4 ++-- plugins/php/versions/70/install.sh | 4 ++-- plugins/php/versions/71/install.sh | 4 ++-- plugins/php/versions/72/install.sh | 4 ++-- plugins/php/versions/73/install.sh | 4 ++-- plugins/php/versions/74/install.sh | 6 +++--- plugins/php/versions/80/install.sh | 4 ++-- plugins/php/versions/81/install.sh | 4 ++-- plugins/php/versions/82/install.sh | 4 ++-- plugins/php/versions/common/bcmath.sh | 2 +- plugins/php/versions/common/exif.sh | 2 +- plugins/php/versions/common/fileinfo.sh | 2 +- plugins/php/versions/common/gd.sh | 2 +- plugins/php/versions/common/gd_old.sh | 2 +- plugins/php/versions/common/gettext.sh | 2 +- plugins/php/versions/common/iconv.sh | 2 +- plugins/php/versions/common/intl.sh | 2 +- plugins/php/versions/common/mcrypt.sh | 2 +- plugins/php/versions/common/openssl.sh | 2 +- plugins/php/versions/common/pcntl.sh | 2 +- plugins/php/versions/common/zlib.sh | 2 +- 28 files changed, 41 insertions(+), 41 deletions(-) diff --git a/plugins/mysql/versions/5.6/install.sh b/plugins/mysql/versions/5.6/install.sh index b0d67d46fd..e54dce9162 100755 --- a/plugins/mysql/versions/5.6/install.sh +++ b/plugins/mysql/versions/5.6/install.sh @@ -74,7 +74,7 @@ Install_mysql() 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 + cd ${rootPath}/plugins/php/lib && /bin/bash openssl.sh export PKG_CONFIG_PATH=$serverPath/lib/openssl/lib/pkgconfig OPTIONS="-DWITH_SSL=${serverPath}/lib/openssl" fi diff --git a/plugins/mysql/versions/5.7/install.sh b/plugins/mysql/versions/5.7/install.sh index 955bbea78d..072cff7c73 100755 --- a/plugins/mysql/versions/5.7/install.sh +++ b/plugins/mysql/versions/5.7/install.sh @@ -61,7 +61,7 @@ Install_mysql() fi # ----- cpu end ------ - cd $serverPath/mdserver-web/plugins/mysql/lib && /bin/bash rpcgen.sh + cd ${rootPath}/plugins/mysql/lib && /bin/bash rpcgen.sh 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-5.7/mysql-boost-${VERSION}.tar.gz @@ -89,7 +89,7 @@ Install_mysql() 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 + cd ${rootPath}/plugins/php/lib && /bin/bash openssl.sh export PKG_CONFIG_PATH=$serverPath/lib/openssl/lib/pkgconfig OPTIONS="-DWITH_SSL=${serverPath}/lib/openssl" fi diff --git a/plugins/mysql/versions/8.0/install.sh b/plugins/mysql/versions/8.0/install.sh index e714c5b433..879330c83b 100755 --- a/plugins/mysql/versions/8.0/install.sh +++ b/plugins/mysql/versions/8.0/install.sh @@ -95,7 +95,7 @@ Install_mysql() fi # ----- cpu end ------ - cd $serverPath/mdserver-web/plugins/mysql/lib && /bin/bash rpcgen.sh + cd ${rootPath}/plugins/mysql/lib && /bin/bash rpcgen.sh INSTALL_CMD=cmake # check cmake version @@ -132,7 +132,7 @@ Install_mysql() 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 + cd ${rootPath}/plugins/php/lib && /bin/bash openssl.sh export PKG_CONFIG_PATH=$serverPath/lib/openssl/lib/pkgconfig OPTIONS="-DWITH_SSL=${serverPath}/lib/openssl" fi diff --git a/plugins/php/versions/52/install.sh b/plugins/php/versions/52/install.sh index a03d552861..7d2c608a0d 100755 --- a/plugins/php/versions/52/install.sh +++ b/plugins/php/versions/52/install.sh @@ -21,7 +21,7 @@ echo "安装php-${version} ..." > $install_tmp mkdir -p $sourcePath/php mkdir -p $serverPath/php -cd $serverPath/mdserver-web/plugins/php/lib && /bin/bash zlib.sh +cd ${rootPath}/plugins/php/lib && /bin/bash zlib.sh if [ ! -d $sourcePath/php/php${PHP_VER} ];then if [ ! -f $sourcePath/php/php-${version}.tar.gz ];then diff --git a/plugins/php/versions/53/install.sh b/plugins/php/versions/53/install.sh index 22817ad17a..9591042247 100755 --- a/plugins/php/versions/53/install.sh +++ b/plugins/php/versions/53/install.sh @@ -21,7 +21,7 @@ echo "安装php-5.3.29 ..." > $install_tmp mkdir -p $sourcePath/php mkdir -p $serverPath/php -cd $serverPath/mdserver-web/plugins/php/lib && /bin/bash zlib.sh +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 diff --git a/plugins/php/versions/54/install.sh b/plugins/php/versions/54/install.sh index e72891d1ef..9d042dd0fe 100755 --- a/plugins/php/versions/54/install.sh +++ b/plugins/php/versions/54/install.sh @@ -21,7 +21,7 @@ mkdir -p $sourcePath/php mkdir -p $serverPath/php -cd $serverPath/mdserver-web/plugins/php/lib && /bin/bash zlib.sh +cd ${rootPath}/plugins/php/lib && /bin/bash zlib.sh if [ ! -d $sourcePath/php/php${PHP_VER} ];then if [ ! -f $sourcePath/php/php-${version}.tar.gz ];then diff --git a/plugins/php/versions/55/install.sh b/plugins/php/versions/55/install.sh index d534b8024b..a801717b93 100755 --- a/plugins/php/versions/55/install.sh +++ b/plugins/php/versions/55/install.sh @@ -19,8 +19,8 @@ echo "安装php-5.5.38 ..." > $install_tmp mkdir -p $sourcePath/php mkdir -p $serverPath/php -cd $serverPath/mdserver-web/plugins/php/lib && /bin/bash freetype_old.sh -cd $serverPath/mdserver-web/plugins/php/lib && /bin/bash zlib.sh +cd ${rootPath}/plugins/php/lib && /bin/bash freetype_old.sh +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 diff --git a/plugins/php/versions/56/install.sh b/plugins/php/versions/56/install.sh index d6ae6167b5..3d185c01b1 100755 --- a/plugins/php/versions/56/install.sh +++ b/plugins/php/versions/56/install.sh @@ -19,8 +19,8 @@ echo "安装php-${version} ..." > $install_tmp mkdir -p $sourcePath/php mkdir -p $serverPath/php -cd $serverPath/mdserver-web/plugins/php/lib && /bin/bash freetype_old.sh -cd $serverPath/mdserver-web/plugins/php/lib && /bin/bash zlib.sh +cd ${rootPath}/plugins/php/lib && /bin/bash freetype_old.sh +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 diff --git a/plugins/php/versions/70/install.sh b/plugins/php/versions/70/install.sh index f544c3b1b9..df569d2ff1 100755 --- a/plugins/php/versions/70/install.sh +++ b/plugins/php/versions/70/install.sh @@ -19,8 +19,8 @@ echo "安装php-${version} ..." > $install_tmp mkdir -p $sourcePath/php mkdir -p $serverPath/php -cd $serverPath/mdserver-web/plugins/php/lib && /bin/bash freetype_old.sh -cd $serverPath/mdserver-web/plugins/php/lib && /bin/bash zlib.sh +cd ${rootPath}/plugins/php/lib && /bin/bash freetype_old.sh +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 diff --git a/plugins/php/versions/71/install.sh b/plugins/php/versions/71/install.sh index 1f75082fa6..9c4c0ac4bf 100755 --- a/plugins/php/versions/71/install.sh +++ b/plugins/php/versions/71/install.sh @@ -19,8 +19,8 @@ echo "安装php-${version} ..." > $install_tmp mkdir -p $sourcePath/php mkdir -p $serverPath/php -cd $serverPath/mdserver-web/plugins/php/lib && /bin/bash freetype_old.sh -cd $serverPath/mdserver-web/plugins/php/lib && /bin/bash zlib.sh +cd ${rootPath}/plugins/php/lib && /bin/bash freetype_old.sh +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 diff --git a/plugins/php/versions/72/install.sh b/plugins/php/versions/72/install.sh index 1e4377f746..4f814f83ba 100755 --- a/plugins/php/versions/72/install.sh +++ b/plugins/php/versions/72/install.sh @@ -20,8 +20,8 @@ echo "安装php-${version} ..." > $install_tmp mkdir -p $sourcePath/php mkdir -p $serverPath/php -cd $serverPath/mdserver-web/plugins/php/lib && /bin/bash freetype_old.sh -cd $serverPath/mdserver-web/plugins/php/lib && /bin/bash zlib.sh +cd ${rootPath}/plugins/php/lib && /bin/bash freetype_old.sh +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 diff --git a/plugins/php/versions/73/install.sh b/plugins/php/versions/73/install.sh index b213717e0e..cb05afe83a 100755 --- a/plugins/php/versions/73/install.sh +++ b/plugins/php/versions/73/install.sh @@ -24,8 +24,8 @@ echo "安装php-${version} ..." > $install_tmp mkdir -p $sourcePath/php mkdir -p $serverPath/php -cd $serverPath/mdserver-web/plugins/php/lib && /bin/bash freetype_old.sh -cd $serverPath/mdserver-web/plugins/php/lib && /bin/bash zlib.sh +cd ${rootPath}/plugins/php/lib && /bin/bash freetype_old.sh +cd ${rootPath}/plugins/php/lib && /bin/bash zlib.sh if [ ! -d $sourcePath/php/php${PHP_VER} ];then diff --git a/plugins/php/versions/74/install.sh b/plugins/php/versions/74/install.sh index 18a555a412..a09ffe377f 100755 --- a/plugins/php/versions/74/install.sh +++ b/plugins/php/versions/74/install.sh @@ -25,9 +25,9 @@ echo "安装php-${version} ..." > $install_tmp mkdir -p $sourcePath/php mkdir -p $serverPath/php -cd $serverPath/mdserver-web/plugins/php/lib && /bin/bash freetype_new.sh -cd $serverPath/mdserver-web/plugins/php/lib && /bin/bash zlib.sh -cd $serverPath/mdserver-web/plugins/php/lib && /bin/bash libzip.sh +cd ${rootPath}/plugins/php/lib && /bin/bash freetype_new.sh +cd ${rootPath}/plugins/php/lib && /bin/bash zlib.sh +cd ${rootPath}/plugins/php/lib && /bin/bash libzip.sh if [ ! -d $sourcePath/php/php${PHP_VER} ];then diff --git a/plugins/php/versions/80/install.sh b/plugins/php/versions/80/install.sh index 815d1d9774..941b12c832 100755 --- a/plugins/php/versions/80/install.sh +++ b/plugins/php/versions/80/install.sh @@ -25,8 +25,8 @@ echo "安装php-${version} ..." > $install_tmp mkdir -p $sourcePath/php mkdir -p $serverPath/php -cd $serverPath/mdserver-web/plugins/php/lib && /bin/bash freetype_new.sh -cd $serverPath/mdserver-web/plugins/php/lib && /bin/bash zlib.sh +cd ${rootPath}/plugins/php/lib && /bin/bash freetype_new.sh +cd ${rootPath}/plugins/php/lib && /bin/bash zlib.sh if [ ! -d $sourcePath/php/php${PHP_VER} ];then diff --git a/plugins/php/versions/81/install.sh b/plugins/php/versions/81/install.sh index 1ac0438243..50b72ebd78 100755 --- a/plugins/php/versions/81/install.sh +++ b/plugins/php/versions/81/install.sh @@ -25,8 +25,8 @@ echo "安装php-${version} ..." > $install_tmp mkdir -p $sourcePath/php mkdir -p $serverPath/php -cd $serverPath/mdserver-web/plugins/php/lib && /bin/bash freetype_new.sh -cd $serverPath/mdserver-web/plugins/php/lib && /bin/bash zlib.sh +cd ${rootPath}/plugins/php/lib && /bin/bash freetype_new.sh +cd ${rootPath}/plugins/php/lib && /bin/bash zlib.sh if [ ! -d $sourcePath/php/php${PHP_VER} ];then diff --git a/plugins/php/versions/82/install.sh b/plugins/php/versions/82/install.sh index 0e03fff589..b12362d3ee 100755 --- a/plugins/php/versions/82/install.sh +++ b/plugins/php/versions/82/install.sh @@ -25,8 +25,8 @@ echo "安装php-${version} ..." > $install_tmp mkdir -p $sourcePath/php mkdir -p $serverPath/php -cd $serverPath/mdserver-web/plugins/php/lib && /bin/bash freetype_new.sh -cd $serverPath/mdserver-web/plugins/php/lib && /bin/bash zlib.sh +cd ${rootPath}/plugins/php/lib && /bin/bash freetype_new.sh +cd ${rootPath}/plugins/php/lib && /bin/bash zlib.sh if [ ! -d $sourcePath/php/php${PHP_VER} ];then diff --git a/plugins/php/versions/common/bcmath.sh b/plugins/php/versions/common/bcmath.sh index e60a17986e..f297456d47 100755 --- a/plugins/php/versions/common/bcmath.sh +++ b/plugins/php/versions/common/bcmath.sh @@ -49,7 +49,7 @@ Install_lib() if [ ! -f "$extFile" ];then if [ ! -d $sourcePath/php${version}/ext ];then - cd $serverPath/mdserver-web/plugins/php && /bin/bash install.sh install ${version} + cd ${rootPath}/plugins/php && /bin/bash install.sh install ${version} fi cd $sourcePath/php${version}/ext/${LIBNAME} diff --git a/plugins/php/versions/common/exif.sh b/plugins/php/versions/common/exif.sh index 6223638140..6eb4ad67e7 100755 --- a/plugins/php/versions/common/exif.sh +++ b/plugins/php/versions/common/exif.sh @@ -52,7 +52,7 @@ Install_lib() if [ ! -f "$extFile" ];then if [ ! -d $sourcePath/php${version}/ext ];then - cd $serverPath/mdserver-web/plugins/php && /bin/bash install.sh install ${version} + cd ${rootPath}/plugins/php && /bin/bash install.sh install ${version} fi cd $sourcePath/php${version}/ext/${LIBNAME} diff --git a/plugins/php/versions/common/fileinfo.sh b/plugins/php/versions/common/fileinfo.sh index 8419f5c6ea..0f07354ac4 100755 --- a/plugins/php/versions/common/fileinfo.sh +++ b/plugins/php/versions/common/fileinfo.sh @@ -49,7 +49,7 @@ Install_lib() if [ ! -f "$extFile" ];then if [ ! -d $sourcePath/php${version}/ext ];then - cd $serverPath/mdserver-web/plugins/php && /bin/bash install.sh install ${version} + cd ${rootPath}/plugins/php && /bin/bash install.sh install ${version} fi cd $sourcePath/php${version}/ext/${LIBNAME} diff --git a/plugins/php/versions/common/gd.sh b/plugins/php/versions/common/gd.sh index 0e54103a65..1195fe4078 100755 --- a/plugins/php/versions/common/gd.sh +++ b/plugins/php/versions/common/gd.sh @@ -52,7 +52,7 @@ Install_lib() if [ ! -f "$extFile" ];then if [ ! -d $sourcePath/php${version}/ext ];then - cd $serverPath/mdserver-web/plugins/php && /bin/bash install.sh install ${version} + cd ${rootPath}/plugins/php && /bin/bash install.sh install ${version} fi cd $sourcePath/php${version}/ext/${LIBNAME} diff --git a/plugins/php/versions/common/gd_old.sh b/plugins/php/versions/common/gd_old.sh index abb16a1f11..1923ef0a9e 100755 --- a/plugins/php/versions/common/gd_old.sh +++ b/plugins/php/versions/common/gd_old.sh @@ -55,7 +55,7 @@ Install_lib() return fi - cd $serverPath/mdserver-web/plugins/php/lib && /bin/bash freetype_old.sh + cd ${rootPath}/plugins/php/lib && /bin/bash freetype_old.sh if [ ! -f "$extFile" ];then diff --git a/plugins/php/versions/common/gettext.sh b/plugins/php/versions/common/gettext.sh index 6a1e7bef77..0534abe180 100755 --- a/plugins/php/versions/common/gettext.sh +++ b/plugins/php/versions/common/gettext.sh @@ -44,7 +44,7 @@ Install_lib() if [ ! -f "$extFile" ];then if [ ! -d $sourcePath/php${version}/ext ];then - cd $serverPath/mdserver-web/plugins/php && /bin/bash install.sh install ${version} + cd ${rootPath}/plugins/php && /bin/bash install.sh install ${version} fi cd $sourcePath/php${version}/ext/${LIBNAME} diff --git a/plugins/php/versions/common/iconv.sh b/plugins/php/versions/common/iconv.sh index 6b87bc08ca..eaf62f66b7 100755 --- a/plugins/php/versions/common/iconv.sh +++ b/plugins/php/versions/common/iconv.sh @@ -45,7 +45,7 @@ Install_lib() return fi - cd $serverPath/mdserver-web/plugins/php/lib && /bin/bash libiconv.sh + cd ${rootPath}/plugins/php/lib && /bin/bash libiconv.sh if [ ! -f "$extFile" ];then diff --git a/plugins/php/versions/common/intl.sh b/plugins/php/versions/common/intl.sh index 07ce82755c..02c2f7bb77 100755 --- a/plugins/php/versions/common/intl.sh +++ b/plugins/php/versions/common/intl.sh @@ -51,7 +51,7 @@ Install_lib() if [ ! -f "$extFile" ];then if [ ! -d $sourcePath/php${version}/ext ];then - cd $serverPath/mdserver-web/plugins/php && /bin/bash install.sh install ${version} + cd ${rootPath}/plugins/php && /bin/bash install.sh install ${version} fi cd $sourcePath/php${version}/ext/${LIBNAME} diff --git a/plugins/php/versions/common/mcrypt.sh b/plugins/php/versions/common/mcrypt.sh index 9efe3564cb..e67d116ebc 100755 --- a/plugins/php/versions/common/mcrypt.sh +++ b/plugins/php/versions/common/mcrypt.sh @@ -46,7 +46,7 @@ Install_lib() return fi - cd $serverPath/mdserver-web/plugins/php/lib && bash libmcrypt.sh + cd ${rootPath}/plugins/php/lib && bash libmcrypt.sh if [ ! -f "$extFile" ];then diff --git a/plugins/php/versions/common/openssl.sh b/plugins/php/versions/common/openssl.sh index 44d10c3348..536db4a551 100755 --- a/plugins/php/versions/common/openssl.sh +++ b/plugins/php/versions/common/openssl.sh @@ -43,7 +43,7 @@ Install_lib() # cd $serverPath/mdserver-web/plugins/php/lib && /bin/bash openssl_10.sh if [ "$version" -lt "70" ];then - cd $serverPath/mdserver-web/plugins/php/lib && /bin/bash openssl_10.sh + cd ${rootPath}/plugins/php/lib && /bin/bash openssl_10.sh fi if [ ! -f "$extFile" ];then diff --git a/plugins/php/versions/common/pcntl.sh b/plugins/php/versions/common/pcntl.sh index 2d86dfaf1e..f04cd3f624 100755 --- a/plugins/php/versions/common/pcntl.sh +++ b/plugins/php/versions/common/pcntl.sh @@ -44,7 +44,7 @@ Install_lib() if [ ! -f "$extFile" ];then if [ ! -d $sourcePath/php${version}/ext ];then - cd $serverPath/mdserver-web/plugins/php && /bin/bash install.sh install ${version} + cd ${rootPath}/plugins/php && /bin/bash install.sh install ${version} fi cd $sourcePath/php${version}/ext/${LIBNAME} diff --git a/plugins/php/versions/common/zlib.sh b/plugins/php/versions/common/zlib.sh index 2e63e2fa14..5d8c03c277 100755 --- a/plugins/php/versions/common/zlib.sh +++ b/plugins/php/versions/common/zlib.sh @@ -46,7 +46,7 @@ Install_lib() if [ ! -f "$extFile" ];then if [ ! -d $sourcePath/php${version}/ext ];then - cd $serverPath/mdserver-web/plugins/php && /bin/bash install.sh install ${version} + cd ${rootPath}/plugins/php && /bin/bash install.sh install ${version} fi cd $sourcePath/php${version}/ext/${LIBNAME} From 8a79beab89b6219f0382a7f495beb3246c783710 Mon Sep 17 00:00:00 2001 From: midoks Date: Tue, 20 Sep 2022 14:40:45 +0800 Subject: [PATCH 43/59] up --- plugins/supervisor/index.py | 2 +- plugins/webstats/tool_task.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/supervisor/index.py b/plugins/supervisor/index.py index 7172170fe7..6571350a19 100755 --- a/plugins/supervisor/index.py +++ b/plugins/supervisor/index.py @@ -103,7 +103,7 @@ def initDreplace(): mw.writeFile(conf, conf_content) if os.path.exists(systemDir) and not os.path.exists(systemService): - activate_file = mw.getServerDir() + '/mdserver-web/bin/activate' + activate_file = mw.getRunDir() + '/bin/activate' if os.path.exists(activate_file): supervisord_bin = mw.execShell( 'source ' + activate_file + '&& which supervisord')[0].strip() diff --git a/plugins/webstats/tool_task.py b/plugins/webstats/tool_task.py index fe129ee318..09e83daf89 100644 --- a/plugins/webstats/tool_task.py +++ b/plugins/webstats/tool_task.py @@ -61,7 +61,7 @@ def createBgTask(): import crontab_api api = crontab_api.crontab_api() - cmd = "cd " + mw.getServerDir() + "/mdserver-web && nice -n 10 python3 " + \ + cmd = "cd " + mw.getRunDir() + " && nice -n 10 python3 " + \ getPluginDir() + "/tool_task.py execute" params = { 'name': name, From 35d42a56038237a582c277816a3f473b8090a4b3 Mon Sep 17 00:00:00 2001 From: midoks Date: Tue, 20 Sep 2022 16:32:11 +0800 Subject: [PATCH 44/59] up --- plugins/php/conf/app_start.php | 2 +- plugins/php/lib/openssl.sh | 12 ------------ 2 files changed, 1 insertion(+), 13 deletions(-) diff --git a/plugins/php/conf/app_start.php b/plugins/php/conf/app_start.php index 97dc7a8c32..63074175fd 100644 --- a/plugins/php/conf/app_start.php +++ b/plugins/php/conf/app_start.php @@ -4,8 +4,8 @@ /** * xhprof 配置,便于调试快速找到问题 - * author midoks@163.com */ + function app_xhprof_start() { $root = '{$ROOT_PATH}'; $lib = $root . '/server/xhprof/xhprof_lib/utils/xhprof_lib.php'; diff --git a/plugins/php/lib/openssl.sh b/plugins/php/lib/openssl.sh index 4d6294eacf..d76ca49ca9 100644 --- a/plugins/php/lib/openssl.sh +++ b/plugins/php/lib/openssl.sh @@ -13,18 +13,6 @@ rootPath=$(dirname "$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 From 33bc6e19e78b2dc4334c3bd58a9ffbb8c29d54e7 Mon Sep 17 00:00:00 2001 From: midoks Date: Tue, 20 Sep 2022 17:10:09 +0800 Subject: [PATCH 45/59] up --- plugins/openresty/install.sh | 1 - plugins/php/lib/libmemcached.sh | 2 -- plugins/php/versions/52/gd.sh | 2 +- plugins/php/versions/52/install.sh | 1 - plugins/php/versions/52/intl.sh | 2 +- plugins/php/versions/53/intl.sh | 2 +- plugins/php/versions/71/mcrypt.sh | 2 +- plugins/php/versions/common/gd_old.sh | 4 ++-- plugins/php/versions/common/iconv.sh | 2 +- plugins/php/versions/common/intl.sh | 2 +- plugins/php/versions/common/openssl.sh | 4 ++-- plugins/php/versions/common/zip.sh | 2 +- 12 files changed, 11 insertions(+), 15 deletions(-) diff --git a/plugins/openresty/install.sh b/plugins/openresty/install.sh index 2bb1709367..802c156ab1 100755 --- a/plugins/openresty/install.sh +++ b/plugins/openresty/install.sh @@ -24,7 +24,6 @@ else useradd -g www -s /bin/bash www fi -# cd /www/server/mdserver-web/plugins/openresty && /bin/bash install.sh install 1.21.4.1 Install_openresty() { # ----- cpu start ------ diff --git a/plugins/php/lib/libmemcached.sh b/plugins/php/lib/libmemcached.sh index 2dca0bf214..a26b9fff07 100644 --- a/plugins/php/lib/libmemcached.sh +++ b/plugins/php/lib/libmemcached.sh @@ -10,8 +10,6 @@ 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 diff --git a/plugins/php/versions/52/gd.sh b/plugins/php/versions/52/gd.sh index aab4f988b7..ab4e397abd 100755 --- a/plugins/php/versions/52/gd.sh +++ b/plugins/php/versions/52/gd.sh @@ -74,7 +74,7 @@ Install_lib() if [ ! -f "$extFile" ];then if [ ! -d $sourcePath/php${version}/ext ];then - cd $serverPath/mdserver-web/plugins/php && /bin/bash install.sh install ${version} + cd ${rootPath}/plugins/php && /bin/bash install.sh install ${version} fi cd $sourcePath/php${version}/ext/${LIBNAME} diff --git a/plugins/php/versions/52/install.sh b/plugins/php/versions/52/install.sh index 7d2c608a0d..2b242cf2c8 100755 --- a/plugins/php/versions/52/install.sh +++ b/plugins/php/versions/52/install.sh @@ -131,7 +131,6 @@ 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 diff --git a/plugins/php/versions/52/intl.sh b/plugins/php/versions/52/intl.sh index 156677458d..bd846aff8a 100755 --- a/plugins/php/versions/52/intl.sh +++ b/plugins/php/versions/52/intl.sh @@ -35,7 +35,7 @@ Install_lib() return fi - cd $serverPath/mdserver-web/plugins/php/lib && /bin/bash icu.sh + cd $rootPath/plugins/php/lib && /bin/bash icu.sh if [ ! -f "$extFile" ];then diff --git a/plugins/php/versions/53/intl.sh b/plugins/php/versions/53/intl.sh index 2279d47ccd..8312fb2a96 100755 --- a/plugins/php/versions/53/intl.sh +++ b/plugins/php/versions/53/intl.sh @@ -40,7 +40,7 @@ Install_lib() php_lib=$sourcePath/php_lib mkdir -p $php_lib - cd $serverPath/mdserver-web/plugins/php/lib && /bin/bash icu.sh + cd ${rootPath}/plugins/php/lib && /bin/bash icu.sh wget -O $php_lib/${LIBNAME}-${LIBV}.tgz http://pecl.php.net/get/${LIBNAME}-${LIBV}.tgz diff --git a/plugins/php/versions/71/mcrypt.sh b/plugins/php/versions/71/mcrypt.sh index dd2482c27f..c29827b76b 100755 --- a/plugins/php/versions/71/mcrypt.sh +++ b/plugins/php/versions/71/mcrypt.sh @@ -44,7 +44,7 @@ Install_lib() if [ ! -f "$extFile" ];then if [ ! -d $sourcePath/php${version}/ext ];then - cd $serverPath/mdserver-web/plugins/php && /bin/bash install.sh install ${version} + cd ${rootPath}/plugins/php && /bin/bash install.sh install ${version} fi cd $sourcePath/php${version}/ext/${LIBNAME} diff --git a/plugins/php/versions/common/gd_old.sh b/plugins/php/versions/common/gd_old.sh index 1923ef0a9e..40412328b6 100755 --- a/plugins/php/versions/common/gd_old.sh +++ b/plugins/php/versions/common/gd_old.sh @@ -40,7 +40,7 @@ else fi -# cd $serverPath/mdserver-web/plugins/php/lib && /bin/bash freetype_old.sh +# cd ${rootPath}/plugins/php/lib && /bin/bash freetype_old.sh # OPTIONS="${OPTIONS} --with-freetype-dir=${serverPath}/lib/freetype_old" # OPTIONS="${OPTIONS} --with-gd --enable-gd-native-ttf" # OPTIONS="${OPTIONS} --with-jpeg --with-jpeg-dir=/usr/lib" @@ -60,7 +60,7 @@ Install_lib() if [ ! -f "$extFile" ];then if [ ! -d $sourcePath/php${version}/ext ];then - cd $serverPath/mdserver-web/plugins/php && /bin/bash install.sh install ${version} + cd ${rootPath}/plugins/php && /bin/bash install.sh install ${version} fi cd $sourcePath/php${version}/ext/${LIBNAME} diff --git a/plugins/php/versions/common/iconv.sh b/plugins/php/versions/common/iconv.sh index eaf62f66b7..e8a8877824 100755 --- a/plugins/php/versions/common/iconv.sh +++ b/plugins/php/versions/common/iconv.sh @@ -50,7 +50,7 @@ Install_lib() if [ ! -f "$extFile" ];then if [ ! -d $sourcePath/php${version}/ext ];then - cd $serverPath/mdserver-web/plugins/php && /bin/bash install.sh install ${version} + cd ${rootPath}/plugins/php && /bin/bash install.sh install ${version} fi cd $sourcePath/php${version}/ext/${LIBNAME} diff --git a/plugins/php/versions/common/intl.sh b/plugins/php/versions/common/intl.sh index 02c2f7bb77..b616050a9e 100755 --- a/plugins/php/versions/common/intl.sh +++ b/plugins/php/versions/common/intl.sh @@ -34,7 +34,7 @@ fi OPTIONS='' if [ "$version" -lt "71" ];then - cd $serverPath/mdserver-web/plugins/php/lib && /bin/bash icu.sh + cd ${rootPath}/plugins/php/lib && /bin/bash icu.sh OPTIONS="--with-icu-dir=${serverPath}/lib/icu" fi diff --git a/plugins/php/versions/common/openssl.sh b/plugins/php/versions/common/openssl.sh index 536db4a551..7fdf987f7f 100755 --- a/plugins/php/versions/common/openssl.sh +++ b/plugins/php/versions/common/openssl.sh @@ -41,7 +41,7 @@ Install_lib() return fi - # cd $serverPath/mdserver-web/plugins/php/lib && /bin/bash openssl_10.sh + # cd ${rootPath}/plugins/php/lib && /bin/bash openssl_10.sh if [ "$version" -lt "70" ];then cd ${rootPath}/plugins/php/lib && /bin/bash openssl_10.sh fi @@ -49,7 +49,7 @@ Install_lib() if [ ! -f "$extFile" ];then if [ ! -d $sourcePath/php${version}/ext ];then - cd $serverPath/mdserver-web/plugins/php && /bin/bash install.sh install ${version} + cd ${rootPath}/plugins/php && /bin/bash install.sh install ${version} fi cd $sourcePath/php${version}/ext/${LIBNAME} diff --git a/plugins/php/versions/common/zip.sh b/plugins/php/versions/common/zip.sh index d2bd49a262..828235592b 100755 --- a/plugins/php/versions/common/zip.sh +++ b/plugins/php/versions/common/zip.sh @@ -54,7 +54,7 @@ Install_lib() if [ ! -f "$extFile" ];then if [ ! -d $sourcePath/php${version}/ext ];then - cd $serverPath/mdserver-web/plugins/php && /bin/bash install.sh install ${version} + cd ${rootPath}/plugins/php && /bin/bash install.sh install ${version} fi cd $sourcePath/php${version}/ext/${LIBNAME} From 7c37df5decc6d9a1af4eae00585dd938a6dfdab5 Mon Sep 17 00:00:00 2001 From: midoks Date: Tue, 20 Sep 2022 17:12:06 +0800 Subject: [PATCH 46/59] Update all_test.sh --- plugins/php-yum/all_test.sh | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/plugins/php-yum/all_test.sh b/plugins/php-yum/all_test.sh index 59bd64c08f..b260025381 100644 --- a/plugins/php-yum/all_test.sh +++ b/plugins/php-yum/all_test.sh @@ -3,18 +3,6 @@ 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 - - -# 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=71 echo "php${PHP_VER} -- start" cmd_ext=$(ls -l $DIR/versions/$PHP_VER/ |awk '{print $9}') From 0126bcb68cacef7acccf4c454edf3ddfd3eeee33 Mon Sep 17 00:00:00 2001 From: midoks Date: Tue, 20 Sep 2022 17:14:38 +0800 Subject: [PATCH 47/59] Update info.json --- plugins/rsyncd/info.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/rsyncd/info.json b/plugins/rsyncd/info.json index 3ab33843a5..987267dc01 100755 --- a/plugins/rsyncd/info.json +++ b/plugins/rsyncd/info.json @@ -9,7 +9,7 @@ "shell":"install.sh", "checks":"server/rsyncd", "path": "server/rsyncd", - "author":"midoks", + "author":"samba", "home":"https://rsync.samba.org/", "date":"2019-03-05", "pid":"4" From ca0aed7240e35b07b09d9f5dfff990c5826dc8f7 Mon Sep 17 00:00:00 2001 From: midoks Date: Tue, 20 Sep 2022 17:17:47 +0800 Subject: [PATCH 48/59] up --- plugins/swap/info.json | 2 +- plugins/webssh/info.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/swap/info.json b/plugins/swap/info.json index b6e9b719aa..b0afe47c35 100755 --- a/plugins/swap/info.json +++ b/plugins/swap/info.json @@ -9,7 +9,7 @@ "checks": "server/swap", "path": "server/swap", "display": 1, - "author": "midoks", + "author": "swap", "date": "2021-01-29", "home": "swap", "type": 0, diff --git a/plugins/webssh/info.json b/plugins/webssh/info.json index 13e1c6586a..648c1d7ba5 100755 --- a/plugins/webssh/info.json +++ b/plugins/webssh/info.json @@ -9,7 +9,7 @@ "shell":"install.sh", "checks":"server/webssh", "path": "server/webssh", - "author":"midoks", + "author":"ssh", "home":"", "date":"2018-12-20", "pid":"4" From 07e017c9a73a876730c0af16eb0affc8fdf9afde Mon Sep 17 00:00:00 2001 From: midoks Date: Tue, 20 Sep 2022 17:46:01 +0800 Subject: [PATCH 49/59] Update lib.sh --- scripts/lib.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/lib.sh b/scripts/lib.sh index 6c491a156e..6aadbe1836 100755 --- a/scripts/lib.sh +++ b/scripts/lib.sh @@ -104,7 +104,8 @@ fi #面板需要的库 if [ ! -f /usr/local/bin/pip3 ];then - python3 -m pip install --upgrade pip setuptools wheel -i https://mirrors.aliyun.com/pypi/simple + # python3 -m pip install --upgrade pip setuptools wheel -i https://mirrors.aliyun.com/pypi/simple + python3 -m pip install --upgrade pip setuptools wheel -i https://pypi.python.org/pypi fi pip install --upgrade pip From 50f198e2d33d5d1b8f27e392f7ea37490534d5d4 Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 21 Sep 2022 15:12:10 +0800 Subject: [PATCH 50/59] =?UTF-8?q?=E4=BC=98=E5=8C=96open=5Fbasedir=E9=85=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- class/core/site_api.py | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/class/core/site_api.py b/class/core/site_api.py index c91e8749df..1d45b6048d 100755 --- a/class/core/site_api.py +++ b/class/core/site_api.py @@ -340,10 +340,16 @@ def getDirUserIniApi(self): name = mw.M('sites').where("id=?", (mid,)).getField('name') data = {} data['logs'] = self.getLogsStatus(name) + data['runPath'] = self.getSiteRunPath(mid) + data['userini'] = False if os.path.exists(path + '/.user.ini'): data['userini'] = True - data['runPath'] = self.getSiteRunPath(mid) + + if data['runPath']['runPath'] != '/': + if os.path.exists(path + data['runPath']['runPath'] + '/.user.ini'): + data['userini'] = True + data['pass'] = self.getHasPwd(name) data['path'] = path data['name'] = name @@ -1095,6 +1101,7 @@ def setSiteRunPathApi(self): sitePath = mw.M('sites').where('id=?', (mid,)).getField('path') newPath = sitePath + runPath + # 处理Nginx filename = self.getHostConf(siteName) if os.path.exists(filename): @@ -1104,8 +1111,7 @@ def setSiteRunPathApi(self): conf = conf.replace(path, newPath) mw.writeFile(filename, conf) - self.delUserInI(sitePath) - self.setDirUserINI(newPath) + self.setDirUserINI(sitePath, runPath) mw.restartWeb() return mw.returnJson(True, '设置成功!') @@ -2350,16 +2356,19 @@ def delUserInI(self, path, up=0): return True # 设置目录防御 - def setDirUserINI(self, newPath): + def setDirUserINI(self, sitePath, runPath): filename = newPath + '/.user.ini' if os.path.exists(filename): mw.execShell("chattr -i " + filename) os.remove(filename) return mw.returnJson(True, '已清除防跨站设置!') + newPath = sitePath + runPath self.delUserInI(newPath) - mw.writeFile(filename, 'open_basedir=' + - newPath + '/:/www/server/php:/tmp/:/proc/') + + openPath = 'open_basedir={}/:{}/'.format(newPath, sitePath) + + mw.writeFile(filename, openPath + ':/www/server/php:/tmp/:/proc/') mw.execShell("chattr +i " + filename) return mw.returnJson(True, '已打开防跨站设置!') From 8b074090a7c6050b55701dba5e0926dbff6c0653 Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 21 Sep 2022 15:37:00 +0800 Subject: [PATCH 51/59] =?UTF-8?q?=E5=89=8D=E7=AB=AF=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- route/static/app/site.js | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/route/static/app/site.js b/route/static/app/site.js index 9a3deca870..db2552915b 100755 --- a/route/static/app/site.js +++ b/route/static/app/site.js @@ -2601,16 +2601,28 @@ function setSizeClassType(){ // 尝试重启PHP function tryRestartPHP(siteName){ $.post('/site/get_site_php_version','siteName='+siteName,function(data){ + var phpversion = data.phpversion; - if (data.phpversion == "00"){ + if (phpversion == "00"){ return } - var reqData = {name:'php', func:'restart'} - reqData['version'] = data.phpversion; + var php_sign = 'php'; + if (phpversion.find('yum') > -1){ + php_sign = 'php-yum'; + phpversion = phpversion.replace('yum',''); + } + + if (phpversion.find('apt') > -1){ + php_sign = 'php-apt'; + phpversion = phpversion.replace('apt',''); + } + + var reqData = {name: php_sign, func:'restart'} + reqData['version'] = phpversion; // console.log(reqData); - var loadT = layer.msg('尝试自动重启PHP['+data.phpversion+']...', { icon: 16, time: 0, shade: 0.3 }); + var loadT = layer.msg('尝试自动重启PHP['+phpversion+']...', { icon: 16, time: 0, shade: 0.3 }); $.post('/plugins/run', reqData, function(data) { layer.close(loadT); layer.msg(data.msg,{icon:data.status?1:2,time:3000,shade: [0.3, '#000']}); From 78728917975ecd5937c72ae72e300c5f3ebf8bdf Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 21 Sep 2022 16:17:11 +0800 Subject: [PATCH 52/59] Update site.js --- route/static/app/site.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/route/static/app/site.js b/route/static/app/site.js index db2552915b..6bceb68861 100755 --- a/route/static/app/site.js +++ b/route/static/app/site.js @@ -2608,12 +2608,12 @@ function tryRestartPHP(siteName){ } var php_sign = 'php'; - if (phpversion.find('yum') > -1){ + if (phpversion.indexOf('yum') > -1){ php_sign = 'php-yum'; phpversion = phpversion.replace('yum',''); } - if (phpversion.find('apt') > -1){ + if (phpversion.indexOf('apt') > -1){ php_sign = 'php-apt'; phpversion = phpversion.replace('apt',''); } From 1c7db0e2ecadcc5bc3d1349b90e80a3cdc49c512 Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 21 Sep 2022 16:51:42 +0800 Subject: [PATCH 53/59] =?UTF-8?q?=E4=BC=98=E5=8C=96open=5Fbasedir=E9=85=8D?= =?UTF-8?q?=E7=BD=AE2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- class/core/site_api.py | 35 +++++++++++++++++++---------------- route/static/app/site.js | 6 +++++- 2 files changed, 24 insertions(+), 17 deletions(-) diff --git a/class/core/site_api.py b/class/core/site_api.py index 1d45b6048d..403b01474e 100755 --- a/class/core/site_api.py +++ b/class/core/site_api.py @@ -357,15 +357,18 @@ def getDirUserIniApi(self): def setDirUserIniApi(self): path = request.form.get('path', '') + runPath = request.form.get('runPath', '') filename = path + '/.user.ini' - self.delUserInI(path) + if os.path.exists(filename): + self.delUserInI(path) mw.execShell("which chattr && chattr -i " + filename) os.remove(filename) return mw.returnJson(True, '已清除防跨站设置!') - mw.writeFile(filename, 'open_basedir=' + path + - '/:/www/server/php:/tmp/:/proc/') + + self.setDirUserINI(path, runPath) mw.execShell("which chattr && chattr +i " + filename) + return mw.returnJson(True, '已打开防跨站设置!') def logsOpenApi(self): @@ -736,11 +739,11 @@ def httpToHttpsApi(self): if conf.find('ssl_certificate') == -1: return mw.returnJson(False, '当前未开启SSL') to = """#error_page 404/404.html; - #HTTP_TO_HTTPS_START + # HTTP_TO_HTTPS_START if ($server_port !~ 443){ rewrite ^(/.*)$ https://$host$1 permanent; } - #HTTP_TO_HTTPS_END""" + # HTTP_TO_HTTPS_END""" conf = conf.replace('#error_page 404/404.html;', to) mw.writeFile(file, conf) @@ -1146,10 +1149,10 @@ def setHasPwdApi(self): if conf.find(rep) == -1: rep = '#error_page 404/404.html;' data = ''' - #AUTH_START + # AUTH_START auth_basic "Authorization"; auth_basic_user_file %s; - #AUTH_END''' % (filename,) + # AUTH_END''' % (filename,) conf = conf.replace(rep, rep + data) mw.writeFile(configFile, conf) # 写密码配置 @@ -1238,13 +1241,13 @@ def operateRedirectConf(self, siteName, method='start'): content = mw.readFile(vhost_file) cnf_301 = ''' - #301-START + # 301-START include %s/*.conf; - #301-END + # 301-END ''' % (self.getRedirectPath( siteName)) cnf_301_source = ''' - #301-START + # 301-START ''' # print('operateRedirectConf', content.find('#301-END')) if content.find('#301-END') != -1: @@ -1430,13 +1433,13 @@ def operateProxyConf(self, siteName, method='start'): content = mw.readFile(vhost_file) proxy_cnf = ''' - #PROXY-START + # PROXY-START include %s/*.conf; - #PROXY-END + # PROXY-END ''' % (self.getProxyPath(siteName)) proxy_cnf_source = ''' - #PROXY-START + # PROXY-START ''' if content.find('#PROXY-END') != -1: @@ -2032,7 +2035,7 @@ def setSecurity(self, sid, name, fix, domains, status): 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 + ']已开启防盗链!') @@ -2357,17 +2360,17 @@ def delUserInI(self, path, up=0): # 设置目录防御 def setDirUserINI(self, sitePath, runPath): + newPath = sitePath + runPath + filename = newPath + '/.user.ini' if os.path.exists(filename): mw.execShell("chattr -i " + filename) os.remove(filename) return mw.returnJson(True, '已清除防跨站设置!') - newPath = sitePath + runPath self.delUserInI(newPath) openPath = 'open_basedir={}/:{}/'.format(newPath, sitePath) - mw.writeFile(filename, openPath + ':/www/server/php:/tmp/:/proc/') mw.execShell("chattr +i " + filename) diff --git a/route/static/app/site.js b/route/static/app/site.js index 6bceb68861..5c96c46d2b 100755 --- a/route/static/app/site.js +++ b/route/static/app/site.js @@ -338,6 +338,7 @@ function webPathEdit(id){ var userini = data['data']; var webpath = userini['path']; var siteName = userini['name']; + var runPath = userini['runPath']['runPath']; var userinicheckeds = userini.userini?'checked':''; var logscheckeds = userini.logs?'checked':''; var opt = '' @@ -385,7 +386,10 @@ function webPathEdit(id){ $("#webedit-con").html(webPathHtml); $("#userini").change(function(){ - $.post('/site/set_dir_user_ini','path='+webpath,function(userini){ + $.post('/site/set_dir_user_ini',{ + 'path':webpath, + 'runPath':runPath, + },function(userini){ layer.msg(userini.msg+'

    注意:设置防跨站需要重启PHP才能生效!

    ',{icon:userini.status?1:2}); tryRestartPHP(siteName); },'json'); From 3265deed3de906279b5dc2e061ff7a7fe2093fd1 Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 21 Sep 2022 17:01:41 +0800 Subject: [PATCH 54/59] Update site_api.py --- class/core/site_api.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/class/core/site_api.py b/class/core/site_api.py index 403b01474e..9bffb28720 100755 --- a/class/core/site_api.py +++ b/class/core/site_api.py @@ -2369,8 +2369,10 @@ def setDirUserINI(self, sitePath, runPath): return mw.returnJson(True, '已清除防跨站设置!') self.delUserInI(newPath) - openPath = 'open_basedir={}/:{}/'.format(newPath, sitePath) + if runPath == '/': + openPath = 'open_basedir={}/'.format(newPath) + mw.writeFile(filename, openPath + ':/www/server/php:/tmp/:/proc/') mw.execShell("chattr +i " + filename) From eedaef7eecd327b07025151d9f025431902dd77a Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 21 Sep 2022 17:06:19 +0800 Subject: [PATCH 55/59] Update site_api.py --- class/core/site_api.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/class/core/site_api.py b/class/core/site_api.py index 9bffb28720..748c07803a 100755 --- a/class/core/site_api.py +++ b/class/core/site_api.py @@ -2371,7 +2371,7 @@ def setDirUserINI(self, sitePath, runPath): self.delUserInI(newPath) openPath = 'open_basedir={}/:{}/'.format(newPath, sitePath) if runPath == '/': - openPath = 'open_basedir={}/'.format(newPath) + openPath = 'open_basedir={}/'.format(sitePath) mw.writeFile(filename, openPath + ':/www/server/php:/tmp/:/proc/') mw.execShell("chattr +i " + filename) From 416e9e7cdab4a281a0af2dc61c844e0cf6a87217 Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 21 Sep 2022 17:30:59 +0800 Subject: [PATCH 56/59] =?UTF-8?q?=E5=A6=82=E6=9E=9C=E7=9B=AE=E5=BD=95?= =?UTF-8?q?=E5=AD=98=E5=9C=A8=EF=BC=8C=E5=B0=B1=E4=B8=8D=E5=88=9D=E5=A7=8B?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- class/core/site_api.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/class/core/site_api.py b/class/core/site_api.py index 748c07803a..1acc0faa58 100755 --- a/class/core/site_api.py +++ b/class/core/site_api.py @@ -2103,12 +2103,16 @@ def getRewriteList(self): return rewriteList def createRootDir(self, path): + autoInit = False if not os.path.exists(path): + autoInit = True 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 autoInit: + mw.writeFile(path + '/index.html', 'Work has started!!!') + mw.execShell('chmod -R 755 ' + path) def nginxAddDomain(self, webname, domain, port): file = self.getHostConf(webname) From 55d987c0bdbfbc498de346f75aa3fc2a7f8f071c Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 21 Sep 2022 17:42:32 +0800 Subject: [PATCH 57/59] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=89=B9=E9=87=8F?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- class/core/site_api.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/class/core/site_api.py b/class/core/site_api.py index 1acc0faa58..afb9835567 100755 --- a/class/core/site_api.py +++ b/class/core/site_api.py @@ -2195,19 +2195,16 @@ def add(self, webname, port, ps, path, version): return mw.returnJson(False, '您添加的域名已存在!') mw.M('domain').where('pid=?', (opid,)).delete() + self.createRootDir(self.sitePath) + self.nginxAddConf() + # 添加更多域名 for domain in siteMenu['domainlist']: - sdomain = domain - swebname = self.siteName - spid = str(pid) - self.addDomain(domain, webname, pid) + self.addDomain(domain, self.siteName, pid) mw.M('domain').add('pid,name,port,addtime', (pid, self.siteName, self.sitePort, mw.getDate())) - self.createRootDir(self.sitePath) - self.nginxAddConf() - data = {} data['siteStatus'] = False mw.restartWeb() From 8a81f8bb83b6e3d8108014f7c58b0b0b1143d9ee Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 21 Sep 2022 17:54:32 +0800 Subject: [PATCH 58/59] Update site_api.py --- class/core/site_api.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/class/core/site_api.py b/class/core/site_api.py index afb9835567..6f687a1da0 100755 --- a/class/core/site_api.py +++ b/class/core/site_api.py @@ -1149,10 +1149,10 @@ def setHasPwdApi(self): if conf.find(rep) == -1: rep = '#error_page 404/404.html;' data = ''' - # AUTH_START + #AUTH_START auth_basic "Authorization"; auth_basic_user_file %s; - # AUTH_END''' % (filename,) + #AUTH_END''' % (filename,) conf = conf.replace(rep, rep + data) mw.writeFile(configFile, conf) # 写密码配置 @@ -1241,13 +1241,13 @@ def operateRedirectConf(self, siteName, method='start'): content = mw.readFile(vhost_file) cnf_301 = ''' - # 301-START + #301-START include %s/*.conf; - # 301-END + #301-END ''' % (self.getRedirectPath( siteName)) cnf_301_source = ''' - # 301-START + #301-START ''' # print('operateRedirectConf', content.find('#301-END')) if content.find('#301-END') != -1: @@ -1433,13 +1433,13 @@ def operateProxyConf(self, siteName, method='start'): content = mw.readFile(vhost_file) proxy_cnf = ''' - # PROXY-START + #PROXY-START include %s/*.conf; - # PROXY-END + #PROXY-END ''' % (self.getProxyPath(siteName)) proxy_cnf_source = ''' - # PROXY-START + #PROXY-START ''' if content.find('#PROXY-END') != -1: @@ -1571,7 +1571,7 @@ def setProxyApi(self): # location ~* ^{from}(.*)$ { tpl = """ -# PROXY-START/ +#PROXY-START/ location ^~ {from} { proxy_pass {to}; proxy_set_header Host {host}; @@ -1594,7 +1594,7 @@ def setProxyApi(self): add_header Cache-Control no-cache; } } -# PROXY-END/ +#PROXY-END/ """ # replace @@ -2035,7 +2035,7 @@ def setSecurity(self, sid, name, fix, domains, status): 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 + ']已开启防盗链!') From aa3950ccfea1abee9be8a7f210f42b246bf1e69c Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 21 Sep 2022 23:10:18 +0800 Subject: [PATCH 59/59] 0.9.10 --- README.md | 20 ++++++++------------ class/core/config_api.py | 2 +- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index eda213e0fb..bc31eec95c 100644 --- a/README.md +++ b/README.md @@ -90,18 +90,14 @@ docker run -itd --name mw-server --privileged=true -p 7200:7200 -p 80:80 -p 443: ``` -### 版本更新 0.9.9 - -* 更换Logo。 -* 增加amazon linux系统支持。 -* 修复rsyncd在debian或ubuntu下安装失败问题。 -* Readme加入一AD。 -* PHP-YUM|PHP-APT优化[性能调整]。 -* 优化Gogs使用MySQL的方式。 -* 配置模板添加一个whmcs。 -* MySQL和MariaDB无法直接卸载。 -* OpenResty加入http_realip_module模块。 -* PHP加入igbinary扩展。 +### 版本更新 0.9.10 + +* 防跨站攻击(open_basedir)功能优化。 +* 创建站点域名批量添加优化。 +* 首页CPU显示tip添加。 +* 优化日志读取。 +* 加入开发模式开关。 +* redis添加性能调整功能。 ### JSDelivr安装地址 diff --git a/class/core/config_api.py b/class/core/config_api.py index 72821da45c..be5ae448a5 100755 --- a/class/core/config_api.py +++ b/class/core/config_api.py @@ -15,7 +15,7 @@ class config_api: - __version = '0.10.0.1' + __version = '0.9.10' def __init__(self): pass