diff --git a/plugins/mail/index.html b/plugins/mail/index.html index 7804682f8..aa6ab36a2 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 37ffe8ffc..69359867e 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 000000000..5f5ce730d --- /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 f4b4aa575..57b7798ff 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 000000000..181c8db23 --- /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