frps端同步frpc2.4-LTS的全套代码库的设计逻辑

This commit is contained in:
2026-08-01 19:31:03 +08:00
parent ccdd5b0725
commit 3214215032
10 changed files with 988 additions and 455 deletions
+115
View File
@@ -0,0 +1,115 @@
#!/bin/bash
# ============================================================
# frpc-console 部署入口(前置引导脚本)
# 此脚本固定在 main 分支,永不变化。
# 职责:引导用户选择通道,拉取对应分支的 deploy.sh 并执行
#
# 用法:
# curl -sSL https://git.whitetop.xyz/.../run-deploy.sh | sudo bash
# curl -sSL https://git.whitetop.xyz/.../run-deploy.sh | sudo bash -s -- --channel preview
# ============================================================
set -e
if [ -t 1 ]; then
RED='\033[0;31m'; GREEN='\033[0;32m'; YELLOW='\033[1;33m'
BLUE='\033[0;34m'; CYAN='\033[0;36m'; MAGENTA='\033[0;35m'; NC='\033[0m'
else
RED=''; GREEN=''; YELLOW=''; BLUE=''; CYAN=''; MAGENTA=''; NC=''
fi
print_info() { echo -e "${BLUE}[INFO]${NC} $1"; }
print_error() { echo -e "${RED}[✗]${NC} $1"; }
REPO_URL="https://git.whitetop.xyz/lxh2875931338/frpc-console.git"
WORK_DIR="/tmp/frpc-console-deploy"
CHANNEL=""
BRANCH=""
parse_args() {
for arg in "$@"; do
case $arg in
--channel)
shift; CHANNEL="$1"
;;
--channel=*)
CHANNEL="${arg#*=}"
;;
--help|-h)
echo "用法: curl .../run-deploy.sh | sudo bash -s -- [选项]"
echo ""
echo "选项:"
echo " --channel lts 使用 LTS 通道 (main 分支)"
echo " --channel preview 使用 Preview 通道 (test 分支)"
echo " --help, -h 显示帮助信息"
exit 0
;;
*)
print_error "未知选项: $arg"
echo "使用 --help 查看帮助"
exit 1
;;
esac
done
}
select_channel() {
if [ -n "$CHANNEL" ]; then
if [ "$CHANNEL" != "lts" ] && [ "$CHANNEL" != "preview" ]; then
print_error "无效通道: $CHANNEL (仅支持 lts / preview)"
exit 1
fi
BRANCH="$([ "$CHANNEL" = "preview" ] && echo "test" || echo "main")"
print_info "使用命令行参数: ${CHANNEL} 通道 (${BRANCH} 分支)"
return
fi
echo ""
echo -e "${CYAN}请选择部署通道:${NC}"
echo " 1. LTS (稳定版,生产推荐) [默认] → main 分支"
echo " 2. Preview (技术预览版,包含新特性) → test 分支"
echo ""
read -p "请选择 [1]: " CHANNEL_INPUT </dev/tty
CHANNEL_INPUT=${CHANNEL_INPUT:-1}
case $CHANNEL_INPUT in
1|"") CHANNEL="lts"; BRANCH="main" ;;
2) CHANNEL="preview"; BRANCH="test" ;;
*) print_error "无效选择"; exit 1 ;;
esac
print_info "已选择: ${CHANNEL} 通道 (${BRANCH} 分支)"
}
fetch_and_run() {
local deploy_url="https://git.whitetop.xyz/lxh2875931338/frpc-console/raw/${BRANCH}/deploy.sh"
echo ""
echo -e "${CYAN}▶ 从 ${BRANCH} 分支拉取 deploy.sh...${NC}"
rm -rf "$WORK_DIR"
mkdir -p "$WORK_DIR"
cd "$WORK_DIR"
if ! curl -sSL -o deploy.sh "$deploy_url"; then
print_error "无法下载 deploy.sh: $deploy_url"
exit 1
fi
chmod +x deploy.sh
echo -e "${GREEN}[✓] deploy.sh 已拉取${NC}"
echo ""
echo -e "${CYAN}▶ 执行部署脚本...${NC}"
echo ""
export DEPLOY_CHANNEL="$CHANNEL"
export DEPLOY_BRANCH="$BRANCH"
exec ./deploy.sh "$@"
}
main() {
clear 2>/dev/null || true
echo -e "${MAGENTA}════════════════════════════════════════════════════════${NC}"
echo -e "${MAGENTA} frpc-console 部署入口${NC}"
echo -e "${MAGENTA}════════════════════════════════════════════════════════${NC}"
echo ""
parse_args "$@"
select_channel
fetch_and_run "$@"
}
main "$@"