#!/bin/sh # 设置脚本在任何命令失败时立即退出 set -e # 设置脚本在执行命令时打印命令本身 set -x # 判断处理器架构 case "$(uname -m)" in aarch64|arm64 ) ARCH=arm64 ;; x86_64|amd64 ) ARCH=amd64 ;; armv7* ) ARCH=arm ;; * ) echo "不支持的架构" exit 1 esac # 使用变量来存储文件路径和应用名称 CLOUDFLARED_PATH="/project/cloudflared" RAYCAST_CMD="python -m uvicorn app.main:app --host 0.0.0.0 --port 3000" # 使用 Python 下载 cloudflared python -c "import urllib.request; urllib.request.urlretrieve('https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-$ARCH', '$CLOUDFLARED_PATH')" || { echo "下载 cloudflared 失败"; exit 1; } # 赋执行权给 cloudflared chmod +x "$CLOUDFLARED_PATH" || { echo "设置 cloudflared 的执行权限失败"; exit 1; } # 运行 Raycast API Proxy $RAYCAST_CMD "$@" & # 运行 cloudflared # "$CLOUDFLARED_PATH" tunnel run --token "${ARGO_AUTH}" & "$CLOUDFLARED_PATH" service install ${ARGO_AUTH} # 捕获中断信号并清理资源 trap 'kill $(jobs -p); exit 1' INT TERM # 等待所有后台进程结束 wait