2025-06-22 00:39:52 +08:00

54 lines
1.4 KiB
Bash
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
cur_path=$(cd $(dirname $0); pwd)
echo $cur_path
app_path=$(cd $cur_path/../../../; pwd)
ftp_path=$app_path/data/cache/hisData_tempMesure
echo $ftp_path
cd $cur_path
# 判断是否已安装vsftp
vsftpd -v
if [ $? -ne 0 ]; then
rpm -Uvh --force --nodeps *.rpm && systemctl start vsftpd && systemctl enable vsftpd
if [ $? -eq 0 ]; then
echo "vsftp installation successfully."
else
# 如果安装失败请手动安装然后根据脚本下面的步骤修改vsftp配置文件重启vsftp后再执行脚本。
echo "vsftp installation failed."
exit
fi
# 修改vsftp配置文件
config=/etc/vsftpd/vsftpd.conf
cp $config $config.bak
sed -i 's/anonymous_enable=YES/anonymous_enable=NO/g' $config
sed -i 's/local_enable=NO/local_enable=YES/g' $config
sed -i 's/write_enable=NO/write_enable=YES/g' $config
sed -i 's/listen=NO/listen=YES/g' $config
sed -i 's/listen_ipv6=YES/listen_ipv6=NO/g' $config
sed -i 's/userlist_enable=YES/userlist_enable=NO/g' $config
sed -i "\$alocal_root=$ftp_path" $config
else
echo "vsftp already installed"
fi
# 判断ftp目录是否存在
if [ ! -d $ftp_path ]; then
echo "ftp目录不存在创建对应目录: "
mkdir -p $ftp_path
if [ $? -eq 0 ]; then
echo "ceated successfully."
echo
else
echo "create failed."
echo
fi
else
echo "directory already exists."
fi