From edb7b39a2c92719919e348c8b3d505dd29735a28 Mon Sep 17 00:00:00 2001 From: monlor Date: Fri, 14 Jun 2024 10:58:30 +0800 Subject: [PATCH 1/3] =?UTF-8?q?feat:=20=F0=9F=8E=B8=20=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E8=84=9A=E6=9C=AC=E6=94=AF=E6=8C=81=E6=9B=B4=E6=96=B0env?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- install.sh | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/install.sh b/install.sh index 2529c57..fa0c6d1 100644 --- a/install.sh +++ b/install.sh @@ -79,15 +79,30 @@ read -rp "请输入服务部署目录(默认/opt/xiaoya): " install_path install_path=${install_path:=/opt/xiaoya} # 检查服务是否已经运行 +update=0 if [ -f "$install_path/docker-compose.yml" ]; then # 询问用户是否要更新服务 - echo - echo "检查到服务已存在,更新会覆盖docker-compose.yml文件,不会覆盖env文件" - read -rp "是否更新服务?(y/n): " update - if [ "${update}" != "y" ]; then - echo "退出安装" - exit 1 - fi + cat <<-EOF + +更新方式: +1. 全部更新,会覆盖更新docker-compose.yml和env配置 +2. 部分更新,仅覆盖更新docker-compose.yml +3. 退出脚本,不更新 +EOF + read -rp "请选择更新方式(默认为1): " update + update=${update:-1} + case $update in + 1|2) + # 备份 + cp -rf "$install_path/env" "$install_path/env.bak" + cp -rf "$install_path/docker-compose.yml" "$install_path/docker-compose.yml.bak" + ;; + *) + echo "退出安装" + exit 1 + ;; + esac + fi DOCKER_HOME="$(docker info | grep "Docker Root Dir" | awk -F ':' '{print$2}')" @@ -99,7 +114,7 @@ if [ -d "$install_path/data" ]; then fi cat <<-EOF -请选择数据保存位置: +数据保存位置: 1. Docker卷(数据保存在: ${DOCKER_HOME}/volumes) 2. 服务部署目录(数据保存在: ${install_path}) EOF @@ -111,7 +126,7 @@ open_token="" folder_id="" # 如果是更新服务,则从原有的compose配置中获取token等信息 -if [ "${update:-}" = "y" ]; then +if [ "${update}" != "0" ]; then token=$(grep ALIYUN_TOKEN "$install_path/env" 2> /dev/null | awk -F '=' '{print $2}') open_token=$(grep ALIYUN_OPEN_TOKEN "$install_path/env" 2> /dev/null | awk -F '=' '{print $2}') folder_id=$(grep ALIYUN_FOLDER_ID "$install_path/env" 2> /dev/null | awk -F '=' '{print $2}') @@ -183,7 +198,7 @@ cd "$install_path" echo "开始生成配置文件docker-compose${service_type}.yml..." curl -#Lo "$install_path/docker-compose.yml" "${DOWNLOAD_URL}/docker-compose${service_type}.yml" -if [ ! -f "$install_path/env" ]; then +if [ "${update}" != "2" ]; then curl -#Lo "$install_path/env" "${DOWNLOAD_URL}/env" fi sedsh "s#ALIYUN_TOKEN=.*#ALIYUN_TOKEN=$token#g" env From c48f4dd996129984c649c6f16961e4a7b9ffb8ef Mon Sep 17 00:00:00 2001 From: monlor Date: Fri, 14 Jun 2024 11:09:45 +0800 Subject: [PATCH 2/3] =?UTF-8?q?fix:=20=F0=9F=90=9B=20jellyfin=E4=B8=8B?= =?UTF-8?q?=E8=BD=BD=E5=A4=B1=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- metadata/entrypoint.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/metadata/entrypoint.sh b/metadata/entrypoint.sh index 157a5f2..e7fca23 100644 --- a/metadata/entrypoint.sh +++ b/metadata/entrypoint.sh @@ -42,7 +42,6 @@ disk_check() { download_meta() { file=$1 - path=$2 echo "Downloading ${file}..." # 检查历史文件,如果存在残留则删除 if [ -f "${MEDIA_DIR}/temp/${file}.aria2" ]; then @@ -61,7 +60,8 @@ download_meta() { success=false for i in {1..5}; do echo "Downloading ${file}, try ${i}..." - if aria2c -o "${file}" --allow-overwrite=true --auto-file-renaming=false --enable-color=false -c -x6 "${ALIST_ADDR}/d/元数据/${path}${file}"; then + echo "Link is ${ALIST_ADDR}/d/元数据/${file}" + if aria2c -o "${file}" --allow-overwrite=true --auto-file-renaming=false --enable-color=false -c -x6 "${ALIST_ADDR}/d/元数据/${file}"; then # 下载的文件小于10M,下载失败,删除 if [ "$(stat -c %s "${file}")" -lt 10000000 ]; then echo "Download ${file} failed, file size less than 10M, retry after 10 seconds." @@ -149,7 +149,7 @@ download_jellyfin_config() { echo "Downloading Jellyfin config..." cd ${MEDIA_DIR}/temp - download_meta config_jf.mp4 Jellyfin/ + download_meta Jellyfin/config_jf.mp4 echo "Extracting Jellyfin config..." @@ -174,8 +174,8 @@ download_jellyfin_media() { echo "Downloading Jellyfin media..." cd "${MEDIA_DIR}/temp" - download_meta all_jf.mp4 Jellyfin/ - download_meta PikPak_jf.mp4 Jellyfin/ + download_meta Jellyfin/all_jf.mp4 + download_meta Jellyfin/PikPak_jf.mp4 echo "Extracting Jellyfin media..." From 580ffd085839b42dae1c3fc195e4614c8da0341d Mon Sep 17 00:00:00 2001 From: monlor Date: Fri, 14 Jun 2024 11:40:09 +0800 Subject: [PATCH 3/3] =?UTF-8?q?refactor:=20=F0=9F=92=A1=20=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E6=96=87=E6=A1=A3=EF=BC=8C=E4=BF=AE=E6=94=B9=E5=8F=98?= =?UTF-8?q?=E9=87=8F=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- alist/README.md | 2 +- env | 4 ++-- helmfile.yaml | 2 +- metadata/README.md | 2 +- metadata/entrypoint.sh | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/alist/README.md b/alist/README.md index 10b8ab0..df7f213 100644 --- a/alist/README.md +++ b/alist/README.md @@ -44,7 +44,7 @@ docker run -d -p 5678:80 -p 2345:2345 -p 2346:2346 --restart=unless-stopped --na `EMBY_APIKEY`: 填入一个emby的api key,用于在infuse中播放emby -`AUTO_UPDATE_ENABLED`: 自动更新小雅的文件,true/false,默认false +`AUTO_UPDATE_ENABLED`: 每天自动更新小雅的文件,true/false,默认false `AUTO_CLEAR_ENABLED`: 自动清理阿里云云盘的文件,true/false,默认false diff --git a/env b/env index 31bae1a..53c8c98 100644 --- a/env +++ b/env @@ -35,7 +35,7 @@ JELLYFIN_ENABLED=false AUTO_UPDATE_EMBY_CONFIG_ENABLED=true # 自动更新emby配置,config.mp4间隔,单位天,默认7天 AUTO_UPDATE_EMBY_INTERVAL= -# 自动更新元数据 -AUTO_UPDATE_METADATA_ENABLED=true +# 自动更新emby元数据 +AUTO_UPDATE_EMBY_METADATA_ENABLED=true # emby的apikey EMBY_APIKEY= \ No newline at end of file diff --git a/helmfile.yaml b/helmfile.yaml index 3665d79..164758b 100644 --- a/helmfile.yaml +++ b/helmfile.yaml @@ -73,7 +73,7 @@ releases: EMBY_ENABLED: true JELLYFIN_ENABLED: false AUTO_UPDATE_EMBY_CONFIG_ENABLED: true - AUTO_UPDATE_METADATA_ENABLED: true + AUTO_UPDATE_EMBY_METADATA_ENABLED: true volumes: - name: data mountPath: /etc/xiaoya diff --git a/metadata/README.md b/metadata/README.md index 1a04b40..2a12620 100644 --- a/metadata/README.md +++ b/metadata/README.md @@ -8,7 +8,7 @@ `AUTO_UPDATE_EMBY_INTERVAL`: 自动更新emby配置间隔,默认7,单位天 -`AUTO_UPDATE_METADATA_ENABLED`: 自动更新每日元数据,你们所说的爬虫,true/false,默认false +`AUTO_UPDATE_EMBY_METADATA_ENABLED`: 每天自动更新emby元数据,你们所说的爬虫,true/false,默认false `EMBY_APIKEY`: emby api 密钥,建议修改emby的api密钥,设置此变量,用于定期同步emby配置 diff --git a/metadata/entrypoint.sh b/metadata/entrypoint.sh index e7fca23..b657c90 100644 --- a/metadata/entrypoint.sh +++ b/metadata/entrypoint.sh @@ -203,7 +203,7 @@ if [ "${EMBY_ENABLED:=false}" = "true" ]; then crontabs="${crontabs}\n${random_min} ${random_hour} */${AUTO_UPDATE_EMBY_INTERVAL:=7} * * /emby.sh update" fi - if [ "${AUTO_UPDATE_METADATA_ENABLED:=false}" = "true" ]; then + if [ "${AUTO_UPDATE_EMBY_METADATA_ENABLED:=false}" = "true" ]; then echo "启动定时更新Emby媒体数据任务..." # 随机生成一个时间,避免给服务器造成压力 random_min=$(shuf -i 0-59 -n 1)