| #!/bin/bash |
|
|
| set -euo pipefail |
|
|
| |
| 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" |
| ./startup.sh -m single |
| echo "服务已启动!" |
| tail -f /app/logs/start.out |
| else |
| echo "错误:启动脚本不存在" |
| exit 1 |
| fi |