zoukankan      html  css  js  c++  java
  • Centos 6.4上面用Shell脚本一键安装vsftpd

    Centos 6.4上面用Shell脚本一键安装vsftpd

    install.sh

    #!/bin/bash
    
    if [ `uname -m` == "x86_64" ];then
    machine=x86_64
    else
    machine=i686
    fi
    ifrpm=$(cat /proc/version | grep -E "redhat|centos")
    ifdpkg=$(cat /proc/version | grep -Ei "ubuntu|debian")
    ifcentos=$(cat /proc/version | grep centos)
    
    if [ "$ifrpm" != "" ];then
        yum -y install vsftpd
        cp -f ./config-ftp/rpm_ftp/* /etc/vsftpd/
    else
        apt-get -y install vsftpd
        if cat /etc/shells | grep /sbin/nologin ;then
            echo ""
        else
            echo /sbin/nologin >> /etc/shells
        fi
        cp -fR ./config-ftp/apt_ftp/* /etc/
    fi
    
    if [ ! -f '/etc/vsftpd' ];then
         mkdir -p /etc/vsftpd
    fi
    
    if [ "$ifcentos" != "" ] && [ "$machine" == "i686" ];then
        rm -rf /etc/vsftpd/vsftpd.conf
        cp -f ./config-ftp/vsftpdcentosi686.conf /etc/vsftpd/vsftpd.conf
    fi
    
    
    if [ ! -f '/storage/vsftpd' ];then
         mkdir -p /storage/vsftpd
    fi
    
    result="`grep '^vsftpd' /etc/passwd | wc -l`"
     
    
    if [ "$result" == "0" ];then
         
        groupadd vsftpd
         
        useradd -g vsftpd -s /sbin/nologin vsftpd
    fi
    
    /etc/init.d/vsftpd start
    
    chown -R vsftpd:vsftpd /storage/vsftpd
    
    #bug kill: '500 OOPS: vsftpd: refusing to run with writable root inside chroot()'
    chmod a-w /storage/vsftpd
    
    MATRIX="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
    LENGTH="9"
    while [ "${n:=1}" -le "$LENGTH" ]
    do
        PASS="$PASS${MATRIX:$(($RANDOM%${#MATRIX})):1}"
        let n+=1
    done
    if [ "$ifrpm" != "" ];then
    echo $PASS | passwd --stdin vsftpd
    else
    echo "vsftpd:$PASS" | chpasswd
    fi
    
    sed -i s/'ftp_password'/${PASS}/g account.log

    完整脚本下载:http://pan.baidu.com/s/1o6E15oA

  • 相关阅读:
    07周总结
    06周总结
    05周总结
    04周总结
    03周总结
    02周总结
    python数据特征预处理
    LeetCode Hard: 23. Merge k Sorted Lists
    LeetCode Hard: 4. Median of Two Sorted Arrays
    LeetCode Medium: 49. Group Anagrams
  • 原文地址:https://www.cnblogs.com/mjorcen/p/3788346.html
Copyright © 2011-2022 走看看