#!/bin/bash

#文件传输协议

echo "========开始检测您是否为本地源还是网络源========"

aa=`ls /etc/yum.repos.d/ | wc -l `

if [[ $aa == 1 ]]

then

echo "当前为本地源"

touch /mnt/sr0

umount /dev/sr0

mount /dev/sr0 /mnt/sr0

else

echo "当前为网络源"

fi

sleep 3

echo "========开始安装部署ftp服务========"

yum clean all

yum -y install vsftpd

cp /etc/vsftpd/vsftpd.conf /etc/vsftpd/vsftpd.conf.bak

sleep 3

echo "========开启ftp服务========"

systemctl start vsftpd

sleep 3

echo "=======给ftp服务设置开机自启========"

systemctl enable vsftpd

sleep 3

echo "========开始创建上传下载的目录========"

mkdir /var/ftp/dir

chmod 777 /var/ftp/dir -R

cd /var/ftp/dir

read -p "已进入/var/ftp/dir目录输入您要创建的文件" aa

touch ${aa}

read -p "已创建文件,输入您创建的文件进行编辑添加" bb

vim ${bb}

sleep 3

echo "进入FTP{服务文件进行配置"

vim /etc/vsftpd/vsftpd.conf

sed -i '/#anon_upload_enable=YES/aanon_upload_enable=YES' /etc/vsftpd/vsftpd.conf

sed -i '/#anon_mkdir_write_enable=YES/aanon_mkdir_write_enable=YES' /etc/vsftpd/vsftpd.conf

sleep 3

echo "========开始重启FTP服务========"

systemctl restart vsftpd.service

sleep 3

echo "========开始把FTP设置为开启自启========"

systemctl enable vsftpd

sleep 3

echo "========查看ftp的服务状态========"

systemctl status vsftpd

sleep 3

echo "========查看ftp的进程========"

ps -ef |grep vsftpd | grep -v grep

sleep 3

echo "查看FTP端口号是否开启成功========"

netstat -antpul | grep 21

sleep 3

echo "========查看端口========"

lsof -i:21

sleep 3

echo "FTP服务段配置完毕!"