Forum archive
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 defaultsXRDP isn't working in this version.
This patch and my attempts at builds on debian all failed, seemingly around trying to make it a service.