From 7794e47c53621860670332a85d09e4b48403d975 Mon Sep 17 00:00:00 2001 From: Edward Ribeiro Date: Mon, 19 Jun 2017 18:26:48 -0300 Subject: [PATCH] =?UTF-8?q?Conserta=20bug=20em=20cria=C3=A7=C3=A3o=20de=20?= =?UTF-8?q?usu=C3=A1rio=20admin=20no=20docker?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- create_admin.py | 8 ++++---- start.sh | 4 ++++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/create_admin.py b/create_admin.py index 09ca17798..eb60ac940 100644 --- a/create_admin.py +++ b/create_admin.py @@ -1,14 +1,13 @@ import os import sys - import django -from django.contrib.auth.models import User +from sapl import settings os.environ.setdefault("DJANGO_SETTINGS_MODULE", "sapl.settings") -django.setup() - def create_superuser(): + from django.contrib.auth.models import User + username = "admin" password = os.environ['ADMIN_PASSWORD'] if 'ADMIN_PASSWORD' in os.environ else None email = os.environ['ADMIN_EMAIL'] if 'ADMIN_EMAIL' in os.environ else '' @@ -31,4 +30,5 @@ def create_superuser(): sys.exit(0) if __name__ == '__main__': + django.setup() create_superuser() diff --git a/start.sh b/start.sh index af6459773..d98481b30 100755 --- a/start.sh +++ b/start.sh @@ -50,8 +50,12 @@ python3 manage.py migrate --noinput #python3 manage.py collectstatic --no-input python3 manage.py rebuild_index --noinput & +echo "Criando usuário admin..." + user_created=$(python3 create_admin.py 2>&1) +echo $user_created + cmd=$(echo $user_created | grep 'ADMIN_USER_EXISTS') user_exists=$?