From 40cb22c89394d498a1f13d2f1a9e522953ae216e Mon Sep 17 00:00:00 2001
From: Chengbin Du <robertduu@gmail.com>
Date: Sat, 18 May 2024 16:12:49 +0800
Subject: [PATCH] add init script

---
 content/posts/2024-05-03/index.md | 40 +++++++++++++++++++++++++++++--
 1 file changed, 38 insertions(+), 2 deletions(-)

diff --git a/content/posts/2024-05-03/index.md b/content/posts/2024-05-03/index.md
index f67468b..fe1a5b1 100644
--- a/content/posts/2024-05-03/index.md
+++ b/content/posts/2024-05-03/index.md
@@ -66,10 +66,45 @@ router $ docker run -d \
  --volume /mnt/mmcblk1p3/jellyfin/cache:/cache \
  --volume /mnt/baidu1:/media/baidu1 \
  --net=host \
- --restart=on-failure \
+ --restart=unless-stopped \
  jellyfin/jellyfin
 ```
 
+#### 添加自启动脚本
+
+```bash
+router $ cat /etc/init.d/zz-b-jellyfin 
+#!/bin/sh /etc/rc.common
+ 
+START=99
+# :!: If multiple init scripts have the same start value, the call order is determined by the alphabetical order of the init script's names.
+STOP=0
+ 
+start() {        
+        echo "start jellyfin"
+        /usr/bin/rclone \
+                --config /root/.config/rclone/rclone.conf \
+                mount alist:/baidu1 /mnt/baidu1 \
+                --vfs-cache-mode writes  \
+                --vfs-cache-max-size 1024M   \
+                --cache-dir /mnt/mmcblk1p3/mnt_baidu1_cache   \
+                --header "Referer:https://pan.baidu.com/"    \
+                --header "User-Agent:pan.baidu.com"   \
+                --allow-non-empty --daemon
+        docker start jellyfin
+}                 
+ 
+stop() {          
+        echo "stop jellyfin"
+        docker stop jellyfin
+        /usr/bin/umount /mnt/baidu1
+}
+
+router $ chmod a+x /etc/init.d/zz-b-jellyfin
+router $ /etc/init.d/zz-b-jellyfin enable
+```
+
+
 #### Jellyfin Server 版本信息
 ```bash
 router $ docker logs jellyfin | head -n 11 
@@ -100,4 +135,5 @@ router $ docker logs jellyfin | head -n 11
 - [使用jellyfin和ttm在Windows系统上搭建本地私人影院](https://zhuanlan.zhihu.com/p/673925871)
 - [在 OpenWrt 中安装 Jellyfin 搭建家庭影音中心](https://leovan.me/cn/2023/01/build-home-media-center-with-jellyfin-on-openwrt/)
 - [在windows系统上挂载alist网盘的webDav](https://echo.xuchaoji.com/index.php/archives/400/)
-- [Using the WebDAV Redirector](https://learn.microsoft.com/en-us/iis/publish/using-webdav/using-the-webdav-redirector)
\ No newline at end of file
+- [Using the WebDAV Redirector](https://learn.microsoft.com/en-us/iis/publish/using-webdav/using-the-webdav-redirector)
+- [Init scripts documentation](https://openwrt.org/docs/techref/initscripts)
\ No newline at end of file