Skip to content

Commit

Permalink
Add a flag for skipping the database setup
Browse files Browse the repository at this point in the history
For example, in the run-mooc-grader container,
when the environment variable `grader_NO_DATABASE` is set to
a non-empty value, then run-mooc-grader skips the database setup
and migrations.

In create-db.sh, the -u parameter was removed from /bin/sh because
the script must not exit when the no-database flag is not set.
  • Loading branch information
markkuriekkinen committed Dec 20, 2021
1 parent 7315326 commit 320e9dc
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
10 changes: 9 additions & 1 deletion dbipc/rootfs/usr/local/sbin/create-db.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
#!/bin/sh -eu
#!/bin/sh -e

flagname="${CONTAINER_TYPE}_NO_DATABASE"
eval flag=\$$flagname
if [ $flag ]; then
echo "Skipping database setup because '${flagname}' is set."
exit 0
fi


prog=${0##*/}
user=$1
Expand Down
8 changes: 8 additions & 0 deletions dbipc/rootfs/usr/local/sbin/init-db.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
#!/bin/sh

flagname="${CONTAINER_TYPE}_NO_DATABASE"
eval flag=\$$flagname
if [ $flag ]; then
echo "Skipping database setup because '${flagname}' is set."
exit 0
fi


user=$1
db=$2
shift 2
Expand Down
2 changes: 1 addition & 1 deletion django/rootfs/usr/local/sbin/run-django.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export HOME="$app_path"
# Use python from virtualenv if present
[ -e "/local/venv_$app_name/bin/activate" ] && . /local/venv_$app_name/bin/activate

# Ensure database state, will run manage.py migrate always
# Ensure database state, will run manage.py migrate if databases are enabled.
init-db.sh "$user" "$db" django-migrate.sh

# With dev code, we need to rerun few init tasks
Expand Down

0 comments on commit 320e9dc

Please sign in to comment.