Spaces:
Paused
Paused
| set -euo pipefail | |
| # 获取最新版本的重定向URL | |
| echo "正在获取最新版本信息..." | |
| redirect_url=$(curl -Ls -o /dev/null -w '%{url_effective}' 'https://github.com/hectorqin/reader/releases/latest') | |
| # 提取版本标签 | |
| tag=$(basename "$redirect_url") | |
| if [[ ! "$tag" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then | |
| echo "错误:无效的版本标签 '$tag'" | |
| exit 1 | |
| fi | |
| version="${tag#v}" | |
| echo "检测到最新版本: $version" | |
| # 构造下载链接 | |
| download_url="https://github.com/hectorqin/reader/releases/download/${tag}/reader-server-${version}.zip" | |
| echo "开始下载: $download_url" | |
| # 下载文件 | |
| if ! curl -LO "$download_url"; then | |
| echo "错误:文件下载失败" | |
| exit 1 | |
| fi | |
| # 解压文件 | |
| zip_file="reader-server-${version}.zip" | |
| echo "正在解压文件..." | |
| unzip "$zip_file" | |
| cd target | |
| chmod +x reader-pro-${version}.jar | |
| cd ../bin | |
| # 执行启动脚本 | |
| if [ -f "./startup.sh" ]; then | |
| echo "正在启动服务..." | |
| chmod +x "./startup.sh" | |
| # 添加自定义系统属性 | |
| export JAVA_OPT_EXT="--reader.app.defaultUserEnableBookSource=false --reader.app.minUserPasswordLength=6" | |
| ./startup.sh -m multi -i "${INVITE_CODE:-}" -k "${SECURE_KEY:-}" | |
| echo "服务已启动!" | |
| tail -f /app/logs/start.out | |
| else | |
| echo "错误:启动脚本不存在" | |
| exit 1 | |
| fi |