start-calibre-server.sh 806 B

12345678910111213141516171819202122
  1. #!/usr/bin/env bash
  2. # Resolve trusted IP addresses
  3. TRUSTED_IPS="$(ip route | awk '/default/ { print $3 }')"
  4. for h in $TRUSTED_HOSTS; do
  5. HOST_IP="$(nslookup -type=A $h | tail -n2 | awk '/Address:/ { print $2 }')"
  6. if [ -z "${HOST_IP}" ]; then
  7. >&2 echo "WARNING: host '$h' not found in network. container with that name will not get write access to the library"
  8. else
  9. TRUSTED_IPS="${TRUSTED_IPS},${HOST_IP}"
  10. fi
  11. done
  12. echo "trusted ips: ${TRUSTED_IPS}"
  13. touch "/opt/calibre/calibre-library/metadata.db"
  14. XDG_RUNTIME_DIR=/tmp/runtime-root /usr/bin/calibre-server \
  15. --disable-use-bonjour \
  16. --enable-local-write \
  17. --userdb /opt/calibre/calibre-library/server-users.sqlite --enable-auth \
  18. --trusted-ips="${TRUSTED_IPS}" \
  19. "$@" \
  20. "/opt/calibre/calibre-library"