fix 自动更新

This commit is contained in:
jxxghp 2023-08-23 07:10:43 +08:00
parent b77c17a999
commit e5e33d4486

25
update
View File

@ -12,35 +12,40 @@ old_version=$(cat /app/version.py)
if [[ "${old_version}" == *APP_VERSION* ]]; then if [[ "${old_version}" == *APP_VERSION* ]]; then
current_version=v$(echo ${old_version} | sed -ne "s/APP_VERSION\s=\s'v\(.*\)'/\1/gp") current_version=v$(echo ${old_version} | sed -ne "s/APP_VERSION\s=\s'v\(.*\)'/\1/gp")
echo "当前版本号:${current_version}" echo "当前版本号:${current_version}"
# 检查后端最新版本
new_version=$(curl ${CURL_OPTIONS} "https://api.github.com/repos/jxxghp/MoviePilot/releases/latest" | jq -r .tag_name) new_version=$(curl ${CURL_OPTIONS} "https://api.github.com/repos/jxxghp/MoviePilot/releases/latest" | jq -r .tag_name)
if [[ "${new_version}" == *v* ]]; then if [[ "${new_version}" == *v* ]]; then
release_version=${new_version} release_version=${new_version}
echo "最新版本号:${release_version}" echo "最新版本号:${release_version}"
if [ "${current_version}" != "${release_version}" ]; then if [ "${current_version}" != "${release_version}" ]; then
echo "发现新版本,开始更新程序..." echo "发现新版本,开始自动升级..."
echo "正在下载后端程序 ${release_version}..."
curl ${CURL_OPTIONS} "https://github.com/jxxghp/MoviePilot/archive/refs/tags/${release_version}.zip" | busybox unzip -d /tmp - curl ${CURL_OPTIONS} "https://github.com/jxxghp/MoviePilot/archive/refs/tags/${release_version}.zip" | busybox unzip -d /tmp -
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
echo "后端下载成功" echo "后端程序下载成功"
curl ${CURL_OPTIONS} "https://github.com/jxxghp/MoviePilot-Frontend/releases/download/${release_version}/dist.zip" | busybox unzip -d /tmp - # 检查前端最新版本
frontend_version=$(curl ${CURL_OPTIONS} "https://api.github.com/repos/jxxghp/MoviePilot-Frontend/releases/latest" | jq -r .tag_name)
echo "正在下载前端程序 ${frontend_version}..."
curl ${CURL_OPTIONS} "https://github.com/jxxghp/MoviePilot-Frontend/releases/download/${frontend_version}/dist.zip" | busybox unzip -d /tmp -
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
echo "前端下载成功" echo "前端程序下载成功"
rm -rf /app rm -rf /app
mv /tmp/MoviePilot* /app mv /tmp/MoviePilot* /app
rm -rf /public rm -rf /public
mv /tmp/dist /public mv /tmp/dist /public
echo "程序更新成功" echo "程序更新成功,前端版本:${frontend_version},后端版本:${release_version}"
else else
echo "前端下载失败,继续使用旧的程序来启动..." echo "前端程序下载失败,继续使用旧的程序来启动..."
fi fi
else else
echo "后端下载失败,继续使用旧的程序来启动..." echo "后端程序下载失败,继续使用旧的程序来启动..."
fi fi
else else
echo "未发现新版本,跳过更新步骤" echo "未发现新版本,跳过更新步骤..."
fi fi
else else
echo "最新版本号获取失败,继续使用旧的程序来启动..." echo "最新版本号获取失败,继续启动..."
fi fi
else else
echo "当前版本号获取失败,继续使用旧的程序来启动..." echo "当前版本号获取失败,继续启动..."
fi fi