소스 검색

calibre-web: add ENABLE_AUTOADDBOOKS and fix s6

John 11 달 전
부모
커밋
831db4ad78

+ 1 - 0
calibre-web/Dockerfile

@@ -8,6 +8,7 @@ ARG UNRAR_VERSION=6.2.12
 
 ENV UID=1000
 ENV GID=1000
+ENV ENABLE_AUTOADDBOOKS=true
 ENV ENABLE_CALIBRE_SERVER=false
 ENV ENABLE_CALIBRE_SERVER_OPDS=false
 ENV ENABLE_CALIBREDB_URLLIBRARYPATH=true

+ 2 - 0
calibre-web/README.md

@@ -90,6 +90,7 @@
 | `-v /自动添加文件夹:/autoaddbooks` |calibre自动添加图书文件夹位置|
 | `-e UID=1000` |uid设置,默认为1000|
 | `-e GID=1000` |gid设置,默认为1000|
+| `-e ENABLE_AUTOADDBOOKS=true` |(true\|false)设定开启自动添加图书功能,默认开启|
 | `-e ENABLE_CALIBRE_SERVER=false` |(true\|false)设定开启calibre-server,默认关闭|
 | `-e ENABLE_CALIBRE_SERVER_OPDS=false` |(true\|false)开启calibre-server的OPDS功能,默认不开启,arm可能不可用|
 | `-e ENABLE_CALIBREDB_URLLIBRARYPATH=true` |(true\|false)开启calibre-server与calibre-web共存补丁,默认开启|
@@ -132,6 +133,7 @@
 |:-|:-|
 | `UID=1000` |uid设置,默认为1000|
 | `GID=1000` |gid设置,默认为1000|
+| `ENABLE_AUTOADDBOOKS=true` |(true\|false)设定开启自动添加图书功能,默认开启|
 | `ENABLE_CALIBRE_SERVER=false` |(true\|false)设定开启calibre-server,默认关闭|
 | `ENABLE_CALIBRE_SERVER_OPDS=false` |(true\|false)开启calibre-server的OPDS功能,默认不开启,arm可能不可用|
 | `ENABLE_CALIBREDB_URLLIBRARYPATH=true` |(true\|false)开启calibre-server与calibre-web共存补丁,默认开启|

+ 5 - 3
calibre-web/root/etc/cont-init.d/calibre-web.sh

@@ -206,7 +206,9 @@ if [ -f /opt/calibre/bin/calibre-server.bak ]; then
   mv /opt/calibre/bin/calibre-server.bak /opt/calibre/bin/calibre-server
 fi
 #添加图书.
-if [ "`ls -A /autoaddbooks`" != "" ];then
-  su -p calibre -s /bin/bash -c "calibredb add -r /autoaddbooks $CALIBREDB_OTHER_OPTION --library-path=/library"
-  rm -r /autoaddbooks/*
+if [ "$ENABLE_AUTOADDBOOKS" == "true" ]; then
+  if [ "`ls -A /autoaddbooks`" != "" ];then
+    su -p calibre -s /bin/bash -c "calibredb add -r /autoaddbooks $CALIBREDB_OTHER_OPTION --library-path=/library"
+    rm -r /autoaddbooks/*
+  fi
 fi

+ 3 - 0
calibre-web/root/etc/services.d/calibre-server/run

@@ -12,4 +12,7 @@ if [ "$ENABLE_CALIBRE_SERVER" == "true" ]; then
   else
     exec s6-setuidgid calibre calibre-server $CALIBRE_SERVER_OTHER_OPTION /library --port $CALIBRE_SERVER_PORT
   fi
+else
+  s6-svc -Od .
+  exit 0
 fi

+ 18 - 13
calibre-web/root/etc/services.d/inotify/run

@@ -1,17 +1,22 @@
 #! /usr/bin/with-contenv bash
 
 # 启动inotify
-while inotifywait -e close -e move -r /autoaddbooks; do
-    if [ "`ls -A /autoaddbooks`" != "" ]; then
-      inotifywait -mr /autoaddbooks -t 30
-      if [ "$ENABLE_CALIBRE_SERVER" == "true" ]; then
-        mv /opt/calibre/bin/calibre-server /opt/calibre/bin/calibre-server.bak
-        ps -ef |grep /opt/calibre/bin/calibre-server |grep -v grep|awk '{print $1}'|xargs kill -9
-        su -p calibre -s /bin/bash -c "calibredb add -r /autoaddbooks $CALIBREDB_OTHER_OPTION --library-path=/library"
-        mv /opt/calibre/bin/calibre-server.bak /opt/calibre/bin/calibre-server
-      else
-        su -p calibre -s /bin/bash -c "calibredb add -r /autoaddbooks $CALIBREDB_OTHER_OPTION --library-path=/library"
+if [ "$ENABLE_AUTOADDBOOKS" == "true" ]; then
+  while inotifywait -e close -e move -r /autoaddbooks; do
+      if [ "`ls -A /autoaddbooks`" != "" ]; then
+        inotifywait -mr /autoaddbooks -t 30
+        if [ "$ENABLE_CALIBRE_SERVER" == "true" ]; then
+          mv /opt/calibre/bin/calibre-server /opt/calibre/bin/calibre-server.bak
+          ps -ef |grep /opt/calibre/bin/calibre-server |grep -v grep|awk '{print $1}'|xargs kill -9
+          su -p calibre -s /bin/bash -c "calibredb add -r /autoaddbooks $CALIBREDB_OTHER_OPTION --library-path=/library"
+          mv /opt/calibre/bin/calibre-server.bak /opt/calibre/bin/calibre-server
+        else
+          su -p calibre -s /bin/bash -c "calibredb add -r /autoaddbooks $CALIBREDB_OTHER_OPTION --library-path=/library"
+        fi
+        rm -r /autoaddbooks/*
       fi
-      rm -r /autoaddbooks/*
-    fi
-done
+  done
+else
+  s6-svc -Od .
+  exit 0
+fi