Repository

Looks good to me!

User Tools

Site Tools


kb:intranet:services:media:calibre:start

Calibre

calibre-server

This is not necessarily a prerequisite for Calibre Web section that follows below, but it does enable calibredb can be used to interface with the library on the server itself.

On Ubuntu 20.04 LTS:

sudo apt install libxcb-xinerama0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-render-util0 libxcb-randr0 qt5-default
sudo -v && wget -nv -O- https://download.calibre-ebook.com/linux-installer.sh | sudo sh /dev/stdin

Can't seem to get past this error, however. The first line in the error message suggests that it might be because of the lack of some X11 service. Or maybe because it needs a desktop package.

$> calibre
qt.qpa.xcb: could not connect to display
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx, xcb.

Aborted

Bingo, from: https://www.digitalocean.com/community/tutorials/how-to-create-a-calibre-ebook-server-on-ubuntu-18-04

calibre expects a desktop environment but it will not find one on a headless server, so you will see some warnings about desktop integration failing. It is safe to ignore these because we will control calibre entirely via its command line tools and web interface.

Following the guide above... first, a quick test:

$> wget http://www.gutenberg.org/ebooks/46.kindle.noimages -O christmascarol.mobi

# Create the directory to house the entire calibre library, say...
$> mkdir /var/www/calibre-library

# Add the book
$> calibredb add *.mobi --with-library /var/www/calibre-library

# Run the server, say on port 4321
$> sudo ufw allow 4321  # or whichever firewall you're working with
$> sudo ufw reload
$> calibre-server --port 4321 /var/www/calibre-library

Once viewable, we can fine-tune, e.g. add users, and enable as a systemd service:

$> calibre-server --manage-users
...

$> cat /etc/systemd/system/calibre-server.service
[Unit]
Description=calibre content server
After=network.target

[Service]
Type=simple
User=YOURUSER
Group=YOURGROUP
ExecStart=/opt/calibre/calibre-server /var/www/calibre-library --enable-local-write --enable-auth --port 4321

[Install]
WantedBy=multi-user.target

$> sudo systemctl enable calibre-server
$> sudo systemctl start calibre-server

For automated book addition, note that need to go via server route, instead of using local calibredb...

# This happens:
$> calibredb add alice.epub --with-library /var/www/calibre-library
Another calibre program such as calibre-server or the main calibre program is running. Having multiple programs that can make changes to a calibre library running at the same time is a bad idea. calibredb can connect directly to a running calibre Content server, to make changes through it, instead. See the documentation of the --with-library option for details.

# crontab
# Note: The anchor '#calibre-library' must match the directory name of the library
*/5 * * * * calibredb add /var/www/calibre-sources/ -r --with-library http://localhost:4321#calibre-library --username YOURUSERNAME --password YOURPASSWORD

calibre-web

An alternative to the built-in server is calibre-web.

Compose file for calibre-web
version: "2.1"
services:
  calibre-web:
    image: lscr.io/linuxserver/calibre-web
    container_name: calibre-web
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=Asia/Singapore
      - DOCKER_MODS=linuxserver/calibre-web:calibre #optional
      #- OAUTHLIB_RELAX_TOKEN_SCOPE=1 #optional
    volumes:
      - /var/www/calibre-web/config:/config
      - /var/www/calibre-library:/books
    ports:
      - 4321:8083
    restart: unless-stopped

For initial configuration, see https://hub.docker.com/r/linuxserver/calibre-web:

  1. Initial credentials: admin:admin123
  2. For e-book conversion: Set the Path to Calibre E-Book Converter field to /usr/bin/ebook-convert
  3. e-viewer must be enabled by the admin for individual users
  4. Uploads can be enabled by enabling it under Basic configuration, then enabling permissions on user-basis as well

If calibredb is installed, remember to change the cron task to interface with the library directly, instead of through the calibre-server:

calibredb add /var/www/calibre-sources/ -r --with-library /var/www/calibre-library && mv /var/www/calibre-sources/* /var/www/calibre-sources-archived/
kb/intranet/services/media/calibre/start.txt · Last modified: 19 months ago ( 2 May 2023) by 127.0.0.1