diff --git a/README.md b/README.md index 4a4b463..70c01fe 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,8 @@ > *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 ## 使用说明 @@ -16,6 +18,8 @@ 安装 ```shell 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 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 文件后运行脚本.) +> 同时支持 github 和 gitee 平台 fork + - 首先 fork 本仓库 - 配置 frps.ini - 修改 frps_linux_install.sh 脚本 - 修改脚本链接并运行 #### 修改 frps_linux_install.sh 脚本 -`FRP_VERSION="0.30.0"` 可根据原版项目更新自行修改为最新版本 -`REPO="stilleshan/frps"` 由于 **fork** 到你自己的仓库,需修改`stilleshan`为你的GitHub账号ID. +`FRP_VERSION="0.36.2"` 可根据原版项目更新自行修改为最新版本 +`REPO="stilleshan/frps"` 由于 **fork** 到你自己的仓库,需修改`stilleshan`为你的 GitHub 或 gitee 账号ID. #### 运行一键脚本 -修改以下脚本链接中的`stilleshan`为你的GitHub账号ID后,运行即可. +修改以下脚本链接中的`stilleshan`为你的 GitHub 或 gitee 账号ID后,运行即可. ```shell 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 卸载脚本为通用脚本,可直接运行,也可同上方式修改链接后运行. ```shell 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相关命令 diff --git a/frps_linux_install.sh b/frps_linux_install.sh index dd91189..34c9a36 100644 --- a/frps_linux_install.sh +++ b/frps_linux_install.sh @@ -1,28 +1,68 @@ -#!/bin/sh -FRP_VERSION="0.36.2" -REPO="stilleshan/frps" -WORK_PATH=$(dirname $(readlink -f $0)) +#!/usr/bin/env bash +PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin +export PATH -# 创建frp文件夹 -mkdir -p /usr/local/frp && \ -# 下载并移动frps文件 -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 frps /usr/local/frp && \ -# 下载frps.in和frps.service -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 && \ -systemctl daemon-reload && \ -# 启动frps -sudo systemctl start frps && \ -sudo systemctl enable frps && \ -# 删除多余文件 -cd ${WORK_PATH} && \ -rm -rf frp_${FRP_VERSION}_linux_amd64 frp_${FRP_VERSION}_linux_amd64.tar.gz frps_linux_install.sh -echo "=======================================================" &&\ -echo -e "\033[32m安装成功,请先修改 frps.ini 文件,确保格式及配置正确无误!\033[0m" && \ -echo -e "\033[31mvi /usr/local/frp/frps.ini \033[0m" && \ -echo -e "\033[32m修改完毕后执行以下命令重启服务:\033[0m" && \ -echo -e "\033[31msudo systemctl restart frps\033[0m" && \ -echo "=======================================================" \ No newline at end of file +# 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 +FRP_VERSION=0.36.2 +REPO=stilleshan/frps +WORK_PATH=$(dirname $(readlink -f $0)) +FRP_NAME=frps +FRP_PATH=/usr/local/frp + +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} + +# 判断是否安装 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}" diff --git a/frps_linux_uninstall.sh b/frps_linux_uninstall.sh index bc1b617..4646326 100644 --- a/frps_linux_uninstall.sh +++ b/frps_linux_uninstall.sh @@ -1,13 +1,32 @@ -#!/bin/sh -# 停止frps -sudo systemctl stop frps && \ -# 删除frps -rm -rf /usr/local/frp && \ -# 删除frps.service -rm -rf /lib/systemd/system/frps.service && \ -sudo systemctl daemon-reload && \ +#!/usr/bin/env bash +PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin +export PATH + +# 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=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 -echo "============================" &&\ -echo -e "\033[32m卸载成功,相关文件已清理完毕!\033[0m" && \ -echo "============================" \ No newline at end of file +rm -rf ${FRP_NAME}_linux_uninstall.sh + +echo -e "${Green}============================${Font}" +echo -e "${Green}卸载成功,相关文件已清理完毕!${Font}" +echo -e "${Green}============================${Font}"