From 38f8fe9a3897c679edbe1ed3af03a4b2059d068f Mon Sep 17 00:00:00 2001 From: midoks Date: Thu, 15 Sep 2022 17:59:37 +0800 Subject: [PATCH] =?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 aa6ab36a2..a8c3a2e59 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 69359867e..81c8295c4 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 @@ 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': diff --git a/plugins/mail/info.json b/plugins/mail/info.json index 36c333647..222e411ca 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 5f5ce730d..f72218f98 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 57b7798ff..337d17960 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 181c8db23..e30a78a16 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