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 11-29-2021, 08:45 AM   #1
siclib
Junior Member
siclib began at the beginning.
 
Posts: 9
Karma: 10
Join Date: Nov 2021
Device: BOOX Poke 2
Question Automate Add new users to Server at specific time of the day

I am not sure if this is the place for this topic but I think ill post it here anyway.

As far as I know, calibre-server has to be turned off in order to manage users.
I am using ubuntu and ideally I want to put soon-added members at the end of the day because I dont want to stop the server at middle of the day and cant stay awake midnight also. Is it possible to achieve this with bash script?

Example:
1AM
check if users.txt is empty or not, if not
stop calibre-server
do a while loop to grab users and passwords from users.txt and add to userdb
delete users and passwords
start calibre-server

Thank you very much
siclib is offline   Reply With Quote
Old 11-29-2021, 11:30 AM   #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
You should write a python script for that, not bash, it will be easier. Something like:

Code:
import subprocess

users = tuple(filter(None, open('users.txt').read().splitlines()))
if users:
    subprocess.check_call('systemctl stop calibre-server'.split())
    for user in users:
         username, password = user.split()
         subprocess.check_call(['calibre-server', '--manage-users', '--', 'add', username, password])
    subprocess.check_call('systemctl start calibre-server')
kovidgoyal is online now   Reply With Quote
Old 11-29-2021, 09:25 PM   #3
siclib
Junior Member
siclib began at the beginning.
 
Posts: 9
Karma: 10
Join Date: Nov 2021
Device: BOOX Poke 2
Thumbs up

Quote:
Originally Posted by kovidgoyal View Post
You should write a python script for that, not bash, it will be easier. Something like:

Code:
import subprocess

users = tuple(filter(None, open('users.txt').read().splitlines()))
if users:
    subprocess.check_call('systemctl stop calibre-server'.split())
    for user in users:
         username, password = user.split()
         subprocess.check_call(['calibre-server', '--manage-users', '--', 'add', username, password])
    subprocess.check_call('systemctl start calibre-server')

This is exactly what I am up to, python surely makes things much easier
In your code i can see you use "-- add" with a space. Is there any documentation on how to edit library restrictions and prompt read-only access? I want to suppress the dialog and input it thru one or a series of commands like what you did there.
Thank you in advance
siclib is offline   Reply With Quote
Old 11-30-2021, 07:47 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
No, I'm afraid there is no command for automatically editing restrictions/readonly. You could probably script something up using expect or pexpect. Or open a ticket asking for the feature.
kovidgoyal is online now   Reply With Quote
Old 11-30-2021, 08:53 AM   #5
siclib
Junior Member
siclib began at the beginning.
 
Posts: 9
Karma: 10
Join Date: Nov 2021
Device: BOOX Poke 2
Quote:
Originally Posted by kovidgoyal View Post
No, I'm afraid there is no command for automatically editing restrictions/readonly. You could probably script something up using expect or pexpect. Or open a ticket asking for the feature.
Ok great, i opened a feature request here

https://bugs.launchpad.net/calibre/+bug/1952764
siclib is offline   Reply With Quote
Reply

Tags
automate, content server, manage users, userdb


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Server chokes on specific library garysrock Server 1 10-09-2019 08:43 PM
add css to specific page Etshy Calibre 1 08-09-2017 08:33 AM
First time reader looking for specific series. Please help! magicalfatcat Reading Recommendations 8 05-04-2016 09:29 PM
Add tag from author and specific column P.K.Dick Library Management 1 10-13-2014 03:20 PM
Bind calibre-server to specific IP/interface Strupniveral Related Tools 3 03-21-2012 01:32 PM


All times are GMT -4. The time now is 07:44 AM.


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