forked from openedx-unsupported/devstack
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathprovision-lms.sh
executable file
·92 lines (71 loc) · 5.43 KB
/
provision-lms.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/usr/bin/env bash
set -eu -o pipefail
set -x
apps=( lms cms )
cms_port=18010
# Load database dumps for the largest databases to save time
./load-db.sh edxapp
./load-db.sh edxapp_csmh
# Bring edxapp containers online
for app in "${apps[@]}"; do
docker compose up -d $app
done
# install git for both LMS and CMS
for app in "${apps[@]}"; do
docker compose exec -T $app bash -e -c 'apt-get update && apt-get -y install --no-install-recommends git'
docker compose exec -T $app bash -e -c 'source /edx/app/edxapp/edxapp_env && cd /edx/app/edxapp/edx-platform && NO_PYTHON_UNINSTALL=1 pip install -e . -r requirements/edx/base.txt -r requirements/edx/assets.txt && npm clean-install'
#Installing prereqs crashes the process
docker compose restart $app
done
# Run edxapp migrations first since they are needed for the service users and OAuth clients
# Make migrate runs migrations for both lms and cms.
docker compose exec -T lms bash -e -c 'source /edx/app/edxapp/edxapp_env && make migrate'
docker compose exec -T lms bash -e -c 'source /edx/app/edxapp/edxapp_env && /edx/app/edxapp/venvs/edxapp/bin/python /edx/app/edxapp/edx-platform/manage.py lms showmigrations --database student_module_history --traceback --pythonpath=. --settings devstack_docker'
docker compose exec -T lms bash -e -c 'source /edx/app/edxapp/edxapp_env && /edx/app/edxapp/venvs/edxapp/bin/python /edx/app/edxapp/edx-platform/manage.py lms migrate --database student_module_history --noinput --traceback --pythonpath=. --settings devstack_docker'
docker compose exec -T cms bash -e -c 'source /edx/app/edxapp/edxapp_env && /edx/app/edxapp/venvs/edxapp/bin/python /edx/app/edxapp/edx-platform/manage.py cms showmigrations --database student_module_history --traceback --pythonpath=. --settings devstack_docker'
docker compose exec -T cms bash -e -c 'source /edx/app/edxapp/edxapp_env && /edx/app/edxapp/venvs/edxapp/bin/python /edx/app/edxapp/edx-platform/manage.py cms migrate --database student_module_history --noinput --traceback --pythonpath=. --settings devstack_docker'
# Create a superuser for edxapp
docker compose exec -T lms bash -e -c 'source /edx/app/edxapp/edxapp_env && python /edx/app/edxapp/edx-platform/manage.py lms --settings=devstack_docker manage_user edx edx@example.com --superuser --staff'
docker compose exec -T lms bash -e -c 'source /edx/app/edxapp/edxapp_env && echo "from django.contrib.auth import get_user_model; User = get_user_model(); user = User.objects.get(username=\"edx\"); user.set_password(\"edx\"); user.save()" | python /edx/app/edxapp/edx-platform/manage.py lms shell --settings=devstack_docker'
# Create an enterprise service user for edxapp and give them appropriate permissions
./enterprise/provision.sh
# Enable the LMS-E-Commerce integration
docker compose exec -T lms bash -e -c 'source /edx/app/edxapp/edxapp_env && python /edx/app/edxapp/edx-platform/manage.py lms --settings=devstack_docker configure_commerce'
# Create demo course and users
#docker compose exec -T lms bash -e -c '/edx/app/edx_ansible/venvs/edx_ansible/bin/ansible-playbook /edx/app/edx_ansible/edx_ansible/playbooks/demo.yml -v -c local -i "127.0.0.1," --extra-vars="COMMON_EDXAPP_SETTINGS=devstack_docker"'
if [[ ${DEVSTACK_SKIP_DEMO-false} == "true" ]]
then
echo "Skipping import of demo course. DEVSTACK_SKIP_DEMO is set to true"
else
# FIXME: Using old version of demo course (open-release/quince.1) until we can
# update devstack and other repos to match: https://github.com/openedx/devstack/issues/1273
docker compose exec -T lms bash -e -c 'git clone https://github.com/openedx/edx-demo-course.git --branch open-release/quince.1 /tmp/edx-demo-course'
docker compose exec -T lms bash -e -c 'source /edx/app/edxapp/edxapp_env && python /edx/app/edxapp/edx-platform/manage.py cms --settings=devstack_docker import /edx/var/edxapp/data /tmp/edx-demo-course && rm -rf /tmp/edx-demo-course'
fi
demo_hashed_password='pbkdf2_sha256$20000$TjE34FJjc3vv$0B7GUmH8RwrOc/BvMoxjb5j8EgnWTt3sxorDANeF7Qw='
for user in honor audit verified staff ; do
email="$user@example.com"
# Set staff flag for staff user
if [[ $user == "staff" ]] ; then
docker compose exec -T lms bash -e -c "source /edx/app/edxapp/edxapp_env && python /edx/app/edxapp/edx-platform/manage.py lms --settings=devstack_docker --service-variant lms manage_user $user $email --initial-password-hash '$demo_hashed_password' --staff"
else
docker compose exec -T lms bash -e -c "source /edx/app/edxapp/edxapp_env && python /edx/app/edxapp/edx-platform/manage.py lms --settings=devstack_docker --service-variant lms manage_user $user $email --initial-password-hash '$demo_hashed_password'"
fi
if [[ "${DEVSTACK_SKIP_DEMO-false}" != "true" ]]
then
# Enroll users in the demo course
docker compose exec -T lms bash -e -c "source /edx/app/edxapp/edxapp_env && python /edx/app/edxapp/edx-platform/manage.py lms --settings=devstack_docker --service-variant lms enroll_user_in_course -e $email -c course-v1:edX+DemoX+Demo_Course"
fi
done
# Fix missing vendor file by clearing the cache
# docker compose exec -T lms bash -e -c 'rm /edx/app/edxapp/edx-platform/.prereqs_cache/Node_prereqs.sha1'
# Create static assets for both LMS and CMS
for app in "${apps[@]}"; do
make "dev.static.$app"
done
# Allow LMS SSO for CMS
./provision-ida-user.sh cms cms "$cms_port"
# Provision a retirement service account user
./provision-retirement-user.sh retirement retirement_service_worker
# Add demo program
./programs/provision.sh lms