08-27-2018, 10:21 AM | #1 |
Junior Member
Posts: 3
Karma: 10
Join Date: Aug 2018
Device: none
|
Calibre Server initialize user(s)
I'm setting up calibre-server with authentication enabled to run inside a docker container. My problem is how to initialize the user database programmatically before launching the normal server.
I've tried putting the responses to the --manage-users prompts in a file, but that doesn't work for the passwords. It really wants an attached tty to do it. I'd like to allow the user to launch the docker container and pass in username and password values as environment variables. And then I'd run a script inside the container to init the db and then start the server. If the db is already initialized, I'd skip running the --manage-users function again. I'm open to any ideas. Thanks! |
08-27-2018, 07:45 PM | #2 |
creator of calibre
Posts: 43,858
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Just use calibre-debug to call the python API used by manage-users directly. There is a nice UserManager class you can use in calibre.srv.users
|
Advert | |
|
08-28-2018, 11:13 AM | #3 |
Junior Member
Posts: 3
Karma: 10
Join Date: Aug 2018
Device: none
|
Thanks! I will have a good look at that. In the meantime, I decided to do something different with Docker...
I created a docker image that just launches the caliber-server; it assumes the user db has been set up (if the user wants to use one). I created a separate docker image that launches the server with --manage-users. Both images use a persistent container to store /root/.config/calibre files (including the server-users.sqlite db, etc). I still need to improve the documentation, but these images are mgering/calibre-server and mgering/calibre-users Thanks again! |
08-28-2018, 11:30 AM | #4 |
creator of calibre
Posts: 43,858
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
calibre-debug -c "from calibre.srv.users import *; m = UserManager(); m.add_user(username, password, readonly=False)"
|
08-28-2018, 04:28 PM | #5 |
Junior Member
Posts: 3
Karma: 10
Join Date: Aug 2018
Device: none
|
Super suggestion! I wound up using your idea as a model for creating little module that I can give to calibre-debug. If there is the proper environment variable defined, it will add the user and password or change the password before launching the server.
I decided to keep the other docker image for managing users with the interactive procedure in case someone wants to do something fancier. Otherwise, they can just run the server image and use (or not use) the environment variables. |
Advert | |
|
Tags |
authentication, docker, server |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Calibre - really slow to initialize?? | yogi62 | Library Management | 18 | 10-20-2017 03:33 AM |
Feature Request: Mask calibre server connection string with user configurable name | Zealousky | Calibre Companion | 8 | 02-20-2015 08:17 AM |
initialize() documentation | pdurrant | Development | 7 | 12-17-2014 09:28 PM |
calibre-server OPDS catalog - manual move to web server | HaakonME | Related Tools | 5 | 09-21-2012 03:11 AM |
500 Internal Server Error accessing content server Calibre 0.8.8 | DaddyO57 | Calibre | 1 | 07-20-2012 06:08 PM |