Skip to content

Commit

Permalink
feat: 🎸 添加resilio自动同步元数据
Browse files Browse the repository at this point in the history
  • Loading branch information
monlor committed May 30, 2024
1 parent ffeb24a commit 753a893
Show file tree
Hide file tree
Showing 17 changed files with 201 additions and 42 deletions.
13 changes: 12 additions & 1 deletion .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,15 @@ jobs:
tags: |
ghcr.io/${{ github.repository_owner }}/xiaoya-jellyfin:latest
${{ env.IS_TAG == 'true' && 'ghcr.io/${{ github.repository_owner }}/xiaoya-jellyfin:${{ env.VERSION }}' || '' }}
platforms: linux/amd64,linux/arm64
platforms: linux/amd64,linux/arm64

- name: Build and push xiaoya-resilio
uses: docker/build-push-action@v4
with:
context: ./resilio
push: true
tags: |
ghcr.io/${{ github.repository_owner }}/xiaoya-resilio:latest
${{ env.IS_TAG == 'true' && 'ghcr.io/${{ github.repository_owner }}/xiaoya-resilio:${{ env.VERSION }}' || '' }}
platforms: linux/amd64,linux/arm64

16 changes: 14 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
* 通过环境变量配置阿里云盘token,无需映射文件
* 元数据下载的流程集成到glue服务,自动下载
* jellyfin和emby启动时自动进行依赖检查,等待元数据下载完成,自动添加hosts
* 完全兼容所有能运行docker的x86和arm设备
* 支持自动清理阿里云盘,自动同步小雅元数据

## 部署

Expand All @@ -26,6 +28,14 @@ curl -LO https://raw.githubusercontent.com/monlor/docker-xiaoya/main/docker-comp
docker compose up -d
```

小雅Alist访问地址:http://你的ip:5678

小雅Emby访问地址:http://你的ip:6908,默认用户:xiaoya,密码:1234

小雅Jellyfin访问地址:http://你的ip:8096

webdav访问地址:http://你的ip:5678/dav,默认用户guest,密码:guest_Api789

## 配置示例

* [只部署小雅alist](/docker-compose-alist.yml)
Expand All @@ -34,6 +44,8 @@ docker compose up -d

## 参考

https://hub.docker.com/r/amilys/embyserver
https://github.com/DDS-Derek/xiaoya-alist

https://www.kdocs.cn/l/cvEe3cv6dGkH

https://github.com/DDS-Derek/xiaoya-alist/blob/master/all_in_one.sh
https://xiaoyaliu.notion.site/xiaoya-docker-69404af849504fa5bcf9f2dd5ecaa75f
14 changes: 11 additions & 3 deletions alist/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
## 小雅影视库
## 小雅Alist

简化部署逻辑,来源:https://xiaoyaliu.notion.site/xiaoya-docker-69404af849504fa5bcf9f2dd5ecaa75f
alist访问端口:80

emby访问端口:2345

jellyfin访问端口:2346

## 启动命令

Expand All @@ -20,7 +24,11 @@ docker run -d -p 5678:80 -p 2345:2345 -p 2346:2346 --restart=unless-stopped --na

`FORCE_LOGIN`: 开启登陆功能,true/false

`WEBDAV_PASSWORD`: webdav用户名为dav,设置密码,默认密码:guest_Api789
`WEBDAV_PASSWORD`: webdav用户名为dav,设置密码。默认用户密码:guest/guest_Api789

`EMBY_ADDR`: emby部署地址,默认http://emby:6908

`JELLYFIN_ADDR`: jellyfin部署地址,默认http://jellyfin:8096

`AUTO_UPDATE_ENABLED`: 自动更新小雅的文件,true/false

Expand Down
5 changes: 5 additions & 0 deletions alist/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ fi

echo -e "$crontabs" | crontab -

# 设置本地变量
echo "e825ed6f7f8f44ffa0563cddaddce14d" > /data/infuse_api_key.txt

echo "${EMBY_ADDR:=http://emby:6908}" > /data/emby_server.txt

echo "${JELLYFIN_ADDR:=http://jellyfin:8096}" > /data/jellyfin_server.txt

exec /entrypoint.sh /opt/alist/alist server --no-prefix
2 changes: 2 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ docker build -t monlor/xiaoya-glue glue
docker build -t monlor/xiaoya-emby emby

docker build -t monlor/xiaoya-jellyfin jellyfin

docker build -t monlor/xiaoya-resilio resilio
23 changes: 20 additions & 3 deletions docker-compose-all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ services:
container_name: emby
environment:
- TZ=Asia/Shanghai
- GIDLIST=0,0
- GIDLIST=0
- ALIST_DOMAIN=alist
privileged: true
devices:
Expand All @@ -57,7 +57,24 @@ services:
- config:/config
- cache:/cache
ports:
- "8096:8096"
- "6908:6908"
restart: unless-stopped
networks:
- default
resilio:
image: ghcr.io/monlor/xiaoya-resilio
container_name: resilio
environment:
- TZ=Asia/Shanghai
ports:
- 8888:8888
- 55555:55555
volumes:
- media:/sync/xiaoya
- config:/sync/config
depends_on:
- glue
- alist
restart: unless-stopped
networks:
- default
Expand All @@ -78,7 +95,7 @@ services:
- config:/config
- cache:/cache
ports:
- 6096:8096
- 8096:8096
restart: unless-stopped
networks:
- default
Expand Down
2 changes: 1 addition & 1 deletion docker-compose-jellyfin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ services:
- config:/config
- cache:/cache
ports:
- 6096:8096
- 8096:8096
restart: unless-stopped
networks:
- default
Expand Down
21 changes: 19 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ services:
container_name: emby
environment:
- TZ=Asia/Shanghai
- GIDLIST=0,0
- GIDLIST=0
- ALIST_DOMAIN=alist
privileged: true
devices:
Expand All @@ -58,7 +58,24 @@ services:
- config:/config
- cache:/cache
ports:
- "8096:8096"
- "6908:6908"
restart: unless-stopped
networks:
- default
resilio:
image: ghcr.io/monlor/xiaoya-resilio
container_name: resilio
environment:
- TZ=Asia/Shanghai
ports:
- 8888:8888
- 55555:55555
volumes:
- media:/sync/xiaoya
- config:/sync/config
depends_on:
- glue
- alist
restart: unless-stopped
networks:
- default
Expand Down
11 changes: 4 additions & 7 deletions emby/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
#!/bin/sh

echo "等待alist启动完成..."
while ! wget -q -T 1 -O /dev/null http://${ALIST_DOMAIN} &> /dev/null; do
sleep 2
done

echo "等待元数据下载完成..."
while test ! -f /config/emby_meta_finished; do
sleep 2
Expand All @@ -31,7 +26,9 @@ else
fi
fi

sed -i "/xiaoya.host/d" /etc/hosts
echo -e "$IP\txiaoya.host" >> /etc/hosts
# 容器里不能使用sed -i,所以使用临时文件
sed -e "/xiaoya.host/d" /etc/hosts > /tmp/hosts
echo -e "$IP\txiaoya.host" >> /tmp/hosts
cat /tmp/hosts > /etc/hosts

/init
26 changes: 13 additions & 13 deletions glue/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,28 +37,28 @@ disk_check() {


if [ "${EMBY_ENABLED:=false}" = "true" ]; then
if [ -f /media/config/emby_meta_finished ]; then
echo "Emby metadata has been downloaded. Delete the file /media/config/emby_meta_finished to re-download."
if [ -f ${MEDIA_DIR}/config/emby_meta_finished ]; then
echo "Emby metadata has been downloaded. Delete the file ${MEDIA_DIR}/config/emby_meta_finished to re-download."
else
disk_check 140
cd "${MEDIA_DIR}/temp"
/update_all.sh "${ALIST_ADDR}"
if [ $? -eq 0 ]; then
touch /media/config/emby_meta_finished
touch ${MEDIA_DIR}/config/emby_meta_finished
fi
fi
fi

if [ "${JELLYFIN_ENABLED:=false}" = "true" ]; then
if [ -f /media/config/jellyfin_meta_finished ]; then
echo "Jellyfin metadata has been downloaded. Delete the file /media/config/jellyfin_meta_finished to re-download."
if [ -f ${MEDIA_DIR}/config/jellyfin_meta_finished ]; then
echo "Jellyfin metadata has been downloaded. Delete the file ${MEDIA_DIR}/config/jellyfin_meta_finished to re-download."
else

disk_check 140

echo "Downloading Jellyfin metadata..."

cd /media/temp
cd ${MEDIA_DIR}/temp

if [ ! -f "${MEDIA_DIR}/temp/config_jf.mp4" ]; then
echo "Downloading config_jf.mp4..."
Expand All @@ -75,16 +75,16 @@ if [ "${JELLYFIN_ENABLED:=false}" = "true" ]; then

echo "Extracting Jellyfin metadata..."

cd /media
cd ${MEDIA_DIR}
7z x -aoa -mmt=16 temp/config_jf.mp4

cd /media/xiaoya
7z x -aoa -mmt=16 /media/temp/all_jf.mp4
cd ${MEDIA_DIR}/xiaoya
7z x -aoa -mmt=16 ${MEDIA_DIR}/temp/all_jf.mp4

cd /media/xiaoya
7z x -aoa -mmt=16 /media/temp/PikPak_jf.mp4
cd ${MEDIA_DIR}/xiaoya
7z x -aoa -mmt=16 ${MEDIA_DIR}/temp/PikPak_jf.mp4

touch /media/config/jellyfin_meta_finished
touch ${MEDIA_DIR}/config/jellyfin_meta_finished

fi
fi
Expand All @@ -102,6 +102,6 @@ echo -e "$crontabs" | crontab -

echo "Complete."

touch /media/config/meta_finished
touch ${MEDIA_DIR}/config/meta_finished

tail -f /dev/null
49 changes: 45 additions & 4 deletions helmfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,14 @@ releases:
- name: alist
namespace: media
chart: monlor/quickchart
version: 0.2.4
version: 0.2.5
values:
- port: 80
extraPort:
- port: 2345
protocol: TCP
- port: 2346
protocol: TCP
nodeSelector:
kubernetes.io/hostname: nuc-1-node-1
image:
Expand Down Expand Up @@ -49,7 +54,7 @@ releases:
- name: glue
namespace: media
chart: monlor/quickchart
version: 0.2.4
version: 0.2.5
values:
- nodeSelector:
kubernetes.io/hostname: nuc-1-node-1
Expand Down Expand Up @@ -97,7 +102,7 @@ releases:
- name: emby
namespace: media
chart: monlor/quickchart
version: 0.2.4
version: 0.2.5
values:
- port: 8096
nodeSelector:
Expand Down Expand Up @@ -147,4 +152,40 @@ releases:
className: nginx
clusterIssuer: cloudflare
hosts:
- host: emby.monlor.cn
- host: emby.monlor.cn

- name: resilio
namespace: media
chart: monlor/quickchart
version: 0.2.5
values:
- port: 8888
nodeSelector:
kubernetes.io/hostname: nuc-1-node-1
image:
repository: ghcr.io
name: monlor/xiaoya-resilio
tag: latest
pullPolicy: Always
env:
TZ: Asia/Shanghai
volumes:
- name: media
mountPath: /media/xiaoya
hostPath:
path: /opt/xiaoya/media
type: DirectoryOrCreate
- name: config
mountPath: /media/config
hostPath:
path: /opt/xiaoya/config
type: DirectoryOrCreate
strategy:
type: Recreate
resources:
limits:
cpu: 2
memory: 4Gi
requests:
cpu: 100m
memory: 512Mi
8 changes: 4 additions & 4 deletions jellyfin/create_jellyfn.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/bin/sh

docker pull nyanmisaka/jellyfin:240220-amd64-legacy
docker pull nyanmisaka/jellyfin:240220-arm64
docker pull nyanmisaka/jellyfin:240401-amd64
docker pull nyanmisaka/jellyfin:240401-arm64

docker buildx imagetools create \
--tag monlor/jellyfin:latest \
nyanmisaka/jellyfin:240220-amd64-legacy \
nyanmisaka/jellyfin:240220-arm64
nyanmisaka/jellyfin:240401-amd64 \
nyanmisaka/jellyfin:240401-arm64
6 changes: 4 additions & 2 deletions jellyfin/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ else
fi
fi

sed -i "/xiaoya.host/d" /etc/hosts
echo -e "$IP\txiaoya.host" >> /etc/hosts
# 容器里不能使用sed -i,所以使用临时文件
sed -e "/xiaoya.host/d" /etc/hosts > /tmp/hosts
echo -e "$IP\txiaoya.host" >> /tmp/hosts
cat /tmp/hosts > /etc/hosts

/jellyfin/jellyfin --datadir /config --cachedir /cache --ffmpeg /usr/lib/jellyfin-ffmpeg/ffmpeg
Loading

0 comments on commit 753a893

Please sign in to comment.