运维技术群:35666658
import os,sys
#version 1.0
#2013-09-09
#luohongjiang
#qq:123769752
#config file path
_config_file="/usr/local/etc/proftpd.conf"
def init(ip,user,_path):
#ip address
IP=ip
#ftp user
_user=user
#configure ftp server path
_config_path=_path
def main():
help='''
$2 is ftp server login host/IP
$3 is ftp server login user
$4 is ftp server login user directory
=======================================
[install] install proftp soft
[conf $2 $3] config proftp soft,login user directory.
$2 is ftp server login user
$3 is ftp server login user directory
'''
print help
def downandinstall():
os.system("yum -y install gcc make autoconf pcre-devel openssl* openssh*")
os.system("curl -o proftpd-1.3.5rc3.tar.gz ftp://ftp.proftpd.org/distrib/source/proftpd-1.3.5rc3.tar.gz")
os.system("tar -xvf proftpd*.tar.gz")
os.system("mkdir -p /var/spool/proftpd")
os.chdir("proftpd-1.3.5rc3")
os.system("./configure –prefix=/usr/local –enable-shadow –enable-autoshadow –enable-facl –enable-pcre –disable-ipv6 –enable-openssl –with-mysql-config –with-modules=mod_ratio:mod_readme:mod_facl")
os.system("make;make install")
###########################
def main_conf():
configfile='''
ServerName "FTP server"
ServerType standalone
DeferWelcome off
Umask 002
MaxInstances 30
Port 21
TimeoutLogin 120
TimeoutIdle 600
TimeoutNoTransfer 900
TimeoutStalled 3600
User ftp
Group ftp
TimesGMT off
UseReverseDNS off
TransferLog /var/spool/proftpd/xferlog.legacy
LogFormat default "%h %l %u %t \"%r\" %s %b"
LogFormat auth "%v [%P] %h %t \"%r\" %s"
LogFormat write "%h %l %u %t \"%r\" %s %b"
<Global>
DisplayLogin welcome.msg
AllowOverwrite yes
IdentLookups off
ExtendedLog /var/spool/proftpd/access.log WRITE,READ write RNFR DELE
ExtendedLog /var/spool/proftpd/auth.log AUTH auth
</Global>
'''
open(_config_file,"wb+").write(configfile)
def virtualhost_conf(IP,_user):
configfile='''
<VirtualHost %s>
ServerAdmin g_linux@qq.com
ServerName "FTP Server"
TransferLog /var/spool/proftpd/my_ftp.log
MaxLoginAttempts 3
RequireValidShell no
MaxCli
转载请注明:IT运维空间 » Shell » 用python 快速安装proftp 及简单配置
发表评论