feat: dev update

This commit is contained in:
DDSRem 2023-09-02 10:52:19 +08:00
parent 9fdd838b7a
commit 62c1a924e8
3 changed files with 75 additions and 66 deletions

View File

@ -8,6 +8,7 @@ ENV LANG="C.UTF-8" \
PGID=0 \ PGID=0 \
UMASK=000 \ UMASK=000 \
MOVIEPILOT_AUTO_UPDATE=true \ MOVIEPILOT_AUTO_UPDATE=true \
MOVIEPILOT_AUTO_UPDATE_DEV=false \
NGINX_PORT=3000 \ NGINX_PORT=3000 \
CONFIG_DIR="/config" \ CONFIG_DIR="/config" \
API_TOKEN="moviepilot" \ API_TOKEN="moviepilot" \

24
dev.sh
View File

@ -1,24 +0,0 @@
#!/bin/bash
# 更新环境
apt update
# 安装 Git
apt install -y git curl
# 更新后端代码
cd /
rm -rf /app
git clone https://github.com/jxxghp/MoviePilot app
pip install -r /app/requirements.txt
echo "后端程序更新成功"
# 检查前端最新版本
frontend_version=$(curl ${CURL_OPTIONS} "https://api.github.com/repos/jxxghp/MoviePilot-Frontend/releases/latest" | jq -r .tag_name)
# 更新前端代码
echo "正在下载前端程序 ${frontend_version}..."
curl -sL "https://github.com/jxxghp/MoviePilot-Frontend/releases/download/${frontend_version}/dist.zip" | busybox unzip -d /tmp -
if [ $? -eq 0 ]; then
rm -rf /public
mv /tmp/dist /public
echo "程序更新成功,前端版本:${frontend_version}"
else
echo "前端程序下载失败"
fi
echo "请重启容器生效"

38
update
View File

@ -2,14 +2,44 @@
if [ -n "${PROXY_HOST}" ]; then if [ -n "${PROXY_HOST}" ]; then
CURL_OPTIONS="-sL -x ${PROXY_HOST}" CURL_OPTIONS="-sL -x ${PROXY_HOST}"
PIP_OPTIONS="-r --proxy=${PROXY_HOST}" PIP_OPTIONS="--proxy=${PROXY_HOST}"
echo "使用代理更新程序" echo "使用代理更新程序"
else else
CURL_OPTIONS="-sL" CURL_OPTIONS="-sL"
PIP_OPTIONS="-r"
echo "不使用代理更新程序" echo "不使用代理更新程序"
fi fi
if [ "${MOVIEPILOT_AUTO_UPDATE}" = "true" ]; then
curl -sL ${CURL_OPTIONS} "https://github.com/jxxghp/MoviePilot/archive/refs/heads/main.zip" | busybox unzip -d /tmp -
if [ $? -eq 0 ]; then
mv /tmp/MoviePilot-main /tmp/app
echo "后端程序下载成功"
# 重新安装依赖
pip install ${PIP_OPTIONS} --upgrade pip
pip install ${PIP_OPTIONS} -r /tmp/app/requirements.txt
if [ $? -eq 0 ]; then
echo "安装依赖成功"
# 检查前端最新版本
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
echo "前端程序下载成功"
rm -rf /app
mv /tmp/MoviePilot* /app
rm -rf /public
mv /tmp/dist /public
echo "程序更新成功,前端版本:${frontend_version},后端版本:${release_version}"
else
echo "前端程序下载失败,继续使用旧的程序来启动..."
fi
else
echo "安装依赖失败,请重新拉取镜像"
fi
else
echo "后端程序下载失败,继续使用旧的程序来启动..."
fi
else
old_version=$(cat /app/version.py) 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")
@ -26,7 +56,8 @@ if [[ "${old_version}" == *APP_VERSION* ]]; then
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
echo "后端程序下载成功" echo "后端程序下载成功"
# 重新安装依赖 # 重新安装依赖
pip install ${PIP_OPTIONS} /tmp/MoviePilot*/requirements.txt pip install ${PIP_OPTIONS} --upgrade pip
pip install ${PIP_OPTIONS} -r /tmp/MoviePilot*/requirements.txt
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
echo "安装依赖成功" echo "安装依赖成功"
# 检查前端最新版本 # 检查前端最新版本
@ -58,3 +89,4 @@ if [[ "${old_version}" == *APP_VERSION* ]]; then
else else
echo "当前版本号获取失败,继续启动..." echo "当前版本号获取失败,继续启动..."
fi fi
fi