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