pull/199/head
midoks 3 years ago
parent c0e1512195
commit 38f8fe9a38
  1. 9
      plugins/mail/index.html
  2. 171
      plugins/mail/index.py
  3. 2
      plugins/mail/info.json
  4. 126
      plugins/mail/js/mail.js
  5. 4
      plugins/mail/versions/1.0/install.sh
  6. 4
      plugins/mail/versions/1.0/install_centos.sh

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

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

@ -2,7 +2,7 @@
"sort": 7,
"ps": "简单邮件服务[DEV]",
"name": "mail",
"title": "mail",
"title": "邮件服务",
"shell": "install.sh",
"versions":["1.0"],
"updates":["1.0"],

@ -64,3 +64,129 @@ function mailPostCallbak(method, version, args,callback){
},'json');
}
function domainList(){
var con = '<div class="task_block">\
<button class="btn btn-sm btn-success mb15" style="margin-right:10px;" onclick="mail.edit_domain_view(true)">添加域名</button>\
<!-- <div class="ssl-item" style="display: flex;width: 150px;float: right;">\
<span style="display: inline-table;margin-top: 2px; margin-right: 5px;">添加证书</span>\
<input type="checkbox" id="certificateSSL" class="btswitch btswitch-ios">\
<label for="certificateSSL" class="btswitch-btn" onclick="mail.open_certificate_view()"></label>\
</div> -->\
<button class="btn btn-sm btn-default mb15" style="float:right" id="flush_domain_record">刷新域名记录</button>\
<div class="domain_table divtable">\
<table class="table table-hover">\
<thead>\
<tr>\
<th>邮箱域名</th>\
<th>MX记录</th>\
<th>A记录</th>\
<th>SPF记录</th>\
<th>DKIM记录</th>\
<th>DMARC记录</th>\
<th>CatchAll</th>\
<th width="160px">SSL</th>\
<th width="120px" style="text-align: right;">操作</th>\
</tr>\
</thead>\
<tbody id="domain_list"></tbody>\
</table>\
</div>\
<div class="page" id="domain_page"></div>\
<ul class="help-info-text c7 mlr20">\
<li>\
<font style="color:red">添加域名后需要添加MX记录用于邮箱服务和TXT记录用于邮箱反垃圾服务才能正常使用邮箱服务</font>\
</li>\
<li>\
<font style="color:red">提示 部分云厂商(阿里云腾讯云)默认关闭25端口需联系厂商开通25端口后才能正常使用邮局服务</font>\
</li>\
<li>该自建邮局版本为基础版本仅提供基础功能更多功能请耐心等候开发进度</li>\
</ul>\
</div>';
$(".soft-man-con").html(con);
}
function serviceStatus(){
var con = '<div class="task_block divtable">\
<table class="table table-hover">\
<thead>\
<tr>\
<th>服务名称</th>\
<th>服务状态</th>\
<th width="190" style="text-align: center">操作</th>\
</tr>\
</thead>\
<tbody>\
<tr>\
<td>Dovecot</td>\
<td><span class="dovecot">获取中...</span></td>\
<td style="text-align: right">\
<a href="javascript:" class="btlink dovecot_start"\
onclick="">启动</a>\
<a href="javascript:" class="btlink dovecot_stop"\
onclick="">停止</a>&nbsp;|&nbsp;\
<a href="javascript:" class="btlink"\
onclick="">重启</a>&nbsp;|&nbsp;\
<a href="javascript:" class="btlink"\
onclick="">修复</a>&nbsp;|&nbsp;\
<a href="javascript:;" class="btlink"\
onclick=">配置文件</a>\
</td>\
</tr>\
<tr>\
<td>Opendkim</td>\
<td><span class="opendkim">获取中...</span></td>\
<td style="text-align: right">\
<a href="javascript:" class="btlink opendkim_start"\
onclick="">启动</a>\
<a href="javascript:" class="btlink opendkim_stop"\
onclick="">停止</a>&nbsp;|&nbsp;\
<a href="javascript:" class="btlink"\
onclick="">重启</a>&nbsp;|&nbsp;\
<a href="javascript:" class="btlink"\
onclick="">修复</a>&nbsp;|&nbsp;\
<a href="javascript:;" class="btlink"\
onclick="">配置文件</a>\
</td>\
</tr>\
<tr>\
<td>Rspamd</td>\
<td><span class="rspamd">获取中...</span></td>\
<td style="text-align: right">\
<a href="javascript:" class="btlink rspamd_start"\
onclick="">启动</a>\
<a href="javascript:" class="btlink rspamd_stop"\
onclick="">停止</a>&nbsp;|&nbsp;\
<a href="javascript:" class="btlink"\
onclick="">重启</a>&nbsp;|&nbsp;\
<a href="javascript:" class="btlink"\
onclick="">修复</a>&nbsp;|&nbsp;\
<a href="javascript:;" class="btlink"\
onclick="">配置文件</a>\
</td>\
</tr>\
<tr>\
<td>Postfix</td>\
<td><span class="postfix">获取中...</span></td>\
<td style="text-align: right">\
<a href="javascript:" class="btlink postfix_start"\
onclick="">启动</a>\
<a href="javascript:" class="btlink postfix_stop"\
onclick="">停止</a>&nbsp;|&nbsp;\
<a href="javascript:" class="btlink"\
onclick="">重启</a>&nbsp;|&nbsp;\
<a href="javascript:" class="btlink"\
onclick="">修复</a>&nbsp;|&nbsp;\
<a href="javascript:;" class="btlink"\
onclick="">配置文件</a>\
</td>\
</tr>\
</tbody>\
</table>\
</div>';
$(".soft-man-con").html(con);
}

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

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

Loading…
Cancel
Save