Removed the command 'run-script' and added the command 'shell', and updated the docs and README

This commit is contained in:
W13R 2022-04-18 17:00:12 +02:00
parent a9c5ec34fc
commit aa85ac5ffc
5 changed files with 38 additions and 44 deletions

View file

@ -40,7 +40,5 @@ The releases are versioned after the following scheme:
`MAJOR`.`MINOR`
- `MAJOR`: will include changes
-> may be incompatible with the previous version
- `MINOR`: will only include bugfixes and smaller changes
-> may not be incompatible with the previous version
- `MAJOR`: may include **breaking changes** and/or significant new features
- `MINOR`: will only include bugfixes and smaller, **non-breaking changes**

View file

@ -10,55 +10,60 @@ You run a command with
---
`server` - Start the server
This starts a caddy instance, uvicorn with the django application and a scheduler that automatically removes expired session data.
### `server`
This starts the application (a caddy instance, uvicorn with the Django application and a scheduler that automatically removes expired session data).
Log files will be written.
---
`setup` - Set up the application
### `setup`
This sets up some database tables, views, and more, generates a secret key for the application and lets you create an admin user.
---
`create-admin` - Lets you create an admin user
### `create-admin`
Lets you create an admin user
---
`generate-secret-key` - generate a new random secret key for django
### `generate-secret-key`
Generate a new random secret key for Django.
This will overwrite the old one.
Warning: After running this, current sessions will be invalid, and the users have to relogin. Don't run this command while the server is running.
---
`clear-sessions` - manually remove all expired sessions from the database
### `clear-sessions`
manually remove all expired sessions from the database
---
`force-db-upgrade` - force a database migration and -upgrade
### `force-db-upgrade`
force a database migration and -upgrade.
This is mainly used in development.
---
`archive-tables` - archive (copy & delete) all entries in app_order and app_registertransaction
### `archive-tables`
archive (copy & delete) all entries in app_order and app_registertransaction.
Use this to archive old orders or transactions (e.g. when the database gets too big).
---
`development-server` - Start the development server
This starts a caddy instance, the django development server with DEBUGGING enabled and the session-clear-scheduler.
### `development-server`
This starts a caddy instance, the Django development server with DEBUGGING enabled and the session-clear-scheduler.
Only the HTTP-Access-Log will be written to its logfile, other logs will be written to the console.
---
`run-script <path>` - Run a python script in the context of the django project (experimental)
`<path>` is the path to the python script
### `shell`
Keep in mind that the current directory won't be changed automatically to the parent folder of the script file.
Start a Django shell.
---
`help` - Show a help text
### `help`
Show a help text
---

View file

@ -1,21 +0,0 @@
#!/usr/bin/env bash
# run a script in the context of the django project
export DJANGO_DEBUG="true"
if [ -z $2 ]; then
echo "Missing second argument <path>: the path to the script"
else
oldcwd="$(pwd)"
script_path=$2
echo "Starting $2 in a django shell:"
echo -e "--------------------------------------------------------------------------------\n"
cat "$script_path" | "$(pwd)/application/manage.py" shell
echo -e "\n--------------------------------------------------------------------------------"
cd "$oldcwd"
fi

12
lib/start-django-shell.sh Normal file
View file

@ -0,0 +1,12 @@
#!/usr/bin/env bash
# start a django shell
export DJANGO_DEBUG="true"
oldcwd="$(pwd)"
echo "Starting a django shell..."
echo -e "--------------------------------------------------------------------------------\n"
"$(pwd)/application/manage.py" shell
echo -e "\n--------------------------------------------------------------------------------"
cd "$oldcwd"

10
run.sh
View file

@ -8,12 +8,12 @@ function show_dm_help { # $1 = exit code
echo -e " server\t\tstart server"
echo -e " setup\t\t\tset up the application"
echo -e " create-admin\t\tcreate an admin account"
echo -e " generate-secret-key\tgenerate a new random secret key for django"
echo -e " generate-secret-key\tgenerate a new random secret key for Django"
echo -e " clear-sessions\tmanually remove all expired sessions from the database"
echo -e " force-db-upgrade\tforce a database migration & upgrade"
echo -e " archive-tables\tarchive (copy & delete) all entries in app_order and app_registertransaction"
echo -e " development-server\tstart django development server and enable debugging"
echo -e " run-script <path>\tRun a python script in the context of the django project (experimental)"
echo -e " development-server\tstart Django development server and enable debugging"
echo -e " shell\t\t\tstart a Django shell"
echo -e " help\t\t\tShow this help text\n"
echo -e "\nExamples:\n"
echo -e " ./run.sh server"
@ -77,9 +77,9 @@ else
python3 "$(pwd)/lib/archive-tables.py"
elif [ $1 = 'run-script' ]; then
elif [ $1 = 'shell' ]; then
source "$(pwd)/lib/run-script.sh"
source "$(pwd)/lib/start-django-shell.sh"
elif [ $1 = 'help' ]; then