Skip to content

Instantly share code, notes, and snippets.

@icarrr
Last active September 23, 2022 21:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save icarrr/642eb1427167802f749829ad62b359a1 to your computer and use it in GitHub Desktop.
Save icarrr/642eb1427167802f749829ad62b359a1 to your computer and use it in GitHub Desktop.
Open edX

Open edX

Install Open edX Using Method Native Installation

Add some variables to your server

echo "export LC_ALL='en_US.UTF-8'" >> ~/.bashrc
echo "export LANG='en_US.UTF-8'" >> ~/.bashrc
echo "export LANGUAGE='en_US.UTF-8'" >> ~/.bashrc
echo "export OPENEDX_RELEASE='the-tag/you-want-to-install'" >> ~/.bashrc

Reload bash

source ~/.bashrc

Create a new file with the name config.yml in the desired directory and add the following script that contains LMS and open the edX Studio address. The following is an example file, please change according to the desired address:

EDXAPP_LMS_BASE: "online.myeducation.org"
EDXAPP_CMS_BASE: "studio.online.myeducation.org"

Install Open edX

wget https://raw.githubusercontent.com/edx/configuration/$OPENEDX_RELEASE/util/install/ansible-bootstrap.sh -O - | sudo bash
wget https://raw.githubusercontent.com/edx/configuration/$OPENEDX_RELEASE/util/install/generate-passwords.sh -O - | bash
wget https://raw.githubusercontent.com/edx/configuration/$OPENEDX_RELEASE/util/install/native.sh -O - | bash

References

https://sibunglon.com/2019/07/13/install-open-edx-using-method-native-installation-ubuntu-16.04/

Open edX - LMS Shell

source /edx/app/edxapp/edxapp_env
sudo -E -H -u edxapp /edx/bin/python.edxapp /edx/app/edxapp/edx-platform/manage.py lms shell --settings=production
#!/usr/bin/env bash
# Ironwood.master script
#
# Script for installing Ansible and the edX configuration repository
# onto a host to enable running ansible to complete configuration.
# This script can be used by Docker, Packer or any other system
# for building images that require having ansible available.
#
# Can be run as follows:
#
# UPGRADE_OS=true CONFIGURATION_VERSION="master" \
# bash <(curl -s https://raw.githubusercontent.com/edx/configuration/master/util/install/ansible-bootstrap.sh)
set -xe
repo_edx_configuration=https://github.com/icarrr/configuration.git
if [[ -z "${ANSIBLE_REPO}" ]]; then
ANSIBLE_REPO="https://github.com/edx/ansible.git"
fi
if [[ -z "${ANSIBLE_VERSION}" ]]; then
ANSIBLE_VERSION="master"
fi
if [[ -z "${CONFIGURATION_REPO}" ]]; then
CONFIGURATION_REPO="$repo_edx_configuration"
fi
if [[ -z "${CONFIGURATION_VERSION}" ]]; then
CONFIGURATION_VERSION=${OPENEDX_RELEASE-master}
fi
if [[ -z "${UPGRADE_OS}" ]]; then
UPGRADE_OS=false
fi
if [[ -z "${RUN_ANSIBLE}" ]]; then
RUN_ANSIBLE=true
fi
#
# Bootstrapping constants
#
VIRTUAL_ENV_VERSION="15.2.0"
PIP_VERSION="9.0.3"
SETUPTOOLS_VERSION="39.0.1"
VIRTUAL_ENV="/tmp/bootstrap"
PYTHON_BIN="${VIRTUAL_ENV}/bin"
ANSIBLE_DIR="/tmp/ansible"
CONFIGURATION_DIR="/tmp/configuration"
EDX_PPA_KEY_SERVER="keyserver.ubuntu.com"
EDX_PPA_KEY_ID="B41E5E3969464050"
cat << EOF
******************************************************************************
Running the edx_ansible bootstrap script with the following arguments:
ANSIBLE_REPO="${ANSIBLE_REPO}"
ANSIBLE_VERSION="${ANSIBLE_VERSION}"
CONFIGURATION_REPO="${CONFIGURATION_REPO}"
CONFIGURATION_VERSION="${CONFIGURATION_VERSION}"
******************************************************************************
EOF
if [[ $(id -u) -ne 0 ]] ;then
echo "Please run as root";
exit 1;
fi
if grep -q 'Trusty Tahr' /etc/os-release
then
SHORT_DIST="trusty"
elif grep -q 'Xenial Xerus' /etc/os-release
then
SHORT_DIST="xenial"
elif grep -q 'Bionic Beaver' /etc/os-release
then
SHORT_DIST="bionic"
else
cat << EOF
This script is only known to work on Ubuntu Trusty, Xenial, and Bionic;
exiting. If you are interested in helping make installation possible
on other platforms, let us know.
EOF
exit 1;
fi
EDX_PPA="deb http://ppa.edx.org ${SHORT_DIST} main"
# Upgrade the OS
apt-get update -y
# To apt-key update in bionic, gnupg is needed.
if [[ "${SHORT_DIST}" == bionic ]] ;then
apt-get install -y gnupg
fi
apt-key update -y
if [ "${UPGRADE_OS}" = true ]; then
echo "Upgrading the OS..."
apt-get upgrade -y
fi
# Required for add-apt-repository
apt-get install -y software-properties-common
if [[ "${SHORT_DIST}" != bionic ]] ;then
apt-get install -y python-software-properties
fi
# Add git PPA
add-apt-repository -y ppa:git-core/ppa
# For older software we need to install our own PPA
# Phased out with Ubuntu 18.04 Bionic
if [[ "${SHORT_DIST}" != bionic ]] ;then
apt-key adv --keyserver "${EDX_PPA_KEY_SERVER}" --recv-keys "${EDX_PPA_KEY_ID}"
add-apt-repository -y "${EDX_PPA}"
fi
# Install python 2.7 latest, git and other common requirements
# NOTE: This will install the latest version of python 2.7 and
# which may differ from what is pinned in virtualenvironments
apt-get update -y
apt-get install -y python2.7 python2.7-dev python-pip python-apt python-yaml python-jinja2 build-essential sudo git-core libmysqlclient-dev libffi-dev libssl-dev
pip install --upgrade pip=="${PIP_VERSION}"
# pip moves to /usr/local/bin when upgraded
PATH=/usr/local/bin:${PATH}
pip install setuptools=="${SETUPTOOLS_VERSION}"
pip install virtualenv=="${VIRTUAL_ENV_VERSION}"
if [[ "true" == "${RUN_ANSIBLE}" ]]; then
# create a new virtual env
/usr/local/bin/virtualenv "${VIRTUAL_ENV}"
PATH="${PYTHON_BIN}":${PATH}
# Install the configuration repository to install
# edx_ansible role
git clone ${CONFIGURATION_REPO} ${CONFIGURATION_DIR}
cd ${CONFIGURATION_DIR}
git checkout ${CONFIGURATION_VERSION}
make requirements
cd "${CONFIGURATION_DIR}"/playbooks
"${PYTHON_BIN}"/ansible-playbook edx_ansible.yml -i '127.0.0.1,' -c local -e "configuration_version=${CONFIGURATION_VERSION}" -e "edx_ansible_source_repo=${repo_edx_configuration}"
# cleanup
rm -rf "${ANSIBLE_DIR}"
rm -rf "${CONFIGURATION_DIR}"
rm -rf "${VIRTUAL_ENV}"
rm -rf "${HOME}/.ansible"
cat << EOF
******************************************************************************
Done bootstrapping, edx_ansible is now installed in /edx/app/edx_ansible.
Time to run some plays. Activate the virtual env with
> . /edx/app/edx_ansible/venvs/edx_ansible/bin/activate
******************************************************************************
EOF
else
mkdir -p /edx/ansible/facts.d
echo '{ "ansible_bootstrap_run": true }' > /edx/ansible/facts.d/ansible_bootstrap.json
fi
#!/bin/bash
if [[ `lsb_release -rs` != "16.04" ]]; then
echo "This script is only known to work on Ubuntu 16.04, exiting..."
exit
fi
# Config.yml is required, must define LMS and CMS names, and the names
# must not infringe trademarks.
if [[ ! -f config.yml ]]; then
echo 'You must create a config.yml file specifying the hostnames (and if'
echo 'needed, ports) of your LMS and Studio hosts.'
echo 'For example:'
echo ' EDXAPP_LMS_BASE: "11.22.33.44"'
echo ' EDXAPP_CMS_BASE: "11.22.33.44:18010"'
exit
fi
grep -Fq EDXAPP_LMS_BASE config.yml
GREP_LMS=$?
grep -Fq EDXAPP_CMS_BASE config.yml
GREP_CMS=$?
if [[ $GREP_LMS == 1 ]] || [[ $GREP_CMS == 1 ]]; then
echo 'Your config.yml file must specify the hostnames (and if'
echo 'needed, ports) of your LMS and Studio hosts.'
echo 'For example:'
echo ' EDXAPP_LMS_BASE: "11.22.33.44"'
echo ' EDXAPP_CMS_BASE: "11.22.33.44:18010"'
exit
fi
grep -Fq edx. config.yml
GREP_BAD_DOMAIN=$?
if [[ $GREP_BAD_DOMAIN == 0 ]]; then
echo '*** NOTE: Open edX and edX are registered trademarks.'
echo 'You may not use "openedx." or "edx." as subdomains when naming your site.'
echo 'For more details, see the edX Trademark Policy: https://edx.org/trademarks'
echo ''
echo 'Here are some examples of unacceptable domain names:'
echo ' openedx.yourdomain.org'
echo ' edx.yourdomain.org'
echo ' openedxyourdomain.org'
echo ' yourdomain-edx.com'
echo ''
echo 'Please choose different domain names.'
exit
fi
echo "Installing release '$OPENEDX_RELEASE'"
##
## Set ppa repository source for gcc/g++ 4.8 in order to install insights properly
##
sudo apt-get install -y python-software-properties
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
##
## Update and Upgrade apt packages
##
sudo apt-get update -y
sudo apt-get upgrade -y
##
## Install system pre-requisites
##
sudo apt-get install -y build-essential software-properties-common curl git-core libxml2-dev libxslt1-dev python-pip libmysqlclient-dev python-apt python-dev libxmlsec1-dev libfreetype6-dev swig gcc g++
sudo pip install --upgrade pip==9.0.3
sudo pip install --upgrade setuptools==39.0.1
sudo -H pip install --upgrade virtualenv==15.2.0
##
## Overridable version variables in the playbooks. Each can be overridden
## individually, or with $OPENEDX_RELEASE.
##
VERSION_VARS=(
edx_platform_version
certs_version
forum_version
XQUEUE_VERSION
configuration_version
demo_version
NOTIFIER_VERSION
INSIGHTS_VERSION
ANALYTICS_API_VERSION
ECOMMERCE_VERSION
ECOMMERCE_WORKER_VERSION
DISCOVERY_VERSION
THEMES_VERSION
)
for var in ${VERSION_VARS[@]}; do
# Each variable can be overridden by a similarly-named environment variable,
# or OPENEDX_RELEASE, if provided.
ENV_VAR=$(echo $var | tr '[:lower:]' '[:upper:]')
eval override=\${$ENV_VAR-\$OPENEDX_RELEASE}
if [ -n "$override" ]; then
EXTRA_VARS="-e $var=$override $EXTRA_VARS"
fi
done
# my-passwords.yml is the file made by generate-passwords.sh.
if [[ -f my-passwords.yml ]]; then
EXTRA_VARS="-e@$(pwd)/my-passwords.yml $EXTRA_VARS"
fi
EXTRA_VARS="-e@$(pwd)/config.yml $EXTRA_VARS"
CONFIGURATION_VERSION=${CONFIGURATION_VERSION-$OPENEDX_RELEASE}
##
## Clone the configuration repository and run Ansible
##
cd /var/tmp
git clone https://github.com/edx/configuration
cd configuration
git checkout $CONFIGURATION_VERSION
git pull
##
## Install the ansible requirements
##
cd /var/tmp/configuration
sudo -H pip install -r requirements.txt
##
## Update script openedx_native
##
sudo bash -c "cat << 'EOF' > /var/tmp/configuration/playbooks/openedx_native.yml
---
# Open edX Native installation for single server community installs.
- name: Bootstrap instance(s)
hosts: all
gather_facts: no
become: True
roles:
- python
- name: Configure instance(s)
hosts: all
become: True
gather_facts: True
vars:
migrate_db: 'yes'
EDXAPP_PREVIEW_LMS_BASE: '{{ EDXAPP_LMS_BASE }}'
EDXAPP_LOGIN_REDIRECT_WHITELIST: [
'{{ EDXAPP_CMS_BASE }}',
'account.{{ EDXAPP_LMS_BASE }}',
'gradebook.{{ EDXAPP_LMS_BASE }}',
'profile.{{ EDXAPP_LMS_BASE }}'
]
EDXAPP_LMS_BASE_SCHEME: http
COMMON_LMS_BASE_URL: '{{ EDXAPP_LMS_BASE_SCHEME }}://{{ EDXAPP_LMS_BASE }}'
EDXAPP_LMS_NGINX_PORT: '80'
EDX_PLATFORM_VERSION: 'master'
# Set to false if deployed behind another proxy/load balancer.
NGINX_SET_X_FORWARDED_HEADERS: True
DISCOVERY_URL_ROOT: 'http://localhost:{{ DISCOVERY_NGINX_PORT }}'
AWS_GATHER_FACTS: false
COMMON_ENABLE_AWS_ROLE: false
ecommerce_create_demo_data: true
credentials_create_demo_data: true
CONFIGURE_JWTS: true
SANDBOX_ENABLE_BLOCKSTORE: false
SANDBOX_ENABLE_DISCOVERY: true
SANDBOX_ENABLE_ECOMMERCE: true
SANDBOX_ENABLE_ANALYTICS_API: true
SANDBOX_ENABLE_INSIGHTS: true
SANDBOX_ENABLE_RABBITMQ: true
SANDBOX_ENABLE_NOTES: false
DEMO_ROLE_ENABLED: true
ECOMMERCE_ENABLE_COMPREHENSIVE_THEMING: false
EDXAPP_ENABLE_MEMCACHE: true
EDXAPP_ENABLE_ELASTIC_SEARCH: true
roles:
- role: mongo_3_2
EOF"
##
## Run the openedx_native.yml playbook in the configuration/playbooks directory
##
cd /var/tmp/configuration/playbooks && sudo -E ansible-playbook -c local ./openedx_native.yml -i "localhost," $EXTRA_VARS "$@"
#!/bin/bash
next_task=$1
if [[ ! $next_task ]]; then
echo "You must define next_task"
exit
fi
if [[ ! $OPENEDX_RELEASE ]]; then
echo "You must define OPENEDX_RELEASE"
exit
fi
VERSION_VARS=(
edx_platform_version
certs_version
forum_version
XQUEUE_VERSION
configuration_version
demo_version
NOTIFIER_VERSION
INSIGHTS_VERSION
ANALYTICS_API_VERSION
ECOMMERCE_VERSION
ECOMMERCE_WORKER_VERSION
DISCOVERY_VERSION
THEMES_VERSION
)
for var in ${VERSION_VARS[@]}; do
# Each variable can be overridden by a similarly-named environment variable,
# or OPENEDX_RELEASE, if provided.
ENV_VAR=$(echo $var | tr '[:lower:]' '[:upper:]')
eval override=\${$ENV_VAR-\$OPENEDX_RELEASE}
if [ -n "$override" ]; then
EXTRA_VARS="-e $var=$override $EXTRA_VARS"
fi
done
# my-passwords.yml is the file made by generate-passwords.sh.
if [[ -f my-passwords.yml ]]; then
EXTRA_VARS="-e@$(pwd)/my-passwords.yml $EXTRA_VARS"
fi
EXTRA_VARS="-e@$(pwd)/config.yml $EXTRA_VARS"
CONFIGURATION_VERSION=${CONFIGURATION_VERSION-$OPENEDX_RELEASE}
cd /var/tmp/configuration/playbooks && sudo -E ansible-playbook -c local ./openedx_native.yml -i "localhost," $EXTRA_VARS "$@" --start-at-task="$next_task"
#!/bin/bash
if [[ ! $OPENEDX_RELEASE ]]; then
echo "You must define OPENEDX_RELEASE"
exit
fi
if [[ `lsb_release -rs` != "20.04" ]]; then
echo "This script is only known to work on Ubuntu 20.04, exiting..."
exit
fi
# Config.yml is required, must define LMS and CMS names, and the names
# must not infringe trademarks.
if [[ ! -f config.yml ]]; then
echo 'You must create a config.yml file specifying the hostnames (and if'
echo 'needed, ports) of your LMS and Studio hosts.'
echo 'For example:'
echo ' EDXAPP_LMS_BASE: "11.22.33.44"'
echo ' EDXAPP_CMS_BASE: "11.22.33.44:18010"'
exit
fi
grep -Fq EDXAPP_LMS_BASE config.yml
GREP_LMS=$?
grep -Fq EDXAPP_CMS_BASE config.yml
GREP_CMS=$?
if [[ $GREP_LMS == 1 ]] || [[ $GREP_CMS == 1 ]]; then
echo 'Your config.yml file must specify the hostnames (and if'
echo 'needed, ports) of your LMS and Studio hosts.'
echo 'For example:'
echo ' EDXAPP_LMS_BASE: "11.22.33.44"'
echo ' EDXAPP_CMS_BASE: "11.22.33.44:18010"'
exit
fi
grep -Fq edx. config.yml
GREP_BAD_DOMAIN=$?
if [[ $GREP_BAD_DOMAIN == 0 ]]; then
echo '*** NOTE: Open edX and edX are registered trademarks.'
echo 'You may not use "openedx." or "edx." as subdomains when naming your site.'
echo 'For more details, see the edX Trademark Policy: https://edx.org/trademarks'
echo ''
echo 'Here are some examples of unacceptable domain names:'
echo ' openedx.yourdomain.org'
echo ' edx.yourdomain.org'
echo ' openedxyourdomain.org'
echo ' yourdomain-edx.com'
echo ''
echo 'Please choose different domain names.'
exit
fi
echo "Installing release '$OPENEDX_RELEASE'"
##
## Set ppa repository source for gcc/g++ 4.8 in order to install insights properly
##
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
##
## Update and Upgrade apt packages
##
sudo apt-get update -y
sudo apt-get upgrade -y
##
## Install system pre-requisites
##
sudo apt-get install -y build-essential software-properties-common curl git-core libxml2-dev libxslt1-dev python3-pip libmysqlclient-dev python3-apt python3-dev libxmlsec1-dev libfreetype6-dev swig gcc g++
# ansible-bootstrap installs yaml that pip 19 can't uninstall.
sudo apt-get remove -y python-yaml
sudo pip install --upgrade pip==20.0.2
sudo pip install --upgrade setuptools==44.1.0
sudo -H pip install --upgrade virtualenv==16.7.10
##
## Overridable version variables in the playbooks. Each can be overridden
## individually, or with $OPENEDX_RELEASE.
##
VERSION_VARS=(
EDX_PLATFORM_VERSION
CERTS_VERSION
FORUM_VERSION
XQUEUE_VERSION
CONFIGURATION_VERSION
DEMO_VERSION
INSIGHTS_VERSION
ANALYTICS_API_VERSION
ECOMMERCE_VERSION
ECOMMERCE_WORKER_VERSION
DISCOVERY_VERSION
THEMES_VERSION
ACCOUNT_MFE_VERSION
GRADEBOOK_MFE_VERSION
PROFILE_MFE_VERSION
)
for var in ${VERSION_VARS[@]}; do
# Each variable can be overridden by a similarly-named environment variable,
# or OPENEDX_RELEASE, if provided.
ENV_VAR=$(echo $var | tr '[:lower:]' '[:upper:]')
eval override=\${$ENV_VAR-\$OPENEDX_RELEASE}
if [ -n "$override" ]; then
EXTRA_VARS="-e $var=$override $EXTRA_VARS"
fi
done
# my-passwords.yml is the file made by generate-passwords.sh.
if [[ -f my-passwords.yml ]]; then
EXTRA_VARS="-e@$(pwd)/my-passwords.yml $EXTRA_VARS"
fi
EXTRA_VARS="-e@$(pwd)/config.yml $EXTRA_VARS"
CONFIGURATION_VERSION=${CONFIGURATION_VERSION-$OPENEDX_RELEASE}
##
## Clone the configuration repository and run Ansible
##
cd /var/tmp
git clone https://github.com/edx/configuration
cd configuration
git checkout $CONFIGURATION_VERSION
git pull
##
## Install the ansible requirements
##
cd /var/tmp/configuration
sudo -H pip3 install -r requirements.txt
##
## Update script openedx_native
##
sudo bash -c "cat << 'EOF' > /var/tmp/configuration/playbooks/openedx_native.yml
---
# Open edX Native installation for single server community installs.
- name: Configure instance(s)
hosts: all
become: True
gather_facts: True
vars:
migrate_db: 'yes'
EDXAPP_PREVIEW_LMS_BASE: 'preview.{{ EDXAPP_LMS_BASE }}'
EDXAPP_LOGIN_REDIRECT_WHITELIST: [
'{{ EDXAPP_CMS_BASE }}',
]
EDXAPP_ENABLE_CORS_HEADERS: true
EDXAPP_ENABLE_CROSS_DOMAIN_CSRF_COOKIE: true
EDXAPP_CROSS_DOMAIN_CSRF_COOKIE_DOMAIN: '{{ EDXAPP_LMS_BASE }}'
EDXAPP_CROSS_DOMAIN_CSRF_COOKIE_NAME: 'native-csrf-cookie'
EDXAPP_LMS_BASE_SCHEME: http
COMMON_LMS_BASE_URL: '{{ EDXAPP_LMS_BASE_SCHEME }}://{{ EDXAPP_LMS_BASE }}'
EDXAPP_LMS_NGINX_PORT: '80'
EDX_PLATFORM_VERSION: 'master'
# Set to false if deployed behind another proxy/load balancer.
NGINX_SET_X_FORWARDED_HEADERS: True
DISCOVERY_URL_ROOT: 'http://localhost:{{ DISCOVERY_NGINX_PORT }}'
AWS_GATHER_FACTS: false
COMMON_ENABLE_AWS_ROLE: false
ecommerce_create_demo_data: true
credentials_create_demo_data: true
CONFIGURE_JWTS: true
SANDBOX_ENABLE_BLOCKSTORE: false
SANDBOX_ENABLE_DISCOVERY: true
SANDBOX_ENABLE_ECOMMERCE: true
SANDBOX_ENABLE_ANALYTICS_API: true
SANDBOX_ENABLE_INSIGHTS: true
SANDBOX_ENABLE_REDIS: true
SANDBOX_ENABLE_NOTES: false
DEMO_ROLE_ENABLED: true
ECOMMERCE_ENABLE_COMPREHENSIVE_THEMING: false
EDXAPP_ENABLE_MEMCACHE: true
EDXAPP_ENABLE_ELASTIC_SEARCH: true
roles:
- role: mongo_3_2
- role: mysql
EOF"
##
## Run the openedx_native.yml playbook in the configuration/playbooks directory
##
cd /var/tmp/configuration/playbooks && sudo -E ansible-playbook -c local ./openedx_native.yml -i "localhost," $EXTRA_VARS "$@"
#!/bin/bash
# Ironwood.master script
##
## Installs the pre-requisites for running Open edX on a single Ubuntu 16.04
## instance. This script is provided as a convenience and any of these
## steps could be executed manually.
##
## Note that this script requires that you have the ability to run
## commands as root via sudo. Caveat Emptor!
##
##
## Sanity checks
##
repo_edx_configuration=https://github.com/icarrr/configuration.git
if [[ ! $OPENEDX_RELEASE ]]; then
echo "You must define OPENEDX_RELEASE"
exit
fi
if [[ `lsb_release -rs` != "16.04" ]]; then
echo "This script is only known to work on Ubuntu 16.04, exiting..."
exit
fi
# Config.yml is required, must define LMS and CMS names, and the names
# must not infringe trademarks.
if [[ ! -f config.yml ]]; then
echo 'You must create a config.yml file specifying the hostnames (and if'
echo 'needed, ports) of your LMS and Studio hosts.'
echo 'For example:'
echo ' EDXAPP_LMS_BASE: "11.22.33.44"'
echo ' EDXAPP_CMS_BASE: "11.22.33.44:18010"'
exit
fi
grep -Fq EDXAPP_LMS_BASE config.yml
GREP_LMS=$?
grep -Fq EDXAPP_CMS_BASE config.yml
GREP_CMS=$?
if [[ $GREP_LMS == 1 ]] || [[ $GREP_CMS == 1 ]]; then
echo 'Your config.yml file must specify the hostnames (and if'
echo 'needed, ports) of your LMS and Studio hosts.'
echo 'For example:'
echo ' EDXAPP_LMS_BASE: "11.22.33.44"'
echo ' EDXAPP_CMS_BASE: "11.22.33.44:18010"'
exit
fi
grep -Fq edx. config.yml
GREP_BAD_DOMAIN=$?
if [[ $GREP_BAD_DOMAIN == 0 ]]; then
echo '*** NOTE: Open edX and edX are registered trademarks.'
echo 'You may not use "openedx." or "edx." as subdomains when naming your site.'
echo 'For more details, see the edX Trademark Policy: https://edx.org/trademarks'
echo ''
echo 'Here are some examples of unacceptable domain names:'
echo ' openedx.yourdomain.org'
echo ' edx.yourdomain.org'
echo ' openedxyourdomain.org'
echo ' yourdomain-edx.com'
echo ''
echo 'Please choose different domain names.'
exit
fi
##
## Log what's happening
##
mkdir -p logs
log_file=logs/install-$(date +%Y%m%d-%H%M%S).log
exec > >(tee $log_file) 2>&1
echo "Capturing output to $log_file"
echo "Installation started at $(date '+%Y-%m-%d %H:%M:%S')"
function finish {
echo "Installation finished at $(date '+%Y-%m-%d %H:%M:%S')"
}
trap finish EXIT
echo "Installing release '$OPENEDX_RELEASE'"
##
## Set ppa repository source for gcc/g++ 4.8 in order to install insights properly
##
sudo apt-get install -y python-software-properties
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
##
## Update and Upgrade apt packages
##
sudo apt-get update -y
sudo apt-get upgrade -y
##
## Install system pre-requisites
##
sudo apt-get install -y build-essential software-properties-common curl git-core libxml2-dev libxslt1-dev python-pip libmysqlclient-dev python-apt python-dev libxmlsec1-dev libfreetype6-dev swig gcc g++
sudo pip install --upgrade pip==9.0.3
sudo pip install --upgrade setuptools==39.0.1
sudo -H pip install --upgrade virtualenv==15.2.0
##
## Overridable version variables in the playbooks. Each can be overridden
## individually, or with $OPENEDX_RELEASE.
##
VERSION_VARS=(
edx_platform_version
certs_version
forum_version
XQUEUE_VERSION
configuration_version
demo_version
NOTIFIER_VERSION
INSIGHTS_VERSION
ANALYTICS_API_VERSION
ECOMMERCE_VERSION
ECOMMERCE_WORKER_VERSION
DISCOVERY_VERSION
THEMES_VERSION
)
for var in ${VERSION_VARS[@]}; do
# Each variable can be overridden by a similarly-named environment variable,
# or OPENEDX_RELEASE, if provided.
ENV_VAR=$(echo $var | tr '[:lower:]' '[:upper:]')
eval override=\${$ENV_VAR-\$OPENEDX_RELEASE}
if [ -n "$override" ]; then
EXTRA_VARS="-e $var=$override $EXTRA_VARS"
fi
done
# my-passwords.yml is the file made by generate-passwords.sh.
if [[ -f my-passwords.yml ]]; then
EXTRA_VARS="-e@$(pwd)/my-passwords.yml $EXTRA_VARS"
fi
EXTRA_VARS="-e@$(pwd)/config.yml $EXTRA_VARS"
CONFIGURATION_VERSION=${CONFIGURATION_VERSION-$OPENEDX_RELEASE}
##
## Clone the configuration repository and run Ansible
##
cd /var/tmp
git clone $repo_edx_configuration configuration
cd configuration
git checkout $CONFIGURATION_VERSION
git pull
##
## Install the ansible requirements
##
cd /var/tmp/configuration
sudo -H pip install -r requirements.txt
##
## Run the openedx_native.yml playbook in the configuration/playbooks directory
##
cd /var/tmp/configuration/playbooks && sudo -E ansible-playbook -c local ./openedx_native.yml -i "localhost," $EXTRA_VARS "$@"
ansible_status=$?
if [[ $ansible_status -ne 0 ]]; then
echo " "
echo "========================================"
echo "Ansible failed!"
echo "----------------------------------------"
echo "If you need help, see https://open.edx.org/getting-help ."
echo "When asking for help, please provide as much information as you can."
echo "These might be helpful:"
echo " Your log file is at $log_file"
echo " Your environment:"
env | egrep -i 'version|release' | sed -e 's/^/ /'
echo "========================================"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment