ausglamr/glamr-dev

83 lines
1.8 KiB
Bash
Executable file

#!/usr/bin/env bash
# Thanks Mouse Reeve for letting me steal your idea.
# exit on errors
set -e
function runweb {
docker compose run --rm web "$@"
}
function execdb {
docker compose exec db $@
}
function migrate {
runweb python manage.py migrate "$@"
}
CMD=$1
if [ -n "$CMD" ]; then
shift
fi
# show commands as they're executed
set -x
case "$CMD" in
announce)
runweb python manage.py announce
;;
backup)
/snap/bin/docker exec -u root ausglamr_db_1 pg_dump -v -Fc -U ausglamr -d "ausglamr" -f /tmp/ausglamr_backup.dump
/snap/bin/docker cp ausglamr_db_1:/tmp/ausglamr_backup.dump /home/hugh/backups/
mv /home/hugh/backups/ausglamr_backup.dump /home/hugh/backups/ausglamr_backup_$(date +'%a').dump
;;
black)
docker compose run --rm web black ausglamr blogs
;;
check_feeds)
runweb python manage.py check_feeds
;;
collectstatic)
runweb python manage.py collectstatic
;;
createsuperuser)
runweb python manage.py createsuperuser --no-input
;;
dbshell)
execdb psql -U ${POSTGRES_USER} ${POSTGRES_DB}
;;
manage)
runweb python manage.py "$@"
;;
makemigrations)
runweb python manage.py makemigrations "$@"
;;
migrate)
migrate "$@"
;;
pylint)
docker compose run --rm web pylint ausglamr blogs
;;
queue_announcements)
runweb python manage.py queue_announcements
;;
resetdb)
docker compose rm -svf
docker volume rm -f ausglamr_pgdata
migrate
;;
send_weekly_email)
runweb python manage.py send_weekly_email
;;
test)
runweb python manage.py test "$@"
;;
*)
set +x
echo "That is not a command"
;;
esac