mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-08 08:57:09 +08:00
chore: update code logic optimization
This commit is contained in:
@@ -50,15 +50,30 @@ function download_and_unzip() {
|
||||
function install_backend_and_download_resources() {
|
||||
# 清理临时目录,上次安装失败可能有残留
|
||||
rm -rf /tmp/*
|
||||
if download_and_unzip "${GITHUB_PROXY}https://github.com/jxxghp/MoviePilot/archive/refs/${1}" "App"; then
|
||||
if ! download_and_unzip "${GITHUB_PROXY}https://github.com/jxxghp/MoviePilot/archive/refs/${1}" "App"; then
|
||||
WARN "后端程序下载失败,继续使用旧的程序来启动..."
|
||||
return 1
|
||||
fi
|
||||
INFO "后端程序下载成功"
|
||||
INFO "依赖安装中..."
|
||||
pip install ${PIP_OPTIONS} --upgrade --root-user-action=ignore pip > /dev/null
|
||||
if pip install ${PIP_OPTIONS} --root-user-action=ignore -r /tmp/App/requirements.txt > /dev/null; then
|
||||
if ! pip install ${PIP_OPTIONS} --upgrade --root-user-action=ignore pip > /dev/null; then
|
||||
ERROR "pip 更新失败,请重新拉取镜像"
|
||||
return 1
|
||||
fi
|
||||
if ! pip install ${PIP_OPTIONS} --root-user-action=ignore -r /tmp/App/requirements.txt > /dev/null; then
|
||||
ERROR "安装依赖失败,请重新拉取镜像"
|
||||
return 1
|
||||
fi
|
||||
INFO "安装依赖成功"
|
||||
frontend_version=$(curl ${CURL_OPTIONS} "https://api.github.com/repos/jxxghp/MoviePilot-Frontend/releases/latest" ${CURL_HEADERS} | jq -r .tag_name)
|
||||
if [[ "${frontend_version}" == *v* ]]; then
|
||||
if download_and_unzip "${GITHUB_PROXY}https://github.com/jxxghp/MoviePilot-Frontend/releases/download/${frontend_version}/dist.zip" "dist"; then
|
||||
if [[ "${frontend_version}" != *v* ]]; then
|
||||
WARN "前端最新版本号获取失败,继续启动..."
|
||||
return 1
|
||||
fi
|
||||
if ! download_and_unzip "${GITHUB_PROXY}https://github.com/jxxghp/MoviePilot-Frontend/releases/download/${frontend_version}/dist.zip" "dist"; then
|
||||
WARN "前端程序下载失败,继续使用旧的程序来启动..."
|
||||
return 1
|
||||
fi
|
||||
INFO "前端程序下载成功"
|
||||
# 提前备份插件目录
|
||||
INFO "备份插件目录中..."
|
||||
@@ -85,7 +100,12 @@ function install_backend_and_download_resources() {
|
||||
rm -rf /tmp/*
|
||||
INFO "程序部分更新成功,前端版本:${frontend_version},后端版本:${1}"
|
||||
INFO "开始更新插件..."
|
||||
if download_and_unzip "${GITHUB_PROXY}https://github.com/jxxghp/MoviePilot-Plugins/archive/refs/heads/main.zip" "Plugins"; then
|
||||
if ! download_and_unzip "${GITHUB_PROXY}https://github.com/jxxghp/MoviePilot-Plugins/archive/refs/heads/main.zip" "Plugins"; then
|
||||
cp -a /plugins/* /app/app/plugins/
|
||||
rm -rf /plugins
|
||||
WARN "插件下载失败,继续使用旧的插件来启动..."
|
||||
return 1
|
||||
fi
|
||||
INFO "插件下载成功"
|
||||
# 恢复插件目录
|
||||
cp -a /plugins/* /app/app/plugins/
|
||||
@@ -97,35 +117,19 @@ function install_backend_and_download_resources() {
|
||||
rm -rf /tmp/*
|
||||
INFO "插件更新成功"
|
||||
INFO "开始更新资源包..."
|
||||
if download_and_unzip "${GITHUB_PROXY}https://github.com/jxxghp/MoviePilot-Resources/archive/refs/heads/main.zip" "Resources"; then
|
||||
if ! download_and_unzip "${GITHUB_PROXY}https://github.com/jxxghp/MoviePilot-Resources/archive/refs/heads/main.zip" "Resources"; then
|
||||
cp -a /resources_bakcup/* /app/app/helper/
|
||||
rm -rf /resources_bakcup
|
||||
WARN "资源包下载失败,继续使用旧的资源包来启动..."
|
||||
return 1
|
||||
fi
|
||||
INFO "资源包下载成功"
|
||||
# 资源包
|
||||
cp -a /tmp/Resources/resources/* /app/app/helper/
|
||||
# 清理临时目录
|
||||
rm -rf /tmp/*
|
||||
INFO "资源包更新成功"
|
||||
else
|
||||
cp -a /resources_bakcup/* /app/app/helper/
|
||||
rm -rf /resources_bakcup
|
||||
WARN "资源包下载失败,继续使用旧的资源包来启动..."
|
||||
fi
|
||||
else
|
||||
cp -a /plugins/* /app/app/plugins/
|
||||
rm -rf /plugins
|
||||
WARN "插件下载失败,继续使用旧的插件来启动..."
|
||||
fi
|
||||
else
|
||||
WARN "前端程序下载失败,继续使用旧的程序来启动..."
|
||||
fi
|
||||
else
|
||||
WARN "前端最新版本号获取失败,继续启动..."
|
||||
fi
|
||||
else
|
||||
ERROR "安装依赖失败,请重新拉取镜像"
|
||||
fi
|
||||
else
|
||||
WARN "后端程序下载失败,继续使用旧的程序来启动..."
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
function test_connectivity_pip() {
|
||||
|
||||
Reference in New Issue
Block a user