加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
pureftpd.sh 5.13 KB
一键复制 编辑 原始数据 按行查看 历史
谭宁宁 提交于 2019-04-08 21:26 . update PATH
#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/home/work/env/bin:/home/work/env/sbin:~/bin
export PATH
# Check if user is root
if [ $(id -u) != "0" ]; then
echo "Error: You must be root to run this script!"
exit 1
fi
clear
echo "+----------------------------------------------------------+"
echo "| Pureftpd for LNMP, Written by Licess |"
echo "+----------------------------------------------------------+"
echo "|This script is a tool to install pureftpd for LNMP |"
echo "+----------------------------------------------------------+"
echo "|For more information please visit https://lnmp.org |"
echo "+----------------------------------------------------------+"
echo "|Usage: ./pureftpd.sh |"
echo "+----------------------------------------------------------+"
cur_dir=$(pwd)
action=$1
. lnmp.conf
. include/main.sh
. include/init.sh
Get_Dist_Name
Install_Pureftpd()
{
Press_Install
Echo_Blue "Installing dependent packages..."
if [ "$PM" = "yum" ]; then
for packages in make gcc gcc-c++ gcc-g77 openssl openssl-devel bzip2;
do yum -y install $packages; done
elif [ "$PM" = "apt" ]; then
apt-get update -y
for packages in build-essential gcc g++ make openssl libssl-dev bzip2;
do apt-get --no-install-recommends install -y $packages; done
fi
Echo_Blue "Download files..."
cd ${cur_dir}/src
Download_Files ${Download_Mirror}/ftp/pure-ftpd/${Pureftpd_Ver}.tar.bz2 ${Pureftpd_Ver}.tar.bz2
if [ $? -eq 0 ]; then
echo "Download ${Pureftpd_Ver}.tar.bz2 successfully!"
else
Download_Files https://download.pureftpd.org/pub/pure-ftpd/releases/${Pureftpd_Ver}.tar.bz2 ${Pureftpd_Ver}.tar.bz2
fi
Echo_Blue "Installing pure-ftpd..."
Tarj_Cd ${Pureftpd_Ver}.tar.bz2 ${Pureftpd_Ver}
./configure --prefix=/home/work/env/pureftpd CFLAGS=-O2 --with-puredb --with-quotas --with-cookie --with-virtualhosts --with-diraliases --with-sysquotas --with-ratios --with-altlog --with-paranoidmsg --with-shadow --with-welcomemsg --with-throttling --with-uploadscript --with-language=english --with-rfc2640 --with-ftpwho --with-tls
Make_Install
Echo_Blue "Copy configure files..."
mkdir /home/work/env/pureftpd/etc
\cp ${cur_dir}/conf/pure-ftpd.conf /home/work/env/pureftpd/etc/pure-ftpd.conf
if [ -L /etc/init.d/pureftpd ]; then
rm -f /etc/init.d/pureftpd
fi
\cp ${cur_dir}/init.d/init.d.pureftpd /etc/init.d/pureftpd
chmod +x /etc/init.d/pureftpd
touch /home/work/env/pureftpd/etc/pureftpd.passwd
touch /home/work/env/pureftpd/etc/pureftpd.pdb
StartUp pureftpd
cd ..
rm -rf ${cur_dir}/src/${Pureftpd_Ver}
if command -v iptables >/dev/null 2>&1; then
if [ -s /bin/lnmp ]; then
iptables -I INPUT 7 -p tcp --dport 20 -j ACCEPT
iptables -I INPUT 8 -p tcp --dport 21 -j ACCEPT
iptables -I INPUT 9 -p tcp --dport 20000:30000 -j ACCEPT
else
iptables -I INPUT -p tcp --dport 20 -j ACCEPT
iptables -I INPUT -p tcp --dport 21 -j ACCEPT
iptables -I INPUT -p tcp --dport 20000:30000 -j ACCEPT
fi
if [ "${PM}" = "yum" ]; then
service iptables save
service iptables reload
elif [ "${PM}" = "apt" ]; then
if [ -s /etc/init.d/netfilter-persistent ]; then
/etc/init.d/netfilter-persistent save
/etc/init.d/netfilter-persistent reload
else
/etc/init.d/iptables-persistent save
/etc/init.d/iptables-persistent reload
fi
fi
fi
if [ ! -s /bin/lnmp ]; then
\cp ${cur_dir}/conf/lnmp /bin/lnmp
chmod +x /bin/lnmp
fi
id -u work
if [ $? -ne 0 ]; then
groupadd work
useradd -s /sbin/nologin -g work work
fi
if [[ -s /home/work/env/pureftpd/sbin/pure-ftpd && -s /home/work/env/pureftpd/etc/pure-ftpd.conf && -s /etc/init.d/pureftpd ]]; then
Echo_Blue "Starting pureftpd..."
/etc/init.d/pureftpd start
Echo_Green "+----------------------------------------------------------------------+"
Echo_Green "| Install Pure-FTPd completed,enjoy it!"
Echo_Green "| =>use command: lnmp ftp {add|list|del|show} to manage FTP users."
Echo_Green "+----------------------------------------------------------------------+"
Echo_Green "| For more information please visit https://lnmp.org"
Echo_Green "+----------------------------------------------------------------------+"
else
Echo_Red "Pureftpd install failed!"
fi
}
Uninstall_Pureftpd()
{
if [ ! -f /home/work/env/pureftpd/sbin/pure-ftpd ]; then
Echo_Red "Pureftpd was not installed!"
exit 1
fi
echo "Stop pureftpd..."
/etc/init.d/pureftpd stop
echo "Remove service..."
Remove_StartUp pureftpd
echo "Delete files..."
rm -f /etc/init.d/pureftpd
rm -rf /home/work/env/pureftpd
echo "Pureftpd uninstall completed."
}
if [ "${action}" = "uninstall" ]; then
Uninstall_Pureftpd
else
Install_Pureftpd 2>&1 | tee /root/pureftpd-install.log
fi
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化