04-20-2017, 01:25 PM | #1 |
Junior Member
Posts: 6
Karma: 10
Join Date: Apr 2017
Device: Android
|
Headless server with non-default DB location
I'm experimenting with setting up a headless calibre-server on Ubuntu Server 17.4. I've come a long way but am facing a bit of a problem.
I've got it running as a service but my books are on a file share so I've set the CALIBRE_OVERRIDE_DATABASE_PATH=/home/calibre/metadata.db environment variable so it saves the DB not on the CIFS mounted file system per the warnings in the FAQ. I've even managed to install and configure one plugin from the command line. so far so good. My problem is with adding books. When I try to run the following command (with the override DB environment variable correctly set) calibre creates a new metadata.db in the library folder rather than editing the metadata.db that calibre-server is actually using. Code:
xvfb-run calibredb add /mnt/calibre/toadd/ -r --with-library /mnt/calibre/library Is alternative DB locations not supported by calibredb or am I doing something wrong? Many thanks. |
04-20-2017, 05:38 PM | #2 | |
Wizard
Posts: 2,115
Karma: 8796704
Join Date: Jun 2010
Device: Kobo Clara HD,Hisence Sero 7 Pro RIP, Nook STR, jetbook lite
|
Quote:
Code:
/mnt/1589cd3b-4281-4652-af95-1aed1a229bcc Edit Verily the path and that they are mounted of your share using a terminal and the cd and l commands. The only device I have that does not mount with a UUID is my NOOK. bernie Last edited by gbm; 04-20-2017 at 05:54 PM. |
|
04-21-2017, 09:57 AM | #3 |
Junior Member
Posts: 6
Karma: 10
Join Date: Apr 2017
Device: Android
|
Thank you for your reply. I'm not certain I fully understand what you are asking me to do.
I've looked at calibre-portable.sh and I see where it creates a conf file and in there I see where it sets the CALIBRE_OVERRIDE_DATABASE_PATH which looks a lot like what I'm already doing. My share is a cifs mounted share so I don't think it has a uuid beyond the //machine/dir path. And I don't understand how that would help. I wanted to have my books stored in one directory and my metadata.db stored in another. The problem wasn't that calibredb couldn't find the books library folder, it was that it was ignoring the CALIBRE_OVERRIDE_DATABASE_PATH environment variable. In any case, I determined the big problem with having the library on a network share is trying to run multiple instances of Calibre on the same library. Since I'm only ever going to have this one server putting the library on a network share has minimal risk of corruption for me. So I'm just using the default location for metadata.db for now and it is working just fine. Now, as I purchase eBooks I can drop them into a toadd folder and a cron job will automatically add them to the Calibre library. Then I can browse and download books through the web or apps like Calibre Companion. Thanks again for the help. |
04-21-2017, 10:47 AM | #4 |
Wizard
Posts: 2,115
Karma: 8796704
Join Date: Jun 2010
Device: Kobo Clara HD,Hisence Sero 7 Pro RIP, Nook STR, jetbook lite
|
Looks to me like you could use calibre-portable.sh to do what you need in setting the variables and changing the line"
Code:
$CALIBRE --with-library "${CALIBRE_LIBRARY_DIRECTORY}" Code:
$CALIBRE-SERVER --with-library "${CALIBRE_LIBRARY_DIRECTORY}" bernie |
04-24-2017, 10:24 AM | #5 |
Junior Member
Posts: 6
Karma: 10
Join Date: Apr 2017
Device: Android
|
I did review the script and I am doing the exact same thing as the script. I have the CALIBRE_OVERRIDE_DATABASE_PATH environment variable set just as it does in that script and I pass the path to the books using --with-library.
My metadata.db file is not located in the default location, hence my setting of the override environment variable. calibre-server runs just fine. It uses the metatadata.db file I indicate in the override environment variable and it puts the book files in the directory I indicate in the --with-library flag. The problem is calibredb seems to ignore the override environment variable. Therefore I cannot add books to my library from the command line when metadata.db is not in the default location. Thanks for trying to help. I just wanted to make is clear what the problem was in case someone else has the same problem in the future. |
04-28-2017, 12:46 PM | #6 | |
Junior Member
Posts: 6
Karma: 10
Join Date: Apr 2017
Device: Android
|
Quote:
But I already am seeing the environment variables like in the Shell script. And I'm calling calibre-server just like in the Shell script. All of that works. The problem is when I call the separate program calibredb, this program ignores the environment variables. And since the portable script doesn't mention calibredb at all it is no help. While I do have it working, it would be nice to know if calibredb is capable of supporting a non-default location for the db file. If calibredb, and calibre-server support this it seems to reason that calibredb should as well. |
|
04-28-2017, 06:56 PM | #7 |
Zealot
Posts: 137
Karma: 2156958
Join Date: Jan 2013
Device: Too many random androids to list
|
This is probably stating the obvious, but it's ridiculously easy to set a bunch of env vars, and then put yourself outside the context you've set them in. Like logging in as another user who doesn't have it set in the first place, su'ing without the -, or forgetting to export the vars in a script.
Since it's headless, you're remote logging in, and I assume not directly as the user the service is running as. Does wrapping calibredb in say, a calibredb-wrapper script that does nothing but set and export the vars you need, and runs calibredb work? |
05-05-2017, 12:15 PM | #8 | |||
Junior Member
Posts: 6
Karma: 10
Join Date: Apr 2017
Device: Android
|
Quote:
Quote:
sudo -u calibre su - calibre sudo -u calibre /bin/bash In each case I've verified that the environment variable is set before running calibredb. Quote:
In every case, rather than using the metadada.db file that is in /home/calibre and defined in the environment variable it creates a new one in /mnt/books/library. Has anyone else actually done this? It seems unlikely that I'm the first person to try. Either calibredb doesn't pay attention to the environment variable or I'm doing something stupid. |
|||
05-06-2017, 05:30 PM | #9 | |
Zealot
Posts: 137
Karma: 2156958
Join Date: Jan 2013
Device: Too many random androids to list
|
Quote:
This isn't something I've done before, but I'm watching with interest because it's something I had been planning to do at some point and just hadn't got around to. Based on your description, and the debugging you've already done, I'm inclined to agree with you: calibredb is not taking any notice of the environment variables. I'd file a bug at this point. |
|
05-06-2017, 10:26 PM | #10 |
creator of calibre
Posts: 44,356
Karma: 23661992
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
I fond that highly unlikely. The code that uses CALIBRE_OVERRIDE_DATABASE is in the database backend. All calibre utilities use that same code.
I'm guessing you only set, not exported the env var. Or xvfb-run is stripping the the env var. Incidentally why are you using xvfb-run? calibre does not need it, it uses a headless QPA backend, which was introduced several years ago, IIRC. |
05-12-2017, 12:09 PM | #11 | |
Junior Member
Posts: 6
Karma: 10
Join Date: Apr 2017
Device: Android
|
Quote:
|
|
05-12-2017, 12:46 PM | #12 |
creator of calibre
Posts: 44,356
Karma: 23661992
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Really, what errors?
|
Tags |
metadata.db calibredb |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Conversions via headless calibre server? | mrdrew | Conversion | 1 | 09-07-2016 10:40 PM |
Content server on ubuntu 12.04 headless server ImageMagick: libltdl.so.7 | Cool Javelin | Calibre | 5 | 04-08-2015 02:20 AM |
DEBIAN Headless SERVER | sMystero | Devices | 10 | 04-03-2015 06:55 PM |
Headless Calibre Server | greene48 | Library Management | 17 | 10-28-2013 01:09 AM |
Calibre Headless Server | dearleuk | Library Management | 2 | 12-02-2012 04:04 AM |