irongit
rango/dev
45 lines1.0 KB
1#!/bin/bash
2# For development only
3
4# if venv doesn't exist, create it
5if [ ! -d "venv" ]; then
6 python -m venv venv
7 # add NGINX_HOST and DOMAIN to venv/Scripts/activate
8 echo "export NGINX_HOST=localhost" >> venv/Scripts/activate
9 echo "export DOMAIN=localhost" >> venv/Scripts/activate
10fi
11
12# if first arg is var, add a variable to venv/Scripts/activate
13if [ "$1" = "var" ]; then
14 echo "export $2=$3" >> venv/Scripts/activate
15fi
16
17# if venv is activated, deactivate it
18if [ ! -z "$VIRTUAL_ENV" ]; then
19 deactivate
20fi
21source venv/Scripts/activate
22
23# if first arg is back, build frontend and run backend
24if [ "$1" = "back" ]; then
25 # build the frontend
26 cd rango/frontend
27 npm run build
28 cd ..
29
30 # create secret key
31 cd backend
32 python manage.py createsecret
33
34 # migrate database
35 python manage.py migrate
36
37 # run backend development server
38 python manage.py runserver & cd ../..
39fi
40
41# if first arg is front, run frontend development server
42if [ "$1" = "front" ]; then
43 cd rango/frontend
44 npm run dev & cd ../..
45fi