pull/199/head
midoks 3 years ago
parent b616854baa
commit c0e1512195
  1. 7
      plugins/mail/index.html
  2. 5
      plugins/mail/index.py
  3. 66
      plugins/mail/js/mail.js
  4. 33
      plugins/mail/versions/1.0/install.sh
  5. 118
      plugins/mail/versions/1.0/install_centos.sh

@ -1,9 +1,10 @@
<div class="bt-form">
<div class="bt-w-main">
<div class="bt-w-menu">
<p class="bgw" onclick="pluginService('mail');">服务</p>
<p class="bgw" onclick="pluginService('mail');">域名列表</p>
<p onclick="pluginInitD('mail');">自启动</p>
<p onclick="pluginConfig('mail');">配置修改</p>
<p onclick="pluginConfig('mail');">服务状态</p>
<p onclick="pluginLogs('mail','','run_log');">日志</p>
</div>
<div class="bt-w-con pd15">
@ -12,5 +13,7 @@
</div>
</div>
<script type="text/javascript">
pluginService('mail');
$.getScript( "/plugins/file?name=mail&f=js/mail.js", function(){
pluginService('mail', $('.plugin_version').attr('version'));
});
</script>

@ -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]

@ -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');
}

@ -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

@ -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
Loading…
Cancel
Save