banner

This is the blog cum Notes I thought I published ages ago but it turns out I never did. So here it is now.

Warm up

  1. Install calibre package via nix or package manager of your choice sudo pacman -Sy calibre

  2. Create library at prefered location where book going to be stored. mkdir -p /home/you/library

  3. Add books to that location calibredb add /path/of/books.pdf --with-library /home/you/library

Main Course

  1. Create a systemd user service in ~/.config/systemd/user create new file called calibre-server.service touch calibre-server.service

  2. Write init script nvim calibre-server.service

[Unit]
Description=calibre content server
 
[Service]
Type=simple
ExecStart=/<path>/calibre-server --port=8180 --enable-local-write /home/you/library
 
[Install]
WantedBy=default.target

Remember to find the correct location of your calibre-server binary

with whereis calibre-server command.

  1. Enabling the service systemctl --user enable calibre-server
  2. Starting the service systemctl --user start calibre-server
  3. Check the service running at localhost:8180 in your browser
  4. Last but not least enable service to keep running in background even after your user logged out: loginctl enable-linger username

Optionals:

Provide domain name for your service using reverse proxy

write nginx.conf file

server {
    listen 10.0.0.20:80;
    server_name library.yourdomain.com;
    root /var/www/html;
    index index.html;
    location / {
        proxy_pass http://127.0.0.1:8180/;
    }
}

Now simply going to https://library.yourdomain.com you will reach to the calibre server without having to know backend hostname or port number.

To Have multiple libraries

  • Inorder to have multiple libraries running on same server just add the different library path to the main command i.e. /<path/calibre-server --port=8180 --enable-local-write /home/you/library/fiction /home/you/library/tech