View Single Post
Old 11-29-2021, 12:30 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: 46,008
Karma: 29579722
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 offline   Reply With Quote