shell 一键安装简易ftp

#!/bin/bashlinux

#Date:2013.7.11centos

#system: centos 6.3 bash


if [[ $EUID -ne 0 ]]; ide

thenip

 echo "This script must be run as root" 1>&2it


exit 1class

fiftp


read -p "enter your ftp username: " Fnamesed


UserExist=`grep -w  $Fname /etc/passwd | wc -l`service

while  [[ $UserExist -ne 0 ]] ;

do

read -p " your ftp username is your system user,do you want to use it : y/n " Ifconti

 if [ $Ifconti == 'y' ] ; then

     UserExist=0

 else

    read -p "please enter another username: " Fname

    UserExist=`grep -w $Fname /etc/passwd | wc -l`

 fi

done;


read -p "enter your ftp password: " Fpwd


echo  $Fpwd


useradd $Fname

echo $Fpwd | passwd --stdin $Fname

Vsftpd=`rpm -qa | grep "vsftpd" | wc -l`



if [ $Vsftpd -ne 0 ] ; then

   killall vsftpd

   rm -rf /etc/vsftpd

   yum -y reinstall vsftpd

else

   yum -y install vsftpd

fi


sed -i '12s/YES/NO/' /etc/vsftpd/vsftpd.conf

sed -i '97s/#//' /etc/vsftpd/vsftpd.conf

sed -i '99s/#//' /etc/vsftpd/vsftpd.conf

echo "chroot_local_user=YES" >> /etc/vsftpd/vsftpd.conf

touch  /etc/vsftpd/chroot_list

echo $Fname >>  /etc/vsftpd/chroot_list

sed -i  "/$Fname/d" /etc/vsftpd/user_list

sed -i "/$Fname/d" /etc/vsftpd/ftpusers

service vsftpd start


chkconfig vsftpd on



注:若是你的selinux 开启的话,可能会报vsftpd: 500 OOPS 的错误