7
0
mirror of https://github.com/ChristianLight/tutor.git synced 2024-06-02 06:10:47 +00:00
tutor/tutor/templates/jobs/init/lms.sh
Régis Behmo 16e6131f96 feat: pluggable local/dev/k8s do <job> commands
We introduce a new filter to implement custom commands in arbitrary containers.
It becomes easy to write convenient ad-hoc commands that users will
then be able to run either on Kubernetes or locally using a documented CLI.

Pluggable jobs are declared as Click commands and are responsible for
parsing their own arguments. See the new CLI_DO_COMMANDS filter.

Close https://github.com/overhangio/2u-tutor-adoption/issues/75
2022-11-15 09:46:08 +01:00

46 lines
1.8 KiB
Bash

dockerize -wait tcp://{{ MYSQL_HOST }}:{{ MYSQL_PORT }} -timeout 20s
{%- if MONGODB_HOST.startswith("mongodb+srv://") %}
echo "MongoDB is using SRV records, so we cannot wait for it to be ready"
{%- else %}
dockerize -wait tcp://{{ MONGODB_HOST }}:{{ MONGODB_PORT }} -timeout 20s
{%- endif %}
echo "Loading settings $DJANGO_SETTINGS_MODULE"
./manage.py lms migrate
# Create oauth2 apps for CMS SSO
# https://github.com/openedx/edx-platform/blob/master/docs/guides/studio_oauth.rst
./manage.py lms manage_user cms cms@openedx --unusable-password
./manage.py lms create_dot_application \
--grant-type authorization-code \
--redirect-uris "{% if ENABLE_HTTPS %}https{% else %}http{% endif %}://{{ CMS_HOST }}/complete/edx-oauth2/" \
--client-id {{ CMS_OAUTH2_KEY_SSO }} \
--client-secret {{ CMS_OAUTH2_SECRET }} \
--scopes user_id \
--skip-authorization \
--update cms-sso cms
./manage.py lms create_dot_application \
--grant-type authorization-code \
--redirect-uris "http://{{ CMS_HOST }}:8001/complete/edx-oauth2/" \
--client-id {{ CMS_OAUTH2_KEY_SSO_DEV }} \
--client-secret {{ CMS_OAUTH2_SECRET }} \
--scopes user_id \
--skip-authorization \
--update cms-sso-dev cms
# Fix incorrect uploaded file path
if [ -d /openedx/data/uploads/ ]; then
if [ -n "$(ls -A /openedx/data/uploads/)" ]; then
echo "Migrating LMS uploaded files to shared directory"
mv /openedx/data/uploads/* /openedx/media/
rm -rf /openedx/data/uploads/
fi
fi
# Create waffle switches to enable some features, if they have not been explicitly defined before
# Completion tracking: add green ticks to every completed unit
(./manage.py lms waffle_switch --list | grep completion.enable_completion_tracking) || ./manage.py lms waffle_switch --create completion.enable_completion_tracking on