• SSR-Bash-Python


    脚本https://raw.githubusercontent.com/FunctionClub/SSR-Bash-Python/master/install.sh

    #!/bin/bash
    export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
    #Check Root
    [ $(id -u) != "0" ] && { echo "Error: You must be root to run this script"; exit 1; }
    #Check OS
    if [ -n "$(grep 'Aliyun Linux release' /etc/issue)" -o -e /etc/redhat-release ];then
        OS=CentOS
        [ -n "$(grep ' 7.' /etc/redhat-release)" ] && CentOS_RHEL_version=7
        [ -n "$(grep ' 6.' /etc/redhat-release)" -o -n "$(grep 'Aliyun Linux release6 15' /etc/issue)" ] && CentOS_RHEL_version=6
        [ -n "$(grep ' 5.' /etc/redhat-release)" -o -n "$(grep 'Aliyun Linux release5' /etc/issue)" ] && CentOS_RHEL_version=5
    elif [ -n "$(grep 'Amazon Linux AMI release' /etc/issue)" -o -e /etc/system-release ];then
        OS=CentOS
        CentOS_RHEL_version=6
    elif [ -n "$(grep bian /etc/issue)" -o "$(lsb_release -is 2>/dev/null)" == 'Debian' ];then
        OS=Debian
        [ ! -e "$(which lsb_release)" ] && { apt-get -y update; apt-get -y install lsb-release; clear; }
        Debian_version=$(lsb_release -sr | awk -F. '{print $1}')
    elif [ -n "$(grep Deepin /etc/issue)" -o "$(lsb_release -is 2>/dev/null)" == 'Deepin' ];then
        OS=Debian
        [ ! -e "$(which lsb_release)" ] && { apt-get -y update; apt-get -y install lsb-release; clear; }
        Debian_version=$(lsb_release -sr | awk -F. '{print $1}')
    elif [ -n "$(grep Ubuntu /etc/issue)" -o "$(lsb_release -is 2>/dev/null)" == 'Ubuntu' -o -n "$(grep 'Linux Mint' /etc/issue)" ];then
        OS=Ubuntu
        [ ! -e "$(which lsb_release)" ] && { apt-get -y update; apt-get -y install lsb-release; clear; }
        Ubuntu_version=$(lsb_release -sr | awk -F. '{print $1}')
        [ -n "$(grep 'Linux Mint 18' /etc/issue)" ] && Ubuntu_version=16
    else
        echo "Does not support this OS, Please contact the author! "
        kill -9 $$
    fi
    
    
    #Install Basic Tools
    if [[ ${OS} == Ubuntu ]];then
        apt-get update
        apt-get install python -y
        apt-get install python-pip -y
        apt-get install git unzip wget -y
        apt-get install language-pack-zh-hans -y
        apt-get install build-essential screen curl -y
    fi
    if [[ ${OS} == CentOS ]];then
        yum install python screen curl -y
        yum install python-setuptools -y && easy_install pip -y
        yum install git unzip wget -y
        yum groupinstall "Development Tools" -y
    fi
    if [[ ${OS} == Debian ]];then
        apt-get update
        apt-get install python screen curl -y
        apt-get install python-pip -y
        apt-get install git unzip wget -y
        apt-get install build-essential -y
    fi
    
    #Install SSR and SSR-Bash
    cd /usr/local/
    git clone https://github.com/FunctionClub/SSR-Bash-Python
    cp SSR-Bash-Python/shadowsocksr.zip /usr/local/shadowsocksr.zip
    chmod -R 777 /usr/local/SSR-Bash-Python/
    cd /usr/local/shadowsocksr
    unzip shadowsocksr.zip
    cd /usr/local/shadowsocksr
    chmod -R 777 *
    bash initcfg.sh
    
    #Install Libsodium
    cd /usr/local/SSR-Bash-Python/
    export LIBSODIUM_VER=1.0.11
    tar xvf libsodium-$LIBSODIUM_VER.tar.gz
    pushd libsodium-$LIBSODIUM_VER
    ./configure --prefix=/usr && make
    make install
    popd
    ldconfig
    cd /usr/local/SSR-Bash-Python/ && rm -rf libsodium-$LIBSODIUM_VER.tar.gz libsodium-$LIBSODIUM_VER
    
    #Start when boot
    if [[ ${OS} == Ubuntu || ${OS} == Debian ]];then
        cat >/etc/init.d/ssr-bash-python <<EOF
    #!/bin/sh
    ### BEGIN INIT INFO
    # Provides:          SSR-Bash_python
    # Required-Start: $local_fs $remote_fs
    # Required-Stop: $local_fs $remote_fs
    # Should-Start: $network
    # Should-Stop: $network
    # Default-Start:        2 3 4 5
    # Default-Stop:         0 1 6
    # Short-Description: SSR-Bash-Python
    # Description: SSR-Bash-Python
    ### END INIT INFO
    iptables-restore < /etc/iptables.up.rules
    bash /usr/local/shadowsocksr/logrun.sh
    EOF
        chmod 755 /etc/init.d/ssr-bash-python
        chmod +x /etc/init.d/ssr-bash-python
        cd /etc/init.d
        update-rc.d ssr-bash-python defaults 95
    fi
    
    if [[ ${OS} == CentOS ]];then
        echo "
    iptables-restore < /etc/iptables.up.rules
    bash /usr/local/shadowsocksr/logrun.sh
    " > /etc/rc.d/init.d/ssr-bash-python
        chmod +x  /etc/rc.d/init.d/ssr-bash-python
        echo "/etc/rc.d/init.d/ssr-bash-python" >> /etc/rc.d/rc.local
        chmod +x /etc/rc.d/rc.local
    fi
    
    
    #Change CentOS7 Firewall
    if [[ ${OS} == CentOS && $CentOS_RHEL_version == 7 ]];then
        systemctl stop firewalld.service
        systemctl disable firewalld.service
        yum install iptables-services -y
        cat << EOF > /etc/sysconfig/iptables
    # sample configuration for iptables service
    # you can edit this manually or use system-config-firewall
    # please do not ask us to add additional ports/services to this default configuration
    *filter
    :INPUT ACCEPT [0:0]
    :FORWARD ACCEPT [0:0]
    :OUTPUT ACCEPT [0:0]
    -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
    -A INPUT -p icmp -j ACCEPT
    -A INPUT -i lo -j ACCEPT
    -A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
    -A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
    -A INPUT -m state --state NEW -m tcp -p tcp --dport 443 -j ACCEPT
    -A INPUT -j REJECT --reject-with icmp-host-prohibited
    -A FORWARD -j REJECT --reject-with icmp-host-prohibited
    COMMIT
    EOF
    systemctl restart iptables.service
    systemctl enable iptables.service
    fi
    
    #Install SSR-Bash Background
    cp /usr/local/SSR-Bash-Python/ssr /usr/local/bin/ssr
    chmod +x /usr/local/bin/ssr
    
    #Modify ShadowsocksR API
    sed -i "s/sspanelv2/mudbjson/g" /usr/local/shadowsocksr/userapiconfig.py
    sed -i "s/UPDATE_TIME = 60/UPDATE_TIME = 10/g" /usr/local/shadowsocksr/userapiconfig.py
    sed -i "s/SERVER_PUB_ADDR = '127.0.0.1'/SERVER_PUB_ADDR = '$(wget -qO- -t1 -T2 ipinfo.io/ip)'/" /usr/local/shadowsocksr/userapiconfig.py
    #INstall Success
    bash /usr/local/SSR-Bash-Python/self-check.sh
    echo '安装完成!输入 ssr 即可使用本程序~'
    echo 'Telegram Group: https://t.me/functionclub'
    echo 'Google Puls: https://plus.google.com/communities/113154644036958487268'
    echo 'Github: https://github.com/FunctionClub'
    echo 'QQ Group:277717865'
    
    echo '祝破瓦一切安好。'
  • 相关阅读:
    Glide优化
    Java多线程知识点
    Android知识点
    Gradle的一些技巧和遇到的问题
    Python用Django写restful api接口
    Python写爬虫爬妹子
    用最简单的例子说明设计模式(三)之责任链、建造者、适配器、代理模式、享元模式
    【Python】扫描指定文件夹下特定后缀的文件
    【Python】生成多级树结构的xml文件
    【转】【Linux】安装pyinstaller
  • 原文地址:https://www.cnblogs.com/xiangxisheng/p/7895018.html
Copyright © 2020-2023  润新知