-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathprovision-set-edx-theme.sh
More file actions
executable file
·52 lines (44 loc) · 2.18 KB
/
provision-set-edx-theme.sh
File metadata and controls
executable file
·52 lines (44 loc) · 2.18 KB
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
#!/usr/bin/env bash
# This script sets up the edX theme in LMS and CMS.
REPO_URL_HTTPS="https://github.com/edx/edx-themes.git"
REPO_URL_SSH="git@github.com:edx/edx-themes.git"
THEME_DIR="/edx/src/edx-themes/edx-platform"
DEVSTACK_FILE="./py_configuration_files/lms.py"
# Clone the edx-themes repository into the src directory
mkdir -p ${DEVSTACK_WORKSPACE}/src
pushd ${DEVSTACK_WORKSPACE}/src
if [ ! -d "edx-themes" ]; then
# Make a best effort to use SSH, but if that doesn't work then fallback to HTTPS.
# Also make a best effort to avoid terminal prompting which breaks automation.
GIT_TERMINAL_PROMPT=0 GIT_SSH_COMMAND="ssh -o StrictHostKeyChecking=accept-new" git clone --depth=1 "$REPO_URL_SSH"
[[ ! -d "edx-themes" ]] && GIT_TERMINAL_PROMPT=0 git clone --depth=1 "$REPO_URL_HTTPS"
else
echo "Directory 'edx-themes' already exists. Skipping clone."
fi
popd
# 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\"\] = Derived(make_mako_template_dirs)|TEMPLATES[1][\"DIRS\"] = Derived(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);
"