mirror of https://github.com/midoks/mdserver-web
parent
7a8c83ee90
commit
b593cc4708
@ -0,0 +1,201 @@ |
|||||||
|
Apache License |
||||||
|
Version 2.0, January 2004 |
||||||
|
http://www.apache.org/licenses/ |
||||||
|
|
||||||
|
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION |
||||||
|
|
||||||
|
1. Definitions. |
||||||
|
|
||||||
|
"License" shall mean the terms and conditions for use, reproduction, |
||||||
|
and distribution as defined by Sections 1 through 9 of this document. |
||||||
|
|
||||||
|
"Licensor" shall mean the copyright owner or entity authorized by |
||||||
|
the copyright owner that is granting the License. |
||||||
|
|
||||||
|
"Legal Entity" shall mean the union of the acting entity and all |
||||||
|
other entities that control, are controlled by, or are under common |
||||||
|
control with that entity. For the purposes of this definition, |
||||||
|
"control" means (i) the power, direct or indirect, to cause the |
||||||
|
direction or management of such entity, whether by contract or |
||||||
|
otherwise, or (ii) ownership of fifty percent (50%) or more of the |
||||||
|
outstanding shares, or (iii) beneficial ownership of such entity. |
||||||
|
|
||||||
|
"You" (or "Your") shall mean an individual or Legal Entity |
||||||
|
exercising permissions granted by this License. |
||||||
|
|
||||||
|
"Source" form shall mean the preferred form for making modifications, |
||||||
|
including but not limited to software source code, documentation |
||||||
|
source, and configuration files. |
||||||
|
|
||||||
|
"Object" form shall mean any form resulting from mechanical |
||||||
|
transformation or translation of a Source form, including but |
||||||
|
not limited to compiled object code, generated documentation, |
||||||
|
and conversions to other media types. |
||||||
|
|
||||||
|
"Work" shall mean the work of authorship, whether in Source or |
||||||
|
Object form, made available under the License, as indicated by a |
||||||
|
copyright notice that is included in or attached to the work |
||||||
|
(an example is provided in the Appendix below). |
||||||
|
|
||||||
|
"Derivative Works" shall mean any work, whether in Source or Object |
||||||
|
form, that is based on (or derived from) the Work and for which the |
||||||
|
editorial revisions, annotations, elaborations, or other modifications |
||||||
|
represent, as a whole, an original work of authorship. For the purposes |
||||||
|
of this License, Derivative Works shall not include works that remain |
||||||
|
separable from, or merely link (or bind by name) to the interfaces of, |
||||||
|
the Work and Derivative Works thereof. |
||||||
|
|
||||||
|
"Contribution" shall mean any work of authorship, including |
||||||
|
the original version of the Work and any modifications or additions |
||||||
|
to that Work or Derivative Works thereof, that is intentionally |
||||||
|
submitted to Licensor for inclusion in the Work by the copyright owner |
||||||
|
or by an individual or Legal Entity authorized to submit on behalf of |
||||||
|
the copyright owner. For the purposes of this definition, "submitted" |
||||||
|
means any form of electronic, verbal, or written communication sent |
||||||
|
to the Licensor or its representatives, including but not limited to |
||||||
|
communication on electronic mailing lists, source code control systems, |
||||||
|
and issue tracking systems that are managed by, or on behalf of, the |
||||||
|
Licensor for the purpose of discussing and improving the Work, but |
||||||
|
excluding communication that is conspicuously marked or otherwise |
||||||
|
designated in writing by the copyright owner as "Not a Contribution." |
||||||
|
|
||||||
|
"Contributor" shall mean Licensor and any individual or Legal Entity |
||||||
|
on behalf of whom a Contribution has been received by Licensor and |
||||||
|
subsequently incorporated within the Work. |
||||||
|
|
||||||
|
2. Grant of Copyright License. Subject to the terms and conditions of |
||||||
|
this License, each Contributor hereby grants to You a perpetual, |
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable |
||||||
|
copyright license to reproduce, prepare Derivative Works of, |
||||||
|
publicly display, publicly perform, sublicense, and distribute the |
||||||
|
Work and such Derivative Works in Source or Object form. |
||||||
|
|
||||||
|
3. Grant of Patent License. Subject to the terms and conditions of |
||||||
|
this License, each Contributor hereby grants to You a perpetual, |
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable |
||||||
|
(except as stated in this section) patent license to make, have made, |
||||||
|
use, offer to sell, sell, import, and otherwise transfer the Work, |
||||||
|
where such license applies only to those patent claims licensable |
||||||
|
by such Contributor that are necessarily infringed by their |
||||||
|
Contribution(s) alone or by combination of their Contribution(s) |
||||||
|
with the Work to which such Contribution(s) was submitted. If You |
||||||
|
institute patent litigation against any entity (including a |
||||||
|
cross-claim or counterclaim in a lawsuit) alleging that the Work |
||||||
|
or a Contribution incorporated within the Work constitutes direct |
||||||
|
or contributory patent infringement, then any patent licenses |
||||||
|
granted to You under this License for that Work shall terminate |
||||||
|
as of the date such litigation is filed. |
||||||
|
|
||||||
|
4. Redistribution. You may reproduce and distribute copies of the |
||||||
|
Work or Derivative Works thereof in any medium, with or without |
||||||
|
modifications, and in Source or Object form, provided that You |
||||||
|
meet the following conditions: |
||||||
|
|
||||||
|
(a) You must give any other recipients of the Work or |
||||||
|
Derivative Works a copy of this License; and |
||||||
|
|
||||||
|
(b) You must cause any modified files to carry prominent notices |
||||||
|
stating that You changed the files; and |
||||||
|
|
||||||
|
(c) You must retain, in the Source form of any Derivative Works |
||||||
|
that You distribute, all copyright, patent, trademark, and |
||||||
|
attribution notices from the Source form of the Work, |
||||||
|
excluding those notices that do not pertain to any part of |
||||||
|
the Derivative Works; and |
||||||
|
|
||||||
|
(d) If the Work includes a "NOTICE" text file as part of its |
||||||
|
distribution, then any Derivative Works that You distribute must |
||||||
|
include a readable copy of the attribution notices contained |
||||||
|
within such NOTICE file, excluding those notices that do not |
||||||
|
pertain to any part of the Derivative Works, in at least one |
||||||
|
of the following places: within a NOTICE text file distributed |
||||||
|
as part of the Derivative Works; within the Source form or |
||||||
|
documentation, if provided along with the Derivative Works; or, |
||||||
|
within a display generated by the Derivative Works, if and |
||||||
|
wherever such third-party notices normally appear. The contents |
||||||
|
of the NOTICE file are for informational purposes only and |
||||||
|
do not modify the License. You may add Your own attribution |
||||||
|
notices within Derivative Works that You distribute, alongside |
||||||
|
or as an addendum to the NOTICE text from the Work, provided |
||||||
|
that such additional attribution notices cannot be construed |
||||||
|
as modifying the License. |
||||||
|
|
||||||
|
You may add Your own copyright statement to Your modifications and |
||||||
|
may provide additional or different license terms and conditions |
||||||
|
for use, reproduction, or distribution of Your modifications, or |
||||||
|
for any such Derivative Works as a whole, provided Your use, |
||||||
|
reproduction, and distribution of the Work otherwise complies with |
||||||
|
the conditions stated in this License. |
||||||
|
|
||||||
|
5. Submission of Contributions. Unless You explicitly state otherwise, |
||||||
|
any Contribution intentionally submitted for inclusion in the Work |
||||||
|
by You to the Licensor shall be under the terms and conditions of |
||||||
|
this License, without any additional terms or conditions. |
||||||
|
Notwithstanding the above, nothing herein shall supersede or modify |
||||||
|
the terms of any separate license agreement you may have executed |
||||||
|
with Licensor regarding such Contributions. |
||||||
|
|
||||||
|
6. Trademarks. This License does not grant permission to use the trade |
||||||
|
names, trademarks, service marks, or product names of the Licensor, |
||||||
|
except as required for reasonable and customary use in describing the |
||||||
|
origin of the Work and reproducing the content of the NOTICE file. |
||||||
|
|
||||||
|
7. Disclaimer of Warranty. Unless required by applicable law or |
||||||
|
agreed to in writing, Licensor provides the Work (and each |
||||||
|
Contributor provides its Contributions) on an "AS IS" BASIS, |
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or |
||||||
|
implied, including, without limitation, any warranties or conditions |
||||||
|
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A |
||||||
|
PARTICULAR PURPOSE. You are solely responsible for determining the |
||||||
|
appropriateness of using or redistributing the Work and assume any |
||||||
|
risks associated with Your exercise of permissions under this License. |
||||||
|
|
||||||
|
8. Limitation of Liability. In no event and under no legal theory, |
||||||
|
whether in tort (including negligence), contract, or otherwise, |
||||||
|
unless required by applicable law (such as deliberate and grossly |
||||||
|
negligent acts) or agreed to in writing, shall any Contributor be |
||||||
|
liable to You for damages, including any direct, indirect, special, |
||||||
|
incidental, or consequential damages of any character arising as a |
||||||
|
result of this License or out of the use or inability to use the |
||||||
|
Work (including but not limited to damages for loss of goodwill, |
||||||
|
work stoppage, computer failure or malfunction, or any and all |
||||||
|
other commercial damages or losses), even if such Contributor |
||||||
|
has been advised of the possibility of such damages. |
||||||
|
|
||||||
|
9. Accepting Warranty or Additional Liability. While redistributing |
||||||
|
the Work or Derivative Works thereof, You may choose to offer, |
||||||
|
and charge a fee for, acceptance of support, warranty, indemnity, |
||||||
|
or other liability obligations and/or rights consistent with this |
||||||
|
License. However, in accepting such obligations, You may act only |
||||||
|
on Your own behalf and on Your sole responsibility, not on behalf |
||||||
|
of any other Contributor, and only if You agree to indemnify, |
||||||
|
defend, and hold each Contributor harmless for any liability |
||||||
|
incurred by, or claims asserted against, such Contributor by reason |
||||||
|
of your accepting any such warranty or additional liability. |
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS |
||||||
|
|
||||||
|
APPENDIX: How to apply the Apache License to your work. |
||||||
|
|
||||||
|
To apply the Apache License to your work, attach the following |
||||||
|
boilerplate notice, with the fields enclosed by brackets "[]" |
||||||
|
replaced with your own identifying information. (Don't include |
||||||
|
the brackets!) The text should be enclosed in the appropriate |
||||||
|
comment syntax for the file format. We also recommend that a |
||||||
|
file or class name and description of purpose be included on the |
||||||
|
same "printed page" as the copyright notice for easier |
||||||
|
identification within third-party archives. |
||||||
|
|
||||||
|
Copyright [yyyy] [name of copyright owner] |
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License"); |
||||||
|
you may not use this file except in compliance with the License. |
||||||
|
You may obtain a copy of the License at |
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0 |
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software |
||||||
|
distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
See the License for the specific language governing permissions and |
||||||
|
limitations under the License. |
After Width: | Height: | Size: 4.1 KiB |
@ -0,0 +1,21 @@ |
|||||||
|
<div class="bt-form"> |
||||||
|
<div class="bt-w-main"> |
||||||
|
<div class="bt-w-menu"> |
||||||
|
<p class="bgw" onclick="pluginService('imail');">服务</p> |
||||||
|
<p onclick="pluginInitD('imail');">自启动</p> |
||||||
|
<p onclick="pluginConfig('imail',null, 'conf');">配置文件</p> |
||||||
|
<p onclick="gogsSetConfig();">配置修改</p> |
||||||
|
<p onclick="gogsUserList();">用户列表</p> |
||||||
|
<p onclick="pluginLogs('imail',null,'run_log');">运行日志</p> |
||||||
|
</div> |
||||||
|
<div class="bt-w-con pd15"> |
||||||
|
<div class="soft-man-con"></div> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
|
||||||
|
<script type="text/javascript"> |
||||||
|
$.getScript( "/plugins/file?name=imail&f=js/imail.js", function(){ |
||||||
|
mail.init(); |
||||||
|
}); |
||||||
|
</script> |
@ -0,0 +1,126 @@ |
|||||||
|
# coding:utf-8 |
||||||
|
|
||||||
|
import sys |
||||||
|
import io |
||||||
|
import os |
||||||
|
import time |
||||||
|
import re |
||||||
|
import socket |
||||||
|
import json |
||||||
|
|
||||||
|
from datetime import datetime |
||||||
|
|
||||||
|
sys.path.append(os.getcwd() + "/class/core") |
||||||
|
import mw |
||||||
|
|
||||||
|
app_debug = False |
||||||
|
if mw.isAppleSystem(): |
||||||
|
app_debug = True |
||||||
|
|
||||||
|
|
||||||
|
class App: |
||||||
|
__setupPath = '/www/server/imail' |
||||||
|
|
||||||
|
def __init__(self): |
||||||
|
self.__setupPath = self.getServerDir() |
||||||
|
|
||||||
|
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 getPluginName(self): |
||||||
|
return 'mail' |
||||||
|
|
||||||
|
def getPluginDir(self): |
||||||
|
return mw.getPluginDir() + '/' + self.getPluginName() |
||||||
|
|
||||||
|
def getServerDir(self): |
||||||
|
return mw.getServerDir() + '/' + self.getPluginName() |
||||||
|
|
||||||
|
def status(self): |
||||||
|
data = mw.execShell( |
||||||
|
"ps -ef|grep " + self.getPluginName() + " |grep -v grep | grep -v python | awk '{print $2}'") |
||||||
|
if data[0] == '': |
||||||
|
return 'stop' |
||||||
|
return 'start' |
||||||
|
|
||||||
|
def initDreplace(self): |
||||||
|
|
||||||
|
file_tpl = self.getInitdConfTpl() |
||||||
|
service_path = mw.getServerDir() |
||||||
|
|
||||||
|
initD_path = self.getServerDir() + '/init.d' |
||||||
|
if not os.path.exists(initD_path): |
||||||
|
os.mkdir(initD_path) |
||||||
|
file_bin = initD_path + '/' + self.getPluginName() |
||||||
|
|
||||||
|
if not os.path.exists(file_bin): |
||||||
|
content = mw.readFile(file_tpl) |
||||||
|
content = contentReplace(content) |
||||||
|
mw.writeFile(file_bin, content) |
||||||
|
mw.execShell('chmod +x ' + file_bin) |
||||||
|
|
||||||
|
# systemd |
||||||
|
# systemDir = mw.systemdCfgDir() |
||||||
|
# systemService = systemDir + '/gogs.service' |
||||||
|
# systemServiceTpl = getPluginDir() + '/init.d/gogs.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') |
||||||
|
|
||||||
|
# log_path = getServerDir() + '/log' |
||||||
|
# if not os.path.exists(log_path): |
||||||
|
# os.mkdir(log_path) |
||||||
|
|
||||||
|
return file_bin |
||||||
|
|
||||||
|
def imOp(self, method): |
||||||
|
file = self.initDreplace() |
||||||
|
|
||||||
|
if not mw.isAppleSystem(): |
||||||
|
data = mw.execShell('systemctl ' + method + ' imail') |
||||||
|
if data[1] == '': |
||||||
|
return 'ok' |
||||||
|
return 'fail' |
||||||
|
|
||||||
|
data = mw.execShell(__SR + file + ' ' + method) |
||||||
|
if data[1] == '': |
||||||
|
return 'ok' |
||||||
|
return data[0] |
||||||
|
|
||||||
|
def start(self): |
||||||
|
return self.imOp('start') |
||||||
|
|
||||||
|
def stop(self): |
||||||
|
return self.imOp('stop') |
||||||
|
|
||||||
|
def restart(self): |
||||||
|
return self.imOp('restart') |
||||||
|
|
||||||
|
def reload(self): |
||||||
|
return self.imOp('reload') |
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__": |
||||||
|
func = sys.argv[1] |
||||||
|
classApp = App() |
||||||
|
try: |
||||||
|
data = eval("classApp." + func + "()") |
||||||
|
print(data) |
||||||
|
except Exception as e: |
||||||
|
print('error:' + str(e)) |
@ -0,0 +1,18 @@ |
|||||||
|
{ |
||||||
|
"sort": 7, |
||||||
|
"ps": "简单邮件服务[DEV]", |
||||||
|
"name": "imail", |
||||||
|
"title": "邮件服务", |
||||||
|
"shell": "install.sh", |
||||||
|
"versions":["0.0.14"], |
||||||
|
"updates":["0.0.14"], |
||||||
|
"tip": "soft", |
||||||
|
"checks": "server/imail", |
||||||
|
"path": "server/imail", |
||||||
|
"display": 1, |
||||||
|
"author": "midoks", |
||||||
|
"date": "2022-09-26", |
||||||
|
"home": "https://github.com/midoks/mdserver-web", |
||||||
|
"type": 0, |
||||||
|
"pid": "5" |
||||||
|
} |
@ -0,0 +1,12 @@ |
|||||||
|
[Unit] |
||||||
|
Description=Gogs |
||||||
|
After=network.target |
||||||
|
|
||||||
|
[Service] |
||||||
|
Type=forking |
||||||
|
ExecStart={$SERVER_PATH}/imail/init.d/imail start |
||||||
|
ExecStop={$SERVER_PATH}/imail/init.d/imail stop |
||||||
|
RemainAfterExit=yes |
||||||
|
|
||||||
|
[Install] |
||||||
|
WantedBy=multi-user.target |
@ -0,0 +1,110 @@ |
|||||||
|
#!/bin/sh |
||||||
|
# |
||||||
|
# /etc/rc.d/init.d/imail |
||||||
|
# |
||||||
|
# Runs the imail |
||||||
|
# |
||||||
|
# |
||||||
|
# chkconfig: - 85 15 |
||||||
|
# |
||||||
|
|
||||||
|
### BEGIN INIT INFO |
||||||
|
# Provides: imail |
||||||
|
# Required-Start: $remote_fs $syslog |
||||||
|
# Required-Stop: $remote_fs $syslog |
||||||
|
# Should-Start: mysql |
||||||
|
# Should-Stop: mysql |
||||||
|
# Default-Start: 2 3 4 5 |
||||||
|
# Default-Stop: 0 1 6 |
||||||
|
# Short-Description: Start imail at boot time. |
||||||
|
# Description: Control imail. |
||||||
|
### END INIT INFO |
||||||
|
|
||||||
|
# Source function library. |
||||||
|
if [ -f /etc/init.d/functions ];then |
||||||
|
. /etc/init.d/functions |
||||||
|
fi |
||||||
|
|
||||||
|
if [ -f /etc/rc.d/init.d/functions ];then |
||||||
|
. /etc/rc.d/init.d/functions |
||||||
|
fi |
||||||
|
|
||||||
|
# Default values |
||||||
|
export HOME={$HOME_DIR} |
||||||
|
export USER={$RUN_USER} |
||||||
|
NAME=imail |
||||||
|
GOGS_HOME={$SERVER_PATH}/imail |
||||||
|
GOGS_PATH=${GOGS_HOME}/$NAME |
||||||
|
GOGS_USER={$RUN_USER} |
||||||
|
SERVICENAME="imail" |
||||||
|
LOCKFILE=/tmp/imail.lock |
||||||
|
LOGPATH=${GOGS_HOME}/log |
||||||
|
LOGFILE=${LOGPATH}/imail.log |
||||||
|
RETVAL=0 |
||||||
|
|
||||||
|
|
||||||
|
[ -r /etc/sysconfig/$NAME ] && . /etc/sysconfig/$NAME |
||||||
|
DAEMON_OPTS="--check $NAME" |
||||||
|
[ ! -z "$GOGS_USER" ] && DAEMON_OPTS="$DAEMON_OPTS --user=${GOGS_USER}" |
||||||
|
|
||||||
|
|
||||||
|
status(){ |
||||||
|
isStart=`ps -ef|grep 'imail web' |grep -v grep|awk '{print $2}'` |
||||||
|
if [ "$isStart" == '' ];then |
||||||
|
echo -e "${SERVICENAME} not running" |
||||||
|
else |
||||||
|
echo -e "${SERVICENAME}(pid $(echo $isStart)) already running" |
||||||
|
fi |
||||||
|
} |
||||||
|
|
||||||
|
start() { |
||||||
|
isStart=`ps -ef|grep 'imail web' |grep -v grep|awk '{print $2}'` |
||||||
|
if [ "$isStart" != '' ];then |
||||||
|
echo "${SERVICENAME}(pid $(echo $isStart)) already running" |
||||||
|
return $RETVAL |
||||||
|
fi |
||||||
|
|
||||||
|
cd ${GOGS_HOME} |
||||||
|
echo -e "Starting ${SERVICENAME}: \c" |
||||||
|
${GOGS_PATH} web > ${LOGFILE} 2>&1 & |
||||||
|
RETVAL=$? |
||||||
|
[ $RETVAL = 0 ] && touch ${LOCKFILE} && echo -e "\033[32mdone\033[0m" |
||||||
|
return $RETVAL |
||||||
|
} |
||||||
|
|
||||||
|
stop() { |
||||||
|
|
||||||
|
pids=`ps -ef|grep 'gogs web' |grep -v grep|awk '{print $2}'` |
||||||
|
arr=($pids) |
||||||
|
echo -e "Stopping gogs... \c" |
||||||
|
for p in ${arr[@]} |
||||||
|
do |
||||||
|
kill -9 $p |
||||||
|
done |
||||||
|
echo -e "\033[32mdone\033[0m" |
||||||
|
} |
||||||
|
|
||||||
|
case "$1" in |
||||||
|
start) |
||||||
|
start |
||||||
|
;; |
||||||
|
stop) |
||||||
|
stop |
||||||
|
;; |
||||||
|
status) |
||||||
|
status |
||||||
|
;; |
||||||
|
restart) |
||||||
|
stop |
||||||
|
start |
||||||
|
;; |
||||||
|
reload) |
||||||
|
stop |
||||||
|
start |
||||||
|
;; |
||||||
|
*) |
||||||
|
echo "Usage: ${NAME} {start|stop|status|restart}" |
||||||
|
exit 1 |
||||||
|
;; |
||||||
|
esac |
||||||
|
exit $RETVAL |
@ -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 |
@ -0,0 +1,95 @@ |
|||||||
|
var mail = { |
||||||
|
plugin_name: 'imail', |
||||||
|
init: function () { |
||||||
|
var _this = this; |
||||||
|
}, |
||||||
|
|
||||||
|
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'); |
||||||
|
} |
||||||
|
} |
@ -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") |
||||||
|
serverPath=$(dirname "$rootPath") |
||||||
|
|
||||||
|
install_tmp=${rootPath}/tmp/mw_install.pl |
||||||
|
VERSION=0.0.14 |
||||||
|
|
||||||
|
## curl -fsSL https://raw.githubusercontent.com/midoks/mdserver-web/dev/scripts/update_dev.sh | bash |
||||||
|
## debug: |
||||||
|
## cd /www/server/mdserver-web/plugins/imail && 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}'` |
||||||
|
|
||||||
|
check_go_environment() { |
||||||
|
if test ! -x "$(command -v go)"; then |
||||||
|
printf "\e[1;31mmissing go running environment\e[0m\n" |
||||||
|
exit 1 |
||||||
|
fi |
||||||
|
} |
||||||
|
|
||||||
|
get_arch() { |
||||||
|
echo "package main |
||||||
|
import ( |
||||||
|
\"fmt\" |
||||||
|
\"runtime\" |
||||||
|
) |
||||||
|
func main() { fmt.Println(runtime.GOARCH) }" > /tmp/go_arch.go |
||||||
|
|
||||||
|
ARCH=$(go run /tmp/go_arch.go) |
||||||
|
} |
||||||
|
|
||||||
|
load_vars() { |
||||||
|
OS=$(uname | tr '[:upper:]' '[:lower:]') |
||||||
|
TARGET_DIR="$serverPath/imail" |
||||||
|
} |
||||||
|
|
||||||
|
get_download_url() { |
||||||
|
DOWNLOAD_URL="https://github.com/midoks/imail/releases/download/$VERSION/imail_${VERSION}_${OS}_${ARCH}.tar.gz" |
||||||
|
} |
||||||
|
|
||||||
|
# download file |
||||||
|
download_file() { |
||||||
|
url="${1}" |
||||||
|
destination="${2}" |
||||||
|
|
||||||
|
printf "Fetching ${url} \n\n" |
||||||
|
|
||||||
|
if test -x "$(command -v curl)"; then |
||||||
|
code=$(curl --connect-timeout 15 -w '%{http_code}' -L "${url}" -o "${destination}") |
||||||
|
elif test -x "$(command -v wget)"; then |
||||||
|
code=$(wget -t2 -T15 -O "${destination}" --server-response "${url}" 2>&1 | awk '/^ HTTP/{print $2}' | tail -1) |
||||||
|
else |
||||||
|
printf "\e[1;31mNeither curl nor wget was available to perform http requests.\e[0m\n" |
||||||
|
exit 1 |
||||||
|
fi |
||||||
|
|
||||||
|
if [ "${code}" != 200 ]; then |
||||||
|
printf "\e[1;31mRequest failed with code %s\e[0m\n" $code |
||||||
|
exit 1 |
||||||
|
else |
||||||
|
printf "\n\e[1;33mDownload succeeded\e[0m\n" |
||||||
|
fi |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
Install_App() |
||||||
|
{ |
||||||
|
echo '正在安装脚本文件...' > $install_tmp |
||||||
|
mkdir -p $serverPath/source |
||||||
|
|
||||||
|
check_go_environment |
||||||
|
load_vars |
||||||
|
get_arch |
||||||
|
get_download_url |
||||||
|
|
||||||
|
DOWNLOAD_FILE="$(mktemp).tar.gz" |
||||||
|
download_file $DOWNLOAD_URL $DOWNLOAD_FILE |
||||||
|
|
||||||
|
if [ ! -d "$TARGET_DIR" ]; then |
||||||
|
mkdir -p "$TARGET_DIR" |
||||||
|
fi |
||||||
|
|
||||||
|
tar -C "$TARGET_DIR" -zxf $DOWNLOAD_FILE |
||||||
|
rm -rf $DOWNLOAD_FILE |
||||||
|
|
||||||
|
pushd "$TARGET_DIR/scripts" >/dev/null 2>&1 |
||||||
|
bash make.sh |
||||||
|
|
||||||
|
systemctl daemon-reload |
||||||
|
|
||||||
|
echo "$VERSION" > $serverPath/imail/version.pl |
||||||
|
echo '安装完成' > $install_tmp |
||||||
|
} |
||||||
|
|
||||||
|
Uninstall_App() |
||||||
|
{ |
||||||
|
|
||||||
|
echo "Uninstall_Mail" > $install_tmp |
||||||
|
} |
||||||
|
|
||||||
|
action=$1 |
||||||
|
if [ "${1}" == 'install' ];then |
||||||
|
Install_App |
||||||
|
else |
||||||
|
Uninstall_App |
||||||
|
fi |
Loading…
Reference in new issue