View Single Post
Old 09-18-2011, 05:42 AM   #1
aruangra has learned how to read e-booksaruangra has learned how to read e-booksaruangra has learned how to read e-booksaruangra has learned how to read e-booksaruangra has learned how to read e-booksaruangra has learned how to read e-booksaruangra has learned how to read e-books
Posts: 78
Karma: 888
Join Date: May 2010
Device: Nook Touch, iPad1, iPad2, iPod Touch 4G, Pixel Qi
[HOW TO] Install Calibre in Intel-Based NAS

I think I should write up the instruction for installing Calibre on Intel-based NAS. Please refer to the following instruction. If you have any question, please let me know.

Best regards,
Anat Ruangrassamee

How to install Calibre in Intel-Based NAS
18 September 2011

I successfully install Calibre on a Synology DS411+II NAS to run news fetching and the content server. I tried to compile libc but had several problems. The key to the success is “Debian 6 chroot environment”. This instruction may work for other Intel-based NASes for example QNAP.

NOTE: The instruction for the ARM-based NAS was added by smintman in the following posts.

Bootstrapped NAS
For Synology, refer to,_ipkg_etc

1. Preparing chroot environment on a PC
I followed the instruction in the following websites with slight modifications to create Debian 6.0.0 packages for i386 targets which is required by Calibre

debootstrap --foreign --arch i386 squeeze chroottarget ""
You may skip this step by simply downloading my chroot target file for the i386 architecture:

2. Setup the chroot environment in your NAS
2.1 Copy the chroot target to a HDD in your NAS (/volume1/debian/ in this instruction) by any approach (FTP, NFS,etc). From now, you should use a terminal program to execute commands.
2.2 At the directory /volume1/debian/, uncompress the chroot target file using this command (Note: Don’t type # and anything in front of #)
ds # tar -xvf chroottarget.tar.gz
2.3 At the directory /volume1/debian/, finish debootstrap second stage on the target platform by using this command:
ds # chroot chroottarget /debootstrap/debootstrap --second-stage
2.4 Copy the file /etc/resolv.conf and /etc/hostname of your NAS to your chroot environment
ds # cp /etc/resolv.conf  /volume1/debian/chroottarget/etc/
ds # cp /etc/hostname /volume1/debian/chroottarget/etc/
3. Start up the chroot environment. Note that when you reboot your NAS, you need to run the following commands to start up the chroot environment.
At the directory /volume1/debian/, input this command:
ds # chroot chroottarget /bin/bash
The command prompt will be changed to chroot (for example “ds-chroot #”). Then input this command to mount “proc”
ds-chroot # mount -t proc proc /proc
4. Update apt-get and install some dependencies and programs.
ds-chroot# echo "deb stable main contrib non-free" > /etc/apt/sources.list
ds-chroot# apt-get update
Then install dependencies for Calibre. This will install Calibre 0.7.7. Note that Calibre does not work in this step. This command is used only for getting necessary dependencies.
ds-chroot# apt-get install calibre 
ds-chroot# apt-get install python
ds-chroot# apt-get install bzip2
ds-chroot# apt-get install unzip
5. Install Calibre
5.1 Make the directory “calibre” in the directory “/opt”
5.2 Download Calibre from . You may use the newest version for i686 (I use Calibre 0.8.15 on my NAS.). You can download the file to your PC and then copy to /volume1/debian/chroottarget/opt/calibre. Then uncompress the file in the directory /opt/calibre
ds-chroot# bzip2 -dv calibre-0.8.15-i686.tar.bz2
Now, you have all program files in the directory /opt/calibre. Congratulations! Calibre should work now

6. Use Calibre
6.1 The recipes are in /opt/calibre/resources/ Unzip the file and move the recipe you want to /opt/calibre
6.2 Make a directory “serve” in /opt/calibre for storing ebooks.
6.3 Run the content server by this command
/opt/calibre/calibre-server --with-library /opt/calibre/serve/ --port 8081 –-daemonize
6.4 Get news and update the database by this command
/opt/calibre/ebook-convert /opt/calibre/***.recipe /opt/calibre/***.epub
/opt/calibre/calibredb add --duplicates --with-library /opt/calibre/serve/ /opt/calibre/***.epub
7. Schedule news fetching
I use APScheduler 2.0.2 for python. Follow the instruction in this website:
This is my script (

import os
import time
from apscheduler.scheduler import Scheduler

# Start the scheduler
sched = Scheduler()

def job_function1():
	os.system("/opt/calibre/ebook-convert /opt/calibre/cnn.recipe /opt/calibre/cnn.epub")
	os.system("/opt/calibre/calibredb add --duplicates --with-library /opt/calibre/serve/ /opt/calibre/cnn.epub")

	os.system('/opt/calibre/ebook-convert /opt/calibre/cnn.recipe /opt/calibre/')
	os.system('/opt/calibre/calibre-smtp -r -v --port 587 --username --password YYYYY --a /opt/calibre/ --s "News Delivery" ""')

# Schedule
sched.add_cron_job(job_function1, day_of_week='mon-sun', hour=4, minute=0)

while True:
The last two lines will keep the script alive. To run the script in background, use this command:
nohup python &
8. When rebooting the NAS, input the following commands to start up the scheduling script and the content server:
cd /volume1/debian/
chroot chroottarget /bin/bash
mount -t proc proc /proc
cd opt/calibre/
/opt/calibre/calibre-server --with-library /opt/calibre/serve/ --port 8081 --daemonize
nohup python &

Last edited by aruangra; 09-22-2011 at 10:45 PM.
aruangra is offline   Reply With Quote