File size: 1,220 Bytes
9636d57 8bfa319 9636d57 7f4d208 9636d57 8bfa319 9636d57 7f4d208 8bfa319 7f4d208 9636d57 b8f7c7a 8bfa319 fb7598e 2de9e70 fb7598e 8bfa319 b88e56f 8bfa319 9636d57 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
#!/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 |