#!/bin/bash
Stack=$1
if [ "${Stack}" = "" ]; then
Stack="install"
else
Stack=$1
fi
install_vsftp()
{
rpm -q vsftpd
read -p "The FTP access directory(default:/home): " directory
if [ "${directory}" != "" ]; then
directorys="${directory}"
else
directorys="/home"
fi
yum -y install vsftpd
if [ "$?" -eq "0" ]; then
if [ -d ${directorys} ]; then
chmod -R 777 ${directorys}
fi
sed -i 's/^anonymous_enable=YES/anonymous_enable=NO/g' /etc/vsftpd/vsftpd.conf
sed -i 's/^#chroot_local_user=YES/chroot_local_user=YES/g' /etc/vsftpd/vsftpd.conf
sed -i 's/^#chroot_list_enable=YES/chroot_list_enable=YES/g' /etc/vsftpd/vsftpd.conf
chkconfig vsftpd on
service vsftpd restart
echo "The FTP directory:${directorys}"
else
echo "VSFTPD installation failed!"
fi
}
add_ftp()
{
read -p "The FTP access directory(Such as:/home): " directory
if [ "${directory}" != "" ]; then
directorys="${directory}"
else
directorys="/home"
fi
if [ -d ${directorys} ]; then
chmod -R 777 ${directorys}
fi
if [ -d ${directorys} ]; then
chmod -R 777 ${directorys}
fi
echo "The FTP directory:${directorys}"
}
case "${Stack}" in
install)
install_vsftp
;;
add)
add_ftp
;;
*)
esac
如果对您有帮助,请点赞关注,谢谢!!!