parse password from env if available

This commit is contained in:
Jakob Ketterl 2021-02-18 01:32:27 +01:00
parent 2eec29db05
commit 0714ce5703

View File

@ -4,6 +4,7 @@ from owrx.users import UserList, User, DefaultPasswordClass
import sys import sys
import random import random
import string import string
import os
class Command(ABC): class Command(ABC):
@ -15,6 +16,10 @@ class Command(ABC):
class UserCommand(Command, metaclass=ABCMeta): class UserCommand(Command, metaclass=ABCMeta):
def getPassword(self, args, username): def getPassword(self, args, username):
if args.noninteractive: if args.noninteractive:
if "OWRX_PASSWORD" in os.environ:
password = os.environ["OWRX_PASSWORD"]
generated = False
else:
print("Generating password for user {username}...".format(username=username)) print("Generating password for user {username}...".format(username=username))
password = self.getRandomPassword() password = self.getRandomPassword()
generated = True generated = True