mirror of https://github.com/stilleshan/frpc.git
optimize
This commit is contained in:
parent
1b1eb29e4f
commit
fff140270a
49
README.md
49
README.md
|
@ -12,21 +12,30 @@
|
|||
**2021-05-31** 更新 Linux 一键安装脚本同时支持 X86 和 ARM
|
||||
**2021-05-29** 更新从`0.36.2`版本起 docker 镜像同时支持 X86 和 ARM
|
||||
|
||||
## 使用说明
|
||||
## 使用
|
||||
以下分为四种部署方法,请根据实际情况自行选择:
|
||||
- 群晖 NAS docker 安装 **[支持 docker 的群晖机型首选]** [点击查看教程](https://www.ioiox.com/archives/26.html)
|
||||
- 群晖 NAS 一键脚本安装 **[不支持 docker 的群晖机型]** [点击查看教程](https://www.ioiox.com/archives/6.html)
|
||||
- Linux 服务器 一键脚本安装 **[内网 Linux 服务器或虚拟机]**
|
||||
- Linux 服务器 docker 安装 **[内网 Linux 服务器或虚拟机]**
|
||||
|
||||
### Linux 服务器 一键脚本安装
|
||||
1. 群晖 NAS docker 安装 **[支持 docker 的群晖机型首选]**
|
||||
2. 群晖 NAS 一键脚本安装 **[不支持 docker 的群晖机型]**
|
||||
3. Linux 服务器 一键脚本安装 **[内网 Linux 服务器或虚拟机]**
|
||||
4. Linux 服务器 docker 安装 **[内网 Linux 服务器或虚拟机]**
|
||||
|
||||
---
|
||||
|
||||
### 1. 群晖 NAS docker 安装 **[支持 docker 的群晖机型首选]**
|
||||
[详情点击查看教程](https://www.ioiox.com/archives/26.html)
|
||||
|
||||
### 2. 群晖 NAS 一键脚本安装 **[不支持 docker 的群晖机型]**
|
||||
[详情点击查看教程](https://www.ioiox.com/archives/6.html)
|
||||
|
||||
### 3. Linux 服务器 一键脚本安装
|
||||
> *本脚本目前同时支持 Linux X86 和 ARM 架构*
|
||||
|
||||
安装
|
||||
```shell
|
||||
wget https://raw.githubusercontent.com/stilleshan/frpc/master/frpc_linux_install.sh && chmod +x frpc_linux_install.sh && ./frpc_linux_install.sh
|
||||
# 国内 gitee 镜像
|
||||
wget https://gitee.com/stilleshan/frpc/raw/master/frpc_linux_install.sh && chmod +x frpc_linux_install.sh && ./frpc_linux_install.sh
|
||||
# 以下为国内镜像
|
||||
wget https://github.ioiox.com/stilleshan/frpc/raw/branch/master/frpc_linux_install.sh && chmod +x frpc_linux_install.sh && ./frpc_linux_install.sh
|
||||
```
|
||||
|
||||
使用
|
||||
|
@ -40,17 +49,19 @@ sudo systemctl restart frpc
|
|||
卸载
|
||||
```shell
|
||||
wget https://raw.githubusercontent.com/stilleshan/frpc/master/frpc_linux_uninstall.sh && chmod +x frpc_linux_uninstall.sh && ./frpc_linux_uninstall.sh
|
||||
# 国内 gitee 镜像
|
||||
wget https://gitee.com/stilleshan/frpc/raw/master/frpc_linux_uninstall.sh && chmod +x frpc_linux_uninstall.sh && ./frpc_linux_uninstall.sh
|
||||
# 以下为国内镜像
|
||||
wget https://github.ioiox.com/stilleshan/frpc/raw/branch/master/frpc_linux_uninstall.sh && chmod +x frpc_linux_uninstall.sh && ./frpc_linux_uninstall.sh
|
||||
```
|
||||
|
||||
### Linux 服务器 docker 安装
|
||||
### 4. Linux 服务器 docker 安装
|
||||
为避免因 **frpc.ini** 文件的挂载,格式或者配置的错误导致容器无法正常运行并循环重启.请确保先配置好 **frpc.ini** 后在运行启动.
|
||||
|
||||
先 **git clone** 本仓库,并正确配置 **frpc.ini** 文件.
|
||||
**git clone** 本仓库,并正确配置 **frpc.ini** 文件.
|
||||
```shell
|
||||
git clone https://gitee.com/stilleshan/frpc.git
|
||||
# git clone 本仓库 gitee 镜像
|
||||
git clone https://github.com/stilleshan/frpc
|
||||
# git clone 本仓库镜像
|
||||
git clone https://github.ioiox.com/stilleshan/frpc
|
||||
# 国内镜像
|
||||
vi /root/frpc/frpc.ini
|
||||
# 配置 frpc.ini 文件
|
||||
```
|
||||
|
@ -69,15 +80,11 @@ docker restart frpc
|
|||
# 重启 frpc 容器即可生效
|
||||
```
|
||||
|
||||
## 版本更新
|
||||
- latest 为最新版
|
||||
- Tags 为历史版本
|
||||
|
||||
## 相关链接
|
||||
更多frp相关信息可参考我的博客
|
||||
## 链接
|
||||
- Blog [www.ioiox.com](https://www.ioiox.com)
|
||||
- GitHub [stilleshan/frpc](https://github.com/stilleshan/frpc)
|
||||
- Docker [stilleshan/frpc](https://hub.docker.com/r/stilleshan/frpc)
|
||||
- Docker Hub [stilleshan/frpc](https://hub.docker.com/r/stilleshan/frpc)
|
||||
- Docker [docker.ioiox.com](https://docker.ioiox.com)
|
||||
- 原版frp项目 [fatedier/frp](https://github.com/fatedier/frp)
|
||||
- [群晖NAS使用Docker安装配置frpc内网穿透教程](https://www.ioiox.com/archives/26.html)
|
||||
- [群晖NAS安装配置免费frp内网穿透教程](https://www.ioiox.com/archives/6.html)
|
||||
|
|
|
@ -16,18 +16,9 @@ WORK_PATH=$(dirname $(readlink -f $0))
|
|||
FRP_NAME=frpc
|
||||
FRP_VERSION=0.39.1
|
||||
FRP_PATH=/usr/local/frp
|
||||
PROXY_URL="https://ghproxy.com/"
|
||||
|
||||
if [ $(uname -m) = "x86_64" ]; then
|
||||
export PLATFORM=amd64
|
||||
else if [ $(uname -m) = "aarch64" ]; then
|
||||
export PLATFORM=arm64
|
||||
fi
|
||||
fi
|
||||
|
||||
FILE_NAME=frp_${FRP_VERSION}_linux_${PLATFORM}
|
||||
|
||||
|
||||
# 判断是否安装 frpc
|
||||
# check frpc
|
||||
if [ -f "/usr/local/frp/${FRP_NAME}" ] || [ -f "/usr/local/frp/${FRP_NAME}.ini" ] || [ -f "/lib/systemd/system/${FRP_NAME}.service" ];then
|
||||
echo -e "${Green}=========================================================================${Font}"
|
||||
echo -e "${RedBG}当前已退出脚本.${Font}"
|
||||
|
@ -38,21 +29,65 @@ if [ -f "/usr/local/frp/${FRP_NAME}" ] || [ -f "/usr/local/frp/${FRP_NAME}.ini"
|
|||
echo -e "${Red}rm -rf /usr/local/frp/${FRP_NAME}.ini${Font}"
|
||||
echo -e "${Red}rm -rf /lib/systemd/system/${FRP_NAME}.service${Font}"
|
||||
echo -e "${Green}=========================================================================${Font}"
|
||||
exit 2
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
||||
# 判断 frpc 进程并 kill
|
||||
while ! test -z "$(ps -A | grep -w ${FRP_NAME})"; do
|
||||
FRPCPID=$(ps -A | grep -w ${FRP_NAME} | awk 'NR==1 {print $1}')
|
||||
kill -9 $FRPCPID
|
||||
done
|
||||
|
||||
# check pkg
|
||||
if type apt-get >/dev/null 2>&1 ; then
|
||||
if ! type wget >/dev/null 2>&1 ; then
|
||||
apt-get install wget -y
|
||||
fi
|
||||
if ! type curl >/dev/null 2>&1 ; then
|
||||
apt-get install curl -y
|
||||
fi
|
||||
fi
|
||||
|
||||
if type yum >/dev/null 2>&1 ; then
|
||||
if ! type wget >/dev/null 2>&1 ; then
|
||||
yum install wget -y
|
||||
fi
|
||||
if ! type curl >/dev/null 2>&1 ; then
|
||||
yum install curl -y
|
||||
fi
|
||||
fi
|
||||
|
||||
# check network
|
||||
GOOGLE_HTTP_CODE=$(curl -o /dev/null --connect-timeout 5 --max-time 8 -s --head -w "%{http_code}" "https://www.google.com")
|
||||
PROXY_HTTP_CODE=$(curl -o /dev/null --connect-timeout 5 --max-time 8 -s --head -w "%{http_code}" "${PROXY_URL}")
|
||||
|
||||
# check arch
|
||||
if [ $(uname -m) = "x86_64" ]; then
|
||||
PLATFORM=amd64
|
||||
fi
|
||||
|
||||
if [ $(uname -m) = "aarch64" ]; then
|
||||
PLATFORM=arm64
|
||||
fi
|
||||
|
||||
FILE_NAME=frp_${FRP_VERSION}_linux_${PLATFORM}
|
||||
|
||||
# download
|
||||
if [ $GOOGLE_HTTP_CODE == "200" ]; then
|
||||
wget -P ${WORK_PATH} https://github.com/fatedier/frp/releases/download/v${FRP_VERSION}/${FILE_NAME}.tar.gz -O ${FILE_NAME}.tar.gz
|
||||
else
|
||||
if [ $PROXY_HTTP_CODE == "200" ]; then
|
||||
wget -P ${WORK_PATH} ${PROXY_URL}https://github.com/fatedier/frp/releases/download/v${FRP_VERSION}/${FILE_NAME}.tar.gz -O ${FILE_NAME}.tar.gz
|
||||
else
|
||||
echo -e "${Red}检测 GitHub Proxy 代理失效 开始使用官方地址下载${Font}"
|
||||
wget -P ${WORK_PATH} https://github.com/fatedier/frp/releases/download/v${FRP_VERSION}/${FILE_NAME}.tar.gz -O ${FILE_NAME}.tar.gz
|
||||
fi
|
||||
fi
|
||||
tar -zxvf ${FILE_NAME}.tar.gz
|
||||
|
||||
mkdir -p ${FRP_PATH}
|
||||
wget -P ${WORK_PATH} https://ghproxy.com/https://github.com/fatedier/frp/releases/download/v${FRP_VERSION}/${FILE_NAME}.tar.gz -O ${FILE_NAME}.tar.gz && \
|
||||
tar -zxvf ${FILE_NAME}.tar.gz && \
|
||||
mv ${FILE_NAME}/${FRP_NAME} ${FRP_PATH}
|
||||
|
||||
# configure frpc.ini
|
||||
cat >${FRP_PATH}/${FRP_NAME}.ini <<EOF
|
||||
[common]
|
||||
server_addr = frp.freefrp.net
|
||||
|
@ -66,6 +101,7 @@ local_port = 5000
|
|||
custom_domains = yourdomain${RANDOM}.com
|
||||
EOF
|
||||
|
||||
# configure systemd
|
||||
cat >/lib/systemd/system/${FRP_NAME}.service <<EOF
|
||||
[Unit]
|
||||
Description=Frp Server Service
|
||||
|
@ -82,9 +118,12 @@ ExecStart=/usr/local/frp/${FRP_NAME} -c /usr/local/frp/${FRP_NAME}.ini
|
|||
WantedBy=multi-user.target
|
||||
EOF
|
||||
|
||||
# finish install
|
||||
systemctl daemon-reload
|
||||
sudo systemctl start ${FRP_NAME}
|
||||
sudo systemctl enable ${FRP_NAME}
|
||||
|
||||
# clean
|
||||
rm -rf ${WORK_PATH}/${FILE_NAME}.tar.gz ${WORK_PATH}/${FILE_NAME} ${FRP_NAME}_linux_install.sh
|
||||
|
||||
echo -e "${Green}====================================================================${Font}"
|
||||
|
|
|
@ -19,6 +19,7 @@ FRP_PATH=/usr/local/frp
|
|||
|
||||
# 停止frpc
|
||||
sudo systemctl stop ${FRP_NAME}
|
||||
sudo systemctl disable ${FRP_NAME}
|
||||
# 删除frpc
|
||||
rm -rf ${FRP_PATH}
|
||||
# 删除frpc.service
|
||||
|
|
|
@ -1,25 +0,0 @@
|
|||
#!/bin/sh
|
||||
FRP_VERSION="0.39.1"
|
||||
REPO="stilleshan/frpc"
|
||||
WORK_PATH=$(dirname $(readlink -f $0))
|
||||
|
||||
# 创建frp文件夹
|
||||
mkdir -p /usr/local/frp && \
|
||||
# 下载并移动frpc文件
|
||||
wget -P ${WORK_PATH} https://github.com/fatedier/frp/releases/download/v${FRP_VERSION}/frp_${FRP_VERSION}_linux_arm.tar.gz && \
|
||||
tar -zxvf frp_${FRP_VERSION}_linux_arm.tar.gz && \
|
||||
cd frp_${FRP_VERSION}_linux_arm && \
|
||||
mv frpc /usr/local/frp && \
|
||||
# 下载frpc.in
|
||||
wget -P /usr/local/frp https://raw.githubusercontent.com/${REPO}/master/frpc.ini && \
|
||||
# 删除多余文件
|
||||
cd ${WORK_PATH} && \
|
||||
rm -rf frp_${FRP_VERSION}_linux_arm frp_${FRP_VERSION}_linux_arm.tar.gz && \
|
||||
rm -rf ${WORK_PATH}/frpc_synology_arm_install.sh
|
||||
# 完成安装,手动修改frpc.ini并启动服务.
|
||||
echo "======================================================================" &&\
|
||||
echo -e "\033[32m安装成功,请先修改 frpc.ini 文件,确保格式及配置正确无误!\033[0m" && \
|
||||
echo -e "\033[31mvi /usr/local/frp/frpc.ini \033[0m" && \
|
||||
echo -e "\033[32m修改完毕后执行以下命令启动服务并保持后台运行:\033[0m" && \
|
||||
echo -e "\033[31mnohup /usr/local/frp/frpc -c /usr/local/frp/frpc.ini >/dev/null 2>&1 & \033[0m" && \
|
||||
echo "======================================================================"
|
|
@ -1,25 +1,91 @@
|
|||
#!/bin/sh
|
||||
FRP_VERSION="0.39.1"
|
||||
REPO="stilleshan/frpc"
|
||||
WORK_PATH=$(dirname $(readlink -f $0))
|
||||
|
||||
# 创建frp文件夹
|
||||
mkdir -p /usr/local/frp && \
|
||||
# 下载并移动frpc文件
|
||||
wget -P ${WORK_PATH} https://github.com/fatedier/frp/releases/download/v${FRP_VERSION}/frp_${FRP_VERSION}_linux_amd64.tar.gz && \
|
||||
tar -zxvf frp_${FRP_VERSION}_linux_amd64.tar.gz && \
|
||||
cd frp_${FRP_VERSION}_linux_amd64 && \
|
||||
mv frpc /usr/local/frp && \
|
||||
# 下载frpc.in
|
||||
wget -P /usr/local/frp https://raw.githubusercontent.com/${REPO}/master/frpc.ini && \
|
||||
# 删除多余文件
|
||||
cd ${WORK_PATH} && \
|
||||
rm -rf frp_${FRP_VERSION}_linux_amd64 frp_${FRP_VERSION}_linux_amd64.tar.gz && \
|
||||
rm -rf ${WORK_PATH}/frpc_synology_install.sh
|
||||
# fonts color
|
||||
Green="\033[32m"
|
||||
Red="\033[31m"
|
||||
Yellow="\033[33m"
|
||||
GreenBG="\033[42;37m"
|
||||
RedBG="\033[41;37m"
|
||||
Font="\033[0m"
|
||||
# fonts color
|
||||
|
||||
# variable
|
||||
WORK_PATH=$(dirname $(readlink -f $0))
|
||||
FRP_NAME=frpc
|
||||
FRP_VERSION=0.39.1
|
||||
FRP_PATH=/usr/local/frp
|
||||
PROXY_URL="https://ghproxy.com/"
|
||||
|
||||
# check frpc
|
||||
if [ -f "/usr/local/frp/${FRP_NAME}" ] || [ -f "/usr/local/frp/${FRP_NAME}.ini" ] || [ -f "/lib/systemd/system/${FRP_NAME}.service" ];then
|
||||
echo -e "${Green}=========================================================================${Font}"
|
||||
echo -e "${RedBG}当前已退出脚本.${Font}"
|
||||
echo -e "${Green}检查到服务器已安装${Font} ${Red}${FRP_NAME}${Font}"
|
||||
echo -e "${Green}请手动确认和删除${Font} ${Red}/usr/local/frp/${Font} ${Green}目录下的${Font} ${Red}${FRP_NAME}${Font} ${Green}和${Font} ${Red}/${FRP_NAME}.ini${Font} ${Green}文件以及${Font} ${Red}/lib/systemd/system/${FRP_NAME}.service${Font} ${Green}文件,再次执行本脚本.${Font}"
|
||||
echo -e "${Green}参考命令如下:${Font}"
|
||||
echo -e "${Red}rm -rf /usr/local/frp/${FRP_NAME}${Font}"
|
||||
echo -e "${Red}rm -rf /usr/local/frp/${FRP_NAME}.ini${Font}"
|
||||
echo -e "${Red}rm -rf /lib/systemd/system/${FRP_NAME}.service${Font}"
|
||||
echo -e "${Green}=========================================================================${Font}"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
while ! test -z "$(ps -A | grep -w ${FRP_NAME})"; do
|
||||
FRPCPID=$(ps -A | grep -w ${FRP_NAME} | awk 'NR==1 {print $1}')
|
||||
kill -9 $FRPCPID
|
||||
done
|
||||
|
||||
# check network
|
||||
GOOGLE_HTTP_CODE=$(curl -o /dev/null --connect-timeout 5 --max-time 8 -s --head -w "%{http_code}" "https://www.google.com")
|
||||
PROXY_HTTP_CODE=$(curl -o /dev/null --connect-timeout 5 --max-time 8 -s --head -w "%{http_code}" "${PROXY_URL}")
|
||||
|
||||
# check arch
|
||||
if [ $(uname -m) = "x86_64" ]; then
|
||||
PLATFORM=amd64
|
||||
elif [ $(uname -m) = "aarch64" ]; then
|
||||
PLATFORM=arm64
|
||||
else
|
||||
PLATFORM=arm
|
||||
fi
|
||||
|
||||
FILE_NAME=frp_${FRP_VERSION}_linux_${PLATFORM}
|
||||
|
||||
# download
|
||||
if [ $GOOGLE_HTTP_CODE == "200" ]; then
|
||||
wget -P ${WORK_PATH} https://github.com/fatedier/frp/releases/download/v${FRP_VERSION}/${FILE_NAME}.tar.gz -O ${FILE_NAME}.tar.gz
|
||||
else
|
||||
if [ $PROXY_HTTP_CODE == "200" ]; then
|
||||
wget -P ${WORK_PATH} ${PROXY_URL}https://github.com/fatedier/frp/releases/download/v${FRP_VERSION}/${FILE_NAME}.tar.gz -O ${FILE_NAME}.tar.gz
|
||||
else
|
||||
echo -e "${Red}检测 GitHub Proxy 代理失效 开始使用官方下载地址下载${Font}"
|
||||
wget -P ${WORK_PATH} https://github.com/fatedier/frp/releases/download/v${FRP_VERSION}/${FILE_NAME}.tar.gz -O ${FILE_NAME}.tar.gz
|
||||
fi
|
||||
fi
|
||||
tar -zxvf ${FILE_NAME}.tar.gz
|
||||
mkdir -p ${FRP_PATH}
|
||||
mv ${FILE_NAME}/${FRP_NAME} ${FRP_PATH}
|
||||
|
||||
# configure frpc.ini
|
||||
cat >${FRP_PATH}/${FRP_NAME}.ini <<EOF
|
||||
[common]
|
||||
server_addr = frp.freefrp.net
|
||||
server_port = 7000
|
||||
token = freefrp.net
|
||||
|
||||
[web1_${RANDOM}]
|
||||
type = http
|
||||
local_ip = 192.168.1.2
|
||||
local_port = 5000
|
||||
custom_domains = yourdomain${RANDOM}.com
|
||||
EOF
|
||||
|
||||
# clean
|
||||
rm -rf ${WORK_PATH}/${FILE_NAME}.tar.gz ${WORK_PATH}/${FILE_NAME} ${FRP_NAME}_synology_install.sh
|
||||
|
||||
# 完成安装,手动修改frpc.ini并启动服务.
|
||||
echo "======================================================================" &&\
|
||||
echo -e "\033[32m安装成功,请先修改 frpc.ini 文件,确保格式及配置正确无误!\033[0m" && \
|
||||
echo -e "\033[31mvi /usr/local/frp/frpc.ini \033[0m" && \
|
||||
echo -e "\033[32m修改完毕后执行以下命令启动服务并保持后台运行:\033[0m" && \
|
||||
echo -e "\033[31mnohup /usr/local/frp/frpc -c /usr/local/frp/frpc.ini >/dev/null 2>&1 & \033[0m" && \
|
||||
echo "======================================================================"
|
||||
echo -e "${Green}=======================================================================${Font}"
|
||||
echo -e "${Green}安装成功,请先修改 frpc.ini 文件,确保格式及配置正确无误!${Font}"
|
||||
echo -e "${Red}vi /usr/local/frp/frpc.ini${Font}"
|
||||
echo -e "${Green}修改完毕后执行以下命令启动服务并保持后台运行:${Font}"
|
||||
echo -e "${Red}nohup /usr/local/frp/frpc -c /usr/local/frp/frpc.ini >/dev/null 2>&1 &${Font}"
|
||||
echo -e "${Green}=======================================================================${Font}"
|
||||
|
|
|
@ -1,8 +1,24 @@
|
|||
#!/bin/sh
|
||||
|
||||
# fonts color
|
||||
Green="\033[32m"
|
||||
Red="\033[31m"
|
||||
Yellow="\033[33m"
|
||||
GreenBG="\033[42;37m"
|
||||
RedBG="\033[41;37m"
|
||||
Font="\033[0m"
|
||||
# fonts color
|
||||
|
||||
while ! test -z "$(ps -A | grep -w ${FRP_NAME})"; do
|
||||
FRPCPID=$(ps -A | grep -w ${FRP_NAME} | awk 'NR==1 {print $1}')
|
||||
kill -9 $FRPCPID
|
||||
done
|
||||
|
||||
# 删除frp
|
||||
rm -rf /usr/local/frp && \
|
||||
# 删除本文件
|
||||
rm -rf frpc_synology_uninstall.sh
|
||||
echo "============================" &&\
|
||||
echo -e "\033[32m卸载成功,相关文件已清理完毕!\033[0m" && \
|
||||
echo "============================"
|
||||
|
||||
echo -e "${Green}============================${Font}"
|
||||
echo -e "${Green}卸载成功,相关文件已清理完毕!${Font}"
|
||||
echo -e "${Green}============================${Font}"
|
||||
|
|
Loading…
Reference in New Issue