TurnKey Linux Virtual Appliance Library

Calibre Server Patch for Core 11.3 Lucid

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.

Fails on 12rc Debian Core

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


Jeremy's picture

Good work Rik

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.

I had the same problem, Jeremy

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).


Also, ISO of Calibre Server on 11.3 Core


Solution for small publisher?

Hi,
I'm a publisher. I want sell my ebooks. I've been trying to figure out how to do this from a static catalog (as is generated by calibre2opds so I can use cheap hosting) but its going no where atm due to lack of custom column support.

I want to store the ebook copies, to be sold, at a 3rd-party service with higher performance (and a pay wall) than Calibre (where I maintain my master ebook copies). I want to synch Calibre and this other server when needed to add, remove or re-price items. I'd like to offer deep links into the 3rd party server from the static catalog to initiate purchase of a book. I'll want to display prices for each book from my static catalog too which I have stored in a custom column in Calibre.

Am I asking too much? Any relatively simple solution to my needs?

Jeremy's picture

I know of no such software

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?

Post new comment

The content of this field is kept private and will not be shown publicly. If you have a Gravatar account, used to display your avatar.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <p> <span> <div> <h1> <h2> <h3> <h4> <h5> <h6> <img> <map> <area> <hr> <br> <br /> <ul> <ol> <li> <dl> <dt> <dd> <table> <tr> <td> <em> <b> <u> <i> <strong> <font> <del> <ins> <sub> <sup> <quote> <blockquote> <pre> <address> <code> <cite> <strike> <caption>

More information about formatting options

Leave this field empty. It's part of a security mechanism.
(Dear spammers: moderators are notified of all new posts. Spam is deleted immediately)