#!/bin/bash

###this script is install vsftpd####
yum -y remove vsftpd
yum clean all
yum -y install vsftpd
CONF=/etc/vsftpd/vsftpd.conf
echo "####write a file path####"
read -p "please write a filename,you best Combined with path:" dir
#####dir is a variable####
if [ -d "$dir" ];then
    rm -rf $dir
 else
      mkdir $dir
 fi
mkdir -p $dir/iso
chmod 755 $dir
  chmod 777 $dir/iso
 echo "#####vsftpd install#####"
 echo "#######/etc/vsftpd/vsftpd.conf#####"
 sed -i 's/#anon_upload_enable=YES/anon_upload_enable=YES/g' $CONF
 sed -i 's/#anon_mkdir_write_enable=YES/anon_mkdir_write_enable=YES/g' $CONF
 sed -i 's/userlist_enable=YES/userlist_enable=NO/g' $CONF
  #sed -i  '/\<userlist_enable\>/s/YES/NO/g' $CONF  ##this command same as before###
  cat >> $CONF << EOF
  anon_umask=022
  anon_root=$dir
  EOF
  ##sed -i '/tcp_wrappers/a anon_umask=022' $CONF
  ##sed -i "/tcp_wrappers/a anon_root=$dir" $CONF   ###this command same as cat---EOF###
  echo "########start server######"
 service vsftpd restart
  chkconfig --add vsftpd
 chkconfig --level 35 vsftpd  on
  iptables -F
  setenforce 0
 echo "##############it is ok##########"
 
 
 
 
copy到linux新建的文件里面,给权限然后直接执行,这个必须搭建了yum仓库