Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Software > Calibre

Notices

Reply
 
Thread Tools Search this Thread
Old 07-08-2017, 07:40 AM   #1
khyox
Junior Member
khyox began at the beginning.
 
Posts: 3
Karma: 10
Join Date: Jul 2017
Device: kindle paperwhite
installing Calibre content server 3 on ubuntu server 16_04

The following guide is a result of my google search to install calibre 3 on a server running ubuntu:

the environment:

a pc running ubuntu server 16_04 lts connected to the internet
a sudo users
a public ip to reach the server from the internet
a port open on linux firewall and router
a kindle paperwhite connected to the internet

install calibre:

Code:
sudo -v && wget -nv -O- https://download.calibre-ebook.com/linux-installer.py | sudo python -c "import sys; main=lambda x:sys.stderr.write('Download failed\n'); exec(sys.stdin.read()); main('/opt')"

I used the /opt folder

Ignore all the warnings

Update your package lists:

Code:
sudo apt-get update
Install xvfb:

Code:
sudo apt-get install xvfb
or install X server library


create calibre log file:

Code:
sudo nano  /opt/calibre/calibre.log
digit some spaces and save the file


Let suppose that the linux user is "myuser"

create calibre users:

I discovered that my calibre user database is in ~/.config/calibre/server-users.sqlite

Code:
sudo calibre-server --userdb /home/myuser/.config/calibre/server-users.sqlite --manage-users
follow the instruction on the screen
I created two user:
- one with write permissions
- one with only read permissions

create the calibre.service:

Code:
sudo nano /lib/systemd/system/calibre.service
insert:


[Unit]
Description=Calibre Service
After=network.target

[Service]
Type=simple
User=mylinuxuser
Group=mylinuxgroup

ExecStart=/usr/bin/calibre-server\
--daemonize\
--max-opds-items=30\
--max-opds-ungrouped-items=100\
--port YOUR_PORT_NUMBER \
--log=/opt/calibre/calibre.log \
--enable-auth \
/PATH_TO_LIBRARY_1 \
/PATH_TO_LIBRARY_2 \
/PATH_TO_LIBRARY_3 \
/................. \
/PATH_TO_LIBRARY_n


[Install]
WantedBy=multi-user.target



please notice that:
- I use a path without spaces and I set an empty space before \
- there is no \ after the last path


Check that it is correctly configured by executing
Code:
sudo systemctl start calibre.service
Calibre Server should start up correctly and you can check by using

Code:
sudo systemctl status calibre.service
2. To enable the service to run on every start up simply execute

Code:
sudo systemctl enable calibre.service
and that will create a symbolic link to the /etc/systemd/system/multi-user.target.wants directory so it will start every time you boot into multi-user mode

to check that everythings are ok open your browser and navigate to \\your ip:your port
insert user and pwd

please consider to allow port in ufw and in your router...

some tricks:

after any changes in file: /lib/systemd/system/calibre.service
please run:


Code:
sudo systemctl daemon-reload
Code:
sudo systemctl start calibre.service
I use the gui CALIBRE interface under windows to manage my libraries and I refresh the content server with the command:

Code:
sudo systemctl stop calibre.service
sudo systemctl start calibre.service
probably there is a better method but I don't know it.......

I actually have 3 libraries, I don't know how many you can have...

I have a kindle paperwhite so I created a book with a link (I created it in word, converted to AZW3 in Calibre and downloaded in my kindle) :

http://caliberuser:calibrepassword@y...ourport/mobile

I use the mobile version because kindle browser probably don't support java script or is extremely slow...

sources:

https://www.digitalocean.com/communi...n-ubuntu-14-04
https://manual.calibre-ebook.com/ser...mand-line-only
https://manual.calibre-ebook.com/gen...re-server.html
http://thanosk.net/content/running-c...-under-systemd
https://manual.calibre-ebook.com/ser...n-linux-system

please consider that I'm not a guru and all this stuff is a result of google search and some night lost...
I hope this can help


many thanks to Kovid and all the calibre guys , peace and love
,

khyox

Last edited by khyox; 07-13-2017 at 04:24 AM.
khyox is offline   Reply With Quote
Advert
Old 07-11-2017, 03:14 PM   #2
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 31,718
Karma: 8695932
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
You dont need to install either xvfb or imagemagick. Those were needed only for very old versions of calibre. You do need to have the X server libraries installed, however. So installing xvfb is probably a good way to do that

You should also change the service file to run the server as a normal linux user rather than root. See the section on systemd integration at https://manual.calibre-ebook.com/server.html
kovidgoyal is offline   Reply With Quote
Old 07-13-2017, 04:25 AM   #3
khyox
Junior Member
khyox began at the beginning.
 
Posts: 3
Karma: 10
Join Date: Jul 2017
Device: kindle paperwhite
ok I have edited the post
many thanks
khyox
khyox is offline   Reply With Quote
Old 08-25-2017, 11:34 PM   #4
oblongau
Junior Member
oblongau began at the beginning.
 
Posts: 9
Karma: 10
Join Date: Sep 2013
Location: Australia
Device: Calibre; Galaxy SII
I have done the above process, modified for my username, port, etc. The calibre server runs (but only briefly, see below), and I can use a Web browser to access the library.

However, when I try to run calibre itself, I get:

Code:
calibre, version 3.6.0
ERROR: Cannot start calibre: Another calibre program that can modify calibre libraries, such as, calibre-server or calibredb is already running. You must first shut it down, before starting the main calibre program. If you are sure no such program is running, try restarting your computer.
The program is on the same computer as the server. Linux Mint 18.2 64 bit.

Now I notice different behaviour... after:
Code:
sudo systemctl start calibre-server
Code:
sudo systemctl status calibre-server
the result is:
Code:
● calibre-server.service - calibre content server
   Loaded: loaded (/etc/systemd/system/calibre-server.service; disabled; vendor preset: enabled)
   Active: deactivating (stop-sigterm) since Sat 2017-08-26 12:18:34 AEST; 7s ago
  Process: 16588 ExecStart=/usr/bin/calibre-server --daemonize --max-opds-items=30 --max-opds-ungrouped-items=100 --port 8282 --log=/home/bob/.calibre-server-log --enable-auth /home/bob/Calibre Library (code=exited, status=0/SUCCESS)
 Main PID: 16588 (code=exited, status=0/SUCCESS)
   CGroup: /system.slice/calibre-server.service
           └─16596 /opt/calibre/bin/calibre-server --daemonize --max-opds-items=30 --max-opds-ungrouped-items=100 --port 8282 --log=/home/bob/.calibre-server-log --enable-auth /home/bob/Calibre Library

Aug 26 12:18:33 bob-mint systemd[1]: Started calibre content server.
I then don't do anything for a few minutes, but if I run the status again I get:

Code:
● calibre-server.service - calibre content server
   Loaded: loaded (/etc/systemd/system/calibre-server.service; disabled; vendor preset: enabled)
   Active: failed (Result: timeout) since Sat 2017-08-26 12:20:04 AEST; 51s ago
  Process: 16588 ExecStart=/usr/bin/calibre-server --daemonize --max-opds-items=30 --max-opds-ungrouped-items=100 --port 8282 --log=/home/bob/.calibre-server-log --enable-auth /home/bob/Calibre Library (code=exited, status=0/SUCCESS)
 Main PID: 16588 (code=exited, status=0/SUCCESS)

Aug 26 12:18:33 bob-mint systemd[1]: Started calibre content server.
Aug 26 12:20:04 bob-mint systemd[1]: calibre-server.service: State 'stop-sigterm' timed out. Killing.
Aug 26 12:20:04 bob-mint systemd[1]: calibre-server.service: Unit entered failed state.
Aug 26 12:20:04 bob-mint systemd[1]: calibre-server.service: Failed with result 'timeout'.
My /etc/systemd/system/calibre-server.service file is:

Code:
[Unit]
Description=calibre content server
After=network.target

[Service]
Type=simple
User=bob
Group=bob

ExecStart=/usr/bin/calibre-server\
--daemonize\
--max-opds-items=30\
--max-opds-ungrouped-items=100\
--port 8282 \
--log="/home/bob/.calibre-server-log"\
--enable-auth \
"/home/bob/Calibre Library"

[Install]
WantedBy=multi-user.target
And I just noted that the instructions above say to create the file "/lib/systemd/system/calibre.service" but https://manual.calibre-ebook.com/server.html says "/etc/systemd/system/calibre-server.service" Does that matter?

What am I missing?
oblongau is offline   Reply With Quote
Old 08-25-2017, 11:43 PM   #5
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 31,718
Karma: 8695932
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
You cannot run calibre and the server at the same time with the same user account. You also dont use --daemonize in your service file.
kovidgoyal is offline   Reply With Quote
Advert
Old 08-26-2017, 12:10 AM   #6
oblongau
Junior Member
oblongau began at the beginning.
 
Posts: 9
Karma: 10
Join Date: Sep 2013
Location: Australia
Device: Calibre; Galaxy SII
Thanks for the quick reply.

The server now stays active after removing --daemonize.

Not sure what you mean by, "You cannot run calibre and the server at the same time with the same user account."

Is that the Linux "User" mentioned in calibre.service? Do you mean I have to create another Linux user to run the server, and put that new username into calibre.service file? You say not to use root there. I presume you are not referring to the username in calibre itself at Preferences|Sharing over the net|User accounts?
oblongau is offline   Reply With Quote
Old 08-27-2017, 09:40 AM   #7
Lofwyr23
Connoisseur
Lofwyr23 can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterLofwyr23 can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterLofwyr23 can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterLofwyr23 can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterLofwyr23 can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterLofwyr23 can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterLofwyr23 can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterLofwyr23 can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterLofwyr23 can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterLofwyr23 can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterLofwyr23 can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameter
 
Posts: 69
Karma: 12662
Join Date: Sep 2013
Device: Kobo Glo HD, Nexus 6
A few suggestions to further improve the handling:

instead of sudo nano to create the log file:
Code:
touch /opt/calibre/calibre.log
Creates an empty file with given name, spares you interaction.

systemd's systemctl provides the restart command to restart services. Instead of starting/stopping use
Code:
systemctl restart <your unit name here>
-----

Quote:
Originally Posted by oblongau View Post
Not sure what you mean by, "You cannot run calibre and the server at the same time with the same user account."
Let's say you use "brackhaus" as user name for your server.

"brackhaus" logs in to your system. The content-server is running. "brackhaus" tries to start calibres' GUI, but fails because the content server already runs with "brackhaus" credentials. Use a different user for the server.

Last edited by Lofwyr23; 08-27-2017 at 09:53 AM.
Lofwyr23 is offline   Reply With Quote
Old 08-27-2017, 09:35 PM   #8
oblongau
Junior Member
oblongau began at the beginning.
 
Posts: 9
Karma: 10
Join Date: Sep 2013
Location: Australia
Device: Calibre; Galaxy SII
Getting closer... I've created a new Linux username and modified /etc/systemd/system/calibre-server.service:

Code:
[Unit]
Description=calibre content server
After=network.target

[Service]
Type=simple
User=calibreserver
Group=calibreserver

ExecStart=/usr/bin/calibre-server\
--max-opds-items=30\
--max-opds-ungrouped-items=100\
--port 8282 \
--log="/opt/calibre/calibre-server.log"\
--enable-auth \
--userdb="/home/bob/.config/calibre/server-users.sqlite"\
"/home/bob/Calibre Library"

[Install]
WantedBy=multi-user.target
The server starts, and I can now run the calibre GUI while the server is running.

Server log:
Code:
calibre server listening on 0.0.0.0:8282
OPDS feeds advertised via BonJour at: 192.168.0.2 port: 8282
However, when I try to use Web page access (http://192.168.0.2:8282/) I get prompted for the calibre username (as expected) and that is accepted. That username and password is set in Preferences|Sharing over the net|User accounts and is not the same as the new Linux username.

When I click on the Web "Calibre Library" button the Web page responds:

Code:
Failed to load books from calibre library, with error:
Failed to communicate with "/interface-data/books-init?library_id=Calibre_Library&sort=author_sort.asc&1503879907902", with status: [500] Internal Server Error
The server log says:
Code:
Unhandled exception in state: State: _job_done Client: 192.168.0.2:46202 Request: GET /interface-data/books-init?library_id=Calibre_Library&sort=author_sort.asc&1503879644611 HTTP/1.1
Traceback (most recent call last):
  File "site-packages/calibre/srv/loop.py", line 565, in tick
  File "site-packages/calibre/srv/loop.py", line 303, in _job_done
  File "site-packages/calibre/srv/pool.py", line 35, in run
  File "site-packages/calibre/srv/http_response.py", line 441, in run_request_handler
  File "site-packages/calibre/srv/routes.py", line 300, in dispatch
  File "site-packages/calibre/srv/auth.py", line 258, in __call__
  File "site-packages/calibre/srv/auth.py", line 281, in do_http_auth
  File "site-packages/calibre/srv/users.py", line 132, in get
  File "site-packages/calibre/srv/users.py", line 79, in conn
CantOpenError: CantOpenError: unable to open database file
/home/bob/Calibre Library has permissions 777.
/home/bob/.config/calibre/server-users.sqlite has permissions 777.

Which "database file" can't it open?

What now?
oblongau is offline   Reply With Quote
Old 08-27-2017, 11:40 PM   #9
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 31,718
Karma: 8695932
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
You misunderstand. You are not supposed to be able to run the calirbe GUI and server on the same library. Either run the server from within the GUI or create a script that stops the server when starting the GUI and restarts it after the GUI quits.

Your error comes from the permission on the userdb file being incorrect. Presumably you created it using the GUI with one linux user and are running the server with another.
kovidgoyal is offline   Reply With Quote
Old 08-28-2017, 04:12 AM   #10
oblongau
Junior Member
oblongau began at the beginning.
 
Posts: 9
Karma: 10
Join Date: Sep 2013
Location: Australia
Device: Calibre; Galaxy SII
I think my confusion comes from the fact that prior to 3.?, I could run the server at system startup, and then run the GUI without problems.

So, to confirm, for a single user with a single library, with the requirement to run the GUI on the machine that stores the library, and to view the library via the Web interface on other devices, is this the process:
  • Configure a username within the GUI at "Preferences|Sharing over the net|User accounts".
  • Specify the port for connections.
  • Select "Require username and password..."
  • Select "run server automatically when calibre starts"
  • Tell the operating system to run calibre at startup.
  • Don't bother doing anything separately with the server.

The only problem remaining is that when I start calibre at system startup, it is not minimised. I'm using the command, in Linux Mint Startup Programs,
Code:
calibre --start-in-tray
Calibre starts, but is not minimised. I've also tried the option "--detach" which does not help.
oblongau is offline   Reply With Quote
Old 08-28-2017, 04:25 AM   #11
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 31,718
Karma: 8695932
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Yes that is correct.

You need to also enable the system tray icon in Preferences->Look & feel first. Then --start-in-tray will work, assuming your desktop environment has a system tray that supports the status notifier spec (most modern ones do).

Last edited by kovidgoyal; 08-28-2017 at 04:28 AM.
kovidgoyal is offline   Reply With Quote
Old 08-28-2017, 05:13 AM   #12
oblongau
Junior Member
oblongau began at the beginning.
 
Posts: 9
Karma: 10
Join Date: Sep 2013
Location: Australia
Device: Calibre; Galaxy SII
Ah, I missed that setting in Preferences. But unfortunately calibre still opens as a window.
oblongau is offline   Reply With Quote
Old 08-28-2017, 06:21 AM   #13
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 31,718
Karma: 8695932
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Run calibre --start-in-tray in a terminal, and it will print out a message telling you why it could not create a system tray icon.
kovidgoyal is offline   Reply With Quote
Old 08-28-2017, 07:16 AM   #14
oblongau
Junior Member
oblongau began at the beginning.
 
Posts: 9
Karma: 10
Join Date: Sep 2013
Location: Australia
Device: Calibre; Galaxy SII
Code:
$ calibre --start-in-tray
Failed to create system tray icon, your desktop environment probably does not support the StatusNotifier spec
I've posted a question on the Linux Mint forum.
oblongau is offline   Reply With Quote
Old 09-09-2017, 01:34 AM   #15
oblongau
Junior Member
oblongau began at the beginning.
 
Posts: 9
Karma: 10
Join Date: Sep 2013
Location: Australia
Device: Calibre; Galaxy SII
A partial answer... StatusNotifier is not enabled by default in MATE.

Install "dconf-editor", run it to set org>mate>panel>general>enable-sni-support

calibre will then run in the background (with "calibre --start-in-tray") but in my case I then get an error popup saying, "Notification Area" has quit unexpectedly. If you reload a panel object, it will automatically be added back to the panel."

The network connection/speaker etc. icons are then not showing. If I click "Reload" then they reappear. There is no indication there that calibre is running, but it is actually properly running in the background and works as server.

More:
https://github.com/mate-desktop/mate-desktop/issues/286
https://github.com/mate-desktop/mate-desktop/issues/288

If would be helpful if others could give their experience with this.
oblongau is offline   Reply With Quote
Reply

Tags
calibre conten server, ubuntu server 16_04 lts

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Content server on ubuntu 12.04 headless server ImageMagick: libltdl.so.7 Cool Javelin Calibre 5 04-08-2015 03:20 AM
Calibre Content Server and Windows Home Server 2011 HughMcC Calibre 8 10-01-2014 08:26 AM
500 Internal Server Error accessing content server Calibre 0.8.8 DaddyO57 Calibre 1 07-20-2012 07:08 PM
Calibre Content Server error in Ubuntu 10.10 Bodman456 Calibre 1 07-07-2010 04:26 PM
Problems installing Version: 0.4.109 on Ubuntu Server 8.10 machalla Calibre 0 12-03-2008 10:23 PM


All times are GMT -4. The time now is 02:23 AM.


MobileRead.com is a privately owned, operated and funded community.