Calibre Web Automated - zbrewer/homelab GitHub Wiki
Calibre Web Automated is a form of Calibre Web that provides a web-based book library, conversion tools, and more. I host this using Docker with the library hosted on TrueNAS.
Before setting up the Calibre Web Docker container, storage for the library and ingest directories should be set up. These directories will hold the database/book files and any books to be added, respectively.
The easiest solution for these is to use local directories on the machine that will host Calibre Web Automated (CWA). They can then be passed through to CWA using bind mounts. However, I wanted to use my NAS for storage to make it easier to add books to the ingest directory, and to make backups easier.
In order to do that, I first created a books
dataset and placed a new calibre-library
and calibre-ingest
directory inside of it. I also created a books-writers
group and a calibre
user on the NAS. I made sure that the calibre
user was in the books-writers
group and updated the ACLs on the books
dataset to provide read, write, and execute permissions to the books-writers
group.
From there, I added new SMB shares for the calibre-library
and calibre-ingest
directories. I ensured these shares were available to the calibre
user. Note that, a single share for the parent books
could also be used.
Next, these shares need to be mounted on the machine that will host CWA. Create a file at /etc/.truenas_calibre_creds
to store the calibre
user's login credentials that will be used for SMB authentication. The format of this file is as follows (with the information in the <>
replaced appropriately):
username=<username>
password=<password>
Make sure this file is owned by the root user and not readable by non-root with:
$ sudo chown root: /etc/.truenas_calibre_creds
$ sudo chmod 600 /etc/.truenas_calibre_creds
Next, create the locations where these shares should be mounted. I used /mnt/calibre-library
and /mnt/calibre-ingest
. Finally, edit /etc/fstab
to add the mounts for these shares. This is in the format:
//<host ip>/<share name> <mount location> cifs credentials=/etc/.truenas_calibre_creds,iocharset=utf8,uid=1000,gid=1000,noperm,nobrl 0 0
Note that the uid
and gid
should be set to the same user that is running the CWA container, usually 1000. The nobrl
option is also needed to host the library over a network share. See here for an explanation.
For me, this looks like:
//10.0.20.10/calibre-library /mnt/calibre-library cifs credentials=/etc/.truenas_calibre_creds,iocharset=utf8,uid=1000,gid=1000,noperm,nobrl 0 0
//10.0.20.10/calibre-ingest /mnt/calibre-ingest cifs credentials=/etc/.truenas_calibre_creds,iocharset=utf8,uid=1000,gid=1000,noperm,nobrl 0 0
Make sure that the cifs-utils
package is installed and run sudo umount -a
to make sure there are no errors and to mount these shares (you may also have to run sudo systemctl daemon-reload
). Try to list the files in these directories (ls /mnt/calibre-library
) to make sure they mounted correctly. You can also use ls -l
on the parent directory ls -l /mnt
to make sure the owners/permissions are set correctly. Optionally you can try to create/delete a file in each to make sure the permissions are set up right.
From there, the container can be started in Docker Compose. I use this compose file, but examples are given on the CWA Github page as well. A couple important notes:
- Make sure the PUID and GUID match the user running Docker Compose, and the UID/GID that mounted the shares above.
- The config directory is just hosted in a Docker volume, but a bind mount could also be used.
- Bind mounts are used for the
cwa-book-ingest
andcalibre-library
volumes, bound to the locations where the SMB shares were mounted in the above step.
Place any existing database/library in the calibre-library
directory (one will be created if you don't have one) and start the container. Ensure that there are no errors in the logs and log in using the admin
/admin123
username/password. Ensure that any existing library contents show up, and change the password for the admin user in the settings. Create any additional users you would like and attempt to use the Upload
button in the upper right to make sure that write permissions are correct and working okay. You can also test the ingest directory by adding a book there (remember, the original will be deleted when ingest is done) and using the Refresh Library
button in the web UI.
CWA can send books to your E-Reader via email. For me, this is a Kindle and "Send to Kindle" email address.
To set this up, first make sure that your Kindle has an email address (or create one if it doesn't) and copy this into the Send to eReader Email Address
field in the user settings in CWA. The Kindle email address can be found by going to the devices page on Amazon and clicking on your Kindle.
Next, on the devices page, go the Preferences
tab (at the top), click on Personal Document Settings
, and add the email address that will be sending books to the Kindle to the Approved Personal Document E-mail List
.
I use Gmail for this and, while the Calibre Web Gmail OAuth Support can be used, I prefer to use the Gmail SMTP server and an app password.
Login to CWA using the admin
account and go to the Setting
page, followed by Edit Email Server Settings
. Use the following settings:
Email Account Type | Standard Email Account |
---|---|
SMTP Hostname | smtp.gmail.com |
SMTP Port | 465 |
Encryption | SSL/TLS |
SMTP Login | [email protected] |
SMTP Password | <App Password> |
From Email | Calibre Web <[email protected]> |
Attachment Size Limit | 25 MB |
Replace <App Password>
with an app password created here and username
with the username of the Gmail account. Click the SAVE AND SEND TEST EMAIL
button and make sure the Admin user receives a test email (or that the email shows up in the Sent
mail for the Gmail account used). Note that this will be sent to the user's email address in CWA, so make sure that is set correctly first.
Assuming this all worked, look for the "paper plane" symbol on book pages and use that to send the book to your E-Reader(s).
SSO is still a work-in-progress in CWA. There is an open feature request to add generic OIDC/OAuth2 support, which would allow me to use Authentik. Until that is added, I'm not using SSO for CWA.
Calibre Web Automated Book Downloader is a separate but related project that supports searching for and downloading books from Anna's Archive and utilizes the ingest directory of CWA to automatically add them. The same Docker Compose stack that is used for CWA can be used to turn up the automated book downloader as well. See the automated downloader Github page for more options and installation instructions.