From 0b4cd83d7e2af9952a6f4641bd1305867dc424e9 Mon Sep 17 00:00:00 2001 From: Sebastien Date: Fri, 20 Mar 2020 16:44:02 +0100 Subject: [PATCH] Fix 'one liner' in docker-entrypoint.sh --- docker-entrypoint.sh | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 0c7a8203..2b5f3a62 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -25,12 +25,11 @@ python manage.py migrate # Check for first install if [ ! -f status.created ]; then # Create the default admin user - echo "[+] Create the default admin user" -# echo "\ -#from django.contrib.auth import get_user_model; \ -#User = get_user_model(); \ -#User.objects.create_superuser('admin', 'admin@dev.patrowl.io', 'Bonjour1!') if User.objects.count() == 0 else pass" | python manage.py shell - echo "from django.contrib.auth import get_user_model; User = get_user_model(); User.objects.create_superuser('admin', 'admin@dev.patrowl.io', 'Bonjour1!')" | python manage.py shell + echo "[+] Create the default admin user (if needeed)" + # Be careful with Python identation and echo command + echo -e "from django.contrib.auth import get_user_model\r\ +User = get_user_model()\r\ +if not User.objects.filter(username='admin').exists(): User.objects.create_superuser('admin', 'admin@dev.patrowl.io', 'Bonjour1!')" | python manage.py shell # Populate the db with default data echo "[+] Populate the db with default data"