Browse Source

Conserta bug em criação de usuário admin no docker

pull/1205/head 3.1.9-BETA
Edward Ribeiro 8 years ago
parent
commit
7794e47c53
  1. 8
      create_admin.py
  2. 4
      start.sh

8
create_admin.py

@ -1,14 +1,13 @@
import os import os
import sys import sys
import django import django
from django.contrib.auth.models import User from sapl import settings
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "sapl.settings") os.environ.setdefault("DJANGO_SETTINGS_MODULE", "sapl.settings")
django.setup()
def create_superuser(): def create_superuser():
from django.contrib.auth.models import User
username = "admin" username = "admin"
password = os.environ['ADMIN_PASSWORD'] if 'ADMIN_PASSWORD' in os.environ else None 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 '' email = os.environ['ADMIN_EMAIL'] if 'ADMIN_EMAIL' in os.environ else ''
@ -31,4 +30,5 @@ def create_superuser():
sys.exit(0) sys.exit(0)
if __name__ == '__main__': if __name__ == '__main__':
django.setup()
create_superuser() create_superuser()

4
start.sh

@ -50,8 +50,12 @@ python3 manage.py migrate --noinput
#python3 manage.py collectstatic --no-input #python3 manage.py collectstatic --no-input
python3 manage.py rebuild_index --noinput & python3 manage.py rebuild_index --noinput &
echo "Criando usuário admin..."
user_created=$(python3 create_admin.py 2>&1) user_created=$(python3 create_admin.py 2>&1)
echo $user_created
cmd=$(echo $user_created | grep 'ADMIN_USER_EXISTS') cmd=$(echo $user_created | grep 'ADMIN_USER_EXISTS')
user_exists=$? user_exists=$?

Loading…
Cancel
Save