Most of the time, there are a lot of options when it comes to open source and self-hosted software. Hosting an eBook library is no exception. I’ve been a Calibre user for many years, so in this post, I’m going to stick to what I know and talk about Calibre. In future posts, I might review other similar software.

What is Calibre?

Let’s start with the basics. Calibre is an open-source, cross-platform ebook management software. It’s been around for more than 15 years. It’s rich in features; it supports almost all formats and can perform converting to other formats. It’s still very actively developed, and I think it’s a one-stop shop at the moment for eBook management.

Notes on Compatability

Installing Calibre on Raspberry Pi, which is an ARM based computer, as opposed to installing it on a standard Intel based Mac/PC, comes with some complications. If you look at Download for Linux page on the official Calibre website, you can see this info:

calibre has a binary install that includes private versions of all its dependencies. It runs on 32-bit and 64-bit Intel compatible machines. 

Then, your best bet to install on Raspberry Pi is either use package manager or Docker.

The same download page also says:

Please do not use your distribution provided calibre package, as those are often buggy/outdated. Instead use the Binary install described below.

So, Docker then? There are lots of Calibre Docker images. The most reliable one I came across, in terms of popularity and maintenance, is linuxserver.io’s image but it only supports arm64 and it didn’t work for me as my Pi is 32-bit. If you’re using a 64-bit Raspberry Pi, this may be good option for you.

Implemented Architecture

You can think of Calibre as comprised of two components:

  • Content server
  • Front end

To keep things simple, you can install Calibre on your computer and run the built-in content server. The downside is that the computer needs to be on all the time if you are going to browse your library via your mobile device.

There are many ways of getting the same results. In my setup, I chose this approach:

Implementation architecture

Calibre-web is the front-end I’m using as it ships as a Docker image and runs on 32-bit Raspberry Pi. The look & feel of the GUI is much better than the built-in one in my opinion.

The problem with Calibre-web is that it only operates on existing Calibre databases. You still need some Calibre running somewhere to create the initial database at least.

Create a Network Share

The first step is to have a shared place to put the library. In Raspberry Pi, this requires installing Samba and updating its configuration.

The following settings may be too broad/open for your network. Make sure to harden the security as you see fit.

Step 1: Update your Raspberry Pi and install Samba:

sudo apt-get update && sudo apt-get upgrade
sudo apt-get install samba samba-common-bin

Step 2: Create a shared folder:

sudo mkdir -m 1777 /share

Step 3: Update Samba configuration

Run

sudo nano /etc/samba/smb.conf

and add the following lines to the end

[calibre]
Comment = Calibre shared folder
Path = /share
Browseable = yes
Writeable = Yes
only guest = no
create mask = 0777
directory mask = 0777
Public = yes
Guest ok = yes

Step 4: Set Samba password

sudo smbpasswd -a pi

Step 5: Reboot

sudo reboot now

Now you can point to that share in your computer where you will install Calibre.

Install Calibre

Installing Calibre is rather straightforward. Go to the download page and pick the installer for your operating system.

Calibre download page

Create Calibre Database

Create an empty folder under the shared folder (magazines/library in this example)

Open Calibre. Click the Calibre icon and select Switch/create new library.

Switch/create library button

Enter the path to the shared library and select the Create an empty library at the new location option.

Choose library dialogue

You should now see an empty library in the application.

Empty Calibre library

Add your books/magazines to your database. You can simply drag&drop on onto the GUI. In this example, I’m going to use Phrack Magazine, which is freely available.

It comes in simple text files, so I combined them into a single text and converted them into PDF using the built-in macOS application Text Editor. You can use any PDF in your case.

Either click Add books and browser your files or simply drag&drop and you should get the same result:

Calibre showing uploaded PDF

Install Calibre-Web

Now it’s time to install the always-on content server that will point to the shared.

Create a folder named config under the shared library (/calibre/magazines).

Then, run the following command to pull the latest calibre-web Docker image and start a container (update the shared volumes and timezone to match your system):

docker run -d --name=calibre-web-demo -e PUID=1000 -e PGID=1000 -e TZ=Europe/London -p 8083:8083 -v /share/magazines/config:/config -v /share/magazines/library:/books --restart unless-stopped linuxserver/calibre-web

Now in your browser, go to http://{Your Raspberry Pi’s IP Address}:8083, and you should see the calibre-web configuration screen:

Calibre-web configuration screen

The only configuration you have to make here is to point to the Calibre database, which is mapped to /books. So all you have to do is enter /books in the Location of Calibre database field.

Click Submit, and you should see a successful update message:

Configuration updated confirmation

Click Login and use the default credentials: admin/admin123.

Calibre-web login page

You should now see the PDF you uploaded earlier:

Calibre-web front page

Now you can use the Calibre application on your computer, upload/convert the books as you please and consume them over standard HTTP on your tablet or phone.

Conclusion

This setup may be overly complicated, and I might want to revise it in the future, but for the time being, it does the job.

Categories: raspberry pi