由于需要经常部署FTP服务,就写了一个脚本一键安装,参数设置还没有写的太详细,也没有作虚拟用户,大致思想,判断是否安装,没有安装去安装vsftp,然后利用read读如用户设置,付给变量,调取变量,执行函数代码。未完待续.............................
################################################
#!/bin/bash vsftpd=/etc/vsftpd/vsftpd.conf ################################### rpm -qa |grep "vsftpd" if [ $? -eq 1 ] then yum install vsftpd -y &> /tmp/vsftp_install if [ $? -eq 0 ] then echo "vsftpd安装成功" else echo "vsftpd安装失败,请查看/tmp/vsftp_install" fi read -p "是否关闭匿名用户登陆,默认以开启:" anonymous anonymous_enable(){ sed -i 's/anonymous_enable=YES/anonymous_enable=NO $vsftpd } case $anonymous in no) anonymous_enable echo "匿名用户以关闭" ;; NO) anonymous_enable echo "匿名用户以关闭" ;; yes) echo "错误,匿名用户默认以开启" ;; YES) echo "错误,匿名用户默认以开启" ;; *) echo "输入错误,请输入yes/no" ;; esac read -p "是否关闭本地用户登陆,默认以开启:" local local_enable(){ sed -i 's/local_enable=YES/local_enable=NO $vsftpd } case $local in no) local_enable echo "本地用户登陆以关闭" NO) local_enable echo "本地用户登陆以关闭" ;; yes) echo "错误,本地用户登陆默认以开启" ;; YES) echo "错误,本地用户登陆默认以开启" ;; *) echo "输入错误,请输入yes/no" ;; esac read -p "是否关闭本地用户写权限,默认以开启:" write write_enable(){ sed -i s/write_enable=YES/write_enable=NO/ $vsftpd } case $write in no) write_enable echo "本地用户写权限以关闭" NO) write_enable echo "本地用户写权限以关闭" ;; yes) echo "错误,本地用户写权限开启" ;; YES) echo "错误,本地用户可写以开启" ;; *) echo "输入错误,请输入yes/no" ;; esac read -p "请输入本地用户上传文件的umask:" umask local_umask(){ sed -i s/local_umask=022/local_umask=$umask/ $vsftpd } if [ -z "$umask && echo $umask |grep -E "[0-9]" if [ $? -eq 0] then local_umask echo "本地用户上传文件的umask以修改为:$umask" else echo "错误,请输入正确的umask" fi anon_upload_enable(){ sed -i s/#anon_upload_enable=YES/anon_upload_enable=YES/ $vsftpd } read -p "是否开启匿名用户上传权限,默认关闭:" anon_upload case $anon_upload in no) echo "错误,匿名用户上传权限默认以关闭" NO) echo "错误,匿名用户上传权限默认以关闭" ;; yes) anon_upload_enable echo "匿名用户上传权限以开启" ;; YES) echo "匿名用户上传权限以开启" ;; *) echo "输入错误,请输入yes/no" ;; esac -------------------------------------