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 47 48 49 50 51 52
| #!/bin/sh
REPO="Harry-zklcdc/go-proxy-bingai" DOWNLOAD_DIR="./go_proxy_bingai_update" EXECUTABLE="go-proxy-bingai" TARGET_DIR="$(pwd)"
LATEST_RELEASE=$(curl -s "https://api.github.com/repos/$REPO/releases/latest") DOWNLOAD_URL=$(echo "$LATEST_RELEASE" | jq -r '.assets[] | select(.name | contains("freebsd-amd64.tar.gz")) | .browser_download_url')
if [ -z "$DOWNLOAD_URL" ]; then echo "无法获取下载链接,请检查仓库和资产名称。" exit 1 fi
mkdir -p "$DOWNLOAD_DIR"
curl -L -o "$DOWNLOAD_DIR/$EXECUTABLE.tar.gz" "$DOWNLOAD_URL"
if [ $? -ne 0 ]; then echo "下载失败,请检查网络连接或下载链接。" exit 1 fi
tar -xzvf "$DOWNLOAD_DIR/$EXECUTABLE.tar.gz" -C "$DOWNLOAD_DIR"
if [ $? -ne 0 ]; then echo "解压失败,请检查压缩包内容。" exit 1 fi
mv "$DOWNLOAD_DIR/$EXECUTABLE" "$TARGET_DIR"
if [ $? -ne 0 ]; then echo "移动文件失败,请检查目标目录路径和权限。" exit 1 fi
rm -rf "$DOWNLOAD_DIR"
echo "更新成功!"
|