reader / install_reader.sh
zxwreader's picture
Update install_reader.sh
99f2ca5 verified
#!/bin/bash
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"
#+x
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