mirror of
https://github.com/midoks/mdserver-web.git
synced 2026-10-10 04:19:26 +08:00
update
This commit is contained in:
@@ -125,7 +125,7 @@ class plugins_api:
|
||||
if version.strip() == '':
|
||||
return public.returnJson(False, "缺少版本信息!", ())
|
||||
|
||||
infoJsonPos = __plugin_name + '/' + name + '/' + 'info.json'
|
||||
infoJsonPos = self.__plugin_dir + '/' + name + '/' + 'info.json'
|
||||
|
||||
if not os.path.exists(infoJsonPos):
|
||||
return public.retJson(False, "配置文件不存在!", ())
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
<div class="bt-form">
|
||||
<div class="bt-w-main">
|
||||
<div class="bt-w-menu">
|
||||
<p class="bgw" onclick="readme();">服务</p>
|
||||
<p class="bgw" onclick="pluginService('pureftp');">服务</p>
|
||||
<p onclick="pluginInitD('pureftp');">自启动</p>
|
||||
<p onclick="pluginConfig('pureftp');">配置修改</p>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="bt-w-con pd15">
|
||||
@@ -11,5 +15,7 @@
|
||||
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
$.getScript( "/plugins/file?name=pureftp&f=js/ftp.js", function(){});
|
||||
$.getScript( "/plugins/file?name=pureftp&f=js/ftp.js", function(){
|
||||
pluginService('pureftp');
|
||||
});
|
||||
</script>
|
||||
Executable
+188
@@ -0,0 +1,188 @@
|
||||
# coding:utf-8
|
||||
|
||||
import sys
|
||||
import io
|
||||
import os
|
||||
import time
|
||||
|
||||
sys.path.append(os.getcwd() + "/class/core")
|
||||
import public
|
||||
|
||||
app_debug = False
|
||||
if public.getOs() == 'darwin':
|
||||
app_debug = True
|
||||
|
||||
|
||||
def getPluginName():
|
||||
return 'pureftp'
|
||||
|
||||
|
||||
def getPluginDir():
|
||||
return public.getPluginDir() + '/' + getPluginName()
|
||||
|
||||
|
||||
def getServerDir():
|
||||
return public.getServerDir() + '/' + getPluginName()
|
||||
|
||||
|
||||
def getInitDFile():
|
||||
if app_debug:
|
||||
return '/tmp/' + getPluginName()
|
||||
return '/etc/init.d/' + getPluginName()
|
||||
|
||||
|
||||
def getConf():
|
||||
path = getServerDir() + "/etc/pure-ftpd.conf"
|
||||
return path
|
||||
|
||||
|
||||
def getInitDTpl():
|
||||
path = getPluginDir() + "/init.d/pure-ftpd.tpl"
|
||||
return path
|
||||
|
||||
|
||||
def getArgs():
|
||||
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 status():
|
||||
cmd = "ps -ef|grep " + getPluginName() + \
|
||||
" |grep -v grep | grep -v python | awk '{print $2}'"
|
||||
data = public.execShell(cmd)
|
||||
if data[0] == '':
|
||||
return 'stop'
|
||||
return 'start'
|
||||
|
||||
|
||||
def contentReplace(content):
|
||||
service_path = public.getServerDir()
|
||||
content = content.replace('{$ROOT_PATH}', public.getRootDir())
|
||||
content = content.replace('{$SERVER_PATH}', service_path)
|
||||
return content
|
||||
|
||||
|
||||
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
|
||||
content = public.readFile(file_tpl)
|
||||
content = contentReplace(content)
|
||||
public.writeFile(file_bin, content)
|
||||
public.execShell('chmod +x ' + file_bin)
|
||||
|
||||
# # config replace
|
||||
# conf_content = public.readFile(getConf())
|
||||
# conf_content = conf_content.replace('{$SERVER_PATH}', service_path)
|
||||
# public.writeFile(getServerDir() + '/redis.conf', conf_content)
|
||||
|
||||
return file_bin
|
||||
|
||||
|
||||
def start():
|
||||
file = initDreplace()
|
||||
data = public.execShell(file + ' start')
|
||||
if data[1] == '':
|
||||
return 'ok'
|
||||
return 'fail'
|
||||
|
||||
|
||||
def stop():
|
||||
file = initDreplace()
|
||||
data = public.execShell(file + ' stop')
|
||||
if data[1] == '':
|
||||
return 'ok'
|
||||
return 'fail'
|
||||
|
||||
|
||||
def restart():
|
||||
file = initDreplace()
|
||||
data = public.execShell(file + ' restart')
|
||||
if data[1] == '':
|
||||
return 'ok'
|
||||
return 'fail'
|
||||
|
||||
|
||||
def reload():
|
||||
file = initDreplace()
|
||||
data = public.execShell(file + ' reload')
|
||||
if data[1] == '':
|
||||
return 'ok'
|
||||
return 'fail'
|
||||
|
||||
|
||||
def initdStatus():
|
||||
if not app_debug:
|
||||
os_name = public.getOs()
|
||||
if os_name == 'darwin':
|
||||
return "Apple Computer does not support"
|
||||
initd_bin = getInitDFile()
|
||||
if os.path.exists(initd_bin):
|
||||
return 'ok'
|
||||
return 'fail'
|
||||
|
||||
|
||||
def initdInstall():
|
||||
import shutil
|
||||
if not app_debug:
|
||||
os_name = public.getOs()
|
||||
if os_name == 'darwin':
|
||||
return "Apple Computer does not support"
|
||||
|
||||
source_bin = initDreplace()
|
||||
initd_bin = getInitDFile()
|
||||
shutil.copyfile(source_bin, initd_bin)
|
||||
public.execShell('chmod +x ' + initd_bin)
|
||||
return 'ok'
|
||||
|
||||
|
||||
def initdUinstall():
|
||||
if not app_debug:
|
||||
os_name = public.getOs()
|
||||
if os_name == 'darwin':
|
||||
return "Apple Computer does not support"
|
||||
initd_bin = getInitDFile()
|
||||
os.remove(initd_bin)
|
||||
return 'ok'
|
||||
|
||||
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 == 'conf':
|
||||
print getConf()
|
||||
else:
|
||||
print 'error'
|
||||
@@ -0,0 +1,128 @@
|
||||
#! /usr/bin/perl
|
||||
|
||||
# (C) 2001-2013 Aristotle Pagaltzis
|
||||
# derived from code (C) 2001-2002 Frank Denis and Matthias Andree
|
||||
|
||||
use strict;
|
||||
|
||||
my ($conffile, @flg) = @ARGV;
|
||||
|
||||
my $PUREFTPD;
|
||||
-x && ($PUREFTPD=$_, last) for qw(
|
||||
${exec_prefix}/sbin/pure-ftpd
|
||||
/www/server/pure-ftpd/sbin/pure-ftpd
|
||||
/www/server/pureftpd/sbin/pure-ftpd
|
||||
/www/server/sbin/pure-ftpd
|
||||
/usr/sbin/pure-ftpd
|
||||
);
|
||||
|
||||
my %simple_switch_for = (
|
||||
IPV4Only => "-4",
|
||||
IPV6Only => "-6",
|
||||
ChrootEveryone => "-A",
|
||||
BrokenClientsCompatibility => "-b",
|
||||
Daemonize => "-B",
|
||||
VerboseLog => "-d",
|
||||
DisplayDotFiles => "-D",
|
||||
AnonymousOnly => "-e",
|
||||
NoAnonymous => "-E",
|
||||
DontResolve => "-H",
|
||||
AnonymousCanCreateDirs => "-M",
|
||||
NATmode => "-N",
|
||||
CallUploadScript => "-o",
|
||||
AntiWarez => "-s",
|
||||
AllowUserFXP => "-w",
|
||||
AllowAnonymousFXP => "-W",
|
||||
ProhibitDotFilesWrite => "-x",
|
||||
ProhibitDotFilesRead => "-X",
|
||||
AllowDotFiles => "-z",
|
||||
AutoRename => "-r",
|
||||
AnonymousCantUpload => "-i",
|
||||
LogPID => "-1",
|
||||
NoChmod => "-R",
|
||||
KeepAllFiles => "-K",
|
||||
CreateHomeDir => "-j",
|
||||
NoRename => "-G",
|
||||
CustomerProof => "-Z",
|
||||
NoTruncate => "-0",
|
||||
);
|
||||
|
||||
my %string_switch_for = (
|
||||
FileSystemCharset => "-8",
|
||||
ClientCharset => "-9",
|
||||
SyslogFacility => "-f",
|
||||
FortunesFile => "-F",
|
||||
ForcePassiveIP => "-P",
|
||||
Bind => "-S",
|
||||
AnonymousBandwidth => "-t",
|
||||
UserBandwidth => "-T",
|
||||
TrustedIP => "-V",
|
||||
AltLog => "-O",
|
||||
PIDFile => "-g",
|
||||
TLSCipherSuite => "-J",
|
||||
CertFile => "-2",
|
||||
);
|
||||
|
||||
my %numeric_switch_for = (
|
||||
MaxIdleTime => "-I",
|
||||
MaxDiskUsage => "-k",
|
||||
TrustedGID => "-a",
|
||||
MaxClientsNumber => "-c",
|
||||
MaxClientsPerIP => "-C",
|
||||
MaxLoad => "-m",
|
||||
MinUID => "-u",
|
||||
TLS => "-Y",
|
||||
);
|
||||
|
||||
my %numpairb_switch_for = (
|
||||
LimitRecursion => "-L",
|
||||
PassivePortRange => "-p",
|
||||
AnonymousRatio => "-q",
|
||||
UserRatio => "-Q",
|
||||
);
|
||||
|
||||
my %numpairc_switch_for = (
|
||||
Umask => "-U",
|
||||
Quota => "-n",
|
||||
PerUserLimits => "-y",
|
||||
);
|
||||
|
||||
my %auth_method_for = (
|
||||
LDAPConfigFile => "ldap",
|
||||
MySQLConfigFile => "mysql",
|
||||
PGSQLConfigFile => "pgsql",
|
||||
PureDB => "puredb",
|
||||
ExtAuth => "extauth",
|
||||
);
|
||||
|
||||
my $simple_switch = qr/(@{[join "|", keys %simple_switch_for ]})\s+yes/i;
|
||||
my $string_switch = qr/(@{[join "|", keys %string_switch_for ]})\s+(\S+)/i;
|
||||
my $numeric_switch = qr/(@{[join "|", keys %numeric_switch_for ]})\s+(\d+)/i;
|
||||
my $numpairb_switch = qr/(@{[join "|", keys %numpairb_switch_for ]})\s+(\d+)\s+(\d+)/i;
|
||||
my $numpairc_switch = qr/(@{[join "|", keys %numpairc_switch_for ]})\s+(\d+):(\d+)/i;
|
||||
my $auth_method = qr/(@{[join "|", keys %auth_method_for ]})\s+(\S+)/i;
|
||||
|
||||
die "Usage: pure-config.pl <configuration file> [extra options]\n"
|
||||
unless defined $conffile;
|
||||
|
||||
open CONF, "< $conffile" or die "Can't open $conffile: $!\n";
|
||||
|
||||
!/^\s*(?:$|#)/ and (chomp, push @flg,
|
||||
/$simple_switch/i ? ($simple_switch_for{$1}) :
|
||||
/$string_switch/i ? ($string_switch_for{$1} . $2) :
|
||||
/$numeric_switch/i ? ($numeric_switch_for{$1} . $2) :
|
||||
/$numpairb_switch/i ? ($numpairb_switch_for{$1} . "$2:$3") :
|
||||
/$numpairc_switch/i ? ($numpairc_switch_for{$1} . "$2:$3") :
|
||||
/$auth_method/i ? ("-l" . "$auth_method_for{$1}:$2") :
|
||||
/UnixAuthentication\s+yes/i ? ("-l" . "unix") :
|
||||
/PAMAuthentication\s+yes/i ? ("-l" . "pam") :
|
||||
()
|
||||
) while <CONF>;
|
||||
|
||||
close CONF;
|
||||
|
||||
if (-t STDOUT) {
|
||||
print "Running: $PUREFTPD ", join(" ", @flg), "\n";
|
||||
}
|
||||
exec { $PUREFTPD } ($PUREFTPD, @flg) or die "cannot exec $PUREFTPD: $!";
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# chkconfig: 2345 85 15
|
||||
# description: Pure-FTPd is an FTP server daemon based upon Troll-FTPd
|
||||
# processname: pure-ftpd
|
||||
|
||||
### BEGIN INIT INFO
|
||||
# Provides: pureftpd
|
||||
# Required-Start: $all
|
||||
# Required-Stop: $all
|
||||
# Default-Start: 2 3 4 5
|
||||
# Default-Stop: 0 1 6
|
||||
# Short-Description: starts pureftpd server
|
||||
# Description: starts pureftpd server
|
||||
### END INIT INFO
|
||||
|
||||
# Pure-FTPd Settings
|
||||
PURE_PERL="{$SERVER_PATH}/pureftp/sbin/pure-ftpd"
|
||||
PURE_CONF="{$SERVER_PATH}/pureftp/etc/pure-ftpd.conf"
|
||||
PURE_PID="/var/run/pure-ftpd.pid"
|
||||
RETVAL=0
|
||||
prog="Pure-FTPd"
|
||||
|
||||
start() {
|
||||
echo -n $"Starting $prog... "
|
||||
$PURE_PERL $PURE_CONF --daemonize
|
||||
if [ "$?" = 0 ] ; then
|
||||
echo " done"
|
||||
else
|
||||
echo " failed"
|
||||
fi
|
||||
}
|
||||
|
||||
stop() {
|
||||
echo -n $"Stopping $prog... "
|
||||
if [ ! -e $PURE_PID ]; then
|
||||
echo -n $"$prog is not running."
|
||||
exit 1
|
||||
fi
|
||||
kill `cat $PURE_PID`
|
||||
if [ "$?" = 0 ] ; then
|
||||
echo " done"
|
||||
else
|
||||
echo " failed"
|
||||
fi
|
||||
}
|
||||
|
||||
restart(){
|
||||
echo $"Restarting $prog..."
|
||||
$0 stop
|
||||
sleep 2
|
||||
$0 start
|
||||
}
|
||||
|
||||
status(){
|
||||
if [ -e $PURE_PID ]; then
|
||||
echo $"$prog is running."
|
||||
else
|
||||
echo $"$prog is not running."
|
||||
fi
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
start
|
||||
;;
|
||||
stop)
|
||||
stop
|
||||
;;
|
||||
restart)
|
||||
restart
|
||||
;;
|
||||
status)
|
||||
status
|
||||
;;
|
||||
*)
|
||||
echo $"Usage: $0 {start|stop|restart}"
|
||||
esac
|
||||
@@ -16,6 +16,7 @@ Install_pureftp()
|
||||
|
||||
VER=$1
|
||||
FILE=pure-ftpd-${VER}.tar.gz
|
||||
FDIR=pure-ftpd-${VER}
|
||||
DOWNLOAD=https://download.pureftpd.org/pub/pure-ftpd/releases/pure-ftpd-${VER}.tar.gz
|
||||
|
||||
|
||||
@@ -23,22 +24,18 @@ Install_pureftp()
|
||||
wget -O $serverPath/source/pureftp/$FILE $DOWNLOAD
|
||||
fi
|
||||
|
||||
if [ ! -d $serverPath/source/pureftp/$FILE ];then
|
||||
cd $serverPath/source/pureftp && tar zxvf $FILE
|
||||
if [ ! -d $serverPath/source/pureftp/$FDIR ];then
|
||||
cd $serverPath/source/pureftp && tar zxvf $FILE
|
||||
fi
|
||||
|
||||
cd pure-ftpd-${1} && ./configure --prefix=${serverPath}/pureftp \
|
||||
--without-inetd \
|
||||
--with-altlog \
|
||||
--with-puredb \
|
||||
--with-throttling \
|
||||
--with-peruserlimits \
|
||||
--with-tls && make && make install
|
||||
|
||||
|
||||
|
||||
cd $serverPath/source/pureftp/$FDIR && ./configure --prefix=${serverPath}/pureftp \
|
||||
--with-everything && make && make install && make clean
|
||||
|
||||
echo "${1}" > ${serverPath}/pureftp/version.pl
|
||||
echo '安装完成' > $install_tmp
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
Uninstall_pureftp()
|
||||
|
||||
Reference in New Issue
Block a user