# Version:1.0# Author: Fruit # Date: -- A- - -: the: A# Description: Only three steps to complete the installation #chmodA+x install_vsftpd.SH# ./install_vsftpd Install_server installation Related services #./install_vsftpd Add_user Configuring user information #./install_vsftpd Start Service # Usage: Enter in the browser or computer address:FTP://192.168.0.1 can be accessed, 192.168.0.1 is the host address. # More: Subsequent will add some security controls and batch create user # # #!/bin/Bash#set-x #调试用allow=Yesdeny=Nosname=vsftpdvfconf="/etc/vsftpd/vsftpd.conf"Vfstart="/etc/init.d/vsftpd"VUser="/etc/vsftpd/vuser"vucdirectory="/etc/vsftpd/vuconf"Vfpam="/ETC/PAM.D/VSFTPDD"vfdirectory="/var/www/html"DB4=db4db4utils="db4-utils"Db4devel="Db4-devel"Sys_tem="/lib64"http=apache#----------The Master profile--------------Main_config () {if[-D $sys _tem]; Then Echo "Your system is 64bit"Systems=$sys _temElse Echo "Your system is 32bit"Systems=/Libfi # Touch$VFpamsed-I.'s/anonymous_enable=yes/anonymous_enable=no/g'$VFconfsed-I.'s/#chown_uploads =yes/chown_uploads=no/g'$VFconfsed-I.'s/#xferlog_file/xferlog_file/g'$VFconfsed-I.'s/#async_abor_enable =yes/async_abor_enable=yes/g'$VFconfsed-I.'s/#ascii_upload_enable =yes/ascii_upload_enable=yes/g'$VFconfsed-I.'s/#ascii_download_enable =yes/ascii_download_enable=yes/g'$VFconfsed-I.'s/#chroot_local_user =yes/chroot_local_user=yes/g'$VFconfsed-I.'s/pam_service_name=vsftpd/pam_service_name=vsftpdd/g'$VFconf {Echo "guest_enable= $allow" Echo "guest_username= $http" Echo "user_config_dir= $VUCdirectory" Echo "virtual_use_local_privs= $allow" } >>$VFconfTouch$VFpam {Echo "Auth sufficient $systems/security/pam_userdb.so db= $VUser" Echo "Account sufficient $systems/security/pam_userdb.so db= $VUser" } >$VFpam}#------------User Configuration-----------------------User_config () {Uname=$1Userhome="local_root="Userworld="anon_world_readable_only="Userupload="anon_upload_enable="Usermkdir="anon_mkdir_write_enable="Userothen="anon_mkdir_write_enable="Userwrite="write_enable=" Echo-E"\033[31;40m ===now Configure the config file=== \033[0m" if[-D $VUCdirectory]; Then Echo "The directory $VUCdirectory exsits." Else mkdir$VUCdirectoryfi Echo "Your want to configure user is: $Uname"Read-P"Please input user home directory (default $VFDirectory)"Home_dirif["X$home_dir"!="x" ] Thenvfdirectory=$home _dirfi Echo "Your Home directory is: $VFDirectory" Touch "$VUCdirectory/$Uname"&&Echo-E"\033[31;40msuccess To configure file=== \033[0m" { Echo "$userhome $vfdirectory" Echo "$userwrite $allow" Echo "$userworld $deny" Echo "$userupload $allow" Echo "$usermkdir $allow" Echo "$userothen $allow" } > $VUCdirectory/$UnameChown-R $http: $http $VFDirectorychmod-R755$VFDirectory}#----------------Increase User---------------------Add_user () {Echo "start Add user ..." while[1 ] DoisOK=yEcho-N"does want to add user?"Read-P"[y/n]:"OKif["X$ok"="x" ] ThenContinueelif["X$ok"="XN" ] Then Echo "=============finish Add user=============" BreakfiisOK=$okif["X$isok"!="XY" ] Then Echo "Error input! Please input y/n"ContinueElseRead-P"Input Username:"Username Read-P"Input userpasswd:"userpasswdEcho "Your username is: $username" Echo "Your userpasswd is: $userpasswd" { Echo "$username" Echo "$userpasswd" } >>$VUser user_config $usernamefi DoneDb_load-T-T Hash-f $VUser $VUser. db}#-----------------Installation Services---------------------Install_server () {rpm-Q $Snameif[$?-eq0]; Then Echo "VSFTPD Service has installed." Else Yum Install-y $Snamefi Yum-YInstall "db4*"}#------------------------------------------------ Case$1 inchinstall_server)Echo "start install $Sname:"Install_server Main_config; Add_user) Add_user;; restart) $VFstart restart;; Start) $VFstart start;; stop) $VFstart stop;; *) Echo "Usage: $ install_server|add_user|restart|start|stop"Exit1EsacExit0
CentOS One-click FTP