Update optimize shell script for Linux X86 and ARM

This commit is contained in:
Stille 2021-05-31 14:51:40 +08:00
parent 1528d0de48
commit 09426798d0
3 changed files with 113 additions and 42 deletions

View File

@ -7,6 +7,8 @@
> *docker image support for X86 and ARM* > *docker image support for X86 and ARM*
## 更新 ## 更新
**2021-05-31** 更新国内镜像方便使用
**2021-05-31** 更新 Linux 一键安装脚本同时支持 X86 和 ARM
**2021-05-29** 更新从`0.36.2`版本起 docker 镜像同时支持 X86 和 ARM **2021-05-29** 更新从`0.36.2`版本起 docker 镜像同时支持 X86 和 ARM
## 使用说明 ## 使用说明
@ -16,6 +18,8 @@
安装 安装
```shell ```shell
wget https://raw.githubusercontent.com/stilleshan/frps/master/frps_linux_install.sh && chmod +x frps_linux_install.sh && ./frps_linux_install.sh wget https://raw.githubusercontent.com/stilleshan/frps/master/frps_linux_install.sh && chmod +x frps_linux_install.sh && ./frps_linux_install.sh
# 国内 gitee 镜像
wget https://gitee.com/stilleshan/frps/raw/master/frps_linux_install.sh && chmod +x frps_linux_install.sh && ./frps_linux_install.sh
``` ```
使用 使用
@ -29,28 +33,36 @@ sudo systemctl restart frps
卸载 卸载
```shell ```shell
wget https://raw.githubusercontent.com/stilleshan/frps/master/frps_linux_uninstall.sh && chmod +x frps_linux_uninstall.sh && ./frps_linux_uninstall.sh wget https://raw.githubusercontent.com/stilleshan/frps/master/frps_linux_uninstall.sh && chmod +x frps_linux_uninstall.sh && ./frps_linux_uninstall.sh
# 国内 gitee 镜像
wget https://gitee.com/stilleshan/frps/raw/master/frps_linux_uninstall.sh && chmod +x frps_linux_uninstall.sh && ./frps_linux_uninstall.sh
``` ```
### 自定义一键脚本(先 fork 本仓库,在自行修改 frps.ini 文件后运行脚本.) ### 自定义一键脚本(先 fork 本仓库,在自行修改 frps.ini 文件后运行脚本.)
> 同时支持 github 和 gitee 平台 fork
- 首先 fork 本仓库 - 首先 fork 本仓库
- 配置 frps.ini - 配置 frps.ini
- 修改 frps_linux_install.sh 脚本 - 修改 frps_linux_install.sh 脚本
- 修改脚本链接并运行 - 修改脚本链接并运行
#### 修改 frps_linux_install.sh 脚本 #### 修改 frps_linux_install.sh 脚本
`FRP_VERSION="0.30.0"` 可根据原版项目更新自行修改为最新版本 `FRP_VERSION="0.36.2"` 可根据原版项目更新自行修改为最新版本
`REPO="stilleshan/frps"` 由于 **fork** 到你自己的仓库,需修改`stilleshan`为你的GitHub账号ID. `REPO="stilleshan/frps"` 由于 **fork** 到你自己的仓库,需修改`stilleshan`为你的 GitHub 或 gitee 账号ID.
#### 运行一键脚本 #### 运行一键脚本
修改以下脚本链接中的`stilleshan`为你的GitHub账号ID后,运行即可. 修改以下脚本链接中的`stilleshan`为你的 GitHub 或 gitee 账号ID后,运行即可.
```shell ```shell
wget https://raw.githubusercontent.com/stilleshan/frps/master/frps_linux_install.sh && chmod +x frps_linux_install.sh && ./frps_linux_install.sh wget https://raw.githubusercontent.com/stilleshan/frps/master/frps_linux_install.sh && chmod +x frps_linux_install.sh && ./frps_linux_install.sh
# 国内 gitee 镜像
wget https://gitee.com/stilleshan/frps/raw/master/frps_linux_install.sh && chmod +x frps_linux_install.sh && ./frps_linux_install.sh
``` ```
#### 卸载脚本 #### 卸载脚本
frps_linux_uninstall.sh 卸载脚本为通用脚本,可直接运行,也可同上方式修改链接后运行. frps_linux_uninstall.sh 卸载脚本为通用脚本,可直接运行,也可同上方式修改链接后运行.
```shell ```shell
wget https://raw.githubusercontent.com/stilleshan/frps/master/frps_linux_uninstall.sh && chmod +x frps_linux_uninstall.sh && ./frps_linux_uninstall.sh wget https://raw.githubusercontent.com/stilleshan/frps/master/frps_linux_uninstall.sh && chmod +x frps_linux_uninstall.sh && ./frps_linux_uninstall.sh
# 国内 gitee 镜像
wget https://gitee.com/stilleshan/frps/raw/master/frps_linux_uninstall.sh && chmod +x frps_linux_uninstall.sh && ./frps_linux_uninstall.sh
``` ```
### frps相关命令 ### frps相关命令

View File

@ -1,28 +1,68 @@
#!/bin/sh #!/usr/bin/env bash
FRP_VERSION="0.36.2" PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
REPO="stilleshan/frps" export PATH
WORK_PATH=$(dirname $(readlink -f $0))
# 创建frp文件夹 # fonts color
mkdir -p /usr/local/frp && \ Green="\033[32m"
# 下载并移动frps文件 Red="\033[31m"
wget -P ${WORK_PATH} https://github.com/fatedier/frp/releases/download/v${FRP_VERSION}/frp_${FRP_VERSION}_linux_amd64.tar.gz && \ Yellow="\033[33m"
tar -zxvf frp_${FRP_VERSION}_linux_amd64.tar.gz && \ GreenBG="\033[42;37m"
cd frp_${FRP_VERSION}_linux_amd64 && \ RedBG="\033[41;37m"
mv frps /usr/local/frp && \ Font="\033[0m"
# 下载frps.in和frps.service # fonts color
wget -P /usr/local/frp https://raw.githubusercontent.com/${REPO}/master/frps.ini && \
wget -P /lib/systemd/system https://raw.githubusercontent.com/${REPO}/master/frps.service && \ # variable
systemctl daemon-reload && \ FRP_VERSION=0.36.2
# 启动frps REPO=stilleshan/frps
sudo systemctl start frps && \ WORK_PATH=$(dirname $(readlink -f $0))
sudo systemctl enable frps && \ FRP_NAME=frps
# 删除多余文件 FRP_PATH=/usr/local/frp
cd ${WORK_PATH} && \
rm -rf frp_${FRP_VERSION}_linux_amd64 frp_${FRP_VERSION}_linux_amd64.tar.gz frps_linux_install.sh if [ $(uname -m) = "x86_64" ]; then
echo "=======================================================" &&\ export PLATFORM=amd64
echo -e "\033[32m安装成功,请先修改 frps.ini 文件,确保格式及配置正确无误!\033[0m" && \ else if [ $(uname -m) = "aarch64" ]; then
echo -e "\033[31mvi /usr/local/frp/frps.ini \033[0m" && \ export PLATFORM=arm64
echo -e "\033[32m修改完毕后执行以下命令重启服务:\033[0m" && \ fi
echo -e "\033[31msudo systemctl restart frps\033[0m" && \ fi
echo "======================================================="
FILE_NAME=frp_${FRP_VERSION}_linux_${PLATFORM}
# 判断是否安装 frps
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 2
fi
# 判断 frps 进程并 kill
while ! test -z "$(ps -A | grep -w ${FRP_NAME})"; do
FRPSPID=$(ps -A | grep -w ${FRP_NAME} | awk 'NR==1 {print $1}')
kill -9 $FRPSPID
done
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}
wget -P ${FRP_PATH} https://ghproxy.com/https://raw.githubusercontent.com/${REPO}/master/${FRP_NAME}.ini && \
wget -P /lib/systemd/system https://ghproxy.com/https://raw.githubusercontent.com/${REPO}/master/${FRP_NAME}.service && \
systemctl daemon-reload
sudo systemctl start ${FRP_NAME}
sudo systemctl enable ${FRP_NAME}
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}修改完毕后执行以下命令重启服务:${Font}"
echo -e "${Red}sudo systemctl restart ${FRP_NAME}${Font}"
echo -e "${Green}====================================================================${Font}"

View File

@ -1,13 +1,32 @@
#!/bin/sh #!/usr/bin/env bash
# 停止frps PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
sudo systemctl stop frps && \ export PATH
# 删除frps
rm -rf /usr/local/frp && \ # fonts color
# 删除frps.service Green="\033[32m"
rm -rf /lib/systemd/system/frps.service && \ Red="\033[31m"
sudo systemctl daemon-reload && \ 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=frps
FRP_VERSION=0.36.2
FRP_PATH=/usr/local/frp
# 停止frpc
sudo systemctl stop ${FRP_NAME}
# 删除frpc
rm -rf ${FRP_PATH}
# 删除frpc.service
rm -rf /lib/systemd/system/${FRP_NAME}.service
sudo systemctl daemon-reload
# 删除本文件 # 删除本文件
rm -rf frps_linux_uninstall.sh rm -rf ${FRP_NAME}_linux_uninstall.sh
echo "============================" &&\
echo -e "\033[32m卸载成功,相关文件已清理完毕!\033[0m" && \ echo -e "${Green}============================${Font}"
echo "============================" echo -e "${Green}卸载成功,相关文件已清理完毕!${Font}"
echo -e "${Green}============================${Font}"