What's new
  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

Calibre eBook management on RT-n66U ?

huotg01

Senior Member
It's probably a crazy question, but...

Is it possible to install the Open source application Calibre (eBook management) directly on the RT-N66U ? (http://calibre-ebook.com/download_linux)

Code:
Dependencies

calibre has the following dependencies (the listed version is the minimum version) 

Package	Version
python	2.7.1 not 3.x
Python Imaging Library	1.1.6
Qt	4.8.0
PyQt	4.9.6
python-mechanize	0.1.11
ImageMagick	6.5.9
xdg-utils	1.0.2
lxml	2.2.1
python-dateutil	1.4.1
cssutils	0.9.9
BeautifulSoup	3.0.5
dnspython	1.6.0
poppler	0.20.2
podofo	0.8.2
libwmf	0.2.8
chmlib	0.40
ICU	4.4
libmtp	1.1.5
netifaces	0.8
psutil	0.6.1
cssselect	0.7.1

Thanks

GH
 
I see Qt in those requirements, which means GUI. You got a monitor connected to your router yet? ;)
 
I see Qt in those requirements, which means GUI. You got a monitor connected to your router yet? ;)

;) You are probably right, but...

In fact Calibre is a book management system that also acts as a server.
When it acts as a server, I can connect to it from my Android device, or from my Windows browser to look at my books library and my download books from it. Would it be then possible to install the server part with the DB (that would be maintained by a Windows program?

GH
 
;) You are probably right, but...

In fact Calibre is a book management system that also acts as a server.
When it acts as a server, I can connect to it from my Android device, or from my Windows browser to look at my books library and my download books from it. Would it be then possible to install the server part with the DB (that would be maintained by a Windows program?

GH

If it requires Qt, then it probably needs a whole X server, so it cannot be compiled and run in a headless environment. You would have to see if the code is modular-enough to be compiled without the GUI parts of it - without the Qt requirement. You will never get Qt compiled on a headless device.
 
Ok. I got it.

With RT-AC68U and Merlin 380.69.

I installed and is working COPS 1.0.1. ( http://blog.slucas.fr/en/oss/calibre-opds-php-server )
1. Copy your calibre library (including the db) to the USB Disk attached to the router (f.e. in calibre/BiblioNAS)
2. Get ENTWARE ( https://github.com/RMerl/asuswrt-merlin/wiki/Entware ), Optware has a too old php version.
3. Install a webserver, I choose lighttpd, and PHP7, and the other packages needed. The official guide of COPS doesn't report every package needed because was written for Debian Distribution, so you need some extra packages. Should work also with the php built in webserver ( https://github.com/seblucas/cops/wiki/Howto---PhpEmbeddedServer , but at this moment isn't available via opkg )


Code:
opkg install php7 php7-fastcgi php7-mod-ctype php7-mod-dom php7-mod-gd php7-mod-intl php7-mod-json php7-mod-mbstring php7-mod-mcrypt php7-mod-pdo php7-mod-pdo-sqlite php7-mod-simplexml php7-mod-sqlite3 php7-mod-xml libxml2 php7-mod-fileinfo lighttpd lighttpd-mod-fastcgi libsqlite3 php7-mod-xmlwriter
(it will install some other necessary packages)

Configure lighttpd : (from: https://github.com/RMerl/asuswrt-merlin/wiki/Lighttpd-web-server-with-PHP-support-through-Entware )
Code:
sed -i 's/#server.port                 = 81/server.port                 = 81/g' "/opt/etc/lighttpd/lighttpd.conf"
sed -i "/server.upload-dirs*/cserver.upload-dirs          = ( \"/opt/tmp\" )" "/opt/etc/lighttpd/lighttpd.conf"

Get PHP working:
Code:
cat >> /opt/etc/lighttpd/conf.d/30-fastcgi.conf  << EOF
server.modules += ( "mod_fastcgi" )
fastcgi.server = ( ".php" =>
( "localhost" =>
( "socket" => "/tmp/php-fcgi.sock",
"bin-path" => "/opt/bin/php-fcgi",
"max-procs" => 1,
"bin-environment" =>
( "PHP_FCGI_CHILDREN" => "2",
"PHP_FCGI_MAX_REQUESTS" => "1000" )
)
)
)
EOF

Get cops (example code for the 1.0.1 version):
Code:
cd /opt/share/www
wget https://github.com/seblucas/cops/releases/download/1.0.1/cops-1.0.1.zip
mkdir cops
unzip cops-1.0.1.zip -d ./cops

Adding mod-rewriter (useful for Kobo users) (from: https://github.com/seblucas/cops/wiki/Url-Rewriting-with-COPS ):
Code:
nano -w /opt/etc/lighttpd/conf.d/10-cops_rewrite.conf

With something like this (it's only one row), in my installation I put cops in /opt/var/share/cops/ (witch will be http://router.asus.com:81/cops) :
Code:
url.rewrite-once = ("/cops/download/(.*)/.*\.(.*)$" => "/cops/fetch.php?data=$1&type=$2", "^/cops/download/(\d+)/(\d+)/.*\.(.*)$" => "/cops/fetch.php?data=$1&db=$2&type=$3")

Configure cops:
Code:
nano -w /opt/share/www/cops/config_local.php
put the absolute path of your calibre db in $config['calibre_directory'] , for example:
Code:
<?php
$config['calibre_directory'] = '/tmp/mnt/NAS/calibre/BiblioNAS/';
?>
and, if you want direct-download using Kobo you should also set $config['cops_use_url_rewriting'] to 1 (need for automatic download from your ebook-reader using onboard browser), put in the row before ?>
Code:
$config['cops_use_url_rewriting'] = "1";
and $config['cops_provide_kepub'] to 1 to have the ebook recognized as a Kepub, so with chaptered paging, statistics, ..., again in the row before ?>
Code:
$config['cops_provide_kepub'] = "1";

for the entire list, look to config_local.php.example

let's start!

Code:
/opt/etc/init.d/S80lighttpd restart

Go to: http://router.asus.com:81/cops/checkconfig.php , everything should be "OK"

COPS ok.png

So go to http://router.asus.com:81/cops and enjoy!

PS: For standard use, (access, light addition, maintenance, reading and download) COPS is good, for heavy work, it's faster using direct Calibre:
1) Stop lighttpd server
2) Mount the NAS using NFS (with nolock option)
3) Add the library to Calibre
4) Do your work using Calibre directly on the DB
5) Disconnect Calibre
6) Lunch lighttpd and enjoy. .

Last update: 2017-02-09, Update package list to get xml-feed work properly.
 
Last edited:
Sincerly, not.
I already had lighttpd for other services, HD attached to the RT-AC68U is an NFS share with multiple usage.

In stand-by the impact in my case is 0, the access are extremly random (a search, a download) and doesn't slow the system.

In this very moment I have:
Skynet
QoS Adaptive
2 client via OpenVPN
3 Client Wi-Fi 5G, one is looking a film in streaming
4 client Wi-Fi 2.4G, one of them is an access point for the TV, SkyTV, TV Box ...
2 client cabled
I have a lot of rules for iptables
HDD is shared by NFS, SMB and a server DLNA. NFS and SMB permantly mounted on some client...

Used RAM: 220MB
CPU 1: 60%
CPU 2: 40%

More or less stats are this all day long. During the night I have backup task and some P2P ...

Maybe could be a problem if I would use the router CPU to convert an ebook from a format to another, but this are tasks witch make no-sense IMO.
My target is consult and download from the library to my Kindle without using PC. When I add o make high-management of ebook I use Calibre on NFS.
 

Latest threads

Support SNBForums w/ Amazon

If you'd like to support SNBForums, just use this link and buy anything on Amazon. Thanks!

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Back
Top