#!/bin/bash # 将 client/release 下的构建产物复制到服务器下载目录并命名为 FunMC-<版本>-<平台>.<后缀> # 用法: # bash scripts/copy-client-to-downloads.sh [版本号] # bash scripts/copy-client-to-downloads.sh # 版本号从 /etc/funmc/server.env 的 CLIENT_VERSION 读取 # 需在项目根目录或指定 CLIENT_DIR、DOWNLOADS_DIR 运行。 set -e SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)" CLIENT_DIR="${CLIENT_DIR:-$REPO_ROOT/client}" DOWNLOADS_DIR="${DOWNLOADS_DIR:-/opt/funmc/downloads}" if [ -n "$1" ]; then VERSION="$1" elif [ -f /etc/funmc/server.env ]; then VERSION=$(grep -E '^CLIENT_VERSION=' /etc/funmc/server.env | cut -d= -f2) fi if [ -z "$VERSION" ]; then echo "用法: $0 <版本号> 或确保 /etc/funmc/server.env 中有 CLIENT_VERSION" echo "示例: $0 0.1.0" exit 1 fi RELEASE="$CLIENT_DIR/release" if [ ! -d "$RELEASE" ]; then echo "未找到 $RELEASE,请先在 client 目录执行 npm run dist:linux 等构建" exit 1 fi mkdir -p "$DOWNLOADS_DIR" # 复制并重命名(Electron 产物: FunConnect--<平台>-.) copied=0 for f in "$RELEASE"/FunConnect-*-Linux-x64.AppImage; do [ -f "$f" ] || continue cp -v "$f" "$DOWNLOADS_DIR/FunMC-${VERSION}-linux-x64.AppImage" copied=$((copied+1)) done for f in "$RELEASE"/FunConnect-*-Win-x64.exe; do [ -f "$f" ] || continue cp -v "$f" "$DOWNLOADS_DIR/FunMC-${VERSION}-windows-x64.exe" copied=$((copied+1)) done for f in "$RELEASE"/FunConnect-*-Mac-arm64.dmg; do [ -f "$f" ] || continue cp -v "$f" "$DOWNLOADS_DIR/FunMC-${VERSION}-macos-arm64.dmg" copied=$((copied+1)) done for f in "$RELEASE"/FunConnect-*-Mac-x64.dmg; do [ -f "$f" ] || continue cp -v "$f" "$DOWNLOADS_DIR/FunMC-${VERSION}-macos-x64.dmg" copied=$((copied+1)) done if [ $copied -eq 0 ]; then echo "未在 $RELEASE 中找到可复制的 FunConnect-* 文件,请先构建客户端" exit 1 fi echo "已复制 $copied 个文件到 $DOWNLOADS_DIR(版本 $VERSION)"