ausglamr/glamr-dev

87 lines
1.9 KiB
Plaintext
Raw Normal View History

2024-01-04 11:54:56 +11:00
#!/usr/bin/env bash
2024-01-26 11:00:26 +11:00
# Thanks Mouse Reeve for letting me steal their idea.
2024-01-04 11:54:56 +11:00
# 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
;;
2024-01-09 18:11:22 +11:00
backup)
2024-01-26 11:00:26 +11:00
${DOCKER_PATH} exec -u root ausglamr_db_1 pg_dump -v -Fc -U ausglamr -d "ausglamr" -f /tmp/ausglamr_backup.dump
${DOCKER_PATH} cp ausglamr_db_1:/tmp/ausglamr_backup.dump ${BACKUPS_DIR}/
mv ${BACKUPS_DIR}/ausglamr_backup.dump ${BACKUPS_DIR}/ausglamr_backup_$(date +'%a').dump
2024-01-09 18:11:22 +11:00
;;
2024-01-04 11:54:56 +11:00
black)
docker compose run --rm web black ausglamr blogs
;;
check_feeds)
runweb python manage.py check_feeds
;;
collectstatic)
runweb python manage.py collectstatic
;;
copystatic)
cp -r static /srv/ausglamr/
;;
2024-01-04 11:54:56 +11:00
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