Skip to content

Commit

Permalink
Allow script/setup to create .env file. Closes #13.
Browse files Browse the repository at this point in the history
  • Loading branch information
m1kc committed Apr 5, 2022
1 parent 180a360 commit f9700fd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion django_spinproject/bin/enhance-settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
14 changes: 14 additions & 0 deletions django_spinproject/bin/enhance-srta.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f9700fd

Please sign in to comment.