moviewyrm/bw-dev

86 lines
1.8 KiB
Text
Raw Normal View History

#!/bin/bash
# exit on errors
set -e
# import our ENV variables
# catch exits and give a friendly error message
function showerr {
echo "Failed to load configuration! You may need to update your .env and quote values with special characters in them."
}
trap showerr EXIT
source .env
trap - EXIT
# show commands as they're executed
set -x
2020-11-09 01:30:47 +00:00
function execdb {
docker-compose exec db $@
}
function execweb {
docker-compose exec web "$@"
}
function initdb {
2020-11-09 01:30:47 +00:00
execweb python manage.py migrate
execweb python manage.py initdb
}
CMD=$1
shift
# show commands as they're executed
set -x
case "$CMD" in
up)
docker-compose up --build "$@"
;;
run)
docker-compose run --rm --service-ports web
;;
initdb)
initdb
;;
makemigrations)
2020-12-16 02:57:17 +00:00
execweb python manage.py makemigrations "$@"
;;
migrate)
2020-11-21 03:04:35 +00:00
execweb python manage.py rename_app fedireads bookwyrm
2020-11-27 19:37:06 +00:00
execweb python manage.py migrate "$@"
;;
2020-11-08 20:14:57 +00:00
bash)
2020-11-09 01:30:47 +00:00
execweb bash
;;
shell)
2020-11-09 01:30:47 +00:00
execweb python manage.py shell
;;
dbshell)
execdb psql -U ${POSTGRES_USER} ${POSTGRES_DB}
;;
restart_celery)
docker-compose restart celery_worker
;;
2020-09-28 21:47:53 +00:00
collectstatic)
2020-11-09 01:30:47 +00:00
execweb python manage.py collectstatic --no-input
2020-09-28 21:47:53 +00:00
;;
2020-11-08 18:29:33 +00:00
build)
docker-compose build
2020-09-28 21:47:53 +00:00
;;
2020-11-05 19:47:40 +00:00
update)
git pull
2021-03-21 21:23:26 +00:00
docker-compose build
2020-11-05 19:47:40 +00:00
docker-compose exec web python manage.py migrate
docker-compose exec web python manage.py collectstatic --no-input
docker-compose restart
;;
2021-03-28 18:46:07 +00:00
populate_feeds)
execweb python manage.py populate_streams
;;
*)
2021-03-28 21:49:58 +00:00
echo "Unrecognised command. Try: build, up, initdb, makemigrations, migrate, bash, shell, dbshell, restart_celery, update, populate_feeds"
;;
esac