SOLVED Manual installation of Calibre - no calibre library found

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,504
I'm trying to get Calibre running in a jail, and running into an unexpected problem. I used an existing jail, adding mountpoints for /calibre_config and /media/books. I installed calibre using pkg install calibre, which ran without errors (though installed lots of dependencies). I set the following sysrc variables:
Code:
calibre_enable="YES"
calibre_port="8082"
calibre_user="media"
calibre_group="media"
calibre_library="/media/books"
calibre_home="/calibre_config"

/media/books and /calibre_config are owned by media:media. But when I try to start calibre, I get this:
Code:
root@downloaders:~ # service calibre start
Starting calibre.
There is no calibre library at: /media/books
/usr/local/etc/rc.d/calibre: WARNING: failed to start calibre

...and I'm not seeing any way to tell it to create one. Any thoughts?
 

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,504
That was it, thanks--though I have no idea why that guide is talking about using xvfb... So for posterity, here's what I did to finish it up:
Code:
mkdir /media/books/toadd
fetch -o /media/books/toadd/pride.mobi http://www.gutenberg.org/ebooks/1342.kindle.noimages
fetch -o christmascarol.mobi http://www.gutenberg.org/ebooks/46.kindle.noimages
calibredb add /media/books/toadd/* --library-path /media/books/
chown -R media:media /media/books
service calibre start

Then browse to jailip:8082 and there it is. Now to get it working behind my Caddy proxy.
 

gt2416

Patron
Joined
Feb 4, 2018
Messages
262
Calibre-web wasn't that hard to install. Git clone it to somewhere like /usr/local
Inside the calibre-web directory run
Code:
pip install --target vendor -r requirements.txt

And start it with
Code:
python2.7 /usr/local/calibre-web/cps.py

You have to install python 2.7 if you haven't already.
To autostart I lazily edited crontab and added
Code:
@reboot python2.7 /usr/local/calibre-web/cps.py
to it.
Works well though !
 

ByteNick

Explorer
Joined
Jan 24, 2015
Messages
98
I installed it allright. The complete installation procedure requires some more pip installs', depending what you want to do with it.
Now, I want to make it a service, and I was trying to write a rc.d file. I wrote the one bellow, but it doesn't want to start alone:
Code:
#!/bin/sh
# File name is calibre-web
# Place this file into /etc/rc.d
# Edit /etc/rc.conf to include calibre_enable=YES
# By default calibre-web runs using root,
# if you want to run calibre-web as another user,
# include calibre_user=username to /etc/rc.conf

# PROVIDE: calibre-web
# BEFORE: LOGIN
# KEYWORD: shutdown

. /etc/rc.subr

name=calibre-web
rcvar=calibre_enable

pid="pgrep calibre-web"
PATH="/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin"

start_cmd="${name}_start"
stop_cmd="${name}_stop"

load_rc_config $name
: ${calibre_enable:=NO}
: ${calibre_user:=root}

calibre-web_start()
{
    if ${pid} >/dev/null
    then
        echo "${name} is already running"
    else
        echo "Starting ${name}"
        python /usr/local/share/calibre-web/cps.py
    fi
}


calibre-web_stop()
{
    if ${pid} >/dev/null
    then
        echo "Stopping ${name}"
        kill $(${pid})
        sleep 1
    else
        echo "${name} is not running"
    fi
}

run_rc_command "$1"


Ii starts, but the server is not responsive. I don't know what is the error.

If I go in the jail, in /usr/local/share/calibre-web and start cps.py, it works.

ANy idea what I am doing wrong?

NB: I had to edit the name above form "calibre-web" to "calibre" because apparently it does not like the "-" in the name
 

gt2416

Patron
Joined
Feb 4, 2018
Messages
262
I think it doesnt work because calibre is already used for the calibre service. Using an underscore instead of a - works.
Also pid code doesn't work because stopping the service doesn't work and you can try to start it multiple times. Heres a modified version of your script.
Note my calibre web is installed in a different directory so you may have to edit that line.
Code:
#!/bin/sh
#!/usr/bin/env python2.7
# File name is calibre-web
# Place this file into /etc/rc.d
# Edit /etc/rc.conf to include calibre_enable=YES
# By default calibre-web runs using root,
# if you want to run calibre-web as another user,
# include calibre_user=username to /etc/rc.conf

# PROVIDE: calibre_web
# BEFORE: LOGIN
# KEYWORD: shutdown

. /etc/rc.subr

name=calibre_web
rcvar=calibre_web_enable

pidfile="/var/run/${name}.pid"
PATH="/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin"
command="python2.7 /usr/local/calibre-web/cps.py"

start_cmd="${name}_start"
stop_cmd="${name}_stop"

load_rc_config $name
: ${calibre_web_enable:=NO}
: ${calibre_web_user:=root}

calibre_web_start()
{
    if [ -e ${pidfile} ];
    then
        echo "${name} is already running"
    else
        echo "Starting ${name}"
        /usr/sbin/daemon -p ${pidfile} ${command}
    fi
}


calibre_web_stop()
{
    if [ -e ${pidfile} ];
    then
        echo "Stopping ${name}"
        kill `cat ${pidfile}`;
        sleep 1
         else
        echo "${name} is not running"
    fi
}

run_rc_command "$1"
 
Last edited:

ByteNick

Explorer
Joined
Jan 24, 2015
Messages
98
Please note that calibre and calibre-web are in different jails. It is the way I always chose to install, so I can reinstall one, without affecting the other.
I will look into it and post the results.
 

ByteNick

Explorer
Joined
Jan 24, 2015
Messages
98
I did a couple of installs, same results:
Code:
root@calibre-web:/usr/local/share/calibre-web # service calibre_web start
Starting calibre_web
root@calibre-web:/usr/local/share/calibre-web # [2019-05-13 00:02:14,777] INFO in web: Starting Calibre Web...
[2019-05-13 00:02:15,079] INFO in server: Starting Gevent server

And then it stalls...

Strangely, If I start it manually, it works:
Code:
root@calibre-web:/usr/local/share/calibre-web # python cps.py
[2019-05-13 00:00:10,200] INFO in web: Starting Calibre Web...
[2019-05-13 00:00:10,534] INFO in server: Starting Gevent server
[2019-05-13 00:00:10,535] INFO in server: Unable to listen on '', trying on IPv4 only...


The contents of my file is:
Code:
#!/bin/sh
#!/usr/bin/env python3.6
# File name is calibre_web
# Place this file into /usr/local/etc/rc.d
# Edit /etc/rc.conf to include calibre_web_enable=YES
# By default calibre_web runs using root,
# if you want to run calibre-web as another user,
# include calibre_web_user=username to /etc/rc.conf

# PROVIDE: calibre_web
# BEFORE: LOGIN
# KEYWORD: shutdown

. /etc/rc.subr

name=calibre_web
rcvar=calibre_web_enable

pidfile="/var/run/${name}.pid"
PATH="/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin"
command="python3.6 /usr/local/share/calibre-web/cps.py"

start_cmd="${name}_start"
stop_cmd="${name}_stop"

load_rc_config $name
: ${calibre_web_enable:=NO}
: ${calibre_web_user:=root}

calibre_web_start()
{
    if [ -e ${pidfile} ];
    then
        echo "${name} is already running"
    else
        echo "Starting ${name}"
        /usr/sbin/daemon -p ${pidfile} ${command}
    fi
}


calibre_web_stop()
{
    if [ -e ${pidfile} ];
    then
        echo "Stopping ${name}"
        kill `cat ${pidfile}`;
        sleep 1
         else
        echo "${name} is not running"
    fi
}

run_rc_command "$1"
 

gt2416

Patron
Joined
Feb 4, 2018
Messages
262
Honestly no idea, I tried in another jail using python3.6 and it works :/
The only difference I can tell is that my calibre-web uses tornado server and not Gevent, but idk why its different from yours.
Code:
 [2019-05-13 11:02:35,237] INFO in web: Starting Calibre Web...
[2019-05-13 11:02:35,975] INFO in server: Starting Tornado server
 

catnas

Explorer
Joined
Dec 12, 2015
Messages
57
Which version of Calibre did you try? I'm trying to build Calibre 4 from ports and it is being a huge pain in the ass.
 

fahadshery

Contributor
Joined
Sep 29, 2017
Messages
179
Hi All,

I tried installing the community plugin but I think its a dead project. Can anyone be kind enough to post step by step guidance to install this manually? or if @danb35 has created any install script already?

thanks
 

gt2416

Patron
Joined
Feb 4, 2018
Messages
262

fahadshery

Contributor
Joined
Sep 29, 2017
Messages
179
 
Top