Attached: A patch to bring TKL Core 11.3 Lucid to a web-based Calibre server. Another brick in the schoolhouse.

Calibre is many things: etext management system; e-text conversion mechanism; metadata and cover fetcher; and finally, a web server that serves an e-text library containing texts in multiple formats. It handles pdf, epub, mobi, and even cbr apparently.

This patch involves only the server backend. Populating the server had me confused for some time.

Scenario 1: Standalone headless server serving etexts on port 80. In this scenario, you'll need a callibre front end somewhere to manage, tag, organize your library. When you're ready to serve, use rsync or sftp the entire library to the server, /var/calibre-data. Although the server is built to autoupdate from the uploaded db, I find I have to run the following in an ssh session on the server: service calibre stop.  (Pause.) Service calibre start.

Scenario 2: You don't want to have to sync libraries. In this case, I can make another patch so the calibre front-end will work from the same machine as the server.

What the patch does:

  • sets the hostname to calibre
  • updates repos and installs what I understand to be dependencies.
  • installs Calibre to /opt/calibre
  • creates /etc/init.d/calibre and sets calibre as a startup service.
  • Adds calibre to confconsole.

Important: the following parameters are defined in /etc/init.d/calibre: un (username); pw (password); port; and path to content (which I've set to /var/calibre-data.

Calibre developers update often. To update calibre, simply run the following:

python -c "import sys; py3 = sys.version_info[0] > 2; u = __import__('urllib.request' if py3 else 'urllib', fromlist=1); exec(u.urlopen('http://status.calibre-ebook.com/linux_installer').read()); main(install_dir='/opt')"

If there's a demand, I can think of a few modifications: adding samba, adding xorg, xfce4, and xdm to manage the front end; a script to update calibre. possibly as a cron job.

Here's the conf:

#!/bin/sh -ex
#Calibre-Server Patch for TurnKey Core 11.3 (Lucid) by rik goldman

#Overlay
#/etc/init.d/calibre
#/etc/confconsole/services.txt


#Set hostname
HOSTNAME=calibre
echo "$HOSTNAME" > /etc/hostname
sed -i "s|127.0.1.1 \(.*\)|127.0.1.1 $HOSTNAME|" /etc/hosts

#hold udev for this version of core
echo udev hold | dpkg --set-selections


# install dependencies
apt-get update
DEBIAN_FRONTEND=noninteractive apt-get -y \
    -o DPkg::Options::=--force-confdef \
    -o DPkg::Options::=--force-confold \
    install \
        build-essential \
    qt4-dev-tools \
    python-setuptools \
    xdg-utils \
    imagemagick

#Install Calibre to /opt/calibre
python -c "import sys; py3 = sys.version_info[0] > 2; u = __import__('urllib.request' if py3 else 'urllib', fromlist=1); exec(u.urlopen('http://status.calibre-ebook.com/linux_installer').read()); main(install_dir='/opt')"

#Create a place for calibre library
mkdir /var/calibre-data

#Startup service in init.d
chmod +x /etc/init.d/calibre
update-rc.d calibre defaults


This patch includes a bare lxde, lxdm, xrdp frontent so managing the library and browsing the library don't necessarily require a lengthy rsync:

#!/bin/sh -ex
#Calibre-Client-Server Patch for TurnKey Core 11.3 (Lucid) by rik goldman

#Overlay
#/etc/init.d/calibre
#/etc/confconsole/services.txt


#Set hostname
HOSTNAME=calibre
echo "$HOSTNAME" > /etc/hostname
sed -i "s|127.0.1.1 \(.*\)|127.0.1.1 $HOSTNAME|" /etc/hosts

#hold udev for this version of core
echo udev hold | dpkg --set-selections


# install dependencies
apt-get update
DEBIAN_FRONTEND=noninteractive apt-get -y \
    -o DPkg::Options::=--force-confdef \
    -o DPkg::Options::=--force-confold \
    install \
        xorg \
    lxde \
    lxdm \
    build-essential \
    qt4-dev-tools \
    python-setuptools \
    xdg-utils \
    imagemagick \
    vnc4server \
    xrdp

#Install Calibre to /opt/calibre
python -c "import sys; py3 = sys.version_info[0] > 2; u = __import__('urllib.request' if py3 else 'urllib', fromlist=1); exec(u.urlopen('http://status.calibre-ebook.com/linux_installer').read()); main(install_dir='/opt')"

#Create a place for calibre library
mkdir /var/calibre-data

#Startup service in init.d
chmod +x /etc/init.d/calibre
update-rc.d calibre defaults

XRDP isn't working in this version.

Forum: 

This patch and my attempts at builds on debian all failed, seemingly around trying to make it a service.

Jeremy Davis's picture

I too have toyed with this as a patch but I don't recall where I got to. IIRC there was an issue that I came to which lead me to leave it (with grand plans to return...) When I get a chance I look forward to having a look at how you went about this one.

Something kept me from patching Calibre. It took a while to figure out the method to its madness, for some reason. After a year of working far too intimately with it for school, I've forgotten what it was that kept me from the patch. I believe it was the issue of syncing the calibre desktop library with the remote server library.

At this very moment I'm baking a patch with Nelson that includes lxde and xrdp, so the server has a minimal front end that can be administered remotely. If it works, it sheds 6 hours of rsyncing for us (12000 volumes).

Jeremy Davis's picture

But as Calibre is open source, you could always get someone (anyone who has the skill/technical expertise) to tweak it to do what you want.

I guess the other option would be to try to find some sort of e-commerce type app/web store that could fulfill your needs.

If both systems use Linux as their underlaying OS then a simple script that utilises rsync should do the job for syncing from Calibre server to whatever you have on the sales end. Although you may still need to manually tweak some stuff. I haven't used Calibre extensively so not sure, possibly it may not be the best choice for your usage scenario?

Add new comment