sandbox.sh 2.5 KB
Newer Older
1
#!/bin/bash
e0d committed
2
##
3
## Installs the pre-requisites for running edX on a single Ubuntu 16.04
e0d committed
4
## instance.  This script is provided as a convenience and any of these
5 6 7
## steps could be executed manually.
##
## Note that this script requires that you have the ability to run
e0d committed
8 9
## commands as root via sudo.  Caveat Emptor!
##
e0d committed
10 11 12 13

##
## Sanity check
##
Ned Batchelder committed
14 15
if [[ `lsb_release -rs` != "16.04" ]]; then
   echo "This script is only known to work on Ubuntu 16.04, exiting...";
e0d committed
16 17 18 19
   exit;
fi

##
20 21 22
## Set ppa repository source for gcc/g++ 4.8 in order to install insights properly
##
sudo apt-get install -y python-software-properties
arbabnazar committed
23
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
24 25

##
26 27 28 29 30 31
## Update and Upgrade apt packages
##
sudo apt-get update -y
sudo apt-get upgrade -y

##
e0d committed
32 33
## Install system pre-requisites
##
Ned Batchelder committed
34
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++
35 36 37
sudo pip install --upgrade pip==8.1.2
sudo pip install --upgrade setuptools==24.0.3
sudo -H pip install --upgrade virtualenv==15.0.2
e0d committed
38

39
##
40 41 42 43 44 45 46 47 48 49 50 51 52
## 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
53 54
  ECOMMERCE_VERSION
  ECOMMERCE_WORKER_VERSION
55 56 57 58 59 60 61 62 63 64 65 66
)

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

67 68 69 70 71
# 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

72
CONFIGURATION_VERSION=${CONFIGURATION_VERSION-${OPENEDX_RELEASE-master}}
73

e0d committed
74 75 76 77
##
## Clone the configuration repository and run Ansible
##
cd /var/tmp
78 79
git clone https://github.com/edx/configuration
cd configuration
80
git checkout $CONFIGURATION_VERSION
Ned Batchelder committed
81
git pull
e0d committed
82 83 84 85 86

##
## Install the ansible requirements
##
cd /var/tmp/configuration
87
sudo -H pip install -r requirements.txt
e0d committed
88 89 90 91

##
## Run the edx_sandbox.yml playbook in the configuration/playbooks directory
##
92
cd /var/tmp/configuration/playbooks && sudo -E ansible-playbook -c local ./edx_sandbox.yml -i "localhost," $EXTRA_VARS "$@"