How-to install: COPS vs Calibre-server in a Jail

xaintly

Cadet
Joined
Aug 7, 2019
Messages
7
I have an ebook library that I wanted to share. It is managed by calibre on windows, using a SMB share from FreeNAS, so I tried out these two servers.

Comparing the UI:

Calibre Server
:
  • Initial page is 'Choose a library' even if there's only 1 library
  • Default display ('Cover Grid') shows 50 book covers at a time
  • Alternate display ('Detailed List') shows 50 books, cover + synopsis
  • Custom display - you can modify the Detailed List so it shows different data
  • Search - Here is where you can search by title or drill down to authors / series / tags
  • Add Books - You can upload books to your library
  • Customization: You can configure what is shown on search results / detailed list and how many books per page to show
In general, this seems more suited to showing recent additions & searching for a specific book than for browsing a library.
If you have >1000 books, showing them 50 at a time is worthless.

Images:

calibre-server-detailed.png

calibre-server-author-search.png



COPS:
  • Initial page shows 'Authors', 'Series', 'Tags', 'All Books (by Title)'
  • It only displays from 1 library, whichever it is configured to show
  • No upload feature
  • Search feature has a single box that simultaneously searches titles, authors, etc
  • No UI 'back' button to go to previous screen from an author, but browser back button works
  • Doesn't show a synopsis on the same page as the book listing
  • Customization: You can hide some options from the main screen, like browsing by publishers, ratings, languages
  • You can set a limit on the number of books to display as well
This seems very well suited to showing a large library. The user interface is very clean and simple.

Images:

cops-main-menu.png

cops-author.png

cops-1-book.png




Installation:

Caveat: I tried to install COPS & Calibre on another linux machine and failed. Calibre uses a sqlite database, which doesn't work over NFS.

Installing both in a jail worked fine.
  1. Create a jail with any name, default options
  2. Add a mountpoint /media/library pointing to whatever folder has your calibre metadata.db file

Installing Calibre:
Code:
pkg install calibre

# Add a calibre user, needs read/write on all files & folders in the library
# The easiest way to is give it the same uid as the owner of the library
$ adduser
Username: calibre
Full name: <whatever>
Uid: <whatever the UID owns the library>
** defaults for all other options **

# Note that if this user doesn't have rights to read/write every file & folder in the libary, calibre-server will explode

# Add these lines to /etc/rc.conf
calibre_enable="YES"
calibre_user="calibre"
calibre_library="/media/library"

# start calibre-server
$ sudo /usr/local/etc/rc.d/calibre start


This is probably the simplest install, there is already a package for calibre, which includes calibre server.
Calibre includes its own web server and starts up on port 8080.
You can visit it immediately after it starts up by going to http://[ip-of-your-jail]:8080/

You could run it as root to avoid having to create a user & make sure everything is accessible to it, but don't.

Installing COPS:

COPS does not include a web server, so we need to install one of those as well. In this example, I'm using apache, but use whatever server you like the most.

Code:
pkg install -y php74-gd php74-sqlite3 php74-json php74-intl php74-xml php74-zip php74-mbstring php74-phar php74-filter php74-openssl php74-zlib php74-xmlwriter php74-pdo_sqlite php74-ctype php74-dom git wget
cd /usr/local/www
git clone https://github.com/seblucas/cops.git
cd cops
wget https://getcomposer.org/download/1.10.6/composer.phar
php composer.phar global require "fxp/composer-asset-plugin:~1.1"
php composer.phar install --no-dev --optimize-autoloader
cp config_local.php.example config_local.php

# edit config_local.php
$config['calibre_directory'] = '/media/library/'; /* must end in trailing slash! */

# install & configure a web server, using apache in this example
pkg install -y apache24 mod_php74

###### edit /usr/local/etc/apache24/httpd.conf

ServerName yourserver.com

# Modify to add index.php after index.html
<IfModule dir_module>
    DirectoryIndex index.html index.php 
</IfModule>

# Add this
<FilesMatch "\.php$">
    SetHandler application/x-httpd-php
</FilesMatch>
<FilesMatch "\.phps$">
    SetHandler application/x-httpd-php-source
</FilesMatch>

# Modify DocumentRoot & directory to run Cops instead of default web page
# If you are adding this to an existing web server running other stuff, you're on your own
# Change these lines to reference cops instead of /usr/local/etc/apache24/data
DocumentRoot "/usr/local/www/cops"
<Directory "/usr/local/www/cops">

#### end of edits to httpd.conf

# edit /etc/rc.conf

apache24_enable="YES"

# start apache
$ apachectl start



COPS should now be running if you go to http://[ip-of-your-jail]/

Some notes:
  • COPS website: https://github.com/seblucas/cops
  • The website says it only needs 4 libraries, but it needs at least these 15
  • The website says to download the latest version of composer, but it doesn't work, you have to use 1.10.6 (other versions might work also)
  • COPS only needs read-access to your library & files, not read-write
  • There's a docker image for COPS as well, that might be easier
 

dknm

Dabbler
Joined
Aug 27, 2018
Messages
25
Thanks for posting this. It gave me the push to troubleshoot my failed calibre install.

setting up a user /w the same UID as the owner and following @danb35 steps, before starting the service did the trick:


Thanks both :)

Did you get user login authentication to work?

I've tried some stuff to get rid of the bonjour error (tried installing py37-pybonjour-1.1.1, that didn't work)...anyway there's a way to avoid using it
Nonetheless, it still fails with error 48 No socket could be created / can't bind [..] IP [...] is in use
Code:
calibre-server --enable-auth --auth-mode basic --disable-use-bonjour --listen-on 127.0.0.1:8080 /media/library
 
Last edited:

csjjpm

Contributor
Joined
Feb 16, 2015
Messages
126
I installed Ubooquity instead as it supports my ebook and comic collection. The books are from a calibre library and the comics are just in folders.
 

rayearth2000

Dabbler
Joined
Apr 22, 2018
Messages
27
Sorry, this is my first time manual install in jail, I have some question there is no command like (sudo, nano)

I get the calibre downloaded,
added user
edit rc.conf
added mount Point from Nas to /media/library
but at last step
start calibre-server I get<start: Command not found>
 
Top