Compare commits

...

33 Commits

Author SHA1 Message Date
Stille e7cd9a21e9 update v0.58.0 2024-05-08 12:57:41 +08:00
Stille fed271b71e update v0.57.0 2024-04-09 12:03:35 +08:00
Stille 138bea6911 update v0.56.0 2024-03-22 12:34:36 +08:00
Stille a7cb5f1c51 update v0.55.1 2024-03-19 18:04:29 +08:00
Stille b69995f880
Merge pull request #19 from shenyunet/master
update for v0.54.0
2024-03-05 10:33:59 +08:00
shenyunet db451bea52 update 2024-03-03 01:38:50 +08:00
shenyunet 8340adca32 update toml 2024-03-03 01:01:08 +08:00
Stille 3679d0459f update v0.51.3 2023-08-17 09:11:47 +08:00
Stille d75e75a839 update v0.51.2 2023-07-26 09:18:48 +08:00
Stille d8907f2731 update v0.51.1 2023-07-21 09:15:36 +08:00
Stille 89a270fd12 update v0.51.0 2023-07-07 10:50:03 +08:00
Stille 03a352ad47 update v0.50.0 2023-06-26 17:19:34 +08:00
Stille 713b1560b3 update v0.49.0 2023-05-29 08:30:48 +08:00
Stille 39f8ccfba1
Merge pull request #15 from sinlov-opensource/master
👷 to support platform `linux/arm/v7`
2023-04-25 22:04:55 +08:00
sinlov 2a64e753bf
Update docker-build-release.yml
add latest to try support `linux/arm/v7`
2023-04-25 18:02:45 +08:00
sinlov 73c0009c16
Update frpc_linux_install.sh
to support arm
2023-04-25 17:56:25 +08:00
sinlov daf0c6f4c7
Update Dockerfile
to support armv7
2023-04-25 17:49:06 +08:00
sinlov 04a0aca2f1
Update docker-build-release.yml
to support platfomr `linux/arm/v7`
2023-04-25 17:22:14 +08:00
Stille 2d114b817c update v0.48.0 2023-03-08 13:37:10 +08:00
Stille c7cf598d4b update v0.47.0 2023-02-10 12:03:28 +08:00
Stille 1935ca8834 update v0.46.1 2023-01-10 10:47:22 +08:00
Stille 3fb28595e1 update v0.46.0 2022-12-19 16:47:07 +08:00
Stille 7d2ba8e906 update v0.45.0 2022-10-27 11:03:59 +08:00
Stille 543f3484d4 update v0.44.0 2022-07-11 10:24:04 +08:00
Stille 43222d9020 update v0.43.0 2022-05-27 17:57:43 +08:00
Stille 02da8f87fa update v0.42.0 2022-04-22 11:50:06 +08:00
Stille 21533a602c update v0.41.0 2022-03-24 09:37:54 +08:00
Stille 06531b63e1 update V0.40.0 2022-03-12 09:27:37 +08:00
Stille fff140270a optimize 2022-02-15 10:19:49 +08:00
Stille 1b1eb29e4f Update v0.39.1 2022-02-09 17:43:57 +08:00
Stille 40fbee9dfc Update v0.39.0 2022-02-09 00:00:30 +08:00
Stille 3e44dfb48f Update v0.38.0 2021-10-26 11:05:59 +08:00
Stille 494c3b0dfb Update v0.37.1 2021-08-04 21:25:42 +08:00
11 changed files with 380 additions and 201 deletions

View File

@ -1,40 +0,0 @@
name: "build for docker"
# on: [push]
on:
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set tag
id: tag
run: |
TAG=$(cat Dockerfile | awk 'NR==4 {print $3}')
echo "::set-env name=TAG::$TAG"
- name: Docker Hub login
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
run: |
echo "${DOCKER_PASSWORD}" | docker login --username ${DOCKER_USERNAME} --password-stdin
- name: Set up Docker Buildx
id: buildx
uses: crazy-max/ghaction-docker-buildx@v1
with:
buildx-version: latest
- name: Build Dockerfile
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
run: |
docker buildx build \
--platform=linux/amd64,linux/arm64 \
--output "type=image,push=true" \
--file ./Dockerfile . \
--tag $(echo "${DOCKER_USERNAME}" | tr '[:upper:]' '[:lower:]')/${{ github.event.repository.name }}:latest \
--tag $(echo "${DOCKER_USERNAME}" | tr '[:upper:]' '[:lower:]')/${{ github.event.repository.name }}:${TAG}

View File

@ -0,0 +1,72 @@
name: "docker build release"
on:
push:
workflow_dispatch:
env:
PROJECT: frpc
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2.3.5
- name: Set tag
id: tag
run: |
if [[ -n $(cat Dockerfile | awk '{if($1~"ENV" && $2=="VERSION")print $3}') ]]; then
VERSION=$(cat Dockerfile | awk '{if($1~"ENV" && $2=="VERSION")print $3}')
echo "tag=$VERSION" >> $GITHUB_ENV
else
echo "tag=$(date +%Y)-$(date +%m)-$(date +%d)" >> $GITHUB_ENV
fi
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push to docker hub
uses: docker/build-push-action@v2
with:
context: .
platforms: linux/amd64,linux/arm64,linux/arm/v7
push: true
tags: |
${{ secrets.DOCKER_USERNAME }}/${{ env.PROJECT }}:latest
${{ secrets.DOCKER_USERNAME }}/${{ env.PROJECT }}:${{ env.tag }}
- name: Sync README.md to Docker Hub
uses: ms-jpq/sync-dockerhub-readme@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
repository: ${{ secrets.DOCKER_USERNAME }}/${{ env.PROJECT }}
readme: "./README.md"
- name: Login harbor
uses: docker/login-action@v1
with:
registry: ${{ secrets.HARBOR_REGISTRY }}
username: ${{ secrets.HARBOR_USERNAME }}
password: ${{ secrets.HARBOR_PASSWORD }}
- name: Build and push to harbor
uses: docker/build-push-action@v2
with:
context: .
platforms: linux/amd64,linux/arm64,linux/arm/v7
push: true
tags: |
${{ secrets.HARBOR_REGISTRY }}/${{ secrets.HARBOR_USERNAME }}/${{ env.PROJECT }}:latest
${{ secrets.HARBOR_REGISTRY }}/${{ secrets.HARBOR_USERNAME }}/${{ env.PROJECT }}:${{ env.tag }}

View File

@ -1,25 +1,27 @@
FROM alpine:3.8
MAINTAINER Stille <stille@ioiox.com>
LABEL maintainer="Stille <stille@ioiox.com>"
ENV FRP_VERSION 0.37.0
ENV VERSION 0.58.0
ENV TZ=Asia/Shanghai
WORKDIR /
RUN set -xe && \
apk add tzdata && \
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
echo "Asia/Shanghai" > /etc/timezone && \
apk del tzdata
RUN apk add --no-cache tzdata \
&& ln -snf /usr/share/zoneinfo/${TZ} /etc/localtime \
&& echo ${TZ} > /etc/timezone
RUN set -x && \
if [ "$(uname -m)" = "x86_64" ]; then export PLATFORM=amd64 ; else if [ "$(uname -m)" = "aarch64" ]; then export PLATFORM=arm64 ; fi fi && \
wget --no-check-certificate https://github.com/fatedier/frp/releases/download/v${FRP_VERSION}/frp_${FRP_VERSION}_linux_${PLATFORM}.tar.gz && \
tar xzf frp_${FRP_VERSION}_linux_${PLATFORM}.tar.gz && \
cd frp_${FRP_VERSION}_linux_${PLATFORM} && \
mkdir /frp && \
mv frpc frpc.ini /frp && \
cd .. && \
rm -rf *.tar.gz frp_${FRP_VERSION}_linux_${PLATFORM}
RUN if [ "$(uname -m)" = "x86_64" ]; then export PLATFORM=amd64 ; \
elif [ "$(uname -m)" = "aarch64" ]; then export PLATFORM=arm64 ; \
elif [ "$(uname -m)" = "armv7" ]; then export PLATFORM=arm ; \
elif [ "$(uname -m)" = "armv7l" ]; then export PLATFORM=arm ; \
elif [ "$(uname -m)" = "armhf" ]; then export PLATFORM=arm ; fi \
&& wget --no-check-certificate https://github.com/fatedier/frp/releases/download/v${VERSION}/frp_${VERSION}_linux_${PLATFORM}.tar.gz \
&& tar xzf frp_${VERSION}_linux_${PLATFORM}.tar.gz \
&& cd frp_${VERSION}_linux_${PLATFORM} \
&& mkdir /frp \
&& mv frpc frpc.toml /frp \
&& cd .. \
&& rm -rf *.tar.gz frp_${VERSION}_linux_${PLATFORM}
VOLUME /frp
CMD /frp/frpc -c /frp/frpc.ini
CMD /frp/frpc -c /frp/frpc.toml

View File

@ -7,32 +7,42 @@
> *docker image support for X86 and ARM*
## 更新
**2021-05-31** 更新国内镜像方便使用
**2021-05-31** 目前 X86 群晖 DMS 7.0 可直接使用 Linux 版本脚本,已实测.由于没有 ARM 版可尝试,请自行尝试.
**2021-05-31** 更新 Linux 一键安装脚本同时支持 X86 和 ARM
**2021-05-29** 更新从`0.36.2`版本起 docker 镜像同时支持 X86 和 ARM
- **2024-03-03** 更新到新版本,支持 toml 配置文件.
- **2021-05-31** 更新国内镜像方便使用
- **2021-05-31** 目前 X86 群晖 DMS 7.0 可直接使用 Linux 版本脚本,已实测.由于没有 ARM 版可尝试,请自行尝试.
- **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
```
使用
```shell
vi /usr/local/frp/frpc.ini
# 修改 frpc.ini 配置
vi /usr/local/frp/frpc.toml
# 修改 frpc.toml 配置
sudo systemctl restart frpc
# 重启 frpc 服务即可生效
```
@ -40,45 +50,43 @@ 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 安装
为避免因 **frpc.ini** 文件的挂载,格式或者配置的错误导致容器无法正常运行并循环重启.请确保先配置好 **frpc.ini** 后在运行启动.
### 4. Linux 服务器 docker 安装
为避免因 **frpc.toml** 文件的挂载,格式或者配置的错误导致容器无法正常运行并循环重启.请确保先配置好 **frpc.toml** 后在运行启动.
**git clone** 本仓库,并正确配置 **frpc.ini** 文件.
**git clone** 本仓库,并正确配置 **frpc.toml** 文件.
```shell
git clone https://gitee.com/stilleshan/frpc.git
# git clone 本仓库 gitee 镜像
vi /root/frpc/frpc.ini
# 配置 frpc.ini 文件
git clone https://github.com/stilleshan/frpc
# git clone 本仓库镜像
git clone https://github.ioiox.com/stilleshan/frpc
# 国内镜像
vi /root/frpc/frpc.toml
# 配置 frpc.toml 文件
```
执行以下命令启动服务
```shell
docker run -d --name=frpc --restart=always -v /root/frpc/frpc.ini:/frp/frpc.ini stilleshan/frpc
docker run -d --name=frpc --restart=always -v /root/frpc/frpc.toml:/frp/frpc.toml stilleshan/frpc
```
> 以上命令 -v 挂载的目录是以 git clone 本仓库为例,也可以在任意位置手动创建 frpc.ini 文件,并修改命令中的挂载路径.
> 以上命令 -v 挂载的目录是以 git clone 本仓库为例,也可以在任意位置手动创建 frpc.toml 文件,并修改命令中的挂载路径.
服务运行中修改 **frpc.ini** 配置后需重启 **frpc** 服务.
服务运行中修改 **frpc.toml** 配置后需重启 **frpc** 服务.
```shell
vi /root/frp/frpc.ini
# 修改 frpc.ini 配置
vi /root/frp/frpc.toml
# 修改 frpc.toml 配置
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)
- [新手入门 - 详解 frp 内网穿透 frpc.ini 配置](https://www.ioiox.com/archives/79.html)
- [新手入门 - 详解 frp 内网穿透 frpc.toml 配置](https://www.ioiox.com/archives/79.html)

View File

@ -1,23 +0,0 @@
[common]
server_addr = frp.freefrp.net
server_port = 7000
token = freefrp.net
[web1_xxxxx]
type = http
local_ip = 192.168.1.2
local_port = 5000
custom_domains = yourdomain.com
[web2_xxxxx]
type = https
local_ip = 192.168.1.2
local_port = 5001
custom_domains = yourdomain.com
[tcp1_xxxxx]
type = tcp
local_ip = 192.168.1.2
local_port = 22
remote_port = 22222
custom_domains = yourdomain.com

25
frpc.toml Normal file
View File

@ -0,0 +1,25 @@
serverAddr = "frp.freefrp.net"
serverPort = 7000
auth.method = "token"
auth.token = "freefrp.net"
[[proxies]]
name = "web1_xxxxx"
type = "http"
localIP = "192.168.1.2"
localPort = 5000
customDomains = ["nas.yourdomain.com"]
[[proxies]]
name = "web2_xxxxx"
type = "https"
localIP = "192.168.1.2"
localPort = 5001
customDomains = ["nas.yourdomain.com"]
[[proxies]]
name = "tcp1_xxxxx"
type = "tcp"
localIP = "192.168.1.3"
localPort = 22
remotePort = 22222

126
frpc_linux_install.sh Normal file → Executable file
View File

@ -14,58 +14,115 @@ Font="\033[0m"
# variable
WORK_PATH=$(dirname $(readlink -f $0))
FRP_NAME=frpc
FRP_VERSION=0.37.0
FRP_VERSION=0.58.0
FRP_PATH=/usr/local/frp
PROXY_URL="https://mirror.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
if [ -f "/usr/local/frp/${FRP_NAME}" ] || [ -f "/usr/local/frp/${FRP_NAME}.ini" ] || [ -f "/lib/systemd/system/${FRP_NAME}.service" ];then
# check frpc
if [ -f "/usr/local/frp/${FRP_NAME}" ] || [ -f "/usr/local/frp/${FRP_NAME}.toml" ] || [ -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} ${Red}/usr/local/frp/${Font} ${Green}目录下的${Font} ${Red}${FRP_NAME}${Font} ${Green}${Font} ${Red}/${FRP_NAME}.toml${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 /usr/local/frp/${FRP_NAME}.toml${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
elif [ $(uname -m) = "aarch64" ]; then
PLATFORM=arm64
elif [ $(uname -m) = "armv7" ]; then
PLATFORM=arm
elif [ $(uname -m) = "armv7l" ]; then
PLATFORM=arm
elif [ $(uname -m) = "armhf" ]; then
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}
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}
cat >${FRP_PATH}/${FRP_NAME}.ini <<EOF
[common]
server_addr = frp.freefrp.net
server_port = 7000
token = freefrp.net
# configure frpc.toml
RADOM_NAME=$(cat /dev/urandom | head -n 10 | md5sum | head -c 8)
cat >${FRP_PATH}/${FRP_NAME}.toml<<EOF
serverAddr = "frp.freefrp.net"
serverPort = 7000
auth.method = "token"
auth.token = "freefrp.net"
[[proxies]]
name = "web1_${RADOM_NAME}"
type = "http"
localIP = "192.168.1.2"
localPort = 5000
customDomains = ["nas.yourdomain.com"]
[[proxies]]
name = "web2_${RADOM_NAME}"
type = "https"
localIP = "192.168.1.2"
localPort = 5001
customDomains = ["nas.yourdomain.com"]
[[proxies]]
name = "tcp1_${RADOM_NAME}"
type = "tcp"
localIP = "192.168.1.3"
localPort = 22
remotePort = 22222
[web1_${RANDOM}]
type = http
local_ip = 192.168.1.2
local_port = 5000
custom_domains = yourdomain${RANDOM}.com
EOF
# configure systemd
cat >/lib/systemd/system/${FRP_NAME}.service <<EOF
[Unit]
Description=Frp Server Service
@ -76,20 +133,23 @@ Wants=network.target
Type=simple
Restart=on-failure
RestartSec=5s
ExecStart=/usr/local/frp/${FRP_NAME} -c /usr/local/frp/${FRP_NAME}.ini
ExecStart=/usr/local/frp/${FRP_NAME} -c /usr/local/frp/${FRP_NAME}.toml
[Install]
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}"
echo -e "${Green}安装成功,请先修改 ${FRP_NAME}.ini 文件,确保格式及配置正确无误!${Font}"
echo -e "${Red}vi /usr/local/frp/${FRP_NAME}.ini${Font}"
echo -e "${Green}安装成功,请先修改 ${FRP_NAME}.toml 文件,确保格式及配置正确无误!${Font}"
echo -e "${Red}vi /usr/local/frp/${FRP_NAME}.toml${Font}"
echo -e "${Green}修改完毕后执行以下命令重启服务:${Font}"
echo -e "${Red}sudo systemctl restart ${FRP_NAME}${Font}"
echo -e "${Green}====================================================================${Font}"

3
frpc_linux_uninstall.sh Normal file → Executable file
View File

@ -14,11 +14,12 @@ Font="\033[0m"
# variable
WORK_PATH=$(dirname $(readlink -f $0))
FRP_NAME=frpc
FRP_VERSION=0.37.0
FRP_VERSION=0.58.0
FRP_PATH=/usr/local/frp
# 停止frpc
sudo systemctl stop ${FRP_NAME}
sudo systemctl disable ${FRP_NAME}
# 删除frpc
rm -rf ${FRP_PATH}
# 删除frpc.service

View File

@ -1,25 +0,0 @@
#!/bin/sh
FRP_VERSION="0.37.0"
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 "======================================================================"

129
frpc_synology_install.sh Normal file → Executable file
View File

@ -1,25 +1,108 @@
#!/bin/sh
FRP_VERSION="0.37.0"
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
# 完成安装,手动修改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 "======================================================================"
# 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.58.0
FRP_PATH=/usr/local/frp
PROXY_URL="https://mirror.ghproxy.com/"
# check frpc
if [ -f "/usr/local/frp/${FRP_NAME}" ] || [ -f "/usr/local/frp/${FRP_NAME}.toml" ] || [ -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}.toml${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}.toml${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.toml
RADOM_NAME=$(cat /dev/urandom | head -n 10 | md5sum | head -c 8)
cat >${FRP_PATH}/${FRP_NAME}.toml <<EOF
serverAddr = "frp.freefrp.net"
serverPort = 7000
auth.method = "token"
auth.token = "freefrp.net"
[[proxies]]
name = "web1_${RADOM_NAME}"
type = "http"
localIP = "192.168.1.2"
localPort = 5000
customDomains = ["nas.yourdomain.com"]
[[proxies]]
name = "web2_${RADOM_NAME}"
type = "https"
localIP = "192.168.1.2"
localPort = 5001
customDomains = ["nas.yourdomain.com"]
[[proxies]]
name = "tcp1_${RADOM_NAME}"
type = "tcp"
localIP = "192.168.1.3"
localPort = 22
remotePort = 22222
EOF
# clean
rm -rf ${WORK_PATH}/${FILE_NAME}.tar.gz ${WORK_PATH}/${FILE_NAME} ${FRP_NAME}_synology_install.sh
# 完成安装,手动修改frpc.toml并启动服务.
echo -e "${Green}=======================================================================${Font}"
echo -e "${Green}安装成功,请先修改 frpc.toml 文件,确保格式及配置正确无误!${Font}"
echo -e "${Red}vi /usr/local/frp/frpc.toml${Font}"
echo -e "${Green}修改完毕后执行以下命令启动服务并保持后台运行:${Font}"
echo -e "${Red}nohup /usr/local/frp/frpc -c /usr/local/frp/frpc.toml >/dev/null 2>&1 &${Font}"
echo -e "${Green}=======================================================================${Font}"

View File

@ -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}"