Calibre OPDS on AsusWRT Merlin with ENTWARE - XIYO/asuswrt-merlin.ng-kr GitHub Wiki
μκ° λ° μ¬μ μꡬ μ¬ν
μ΄ νν 리μΌμ Asus RT-AC68Uμμ AsusWRT Merlin νμ¨μ΄λ₯Ό μ¬μ©νμ¬ κ°λ°λμμ§λ§, μ½κ°μ μμ μ ν΅ν΄ Entware 리ν¬μ§ν 리(opkg)λ₯Ό μ¬μ©νλ λͺ¨λ λΌμ°ν°μ μ μ©λ μ μμ΅λλ€. μ΄ κ°μ΄λλ 리λ μ€ μμ€ν μ λν΄ μ½κ°μ κ²½νμ΄ μλ μ¬μ©μλ₯Ό μν κ²μ λλ€.
νμν κ²: ENTWARE 리ν¬μ§ν λ¦¬κ° νμ±νλ λΌμ°ν°μ Calibre λΌμ΄λΈλ¬λ¦¬κ° μλ νλ λλΌμ΄λΈκ° νμνμ§λ§, μ΄ νν 리μΌμ μ½κ³ μλ€λ©΄ μ΄λ―Έ κ°κ³ μμ κ²μ λλ€. νμ¬(2018λ 4μ) Optwareμλ λ무 μ€λλ λ²μ μ php μμ§μ΄ μμΌλ―λ‘, Entwareλ‘ λ³κ²½ν΄μΌ ν©λλ€.
μμνκΈ°
ENTWAREλ₯Ό μ€μΉνκ³ μ λ°μ΄νΈν©λλ€. (ASUS WRT Merlin: https://github.com/RMerl/asuswrt-merlin.ng/wiki/Entware , μΌλ°: https://github.com/Entware-ng/Entware-ng/wiki )
opkg update
μΉμλ² μ€λΉ
μ΄λ―Έ μΉμλ²λ₯Ό μ€νμ€μ΄λΌλ©΄ λͺ¨λ ν¨ν€μ§κ° μλμ§ νμΈνμΈμ. λ§λ μ μλ λ¬Έμ μ 99%λ λλ½λ ν¨ν€μ§λ‘ μΈν΄ λ°μν©λλ€.
μΉμλ²λ₯Ό μ€μΉνκ³ , λλ lighttpd, PHP7, κ·Έλ¦¬κ³ νμν κΈ°ν ν¨ν€μ§λ₯Ό μ ννμ΅λλ€. COPSμ 곡μ κ°μ΄λμλ Debian λ°°ν¬μ©μΌλ‘ μμ±λμ΄ "common"μ λ§μ λΌμ΄λΈλ¬λ¦¬κ° ν¬ν¨λμ΄ μμ΄μ νμν λͺ¨λ ν¨ν€μ§κ° λμμμ§ μμΌλ―λ‘ λͺ κ°μ§ "μΆκ°" ν¨ν€μ§κ° νμν©λλ€. php λ΄μ₯ μΉμλ²( https://github.com/seblucas/cops/wiki/Howto---PhpEmbeddedServer )μλ μλν΄μΌ νμ§λ§ νμ¬ opkgλ₯Ό ν΅ν΄ μ¬μ©ν μ μμ΅λλ€.
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
(μλ§λ opkgλ μ΄κ²μ μν μ’ μμ±μΌλ‘ λͺλͺ λ€λ₯Έ ν¨ν€μ§λ₯Ό μ€μΉν κ²μ λλ€)
lighttpd κ΅¬μ± : (μΆμ²: https://github.com/RMerl/asuswrt-merlin.ng/wiki/Lighttpd-web-server-with-PHP-support-through-Entware )
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"
(OpenWRT κ²½λ‘λ μ΄κ³³μ μ°Έμ‘°: https://wiki.openwrt.org/doc/howto/http.lighttpd )
κ·Έλ¦¬κ³ λ§μΉ¨λ΄, PHP μλμν€κΈ°:
cat >> /opt/etc/lighttpd/conf.d/30-fastcgi.conf << EOF
server.modules += ( "mod_scgi" )
scgi.server = (
"/RPC2" =>
( "127.0.0.1" =>
(
"socket" => "/opt/var/rpc.socket",
"check-local" => "disable"
)
)
)
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" => "1",
"PHP_FCGI_MAX_REQUESTS" => "100"
)
)
)
)
server.port = 81
EOF
(λ€μ, OpenWRT λ° κΈ°νμ λν΄ κ²½λ‘λ₯Ό μ‘°μ ) μ±λ₯ λ¬Έμ κ° μλ κ²½μ° PHP_FCGI_MAX_REQUESTS λ° PHP_FCGI_CHILDREN κ°μ μ€μ λλ€.
COPS μ€μΉ
COPSλ₯Ό κ°μ Έμ΅λλ€(1.0.1 λ²μ μ λν μμ μ½λ):
cd /opt/share/www
wget https://github.com/seblucas/cops/releases/download/1.1.1/cops-1.1.1.zip
mkdir cops
unzip cops-1.0.1.zip -d ./cops
KOBOλ₯Ό μν URL 리λΌμ΄νΈ: mod-rewrite μΆκ°(Kobo μ¬μ©μμκ² μ μ©) (μΆμ²: https://github.com/seblucas/cops/wiki/Url-Rewriting-with-COPS ): opkg install lighttpd-mod-rewrite
nano -w /opt/etc/lighttpd/conf.d/99-cops_rewrite.conf
μ΄λ κ² νμΈμ(λ¨μ§ ν μ€ λΏμ΄μμ), λ΄ μ€μΉμμλ /opt/var/share/www/cops/μ copsλ₯Ό λ£μμ΅λλ€(http://router.asus.com:81/cops λ‘ μ΄λ):
cat >> /opt/etc/lighttpd/conf.d/99-cops_rewrite.conf << EOF
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")
EOF
COPS μ€μ :
nano -w /opt/share/www/cops/config_local.php
$config['calibre_directory']μ calibre dbμ μ λ κ²½λ‘λ₯Ό λ£μ΅λλ€, μλ₯Ό λ€μ΄:
<?php
$config['calibre_directory'] = '/tmp/mnt/NAS/calibre/BiblioNAS/';
?>
μ¬μ© κ°λ₯ν λͺ¨λ λ³μλ config_local.php.example νμΌκ³Ό config_default.php νμΌμμ νμΈν μ μμ΅λλ€. μμ νλ €λ λ³μλ₯Ό config_local.phpμ μνλ κ°μΌλ‘ μ€μ νμΈμ. κ·Έλ μ§ μμΌλ©΄ COPSλ₯Ό μ²μ μ λ°μ΄νΈν λ μμ μ¬νμ΄ μμ€λ©λλ€!
KOBOλ₯Ό μν URL 리λΌμ΄νΈ: Koboλ₯Ό μ¬μ©νμ¬ μ§μ λ€μ΄λ‘λλ₯Ό μνλ©΄ $config['cops_use_url_rewriting']λ₯Ό 1λ‘ μ€μ ν΄μΌ ν©λλ€(λ΄μ₯ λΈλΌμ°μ λ₯Ό μ¬μ©νμ¬ ebook-readerμμ μλ λ€μ΄λ‘λ νμ), ?> μ μ€μ λ£κΈ°
$config['cops_use_url_rewriting'] = "1";
κ·Έλ¦¬κ³ $config['cops_provide_kepub']λ₯Ό 1λ‘ μ€μ νμ¬ μ μμ± μ KepubμΌλ‘ μΈμνκ² νμΈμ(μ₯λ³ νμ΄μ§, ν΅κ³ λ±), λ€μ ?> μμ μΆκ°
$config['cops_provide_kepub'] = "1";
μ€λΉλμ ¨λμ? μμνμΈμ!
μλ²λ₯Ό μμν©μλ€!
/opt/etc/init.d/S80lighttpd restart
(λ€μ, μμ λ AsusWRT Merlinμ μν κ²μ΄λ©°, λ€λ₯Έ νμ¨μ΄κ° μλ κ²½μ° κ²½λ‘λ₯Ό μμ νμΈμ)
μ νν ν¬νΈμμ λΌμ°ν° ipλ‘ μ΄λνμΈμ, μλ₯Ό λ€μ΄; http://router.asus.com:81/cops/checkconfig.php , λͺ¨λ νλͺ©μ΄ "OK"λ‘ νμλμ΄μΌ ν©λλ€.
λ§μ§λ§ κ³ λ € μ¬ν
νμ€ μ¬μ©(μ κ·Ό, κ²μ, μ½κΈ° λ° λ€μ΄λ‘λ)μ κ²½μ° COPSλ Kindleμμλ μ’μ΅λλ€. Calibreμμ μ΄λ € μλ λμ μ¬μ©μκ° DBμμ μμ νμ§ μλλ‘ μΉμλ²λ₯Ό μ€μ§νλ κ²μ μμ§ λ§μΈμ!
- lighttpd μλ² μ€μ§
- PCμμ NFS(λ½ μλ μ΅μ μ¬μ©) λλ SMBλ₯Ό μ¬μ©νμ¬ μμΉ λ§μ΄νΈ(NFSλ₯Ό μ¬μ©ν μ μλ κ²½μ°, NFSλ λ λΉ λ₯΄κ³ μμ νλ©°, μλ₯Ό λ€μ΄, ν IPλ§ κ³΅μ μ μ°κ²°νλλ‘ νμ©νμ¬ μ¬λ¬ κ° μ΄κΈ°λ₯Ό λ°©μ§ν μ μμ΅λλ€)
- Calibreμ λΌμ΄λΈλ¬λ¦¬ μΆκ°
- Calibreλ₯Ό μ¬μ©νμ¬ μμ μν
- λΌμ΄λΈλ¬λ¦¬μμ Calibre μ°κ²° ν΄μ .
- 곡μ ν΄μ .
- lighttpd μ€ν.
λΌμ°ν°, LAN λ±μ λλ¦¬κ² λ§λ€κΉμ?
κ°λ₯ν©λλ€. νλμ¨μ΄, λΌμ΄λΈλ¬λ¦¬μ 무κ², λμμ μ μν μ¬μ©μ μ λ±μ λ°λΌ λ¬λΌμ§λλ€. λμ RT-AC68Uμμλ μ΄λ€ λ¬Έμ λ λ°κ²¬νμ§ λͺ»νμ΅λλ€. λ΄ λͺ©νλ PCλ₯Ό μ¬μ©νμ§ μκ³ Kindleμμ μ§μ μ μμ± μ μ‘°ννκ³ λ€μ΄λ‘λνλ κ²μ΄μμ΅λλ€. μ΄λ₯Ό λ¬μ±νμ΅λλ€. μ μμ± μ κ³ κΈ κ΄λ¦¬λ₯Ό μΆκ°νκ±°λ λ§λ€ λμλ NFSμμ Calibreλ₯Ό μ¬μ©ν©λλ€.
COPSμμ μΈλ€μΌ μμ± λ° μ²λ¦¬μ κ΄ν κ²μ ꡬμ±ν νμκ° μλ€λ©΄ μ±λ₯, λͺ©λ‘ λ±μ ν₯μμν€κΈ° μν΄ cops/config_local.phpμμ μ΄ μ€λ€μ μ‘°μ ν μ μμ΅λλ€. μ΄κ²μ΄ λμ κ²μ΄κ³ , μ½κ°μ CPUκ° κ³΅κ²©μ μ΄μ§λ§... λΉμ μ νμμ λ°λΌ ꡬμ±νμΈμ!
/* * λ€μ΄λ‘λ μ μ Epub λ©νλ°μ΄ν° μ λ°μ΄νΈ * 1 : μ (νμ±ν) * 0 : μλμ€ */ $config['cops_update_epub-metadata'] = "1";
/*
* μΈλ€μΌμ μ€μκ°μΌλ‘ μμ±λλ―λ‘ λλ¦° CPUλ₯Ό κ°μ§ μλ²μμ λ¬Έμ κ° λ°μν μ μμ΅λλ€ (Raspberry Pi, Dockstar, Piratebox, ...).
* μ΄ κ΅¬μ± νλͺ©μ μ¬μ©νλ©΄ μΈλ€μΌμ΄ μ΄λ»κ² μμ±λ μ§ μ¬μ©μ μ μν μ μμ΅λλ€
* "" : μΈλ€μΌ μμ± (CPU μ¬μ©λ λμ)
* "1" : νμ μ 체 ν¬κΈ° μ΄λ―Έμ§ μ μ‘ (λ€νΈμν¬ μ¬μ©λ λμ)
* μ΄λ€ url : μΈλ€μΌλ‘ μμ μ΄λ―Έμ§ μ μ‘ (μ: "images/bookcover.png" μλ)
*/
$config['cops_thumbnail_handling'] = "1";
/*
* 리μ¬μ΄μ¦λ μΈλ€μΌμ μ μ§ν λλ ν 리: 첫 μ κ·Όμμλ§ μΈλ€μΌμ 리μ¬μ΄μ¦ν ν μ΄ μΊμλ₯Ό μ¬μ©νλλ‘ νμ©.
* $config['cops_thumbnail_handling']μ ""μ΄μ΄μΌ ν©λλ€.
* "" : μΈλ€μΌ μΊμνμ§ μμ
* "/tmp/cache/" (μ) : /tmp/cache/μ μΈλ€μΌ μμ±
* μ£Όμ : /λ‘ λλμΌ ν©λλ€.
*/
$config['cops_thumbnail_cache
_directory'] = ""; /* * νμ΄μ§ λΉ μ΅λ νλͺ© μ * -1 무μ ν */ $config['cops_max_item_per_page'] = "-1";
/*
* νμν μ΅κ·Ό μ±
μ μ
*/
$config['cops_recentbooks_limit'] = '50';
μΉμλ²μμ max contemporray access λ° call μμ μ μνν μ μμ΅λλ€( lighttpd man νμ΄μ§ μ°Έμ‘°), μλ₯Ό λ€μ΄, /opt/etc/lighttpd/conf.d/30-fastcgi.confμμ PHP_FCGI_MAX_REQUESTS κ°μ μ€μ λλ€.