Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can u make the bash scripts for Debien/Ubuntu? #3

Open
prprshooter opened this issue May 2, 2018 · 5 comments
Open

can u make the bash scripts for Debien/Ubuntu? #3

prprshooter opened this issue May 2, 2018 · 5 comments

Comments

@prprshooter
Copy link

No description provided.

@AlphaBrock
Copy link

AlphaBrock commented May 2, 2018

here you are,it work for CentOS 7, Debian8/9, Ubuntu14.04+

#!/usr/bin/env bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
#=================================================================#
#   System Required:  CentOS 7, Debian8/9, Ubuntu14.04+           #
#   Description: One click Install PUBG-Radar                     #
#   Author: AlphaBrock <[email protected]>                  #
#   Thanks: @794959818 <https://github.com/794959818/pubgradar>   #
#=================================================================#

clear
    echo "#######################################################################"
    echo "#                                                                     #"
    echo "# One click Install PUBG-Radar                                        #"
    echo "# Intro: https://github.com/794959818/pubgradar                       #"
    echo "# Author: AlphaBrock <[email protected]>                        #"
    echo "# Thanks: @794959818 <https://github.com/794959818/pubgradar>         #"
    echo "#                                                                     #"
    echo "#######################################################################"
    echo
    echo "Press any key to continue"
#Current folder
cur_dir=`pwd`

# Color
red='\033[0;31m'
green='\033[0;32m'
yellow='\033[0;33m'
plain='\033[0m'

# Make sure only root can run our script
[[ $EUID -ne 0 ]] && echo -e "[${red}Error:${plain}] 必须以ROOT权限运行!" && exit 1

# Disable selinux
disable_selinux(){
    if [ -s /etc/selinux/config ] && grep 'SELINUX=enforcing' /etc/selinux/config; then
        sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
        setenforce 0
    fi
}

#Check system
check_sys(){
    local checkType=$1
    local value=$2

    local release=''
    local systemPackage=''

    if [[ -f /etc/redhat-release ]]; then
        release="centos"
        systemPackage="yum"
    elif cat /etc/issue | grep -Eqi "debian"; then
        release="debian"
        systemPackage="apt"
    elif cat /etc/issue | grep -Eqi "ubuntu"; then
        release="ubuntu"
        systemPackage="apt"
    elif cat /etc/issue | grep -Eqi "centos|red hat|redhat"; then
        release="centos"
        systemPackage="yum"
    elif cat /proc/version | grep -Eqi "debian"; then
        release="debian"
        systemPackage="apt"
    elif cat /proc/version | grep -Eqi "ubuntu"; then
        release="ubuntu"
        systemPackage="apt"
    elif cat /proc/version | grep -Eqi "centos|red hat|redhat"; then
        release="centos"
        systemPackage="yum"
    fi

    if [[ ${checkType} == "sysRelease" ]]; then
        if [ "$value" == "$release" ]; then
            return 0
        else
            return 1
        fi
    elif [[ ${checkType} == "packageManager" ]]; then
        if [ "$value" == "$systemPackage" ]; then
            return 0
        else
            return 1
        fi
    fi
}

# Get version
getversion(){
    if [[ -s /etc/redhat-release ]]; then
        grep -oE  "[0-9.]+" /etc/redhat-release
    else
        grep -oE  "[0-9.]+" /etc/issue
    fi
}

# CentOS version
centosversion(){
    if check_sys sysRelease centos; then
        local code=$1
        local version="$(getversion)"
        local main_ver=${version%%.*}
        if [ "$main_ver" == "$code" ]; then
            return 0
        else
            return 1
        fi
    else
        return 1
    fi
}

get_char(){
    SAVEDSTTY=`stty -g`
    stty -echo
    stty cbreak
    dd if=/dev/tty bs=1 count=1 2> /dev/null
    stty -raw
    stty echo
    stty $SAVEDSTTY
}

install_shadowsocksr(){
    echo -e "${green}是否需要安装ss/ssr?${plain}[y/N]" && echo
	stty erase '^H' && read -p "(默认: n):" unyn
	[[ -z ${unyn} ]] && echo && echo -e "${green}已取消...${plain}"
	if [[ ${unyn} == [Yy] ]]; then
    wget --no-check-certificate https://raw.githubusercontent.com/teddysun/shadowsocks_install/master/shadowsocksR.sh 
    chmod +x shadowsocksR.sh
    ./shadowsocksR.sh 2>&1 | tee shadowsocksR.log
	echo && echo -e "${green}ss/ssr安装完成 !${plain}" && echo
    read -p "回车后安装吃鸡雷达:"
	fi
}
# Pre-installation settings
pre_install(){
    if check_sys packageManager yum || check_sys packageManager apt; then
        # Not support CentOS 5
        if centosversion 5 || centosversion 6; then
            echo -e "$[{red}Error:${plain}] 脚本不支持 CentOS 5,请更换到 CentOS 7/Debian 8+/Ubuntu 14+ 再试一次."
            exit 1
        fi
    else
        echo -e "[${red}Error:${plain}] 你的系统不被脚本支持. 请更换到 CentOS/Debian/Ubuntu 再试一次."
        exit 1
    fi
    # Install necessary dependencies
    if check_sys packageManager yum; then
        yum -y update
        yum -y groupinstall 'Development Tools'
        yum install -y curl flex bison git net-tools
        yum install -y libpcap-devel
        curl --silent --location https://rpm.nodesource.com/setup_8.x | sudo bash -
        yum install -y nodejs
    elif check_sys packageManager apt; then
        apt-get -y update
        apt-get -y install build-essential
        apt-get -y install libpcap-dev flex bison git sudo curl
        curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
        apt-get install -y nodejs
    fi
    cd ${cur_dir}
}

# Firewall set
firewall_set(){
    echo -e "[${green}Info${plain}] firewall 开始设置..."
    if centosversion 6; then
        /etc/init.d/iptables status > /dev/null 2>&1
        if [ $? -eq 0 ]; then
            iptables -L -n | grep -i 20086 > /dev/null 2>&1
            if [ $? -ne 0 ]; then
                iptables -I INPUT -m state --state NEW -m tcp -p tcp --dport 20086 -j ACCEPT
                iptables -I INPUT -m state --state NEW -m udp -p udp --dport 20086 -j ACCEPT
                /etc/init.d/iptables save
                /etc/init.d/iptables restart
            else
                echo -e "[${green}Info${plain}] 20086已放行."
            fi
        else
            echo -e "[${yellow}Warning${plain}] iptables 似乎已关闭或者未安装."
        fi
    elif centosversion 7; then
        systemctl status firewalld > /dev/null 2>&1
        if [ $? -eq 0 ]; then
            firewall-cmd --permanent --zone=public --add-port=20086/tcp
            firewall-cmd --permanent --zone=public --add-port=20086/udp
            firewall-cmd --reload
        else
            echo -e "[${yellow}Warning${plain}] firewalld 似乎未运行或未安装."
        fi
    fi
    echo -e "[${green}Info${plain}] firewall 设置完成..."
}

# Install pubg radar
install_radar(){
    git clone https://github.com/794959818/pubgradar.git
    cd pubgradar
    npm i 
    # if check_sys packageManager yum; then
    #     npm i -g pino
    #     npm install -g forever
    # elif check_sys packageManager apt; then
        npm i -g pino
        npm install -g forever
    # fi
}

# start up pubg radar
start_radar(){
    cd ${cur_dir} && cd pubgradar
    ifconfig
    IP=$(ifconfig -a | grep inet | grep -v 127.0.0.1 | grep -v inet6 | awk '{print $2}' | tr -d "addrs:")
    read -p "请输入网卡名称: " eth
    echo -e "[${green}内网IP${plain}]:${IP}"
    read -p "请输入内网ip: " ip
    forever start index.js sniff $eth $ip | pino
    echo -e "[${green}访问地址${plain}]:${IP}:20086"
}

# Install pubg radar
install_pubgradar(){
    disable_selinux
    install_shadowsocksr
    pre_install
    firewall_set
    install_radar
    start_radar
}

# Initialization step
action=$1
[ -z $1 ] && action=install
case "$action" in
    install)
        ${action}_pubgradar
        ;;
    *)
        echo "Arguments error! [${action}]"
        echo "Usage: `basename $0` [install]"
        ;;
esac

@prprshooter
Copy link
Author

prprshooter commented May 2, 2018

it works!!但是内网ip到底要填什么...
app架在vps上用sstap连到服务器上
vps ifconfig如下:
`eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet ... netmask 255.255.255.255 broadcast ...
inet6 * prefixlen 64 scopeid 0x20
ether fa:16:3e:be:0c:96 txqueuelen 1000 (Ethernet)
RX packets 656041 bytes 513361441 (489.5 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 478328 bytes 215440067 (205.4 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10
loop txqueuelen 1 (Local Loopback)
RX packets 64 bytes 5440 (5.3 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 64 bytes 5440 (5.3 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
`
试过172.0.0.1 0.0.0.0 外网ip都不行

@AlphaBrock 假如dalao知道的话麻烦解答下咯

@AlphaBrock
Copy link

@prprshooter
脚本会自动获取内网IP,如果获取失败你到你的VPS/ECS控制台也能看到

@shinegod
Copy link

shinegod commented May 3, 2018

/root/pubgradar/backend/bunchstash.js:148
throw new Error(NumGUIDsInBunch + ' (NumGUIDsInBunch) > 2048')
^

Error: 1079804250 (NumGUIDsInBunch) > 2048
at Object._receiveUEGUIDBunch (/root/pubgradar/backend/bunchstash.js:148:13)
at Object._processRawBunch (/root/pubgradar/backend/bunchstash.js:90:12)
at Object.feedEvent (/root/pubgradar/backend/bunchstash.js:72:34)
at Cap. (/root/pubgradar/index.js:60:35)
at emitTwo (events.js:126:13)
at Cap.emit (events.js:214:7)
error: Forever detected script exited with code: 1
error: Script restart attempt #1
Scientific Chicken Dinner listening on http://localhost:20086

/root/pubgradar/backend/uebuffer.js:63
throw new utils.BufferNotEnoughError('UEBuffer is at end, cannot read more')
^
BufferNotEnoughError: UEBuffer is at end, cannot read more
at Object.readBit (/root/pubgradar/backend/uebuffer.js:63:13)
at Object.parseUEBunchPacket (/root/pubgradar/backend/packetparser.js:130:41)
at Object.parse (/root/pubgradar/backend/packetparser.js:205:23)
at Cap. (/root/pubgradar/index.js:57:29)
at emitTwo (events.js:126:13)
at Cap.emit (events.js:214:7)
error: Forever detected script exited with code: 1

@shinegod
Copy link

shinegod commented May 3, 2018

@AlphaBrock

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants