From 3178d9da88d8310018af9fabb3fc550ac843a0cc Mon Sep 17 00:00:00 2001 From: jxxghp Date: Thu, 2 Nov 2023 12:27:30 +0800 Subject: [PATCH] fix update --- update | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/update b/update index f64a90f3..417f3b13 100644 --- a/update +++ b/update @@ -1,13 +1,12 @@ #!/bin/bash -# Common function to download and unzip files +# 下载及解压 download_and_unzip() { url="$1" target_dir="$2" echo "正在下载 ${url}..." curl ${CURL_OPTIONS} "$url" | busybox unzip -d /tmp - if [ $? -eq 0 ]; then - echo "下载成功" if [ -e /tmp/MoviePilot-* ]; then mv /tmp/MoviePilot-* /tmp/${target_dir} fi @@ -16,7 +15,7 @@ download_and_unzip() { fi } -# Common function to install backend and download resources +# 下载程序资源,$1: 后端版本路径 install_backend_and_download_resources() { download_and_unzip "https://github.com/jxxghp/MoviePilot/archive/refs/${1}" "App" if [ $? -eq 0 ]; then @@ -36,13 +35,22 @@ install_backend_and_download_resources() { download_and_unzip "https://github.com/jxxghp/MoviePilot-Frontend/releases/download/${frontend_version}/dist.zip" "dist" if [ $? -eq 0 ]; then echo "前端程序下载成功" - find /app/* -type d ! -path "/app/app/plugins" -exec rm -rf {} \; - find /app/* -type f ! -path "/app/app/plugins/*" -exec rm -f {} \; - mv -f /tmp/App/* /app/ + # 备份插件目录 + mv -f /app/app/plugins /plugins + # 清空目录 + rm -rf /app + # 后端程序 + mv -f /tmp/App /app + # 恢复插件目录 + mv -f /plugins /app/app/plugins + # 插件仓库 + mv -f /tmp/Plugins/plugins/* /app/app/plugins/ + # 资源包 + mv -f /tmp/Resources/resources/* /app/app/helper/ + # 前端程序 rm -rf /public mv /tmp/dist /public - mv -f /tmp/Plugins/plugins/* /app/app/plugins/ - mv -f /tmp/Resources/resources/* /app/app/helper/ + # 清理临时目录 rm -rf /tmp/* echo "程序更新成功,前端版本:${frontend_version},后端版本:${1}" else