forked from openedx-unsupported/devstack
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathprovision-set-edx-theme.sh
executable file
·47 lines (39 loc) · 1.72 KB
/
provision-set-edx-theme.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
#!/usr/bin/env bash
# This script sets up the edX theme in LMS and CMS.
REPO_URL="https://github.com/edx/edx-themes"
THEME_DIR="/edx/src/edx-themes/edx-platform"
DEVSTACK_FILE="../edx-platform/lms/envs/devstack.py"
# Clone the edx-themes repository into the src directory
cd ../src
if [ ! -d "edx-themes" ]; then
git clone "$REPO_URL"
else
echo "Directory 'edx-themes' already exists. Skipping clone."
fi
cd ../devstack
# Uncomment relevant lines in the devstack.py file
sed -i '' "s|^# from .common import _make_mako_template_dirs|from .common import _make_mako_template_dirs|" "$DEVSTACK_FILE"
sed -i '' "s|^# ENABLE_COMPREHENSIVE_THEMING = True|ENABLE_COMPREHENSIVE_THEMING = True|" "$DEVSTACK_FILE"
sed -i '' "s|^# COMPREHENSIVE_THEME_DIRS = \[|COMPREHENSIVE_THEME_DIRS = \[|" "$DEVSTACK_FILE"
sed -i '' "s|^# \"/edx/app/edxapp/edx-platform/themes/\"| \"/edx/app/edxapp/edx-platform/themes/\",|" "$DEVSTACK_FILE"
sed -i '' "/COMPREHENSIVE_THEME_DIRS = \[/a\\
\"$THEME_DIR\",
" "$DEVSTACK_FILE"
sed -i '' "s|^# \]|]|" "$DEVSTACK_FILE"
sed -i '' "s|^# TEMPLATES\[1\]\[\"DIRS\"\] = _make_mako_template_dirs|TEMPLATES[1][\"DIRS\"] = _make_mako_template_dirs|" "$DEVSTACK_FILE"
sed -i '' "s|^# derive_settings(__name__)|derive_settings(__name__)|" "$DEVSTACK_FILE"
# Add the theme directory to COMPREHENSIVE_THEME_DIRS if not already present
if ! grep -qF "$THEME_DIR" "$DEVSTACK_FILE"; then
sed -i '' "/COMPREHENSIVE_THEME_DIRS = \[/a\\
\"$THEME_DIR\",
" "$DEVSTACK_FILE"
fi
# Set the theme site-wide
SERVICE_NAME="mysql80"
DATABASE="edxapp"
THEME_NAME="edx.org-next"
SITE_ID=1
docker compose exec -T "$SERVICE_NAME" mysql -e "
USE $DATABASE;
INSERT INTO theming_sitetheme (theme_dir_name, site_id) VALUES ('$THEME_NAME', $SITE_ID);
"