Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Server

Notices

Reply
 
Thread Tools Search this Thread
Old 08-27-2018, 10:21 AM   #1
stokstral
Junior Member
stokstral began at the beginning.
 
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!
stokstral is offline   Reply With Quote
Old 08-27-2018, 07:45 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: 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
kovidgoyal is offline   Reply With Quote
Advert
Old 08-28-2018, 11:13 AM   #3
stokstral
Junior Member
stokstral began at the beginning.
 
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!
stokstral is offline   Reply With Quote
Old 08-28-2018, 11:30 AM   #4
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: 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)"
kovidgoyal is offline   Reply With Quote
Old 08-28-2018, 04:28 PM   #5
stokstral
Junior Member
stokstral began at the beginning.
 
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.
stokstral is offline   Reply With Quote
Advert
Reply

Tags
authentication, docker, server


Forum Jump

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


All times are GMT -4. The time now is 10:18 AM.


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