#!/bin/bash # Date:2018/11/29 # Author: linyaohong # BLOG: ************ # Qq:122123498 # Version:1.0 # User: Centos 7 export PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin # set color SRED="\E[41;5m" RED="\E[31m" GREEN="\E[32m" CEND="\E[0m" #set run_user and install dir and ver run_user="www" pureftpd_install_dir="/usr/local/pureftpd" pureftpd_ver="1.0.47" # Check you network status NET_NUM=`ping -c 4 www.baidu.com |awk '/packet loss/{print $6}' |sed -e 's/%//'` if [ -z "$NET_NUM" ] || [ $NET_NUM -ne 0 ];then echo "Please check your internet" exit 1 fi #install lsb_release yum -y install redhat-lsb # check_os CentOS_ver=$(lsb_release -sr | awk -F. '{print $1}') if [ ${CentOS_ver} != "7" ]; then echo "Error: You must be Centos7 to run this script" exit 1 fi THREAD=$(grep 'processor' /proc/cpuinfo | sort -u | wc -l) # Check if user is root #[ $(id -u) != "0" ] && { echo "Error: You must be root to run this script"; exit 1; } if [ $(id -u) != "0" ]; then echo "Error: You must be root to run this script" exit 1 fi # Chenck if pure-ftpd install if [ $(rpm -qa|grep pure-ftpd|wc -l) != "0" ];then echo -e "${SRED}mpure-ftpd is exists ${CEND}" read -p "Do you want to uninstall pure-ftpd (y|n): " option case "${option}" in y|Y) rpm -e pure-ftpd ;; n|N) echo "The user opts out and does not uninstall" ;; *) echo "Please input y|n" esac fi # install pure_ftpd id -u ${run_user} >/dev/null 2>&1 [ $? -ne 0 ] && useradd -M -s /sbin/nologin ${run_user} wget http://106.14.199.213/sm/src/pure-ftpd-${pureftpd_ver}.tar.gz tar -zxvf pure-ftpd-${pureftpd_ver}.tar.gz cd pure-ftpd-${pureftpd_ver} [ ! -d "${pureftpd_install_dir}" ] && mkdir -p ${pureftpd_install_dir} ./configure --prefix=${pureftpd_install_dir} --with-puredb --with-quotas --with-cookie --with-virtualhosts --with-virtualchroot --with-diraliases --with-sysquotas --with-ratios --with-altlog --with-paranoidmsg --with-shadow --with-welcomemsg --with-throttling --with-uploadscript --with-language=english --with-rfc 2640 --with-tls make -j ${THREAD} && make install cat >/lib/systemd/system/pureftpd.service < ${pureftpd_install_dir}/etc/pure-ftpd.conf </dev/null 2>&1 if [ $? = "0" ];then firewall-cmd --permanent --zone=public --add-port=21/tcp >/dev/null 2>&1 firewall-cmd --permanent --zone=public --add-port=39000-40000/tcp >/dev/null 2>&1 firewall-cmd --reload >/dev/null 2>&1 echo -e "${GREEN}firewalld port open 21 and 39000-40000${CEND}" else echo -e "${SRED}your firewall is closed! Please open firewalld ${CEND}" echo -e "${RED}please open 21 and 39000-40000 port" echo -e "${GREEN}firewall-cmd --permanent --zone=public --add-port=21/tcp${CEND}" echo -e "${GREEN}firewall-cmd --permanent --zone=public --add-port=39000-40000/tcp${CEND}" echo -e "${GREEN}firewall-cmd --reload${CEND}" exit 1 fi