Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docker和systemd下的持久化侧载以及sed命令的修改 #20

Closed
Ovler-Young opened this issue Jan 4, 2024 · 3 comments
Closed
Labels
enhancement New feature or request

Comments

@Ovler-Young
Copy link

Ovler-Young commented Jan 4, 2024

考虑到我管理的服务器中转发方案并非 nginx 或 caddy ,也有直接使用 ip 进行访问不使用转发的需求, #8 中的方案无法直接使用,但给予了我灵感,在每次 jellyfin 启动前先进行文件的修改也能完成持久化侧载。调试过程中发现 readme 所给的 sed 命令重复运行会重复插入,故稍作更改,增加了</div>的识别片段以避免js的重复插入。

将 docker 容器的启动参数在原来 /init 的基础上增加 sed 部分,即可实现每次docker启动时自动修改html文件。

hotio/jellyfin 的容器内html文件地址为例,将 /init 改为如下即可:

sed -i 's#</div></body>#</div><script src="https://jellyfin-danmaku.pages.dev/ede.user.js" defer></script></body>#' /usr/share/jellyfin/web/index.html && /init

对于官方的容器如下:

sed -i 's#</div></body>#</div><script src="https://jellyfin-danmaku.pages.dev/ede.user.js" defer></script></body>#' /jellyfin/jellyfin-web/index.html && /jellyfin/jellyfin

另外,使用 systemd 自动运行 jellyfin 也可类似的进行修改,将 execstart 进行覆盖即可。

ExecStart = sed -i 's#</div></body>#</div><script src="https://jellyfin-danmaku.pages.dev/ede.user.js" defer></script></body>#' /usr/share/jellyfin/web/index.html && /usr/bin/jellyfin $JELLYFIN_WEB_OPT $JELLYFIN_RESTART_OPT $JELLYFIN_FFMPEG_OPT $JELLYFIN_SERVICE_OPT $JELLYFIN_NOWEBAPP_OPT $JELLYFIN_ADDITIONAL_OPTS
@Ovler-Young Ovler-Young added the enhancement New feature or request label Jan 4, 2024
@Izumiko
Copy link
Owner

Izumiko commented Jan 5, 2024

不需要每次启动时修改html吧?只有在创建容器,或者更新image之后,运行一次sed即可。readme中提到的持久化是指更新image之后,不用再手动运行那一次。

@Ovler-Young
Copy link
Author

因为对sed命令进行了修改,重复运行并不会重复插入。
只在创建容器或者更新image之后运行sed的确更优雅,但是似乎没有找到能这么干的设置处。
更改启动参数之后,后续升级更新也不再需要手动修改。

@Izumiko
Copy link
Owner

Izumiko commented Jan 7, 2024

我更新一下readme,另外,sytemd那个方式,用ExecStartPre估计更好点
systemctl edit jellyfin.service
然后添加

[Service]
ExecStartPre=-/usr/bin/sed -i 's#</div></body>#</div><script src="https://jellyfin-danmaku.pages.dev/ede.user.js" defer></script></body>#' /usr/share/jellyfin/web/index.html

@Izumiko Izumiko closed this as completed Jan 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants