6
0
mirror of https://github.com/ChristianLight/tutor.git synced 2024-12-12 14:17:46 +00:00

Dynamic openedx settings configuration

`tutor.production` should not be hardcoded in the init scripts. Instead,
we load the `$SERVICE_VARIANT.envs.$SETTINGS` settings.

This was inspired by a conversation on slack:
https://openedx.slack.com/archives/CGE253B7V/p1573561290003700?thread_ts=1573478499.002800&cid=CGE253B7V

Thanks @cacciaresi!
This commit is contained in:
Régis Behmo 2019-11-14 09:27:28 +01:00
parent b1d0039d66
commit 1f08006e90
4 changed files with 29 additions and 9 deletions

View File

@ -59,18 +59,28 @@ def initialise(runner):
def create_user_command(superuser, staff, username, email, password=None): def create_user_command(superuser, staff, username, email, password=None):
command = """
export DJANGO_SETTINGS_MODULE=$SERVICE_VARIANT.envs.$SETTINGS
echo "Loading settings $DJANGO_SETTINGS_MODULE"
"""
opts = "" opts = ""
if superuser: if superuser:
opts += " --superuser" opts += " --superuser"
if staff: if staff:
opts += " --staff" opts += " --staff"
command = "./manage.py lms --settings=tutor.production manage_user {opts} {username} {email}\n" command += """
./manage.py lms manage_user {opts} {username} {email}
"""
if password: if password:
command += "./manage.py lms --settings=tutor.production shell -c \"from django.contrib.auth import get_user_model; u = get_user_model().objects.get(username='{username}'); u.set_password('{password}'); u.save()\"" command += """
./manage.py lms shell -c "from django.contrib.auth import get_user_model; u = get_user_model().objects.get(username='{username}'); u.set_password('{password}'); u.save()"
"""
else: else:
command += ( command += """
"./manage.py lms --settings=tutor.production changepassword {username}" ./manage.py lms changepassword {username}
) """
return command.format(opts=opts, username=username, email=email, password=password) return command.format(opts=opts, username=username, email=email, password=password)

View File

@ -1,2 +1,5 @@
export DJANGO_SETTINGS_MODULE=$SERVICE_VARIANT.envs.$SETTINGS
echo "Loading settings $DJANGO_SETTINGS_MODULE"
git clone https://github.com/edx/edx-demo-course --branch open-release/ironwood.2 --depth 1 ../edx-demo-course git clone https://github.com/edx/edx-demo-course --branch open-release/ironwood.2 --depth 1 ../edx-demo-course
python ./manage.py cms --settings=tutor.production import ../data ../edx-demo-course python ./manage.py cms import ../data ../edx-demo-course

View File

@ -1 +1,4 @@
./manage.py cms --settings=tutor.production reindex_course --all --setup export DJANGO_SETTINGS_MODULE=$SERVICE_VARIANT.envs.$SETTINGS
echo "Loading settings $DJANGO_SETTINGS_MODULE"
./manage.py cms reindex_course --all --setup

View File

@ -1,7 +1,11 @@
dockerize -wait tcp://{{ MYSQL_HOST }}:{{ MYSQL_PORT }} -timeout 20s dockerize -wait tcp://{{ MYSQL_HOST }}:{{ MYSQL_PORT }} -timeout 20s
./manage.py lms --settings=tutor.production migrate
./manage.py lms --settings=tutor.production create_oauth2_client \ export DJANGO_SETTINGS_MODULE=$SERVICE_VARIANT.envs.$SETTINGS
echo "Loading settings $DJANGO_SETTINGS_MODULE"
./manage.py lms migrate
./manage.py lms create_oauth2_client \
"http://androidapp.com" "http://androidapp.com/redirect" public \ "http://androidapp.com" "http://androidapp.com/redirect" public \
--client_id android --client_secret {{ ANDROID_OAUTH2_SECRET }} \ --client_id android --client_secret {{ ANDROID_OAUTH2_SECRET }} \
--trusted --trusted