Refactor internal functions
This commit is contained in:
parent
844a2ff694
commit
69e5a5bb16
55
dev.sh
55
dev.sh
|
@ -1,27 +1,13 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
declare -A tasks
|
# Helper functions not exposed to the user {
|
||||||
declare -A descriptions
|
# Load example data
|
||||||
|
_init () {
|
||||||
run () {
|
python ./src/manage.py loaddata src/network_inventory.yaml
|
||||||
setup
|
|
||||||
find . -name __pycache__ -o -name "*.pyc" -delete
|
|
||||||
sudo iptables -I INPUT -p tcp --dport $WEBPORT -j ACCEPT
|
|
||||||
printf "\n---\n webserver: http://$(hostname -f):$WEBPORT\n---\n"
|
|
||||||
overmind start -D
|
|
||||||
}
|
}
|
||||||
descriptions["run"]="Start the webserver."
|
|
||||||
tasks["run"]=run
|
|
||||||
descriptions["start"]="Alias for run."
|
|
||||||
tasks["start"]=run
|
|
||||||
|
|
||||||
stop () {
|
# Setup the database
|
||||||
overmind quit
|
_setup () {
|
||||||
}
|
|
||||||
descriptions["stop"]="Stop the webserver and DB."
|
|
||||||
tasks["stop"]=stop
|
|
||||||
|
|
||||||
setup () {
|
|
||||||
overmind start -l db -D
|
overmind start -l db -D
|
||||||
if [ -f .direnv/first_run ]; then
|
if [ -f .direnv/first_run ]; then
|
||||||
sleep 2
|
sleep 2
|
||||||
|
@ -48,12 +34,35 @@ setup () {
|
||||||
python ./src/manage.py loaddata nets
|
python ./src/manage.py loaddata nets
|
||||||
python ./src/manage.py loaddata softwares
|
python ./src/manage.py loaddata softwares
|
||||||
python ./src/manage.py shell -c "from django.contrib.auth import get_user_model; User = get_user_model(); User.objects.create_superuser('admin', 'admin@example.com', 'password')"
|
python ./src/manage.py shell -c "from django.contrib.auth import get_user_model; User = get_user_model(); User.objects.create_superuser('admin', 'admin@example.com', 'password')"
|
||||||
init
|
_init
|
||||||
touch .direnv/first_run
|
touch .direnv/first_run
|
||||||
fi
|
fi
|
||||||
overmind quit
|
overmind quit
|
||||||
sleep 2
|
sleep 2
|
||||||
}
|
}
|
||||||
|
#}
|
||||||
|
|
||||||
|
# Main tasks start
|
||||||
|
declare -A tasks
|
||||||
|
declare -A descriptions
|
||||||
|
|
||||||
|
run () {
|
||||||
|
_setup
|
||||||
|
find . -name __pycache__ -o -name "*.pyc" -delete
|
||||||
|
sudo iptables -I INPUT -p tcp --dport $WEBPORT -j ACCEPT
|
||||||
|
printf "\n---\n webserver: http://$(hostname -f):$WEBPORT\n---\n"
|
||||||
|
overmind start -D
|
||||||
|
}
|
||||||
|
descriptions["run"]="Start the webserver."
|
||||||
|
tasks["run"]=run
|
||||||
|
descriptions["start"]="Alias for run."
|
||||||
|
tasks["start"]=run
|
||||||
|
|
||||||
|
stop () {
|
||||||
|
overmind quit
|
||||||
|
}
|
||||||
|
descriptions["stop"]="Stop the webserver and DB."
|
||||||
|
tasks["stop"]=stop
|
||||||
|
|
||||||
venv () {
|
venv () {
|
||||||
nix build .#venv -o .venv
|
nix build .#venv -o .venv
|
||||||
|
@ -84,10 +93,6 @@ cleanall () {
|
||||||
descriptions["cleanall"]="Completly remove any files which are not checked into git."
|
descriptions["cleanall"]="Completly remove any files which are not checked into git."
|
||||||
tasks["cleanall"]=cleanall
|
tasks["cleanall"]=cleanall
|
||||||
|
|
||||||
init () {
|
|
||||||
python ./src/manage.py loaddata src/network_inventory.yaml
|
|
||||||
}
|
|
||||||
|
|
||||||
debug () {
|
debug () {
|
||||||
pytest --pdb --nomigrations --cov=. --cov-report=html ./src/
|
pytest --pdb --nomigrations --cov=. --cov-report=html ./src/
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue