frp安装

#!/usr/bin/env bash 
__Author__="liy"

if [ $UID -ne 0 ];then
        echo -e "\033[31mUser root is required. The current user is $USER\033[0m"
        exit 127
fi 

tmp=`mktemp -d`
token="Password"
tcp_port="3007"
udp_port="3008"
dashboard_user="admin"
dashboard_pwd="Password"
download_url="https://github.com/fatedier/frp/releases/download/v0.37.1/frp_0.37.1_linux_amd64.tar.gz"

function init(){
        which wget &>/dev/null
        if [ $? -ne 0 ];then
                apt install wget -y
        fi
        set -x 
    wget $download_url -O /usr/local/src/frp.tar.gz
        set +x 
        if [ $? -ne 0 ];then
                echo -e "\033[31mfailed to download frp!\033[0m"
                exit 127
        fi
        set -x 
        # Create Wroker Directory.
        mkdir /var/log/frp /etc/frp/ -p
        tar -xvf /usr/local/src/frp.tar.gz -C $tmp
        set +x 
}

function install_frps(){
        set -x
        cp $tmp/frp*/frps /usr/bin/ && setcap cap_net_bind_service=+eip /usr/bin/frps 
        cp $tmp/frp*/frps.ini /etc/frp/frps.ini
        cp $tmp/frp*/systemd/frps.service /lib/systemd/system/
        set +x
        systemctl daemon-reload 
}

function writeConf(){
cat << EOF > /etc/frp/frps.ini
[common]
# Auth
token = $token

# Listen
bind_port = $tcp_port
bind_udp_port = $udp_port
bind_addr = 0.0.0.0

# http 
vhost_http_port = 80

# Darshboard
dashboard_port = 7500
dashboard_user = $dashboard_user
dashboard_pwd =  $dashboard_pwd

# Prometheus API
enable_prometheus = true 

# log 
log_file = /var/log/frps.log
log_level = warn
log_max_days = 15
disable_log_color = false 
detailed_errors_to_client = false
EOF
}


function main(){
        init
        install_frps
        writeConf
}

main
上一篇:Elasticsearch学习笔记3 -- 文档操作


下一篇:【硬刚ES】ES基础(三十六)处理并发读写操作