Calibre
Over the past few years I have kept hearing how great it can be to run a Calibre server for your personal eBooks. Any time I have looked into it, Calibre's documentation has just never made sense to me as far what I actually need to do. Yesterday I stumbled upon a guide from Digital Ocean. And it makes sense what I am working with now, so I am going to give it a try.
Verify System Requirements
All the guide lists for requirements is the following:
A server running Ubuntu 20.04 with a sudo user and a firewall.
Well OK then. I'll start with 1vCPU and 2GB of memory, with a 30GB virtual disk. I will plan to mount the library of books from my fileserver.
Create Virtual Machine
Steps performed on HV-03 via Windows Admin Center
- Navigate to
Virtual Machines - Click on
AddthenNew- Name:
CALIBRE-01 - Generation:
Generation 2 (Recommended) - Virtual Processors Count:
1 - Startup Memory:
2 GB - Virtual Switch:
Default External Switch - Storage:
- New Disk 1 Size (GB):
30
- New Disk 1 Size (GB):
- Click on
Create
- Name:
- Select
Calibre-01 - Click on
Settings- Navigate to
Disks- Add my Ubuntu 22.04 ISO
- Click
Save disk settings
- Navigate to
Boot order- DVD
- Hard Disk
- Network Adapter
- Click
Save boot order
- Navigate to
Security- Enable Secure Boot:
Yes - Template:
Microsoft UEFI Certificate Authority - Click
Save security settings
- Enable Secure Boot:
- Navigate to
- Power on
CALIBRE-01
Install the Operating System
Steps performed on CALIBRE-01
- I open the console
Failed to Power on with Error 'General access denied error'. Hyper-V Virtual Machine Management service Account does not have permission to open attachment 'c:\Images\Ubuntu\ubuntu-22.04-live-server-amd64-iso'
Well this is a new one for me. Looking online I came up with very little useful information that I haven't already tried. When I check the permissions on the folder and files themselves I found a whole bunch of permissions assigned to Account Unknown. This seems odd to me since I have not messed around much with permissions on HV-03. Maybe they were originally there when I copied the files to HV-03? To get this fixed I had to add the Domain Admins Group to a number of local groups on HV-03. Specifically:
Remote Management UsersDevice OwnersCertificate Services DCOM AccessAccess Control Assistance Operators
With the permission issue fixed I re-attach the Ubuntu ISO and it works just fine this time. The system boots without error and loads the Ubuntu 22.04 ISO.
I walk through the Ubuntu installation wizard on CALIBRE-01. While it is working I jump over to DC-02 in Windows Admin Center and create the A record CALIBRE.domain.local
Configure the Operating System
Configure SSH Key
Steps performed on my desktop via Windows Terminal
ssh-keygen -t ed25519Move-Item -Path c:\Users\david\filename* -Destination c:\Users\david\.ssh -Force- I open
Windows Terminal Settings - I open the
JSONfile and add the following:
{
"colorScheme": "Ubuntu-ColorScheme",
"commandline": "ssh -i \"~/.ssh/example\" [email protected]",
"experimental.retroTerminalEffect": false,
"font":
{
"face": "Cascadia Code"
},
"guid": "{0caa0dad-35be-5f56-a8ff-XXXXXXXXXXXX}",
"hidden": false,
"name": "CALIBRE-01",
"tabTitle": "CALIBRE-01"
},
- I verify the
GUIDis unique and save theJSONfile
Configure SSH
Steps performed on CALIBRE-01
mkdir /home/david/.sshnano /home/david/.ssh/authorized_keys- I paste in the public key and save the file
chmod 600 /home/david/.ssh/authorized_keyssudo nano /etc/ssh/sshd_configPermitRootLogin noPubkeyAuthentication yesPubkeyAcceptedKeyTypes ssh-ed25519PasswordAuthentication noAuthorizedKeysFile /home/david/.ssh/authorized_keys
- I save the file
sudo sshd -tsudo systemctl restart ssh
Configure Firewall
Steps performed on CALIBRE-01
sudo ufw allow OpenSSHsudo ufw enablesudo ufw status
Status: active
To Action From
-- ------ ----
OpenSSH ALLOW Anywhere
OpenSSH (v6) ALLOW Anywhere (v6)
Install Calibre Server
Step 1 - Downloading and Installing the Calibre Content Server
Steps performed on CALIBRE-01
sudo apt update && sudo apt install -y libfontconfig libgl1-mesa-glxwget https://download.calibre-ebook.com/linux-installer.shsudo sh linux-installer.shUsing python executable: /usr/bin/python3You are missing the system library libEGL.so.1. Try installing packages such as libegl1 and libopengl0
sudo apt install libegl1 libopengl0sudo sh linux-installer.shDownloading calibre-6.13-0-x86_64.txzRun "calbire" to start calibre
Step 2 - Creating a Library and Adding Your First Book
This step has you make a library directory and download a book to this directory. This is basically just a test. I want to just skip this and move straight into using my mount to my fileserver. First thing I do is create a copy of my book directory on my fileserver for testing.
Steps performed on DC-02 via Windows Admin Center
- Navigate to
Active Directory - Navigate to
Browse - Navigate to
Managed Service ACcounts - Create a basic service account named
_service_calibre
Steps performed on Fileserver via Windows Admin Center
- I give
_service_calibreaccess to the books directory
Steps performed on CALIBRE-01
sudo apt install cifs-utilsnano /home/david/.calibrecredentials
username=_service_calibre
password=XXXXXXXXXXXX
domain=domain.local
- I save the
.calibrecredentialsfile sudo nano /etc/fstab
//10.10.10.XXX/Data/Files/Books /mnt/calibre-library cifs credentials=/home/david.calibrecredentials,iocharset=utf8 0 0
sudo mount -amount error(13): Permission denied
I corrected my typo but that changed it from dealing with a permission denied error to an Input/Output error. I was able to get the issue resolved with the following:
sudo nano /etc/fstab
//10.10.10.XXX/Data/Files/Books /mnt/calibre-library cifs credentials=/home/david/.calibrecredentials,uid=1000,gid=1000,iocharset=utf8 0 0
So next the guide tells me to add a book to my library with the command:
calibredb add .**.mobi --with-library /mnt/calibre-library/mnt/calibre-library/**.mobi not found
Well that's strange. I try with mobi and epub, both of which I have and they both give the same error. I wonder if Calibre doesn't like my folder structure? So I delete all the books and sub-folders. Then I copy in one mobi file to test.
calibredb add **.mobi --with-library /mnt/calibre-libraryapsw.BusyError: BusyError: database is locked
I try running the same command again and get:
PermissionError: [Errno 13] Permission denied: 'mnt/calibre-library/metadata.db'
Well I see it create the database inside the mount point? Hmmm....Seems like I may need to have two separate places? When trying to unmount I am unable to. It's acting like the mount is currently in use. Expect that I haven't started Calibre at this point, so what gives? I comment out the mount in /etc/fstab and reboot.
I'll take a step back and just follow along with the walkthrough until I get a better handle on things.
wget http://www.gutenberg.org/ebooks/46.kindle.noimages -O christmascarol.mobimkdir /home/david/calibrecalibredb add .mobi --with-library calibre/
This throws out a bunch of errors about being unable to import and no such file or directory.
I run the command again and it throws out the same errors but this time it says the book already exists in the database. So when adding it does make a copy of the .mobi file and places it in a subfolder of /home/david/calibre. My reading points to Calibre not supporting networking locations. Because they put the database in the same folder as the actual Ebooks. That is a weird way to do it in my opinion but I'm no developer. Ok fine. Considering how small the book files are I can handle all of them living on the Calibre server and just backing up the books with a script back to the fileserver.
Step 3 - Running the Calibre Content Server and Viewing Your Library
Steps performed on CALIBRE-01
sudo ufw allow 8080calibre-server calibre-library
Failed to import PyQt module: PyQt6.QtGui with error: libxkbcommon.so.0: cannot open shared object file: No such file or directory
Traceback (most recent call last):
File "runpy.py", line 196, in _run_module_as_main
File "runpy.py", line 86, in _run_code
File "site.py", line 47, in <module>
File "site.py", line 43, in main
File "calibre/srv/standalone.py", line 227, in main
File "calibre/srv/standalone.py", line 69, in __init__
File "calibre/srv/handler.py", line 200, in __init__
File "importlib/__init__.py", line 126, in import_module
File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "bypy-importer.py", line 279, in exec_module
File "calibre/srv/ajax.py", line 15, in <module>
File "bypy-importer.py", line 279, in exec_module
File "calibre/srv/content.py", line 17, in <module>
File "bypy-importer.py", line 279, in exec_module
File "calibre/ebooks/covers.py", line 15, in <module>
ImportError: cannot import name 'QBrush' from 'qt.core' (/opt/calibre/lib/calibre-extensions/python-lib.bypy.frozen/qt/core.pyc)
Reading to find a solution to this error. Calibre's own download page points to this link that you have to install additional packages. Maybe? Supposedly there is a list, but I see nothing of the sort, just instructions to install one package. Ok then.
sudo apt install libxcb-xinerama0sudo sh linux-installer.sh
That still wasn't enough. I find on Calibre's site where it says I need xdg-utils as well.
sudo apt install xdg-utils
My alarm just rang, I'm out of time for today, so I'll have to come back and finish this up tomorrow.