diff --git a/django_spinproject/bin/enhance-settings.py b/django_spinproject/bin/enhance-settings.py index 1bf77f7..12211ef 100755 --- a/django_spinproject/bin/enhance-settings.py +++ b/django_spinproject/bin/enhance-settings.py @@ -207,7 +207,7 @@ def readonly(x): DJANGO_DEBUG_SQL=False DJANGO_ALLOWED_HOSTS="" DJANGO_DATABASE_URL="sqlite:///db.sqlite3"''' -for filename in ['.env', '.env.example']: +for filename in ['.env.example']: with open(os.path.join(path, name, filename), 'w') as f: print(f'Writing {filename}...') f.write(template) diff --git a/django_spinproject/bin/enhance-srta.py b/django_spinproject/bin/enhance-srta.py index 46f1446..ce738fc 100755 --- a/django_spinproject/bin/enhance-srta.py +++ b/django_spinproject/bin/enhance-srta.py @@ -39,9 +39,23 @@ script/bootstrap +# Create .env if not present +MAIN_FOLDER=main +if [ ! -e $MAIN_FOLDER/.env ]; then + # Copy template + cp $MAIN_FOLDER/.env.example $MAIN_FOLDER/.env + # Create secret key (TODO: find a crypto-safer way like /dev/random) + SECRET=$(mcookie) + sed -i 's|DJANGO_SECRET_KEY=""|DJANGO_SECRET_KEY="'$SECRET'"|g' $MAIN_FOLDER/.env + # Show + cat $MAIN_FOLDER/.env + echo ".env has been autogenerated, to edit: $ nano $MAIN_FOLDER/.env" +fi +# Clear SQLite database if present if [ -e db.sqlite3 ]; then mv db.sqlite3 db.sqlite3~ fi +# Run migrations poetry run python manage.py migrate''', "test": '''#!/bin/bash