From ba8c2999c469eefa052934249e647b449a109047 Mon Sep 17 00:00:00 2001 From: Xavier Antoviaque Date: Thu, 6 Jun 2013 17:46:05 -0300 Subject: [PATCH 01/23] Install: Fix use of DEBIAN_FRONTEND - `sudo` clears environment Before executing a command, for security reasons `sudo` clears the environment, so the value of DEBIAN_FRONTEND was never passed to apt-get. This was causing the mysql packqge to still prompt for a value interactively. --- scripts/install-system-req.sh | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/scripts/install-system-req.sh b/scripts/install-system-req.sh index 43e405524d..39f1ec9f6f 100755 --- a/scripts/install-system-req.sh +++ b/scripts/install-system-req.sh @@ -35,18 +35,13 @@ case `uname -s` in squeeze|wheezy|jessie|maya|lisa|olivia|nadia|natty|oneiric|precise|quantal|raring) output "Installing Debian family requirements" - # DEBIAN_FRONTEND=noninteractive is required for silent mysql-server installation - export DEBIAN_FRONTEND=noninteractive - # add repositories cat $APT_REPOS_FILE | xargs -n 1 sudo add-apt-repository -y - sudo apt-get -y update - sudo apt-get -y install gfortran - sudo apt-get -y install graphviz libgraphviz-dev graphviz-dev - sudo apt-get -y install libatlas-dev libblas-dev - sudo apt-get -y install ruby-rvm + sudo apt-get -yq update + sudo DEBIAN_FRONTEND=noninteractive apt-get -yq install gfortran graphviz \ + libgraphviz-dev graphviz-dev libatlas-dev libblas-dev ruby-rvm # install packages listed in APT_PKGS_FILE - cat $APT_PKGS_FILE | xargs sudo apt-get -y install + cat $APT_PKGS_FILE | xargs sudo DEBIAN_FRONTEND=noninteractive apt-get -yq install ;; *) error "Unsupported distribution - $distro" From 7a95c37442e05108b186d826acc5ac44c420c236 Mon Sep 17 00:00:00 2001 From: Xavier Antoviaque Date: Thu, 6 Jun 2013 18:00:21 -0300 Subject: [PATCH 02/23] Install: Options "-q" (quiet), "-n" (no pull), "-y" (non interactive) Added several options to the `create-dev-env.sh` script to improve its ability to be used by another script: * -y -- non interactive mode (no prompt, proceed immediately) * -n -- do not attempt to pull edx-platform * -q -- be more quiet (removes info at beginning & end) This will be used, in particular, for Vagrant provisioning. --- scripts/create-dev-env.sh | 104 ++++++++++++++++++++++++-------------- 1 file changed, 66 insertions(+), 38 deletions(-) diff --git a/scripts/create-dev-env.sh b/scripts/create-dev-env.sh index 56fd744972..06d31e9993 100755 --- a/scripts/create-dev-env.sh +++ b/scripts/create-dev-env.sh @@ -49,8 +49,11 @@ usage() { Usage: $PROG [-c] [-v] [-h] + -y non interactive mode (no prompt, proceed immediately) -c compile scipy and numpy + -n do not attempt to pull edx-platform -s give access to global site-packages for virtualenv + -q be more quiet (removes info at beginning & end) -v set -x + spew -h this @@ -78,21 +81,23 @@ change_git_push_defaults() { clone_repos() { - change_git_push_defaults - cd "$BASE" - if [[ -d "$BASE/edx-platform/.git" ]]; then - output "Pulling edx platform" - cd "$BASE/edx-platform" - git pull - else - output "Cloning edx platform" - if [[ -d "$BASE/edx-platform" ]]; then - output "Creating backup for existing edx platform" - mv "$BASE/edx-platform" "${BASE}/edx-platform.bak.$$" + if [[ ! $nopull ]]; then + change_git_push_defaults + + if [[ -d "$BASE/edx-platform/.git" ]]; then + output "Pulling edx platform" + cd "$BASE/edx-platform" + git pull + else + output "Cloning edx platform" + if [[ -d "$BASE/edx-platform" ]]; then + output "Creating backup for existing edx platform" + mv "$BASE/edx-platform" "${BASE}/edx-platform.bak.$$" + fi + git clone https://github.com/edx/edx-platform.git fi - git clone https://github.com/edx/edx-platform.git fi } @@ -149,7 +154,7 @@ if [[ "x$VIRTUAL_ENV" != "x" ]]; then fi # Read arguments -ARGS=$(getopt "cvhs" "$*") +ARGS=$(getopt "cvhsynq" "$*") if [[ $? != 0 ]]; then usage exit 1 @@ -170,6 +175,18 @@ while true; do verbose=true shift ;; + -y) + noninteractive=true + shift + ;; + -q) + quiet=true + shift + ;; + -n) + nopull=true + shift + ;; -h) usage exit 0 @@ -181,7 +198,8 @@ while true; do esac done -cat< Date: Thu, 6 Jun 2013 18:06:46 -0300 Subject: [PATCH 03/23] Install: Improves ruby/rvm install - Directly install the right version The script used to download the latest version of ruby through rvm, then later on install the one used by the project. Now we directly download the version of the project when rvm is installed. --- scripts/create-dev-env.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/create-dev-env.sh b/scripts/create-dev-env.sh index 06d31e9993..11703fab83 100755 --- a/scripts/create-dev-env.sh +++ b/scripts/create-dev-env.sh @@ -349,6 +349,11 @@ if [ "$HOME/.rvm" != $RUBY_DIR ]; then fi fi +# Let the repo override the version of Ruby to install +if [[ -r $BASE/edx-platform/.ruby-version ]]; then + RUBY_VER=`cat $BASE/edx-platform/.ruby-version` +fi + # rvm has issues in debian family, this is taken from stack overflow case `uname -s` in Darwin) @@ -361,7 +366,7 @@ case `uname -s` in http://stackoverflow.com/questions/9056008/installed-ruby-1-9-3-with-rvm-but-command-line-doesnt-show-ruby-v/9056395#9056395" sudo apt-get --purge remove ruby-rvm sudo rm -rf /usr/share/ruby-rvm /etc/rvmrc /etc/profile.d/rvm.sh - curl -sL https://get.rvm.io | bash -s stable --ruby --autolibs=enable --auto-dotfiles + curl -sSL https://get.rvm.io | bash -s stable --ruby=$RUBY_VER --autolibs=enable --auto-dotfiles ;; esac @@ -386,11 +391,6 @@ case `uname -s` in ;; esac -# Let the repo override the version of Ruby to install -if [[ -r $BASE/edx-platform/.ruby-version ]]; then - RUBY_VER=`cat $BASE/edx-platform/.ruby-version` -fi - # Current stable version of RVM (1.19.0) requires the following to build Ruby: # # autoconf automake libtool pkg-config libyaml libxml2 libxslt libksba openssl From 52c9a534851a19f7f71a3894d796b29620906d03 Mon Sep 17 00:00:00 2001 From: Xavier Antoviaque Date: Thu, 6 Jun 2013 18:09:04 -0300 Subject: [PATCH 04/23] Install: Make curl options more consistent, add logging of errors The options passed to curl were not always the same - added logging of error (-S) everywhere (was only used for Mac before) and made it quiet in the rare few cases where it wasn't yet (-s). --- scripts/create-dev-env.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/create-dev-env.sh b/scripts/create-dev-env.sh index 11703fab83..513e269ad9 100755 --- a/scripts/create-dev-env.sh +++ b/scripts/create-dev-env.sh @@ -357,7 +357,7 @@ fi # rvm has issues in debian family, this is taken from stack overflow case `uname -s` in Darwin) - curl -sL get.rvm.io | bash -s -- --version 1.15.7 + curl -sSL get.rvm.io | bash -s -- --version 1.15.7 ;; [Ll]inux) @@ -472,8 +472,8 @@ SCIPY_VER="0.10.1" if [[ -n $compile ]]; then output "Downloading numpy and scipy" - curl -sL -o numpy.tar.gz http://downloads.sourceforge.net/project/numpy/NumPy/${NUMPY_VER}/numpy-${NUMPY_VER}.tar.gz - curl -sL -o scipy.tar.gz http://downloads.sourceforge.net/project/scipy/scipy/${SCIPY_VER}/scipy-${SCIPY_VER}.tar.gz + curl -sSL -o numpy.tar.gz http://downloads.sourceforge.net/project/numpy/NumPy/${NUMPY_VER}/numpy-${NUMPY_VER}.tar.gz + curl -sSL -o scipy.tar.gz http://downloads.sourceforge.net/project/scipy/scipy/${SCIPY_VER}/scipy-${SCIPY_VER}.tar.gz tar xf numpy.tar.gz tar xf scipy.tar.gz rm -f numpy.tar.gz scipy.tar.gz @@ -492,7 +492,7 @@ DISTRIBUTE_VER="0.6.28" output "Building Distribute" SITE_PACKAGES="$HOME/.virtualenvs/edx-platform/lib/python2.7/site-packages" cd "$SITE_PACKAGES" -curl -OL http://pypi.python.org/packages/source/d/distribute/distribute-${DISTRIBUTE_VER}.tar.gz +curl -sSLO http://pypi.python.org/packages/source/d/distribute/distribute-${DISTRIBUTE_VER}.tar.gz tar -xzvf distribute-${DISTRIBUTE_VER}.tar.gz cd distribute-${DISTRIBUTE_VER} python setup.py install From 9971c799b28b2f1d318ce50a710dcf80f18df177 Mon Sep 17 00:00:00 2001 From: Xavier Antoviaque Date: Thu, 6 Jun 2013 18:12:12 -0300 Subject: [PATCH 05/23] Install: Make `apt-get` and `mkvirtualenv` output log friendly Added options to make the output of `apt-get` and `mkvirtualenv` friendlier to getting logged. This allows to be more easily recorded in log files or when the install is performed through utilities - like Vagrant. --- scripts/create-dev-env.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/create-dev-env.sh b/scripts/create-dev-env.sh index 513e269ad9..4e943d9a7b 100755 --- a/scripts/create-dev-env.sh +++ b/scripts/create-dev-env.sh @@ -364,7 +364,7 @@ case `uname -s` in warning "Setting up rvm on linux. This is a known pain point. If the script fails here refer to the following stack overflow question: http://stackoverflow.com/questions/9056008/installed-ruby-1-9-3-with-rvm-but-command-line-doesnt-show-ruby-v/9056395#9056395" - sudo apt-get --purge remove ruby-rvm + sudo apt-get --purge remove -yq ruby-rvm sudo rm -rf /usr/share/ruby-rvm /etc/rvmrc /etc/profile.d/rvm.sh curl -sSL https://get.rvm.io | bash -s stable --ruby=$RUBY_VER --autolibs=enable --auto-dotfiles ;; @@ -451,14 +451,14 @@ fi # Create edX virtualenv and link it to repo # virtualenvwrapper automatically sources the activation script if [[ $systempkgs ]]; then - mkvirtualenv -a "$HOME/.virtualenvs" --system-site-packages edx-platform || { + mkvirtualenv -q -a "$HOME/.virtualenvs" --system-site-packages edx-platform || { error "mkvirtualenv exited with a non-zero error" return 1 } else # default behavior for virtualenv>1.7 is # --no-site-packages - mkvirtualenv -a "$HOME/.virtualenvs" edx-platform || { + mkvirtualenv -q -a "$HOME/.virtualenvs" edx-platform || { error "mkvirtualenv exited with a non-zero error" return 1 } From 947908e028d7b272e22ea3f8ce8eb213bdbb71c4 Mon Sep 17 00:00:00 2001 From: Xavier Antoviaque Date: Thu, 6 Jun 2013 18:15:33 -0300 Subject: [PATCH 06/23] Install: Fix install script freeze (syncdb superuser account creation) Since the output is passed through tee, when the django admin asks the user if he would like to create a super user account, it blocks the install, without even showing the question. Disabled interactivity for syncdb. --- scripts/create-dev-env.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/create-dev-env.sh b/scripts/create-dev-env.sh index 4e943d9a7b..31b369ed14 100755 --- a/scripts/create-dev-env.sh +++ b/scripts/create-dev-env.sh @@ -543,7 +543,7 @@ mkdir -p "$BASE/log" mkdir -p "$BASE/db" mkdir -p "$BASE/data" -rake django-admin[syncdb] +rake django-admin[syncdb,lms,dev,--noinput] rake django-admin[migrate] rake cms:update_templates # Configure Git From 14040767322f354e18b8f16ec045feed148ddd18 Mon Sep 17 00:00:00 2001 From: Xavier Antoviaque Date: Thu, 6 Jun 2013 18:20:54 -0300 Subject: [PATCH 07/23] Vagrant: Add support for Vagrant install (`vagrant up`) Cf README, this adds support to install and setup a dev instance through Vagrant. The Vagrantfile at the root handles the vagrant commands like `vagrant up`. Provisioning is done by the shell script `vagrant-provisionning.sh`, which is a light wrapper around the `create-dev-setup.sh` which does most of the job using the standard process, but limiting possible side-effect by ensuring the environment on which the install is performed is clean. Based on an Ubuntu precise 12.04 LTS. --- .gitignore | 1 + README.md | 128 +++++++++++++++++++++++++++++++- Vagrantfile | 33 ++++++++ scripts/vagrant-provisioning.sh | 110 +++++++++++++++++++++++++++ 4 files changed, 270 insertions(+), 2 deletions(-) create mode 100644 Vagrantfile create mode 100755 scripts/vagrant-provisioning.sh diff --git a/.gitignore b/.gitignore index 69bc47afdd..b1a36e5f2e 100644 --- a/.gitignore +++ b/.gitignore @@ -44,3 +44,4 @@ node_modules .prereqs_cache autodeploy.properties .ws_migrations_complete +.vagrant/ diff --git a/README.md b/README.md index 4dbf069da3..8a18b3a939 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,132 @@ This is the main edX platform which consists of LMS and Studio. See [code.edx.org](http://code.edx.org/) for other parts of the edX code base. -Installation -============ +Installation - The first time +============================= + +The following instructions will help you to download and setup a virtual machine +with a minimal amount of steps, using Vagrant. It is recommended for a first +installation, as it will save you from many of the common pitfalls of the +installation process. + +1. Install Git: http://git-scm.com/downloads +2. Install VirtualBox: https://www.virtualbox.org/wiki/Downloads +3. Install Vagrant: http://www.vagrantup.com/ (Vagrant 1.2.2 or later) +4. Open a terminal +5. Download the project: `git clone git://github.com/edx/edx-platform.git` +6. Enter the project directory: `cd edx-platform/` +7. Start: `vagrant up` + +The last step might require your administrator password to setup NFS. + +Afterwards, it will download an image, install all the dependencies and configure +the VM. It will take a while, go grab a coffee. + +Once completed, hopefully you should see a "Success!" message indicating that the +installation went fine. (If not, refer to the Troubleshooting section below.) + +Accessing the VM +---------------- + +Vagrant should automatically log you in the virtual machine once the installation +is finished. You can also type, from another terminal: + +``` +$ vagrant ssh +``` + +Note: This won't work from Windows, install install PuTTY from +http://www.chiark.greenend.org.uk/%7Esgtatham/putty/download.html instead. Then +connect to 127.0.0.1, port 2222, using vagrant/vagrant as a user/password. + +Using edX +--------- + +Once inside the VM, you can start Studio and LMS with the following commands +(from the `/edx/edx-platform` folder): + +Learning management system (LMS): + +``` +$ rake lms[cms.dev,0.0.0.0:8000] +``` + +Studio: + +``` +$ rake cms[dev,0.0.0.0:8001] +``` + +Once started, open the following URLs in your browser: + +* Learning management system (LMS): http://192.168.20.40:8000/ +* Studio (CMS): http://192.168.20.40:8001/ + +You can develop by editing the files directly in the `edx-platform/` directory you +downloaded before, you don't need to connect to the VM to edit them (the VM uses +those files to run edX, mirroring the folder in `/edx/edx-platform`). + +Stopping & starting +------------------- + +To stop the VM (from your `edx-platform/` directory): + +``` +$ vagrant halt +``` + +To restart: + +``` +$ vagrant up +``` + +or, to start without attempting to update the dependencies: + +``` +$ vagrant up --no-provision +``` + +Troubleshooting +--------------- + +### Reinstalling + +If something goes wrong, you can easily recreate the installation from scratch by +typing: + +``` +$ vagrant destroy -f && vagrant up +``` + +This will delete the current VM, create a new VM, re-install all the dependencies, +and reconfigure. + +### "Mounting NFS shared folders failed" + +If you get the following error message when you run `$ vagrant up`: + +``` +It appears your machine doesn't support NFS, or there is not an +adapter to enable NFS on this machine for Vagrant. Please verify +that `nfsd` is installed on your machine, and try again. If you're +on Windows, NFS isn't supported. +``` + +You need to install NFS. Under Debian/Ubuntu, for example: + +``` +$ sudo apt-get install nfs-common nfs-kernel-server +``` + +Installation - Advanced +======================= + +Note: The following installation instructions are for advanced users & developers +who are familiar with setting up Python, Ruby & node.js virtual environments. +Even if you know what you are doing, edX has a large code base with multiple +dependencies, so you might still want to use the method described above the +first time, as Vagrant helps avoiding issues due to the different environments. There is a `scripts/create-dev-env.sh` that will attempt to set up a development environment. diff --git a/Vagrantfile b/Vagrantfile new file mode 100644 index 0000000000..0a4032a88d --- /dev/null +++ b/Vagrantfile @@ -0,0 +1,33 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : + +Vagrant.configure("2") do |config| + config.vm.box = "precise32" + config.vm.box_url = "http://files.vagrantup.com/precise32.box" + + config.vm.network :forwarded_port, guest: 8000, host: 9000 + config.vm.network :forwarded_port, guest: 8001, host: 9001 + + # Create a private network, which allows host-only access to the machine + # using a specific IP. + config.vm.network :private_network, ip: "192.168.20.40" + + nfs_setting = RUBY_PLATFORM =~ /darwin/ || RUBY_PLATFORM =~ /linux/ + config.vm.synced_folder ".", "/edx/edx-platform", id: "vagrant-root", :nfs => nfs_setting + + # Make it so that network access from the vagrant guest is able to + # use SSH private keys that are present on the host without copying + # them into the VM. + config.ssh.forward_agent = true + + config.vm.provider :virtualbox do |vb| + # Use VBoxManage to customize the VM. For example to change memory: + vb.customize ["modifyvm", :id, "--memory", "1024"] + + # This setting makes it so that network access from inside the vagrant guest + # is able to resolve DNS using the hosts VPN connection. + vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"] + end + + config.vm.provision :shell, :path => "scripts/vagrant-provisioning.sh" +end diff --git a/scripts/vagrant-provisioning.sh b/scripts/vagrant-provisioning.sh new file mode 100755 index 0000000000..7d69e0f0e6 --- /dev/null +++ b/scripts/vagrant-provisioning.sh @@ -0,0 +1,110 @@ +#!/bin/bash -e +# +# Copyright (C) 2013 edX +# +# Authors: Xavier Antoviaque +# +# This software's license gives you freedom; you can copy, convey, +# propagate, redistribute and/or modify this program under the terms of +# the GNU Affero General Public License (AGPL) as published by the Free +# Software Foundation (FSF), either version 3 of the License, or (at your +# option) any later version of the AGPL published by the FSF. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero +# General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program in a file in the toplevel directory called +# "AGPLv3". If not, see . + + +############################################################################### + +# vagrant-provisioning.sh: +# +# Script to setup base environment on Vagrant, based on `precise32` image +# Runs ./scripts/create-dev-env.sh for the actual setup +# +# This script is ran by `$ vagrant up`, see the README for more explanations + + +# APT - Packages ############################################################## + +apt-get update +apt-get install -y python-software-properties vim + + +# Curl - No progress bar ###################################################### + +[[ -f ~vagrant/.curlrc ]] || echo "silent show-error" > ~vagrant/.curlrc +chown vagrant.vagrant ~vagrant/.curlrc + + +# SSH - Known hosts ########################################################### + +# Github +([[ -f ~vagrant/.ssh/known_hosts ]] && grep "zBX7bKA= ssh" ~vagrant/.ssh/known_hosts) || { + echo "|1|4DtBcMsTM4zgl/jTS7h3ZkmS/Vc=|XkRnn2xEhr8ixOxeskJAzBX7bKA= ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==" >> ~vagrant/.ssh/known_hosts +} +([[ -f ~vagrant/.ssh/known_hosts ]] && grep "jO3J5bvw= ssh" ~vagrant/.ssh/known_hosts) || { + echo "|1|9rANf/qOAPgKH/TXpGuZCAgGxMs=|x9VYWEDI8kiotbhhNXqjO3J5bvw= ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==" >> ~vagrant/.ssh/known_hosts +} +chown vagrant.vagrant ~vagrant/.ssh/known_hosts + + +# edX - Development environment ############################################### + +chown vagrant.vagrant /edx + +# For convenience with `vagrant ssh`, the `edx-plateform` virtualenv is always +# loaded after the first run, so we need to deactivate that behavior to run +# `create-dev-env.sh`. +[[ -f ~vagrant/.bash_profile ]] && { + mv ~vagrant/.bash_profile ~vagrant/.bash_profile.bak +} +sudo -u vagrant -i bash -c "cd /edx/edx-platform && ./scripts/create-dev-env.sh -ynq" + + +# Virtualenv - Always load #################################################### + +([[ -f ~vagrant/.bash_profile ]] && grep "edx-platform/bin/activate" ~vagrant/.bash_profile) || { + echo -e "\n. /home/vagrant/.virtualenvs/edx-platform/bin/activate\n" >> ~vagrant/.bash_profile +} + + +# Directory ################################################################### + +grep "cd /edx/edx-platform" ~vagrant/.bash_profile || { + echo -e "\ncd /edx/edx-platform\n" >> ~vagrant/.bash_profile +} + + +# End ######################################################################### + +cat << EOF +============================================================================== +Success! +============================================================================== + +Now, from the virtual machine (connect with "vagrant ssh" if vagrant didn't +log you in already), you can start Studio & LMS with the following commands: + +- Learning management system (LMS): + $ rake lms[cms.dev,0.0.0.0:8000] + + => http://192.168.20.40:8000/ + +- Studio: + $ rake cms[dev,0.0.0.0:8001] + + => http://192.168.20.40:8001/ + + +See the README for details. + + +EOF + + From e614d1aa6ff5c8f7c7ad36efd766c45da695d939 Mon Sep 17 00:00:00 2001 From: Xavier Antoviaque Date: Sat, 8 Jun 2013 12:46:50 -0300 Subject: [PATCH 08/23] vagrant: Normalize shell script EOL to Unix LF --- .gitattributes | 1 + 1 file changed, 1 insertion(+) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000000..dfdb8b771c --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +*.sh text eol=lf From 293aaedc33b4debbcf38031a9d15e241c0e01f6d Mon Sep 17 00:00:00 2001 From: David Baumgold Date: Fri, 7 Jun 2013 13:42:21 -0400 Subject: [PATCH 09/23] Vagrant: install edx-platform under /opt Compatibility with the Filesystem Hierarchy Standard: http://www.pathname.com/fhs/ --- README.md | 26 +++++++++++++------------- Vagrantfile | 2 +- scripts/vagrant-provisioning.sh | 14 +++++++------- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 8a18b3a939..5aa792a089 100644 --- a/README.md +++ b/README.md @@ -5,8 +5,8 @@ See [code.edx.org](http://code.edx.org/) for other parts of the edX code base. Installation - The first time ============================= -The following instructions will help you to download and setup a virtual machine -with a minimal amount of steps, using Vagrant. It is recommended for a first +The following instructions will help you to download and setup a virtual machine +with a minimal amount of steps, using Vagrant. It is recommended for a first installation, as it will save you from many of the common pitfalls of the installation process. @@ -18,12 +18,12 @@ installation process. 6. Enter the project directory: `cd edx-platform/` 7. Start: `vagrant up` -The last step might require your administrator password to setup NFS. +The last step might require your administrator password to setup NFS. -Afterwards, it will download an image, install all the dependencies and configure +Afterwards, it will download an image, install all the dependencies and configure the VM. It will take a while, go grab a coffee. -Once completed, hopefully you should see a "Success!" message indicating that the +Once completed, hopefully you should see a "Success!" message indicating that the installation went fine. (If not, refer to the Troubleshooting section below.) Accessing the VM @@ -36,15 +36,15 @@ is finished. You can also type, from another terminal: $ vagrant ssh ``` -Note: This won't work from Windows, install install PuTTY from -http://www.chiark.greenend.org.uk/%7Esgtatham/putty/download.html instead. Then +Note: This won't work from Windows, install install PuTTY from +http://www.chiark.greenend.org.uk/%7Esgtatham/putty/download.html instead. Then connect to 127.0.0.1, port 2222, using vagrant/vagrant as a user/password. Using edX --------- Once inside the VM, you can start Studio and LMS with the following commands -(from the `/edx/edx-platform` folder): +(from the `/opt/edx-platform` folder): Learning management system (LMS): @@ -60,12 +60,12 @@ $ rake cms[dev,0.0.0.0:8001] Once started, open the following URLs in your browser: -* Learning management system (LMS): http://192.168.20.40:8000/ +* Learning management system (LMS): http://192.168.20.40:8000/ * Studio (CMS): http://192.168.20.40:8001/ -You can develop by editing the files directly in the `edx-platform/` directory you +You can develop by editing the files directly in the `edx-platform/` directory you downloaded before, you don't need to connect to the VM to edit them (the VM uses -those files to run edX, mirroring the folder in `/edx/edx-platform`). +those files to run edX, mirroring the folder in `/opt/edx-platform`). Stopping & starting ------------------- @@ -93,7 +93,7 @@ Troubleshooting ### Reinstalling -If something goes wrong, you can easily recreate the installation from scratch by +If something goes wrong, you can easily recreate the installation from scratch by typing: ``` @@ -125,7 +125,7 @@ Installation - Advanced Note: The following installation instructions are for advanced users & developers who are familiar with setting up Python, Ruby & node.js virtual environments. -Even if you know what you are doing, edX has a large code base with multiple +Even if you know what you are doing, edX has a large code base with multiple dependencies, so you might still want to use the method described above the first time, as Vagrant helps avoiding issues due to the different environments. diff --git a/Vagrantfile b/Vagrantfile index 0a4032a88d..ac17764219 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -13,7 +13,7 @@ Vagrant.configure("2") do |config| config.vm.network :private_network, ip: "192.168.20.40" nfs_setting = RUBY_PLATFORM =~ /darwin/ || RUBY_PLATFORM =~ /linux/ - config.vm.synced_folder ".", "/edx/edx-platform", id: "vagrant-root", :nfs => nfs_setting + config.vm.synced_folder ".", "/opt/edx-platform", id: "vagrant-root", :nfs => nfs_setting # Make it so that network access from the vagrant guest is able to # use SSH private keys that are present on the host without copying diff --git a/scripts/vagrant-provisioning.sh b/scripts/vagrant-provisioning.sh index 7d69e0f0e6..d0df984d10 100755 --- a/scripts/vagrant-provisioning.sh +++ b/scripts/vagrant-provisioning.sh @@ -3,6 +3,7 @@ # Copyright (C) 2013 edX # # Authors: Xavier Antoviaque +# David Baumgold # # This software's license gives you freedom; you can copy, convey, # propagate, redistribute and/or modify this program under the terms of @@ -55,16 +56,15 @@ chown vagrant.vagrant ~vagrant/.ssh/known_hosts # edX - Development environment ############################################### +sudo -u vagrant chown vagrant.vagrant /opt/edx-platform -chown vagrant.vagrant /edx - -# For convenience with `vagrant ssh`, the `edx-plateform` virtualenv is always +# For convenience with `vagrant ssh`, the `edx-platform` virtualenv is always # loaded after the first run, so we need to deactivate that behavior to run # `create-dev-env.sh`. [[ -f ~vagrant/.bash_profile ]] && { mv ~vagrant/.bash_profile ~vagrant/.bash_profile.bak } -sudo -u vagrant -i bash -c "cd /edx/edx-platform && ./scripts/create-dev-env.sh -ynq" +sudo -u vagrant -i bash -c "cd /opt/edx-platform && ./scripts/create-dev-env.sh -ynq" # Virtualenv - Always load #################################################### @@ -76,8 +76,8 @@ sudo -u vagrant -i bash -c "cd /edx/edx-platform && ./scripts/create-dev-env.sh # Directory ################################################################### -grep "cd /edx/edx-platform" ~vagrant/.bash_profile || { - echo -e "\ncd /edx/edx-platform\n" >> ~vagrant/.bash_profile +grep "cd /opt/edx-platform" ~vagrant/.bash_profile || { + echo -e "\ncd /opt/edx-platform\n" >> ~vagrant/.bash_profile } @@ -96,7 +96,7 @@ log you in already), you can start Studio & LMS with the following commands: => http://192.168.20.40:8000/ -- Studio: +- Studio: $ rake cms[dev,0.0.0.0:8001] => http://192.168.20.40:8001/ From ee4b34b6ad83bcbc115814fcccf03aef56960fb9 Mon Sep 17 00:00:00 2001 From: Xavier Antoviaque Date: Sat, 8 Jun 2013 13:02:53 -0300 Subject: [PATCH 10/23] vagrant: Moves from `/opt/edx-platform` to `/opt/edx/edx-platform` To allow the vagrant user to create the /opt/edx/[log|data|db] folders --- README.md | 4 ++-- Vagrantfile | 2 +- scripts/vagrant-provisioning.sh | 9 +++++---- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 5aa792a089..65807205a4 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,7 @@ Using edX --------- Once inside the VM, you can start Studio and LMS with the following commands -(from the `/opt/edx-platform` folder): +(from the `/opt/edx/edx-platform` folder): Learning management system (LMS): @@ -65,7 +65,7 @@ Once started, open the following URLs in your browser: You can develop by editing the files directly in the `edx-platform/` directory you downloaded before, you don't need to connect to the VM to edit them (the VM uses -those files to run edX, mirroring the folder in `/opt/edx-platform`). +those files to run edX, mirroring the folder in `/opt/edx/edx-platform`). Stopping & starting ------------------- diff --git a/Vagrantfile b/Vagrantfile index ac17764219..0d409cc408 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -13,7 +13,7 @@ Vagrant.configure("2") do |config| config.vm.network :private_network, ip: "192.168.20.40" nfs_setting = RUBY_PLATFORM =~ /darwin/ || RUBY_PLATFORM =~ /linux/ - config.vm.synced_folder ".", "/opt/edx-platform", id: "vagrant-root", :nfs => nfs_setting + config.vm.synced_folder ".", "/opt/edx/edx-platform", id: "vagrant-root", :nfs => nfs_setting # Make it so that network access from the vagrant guest is able to # use SSH private keys that are present on the host without copying diff --git a/scripts/vagrant-provisioning.sh b/scripts/vagrant-provisioning.sh index d0df984d10..6a00035dcc 100755 --- a/scripts/vagrant-provisioning.sh +++ b/scripts/vagrant-provisioning.sh @@ -56,7 +56,8 @@ chown vagrant.vagrant ~vagrant/.ssh/known_hosts # edX - Development environment ############################################### -sudo -u vagrant chown vagrant.vagrant /opt/edx-platform + +chown vagrant.vagrant /opt/edx # For convenience with `vagrant ssh`, the `edx-platform` virtualenv is always # loaded after the first run, so we need to deactivate that behavior to run @@ -64,7 +65,7 @@ sudo -u vagrant chown vagrant.vagrant /opt/edx-platform [[ -f ~vagrant/.bash_profile ]] && { mv ~vagrant/.bash_profile ~vagrant/.bash_profile.bak } -sudo -u vagrant -i bash -c "cd /opt/edx-platform && ./scripts/create-dev-env.sh -ynq" +sudo -u vagrant -i bash -c "cd /opt/edx/edx-platform && ./scripts/create-dev-env.sh -ynq" # Virtualenv - Always load #################################################### @@ -76,8 +77,8 @@ sudo -u vagrant -i bash -c "cd /opt/edx-platform && ./scripts/create-dev-env.sh # Directory ################################################################### -grep "cd /opt/edx-platform" ~vagrant/.bash_profile || { - echo -e "\ncd /opt/edx-platform\n" >> ~vagrant/.bash_profile +grep "cd /opt/edx/edx-platform" ~vagrant/.bash_profile || { + echo -e "\ncd /opt/edx/edx-platform\n" >> ~vagrant/.bash_profile } From 214734d1dc3d02eb8f5a432602e76114aef83317 Mon Sep 17 00:00:00 2001 From: Xavier Antoviaque Date: Mon, 1 Jul 2013 12:07:44 -0300 Subject: [PATCH 11/23] vagrant: Set `$PROJECT_HOME` - `$BASE` was set to the default path Yarko's `$BASE` patch has been merged and rewritten since the original pull request was created, resulting in the `$BASE` being incorrectly set to the default `/home/vagrant/edx_all` by the new code. --- scripts/vagrant-provisioning.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/vagrant-provisioning.sh b/scripts/vagrant-provisioning.sh index 6a00035dcc..fc87b5b7f0 100755 --- a/scripts/vagrant-provisioning.sh +++ b/scripts/vagrant-provisioning.sh @@ -65,7 +65,7 @@ chown vagrant.vagrant /opt/edx [[ -f ~vagrant/.bash_profile ]] && { mv ~vagrant/.bash_profile ~vagrant/.bash_profile.bak } -sudo -u vagrant -i bash -c "cd /opt/edx/edx-platform && ./scripts/create-dev-env.sh -ynq" +sudo -u vagrant -i bash -c "cd /opt/edx/edx-platform && PROJECT_HOME=/opt/edx ./scripts/create-dev-env.sh -ynq" # Virtualenv - Always load #################################################### From 055ef6e1aa2f8e26d387ee6b2f8a15a3c62797c9 Mon Sep 17 00:00:00 2001 From: Xavier Antoviaque Date: Mon, 1 Jul 2013 13:48:50 -0300 Subject: [PATCH 12/23] vagrant: Update README (QA, link to wiki & disk space requirement) --- README.md | 49 +++++++++++++------------------------------------ 1 file changed, 13 insertions(+), 36 deletions(-) diff --git a/README.md b/README.md index 65807205a4..f7cbc722b5 100644 --- a/README.md +++ b/README.md @@ -10,13 +10,15 @@ with a minimal amount of steps, using Vagrant. It is recommended for a first installation, as it will save you from many of the common pitfalls of the installation process. -1. Install Git: http://git-scm.com/downloads -2. Install VirtualBox: https://www.virtualbox.org/wiki/Downloads -3. Install Vagrant: http://www.vagrantup.com/ (Vagrant 1.2.2 or later) -4. Open a terminal -5. Download the project: `git clone git://github.com/edx/edx-platform.git` -6. Enter the project directory: `cd edx-platform/` -7. Start: `vagrant up` +1. Make sure you have plenty of available disk space, >5GB +2. Install Git: http://git-scm.com/downloads +3. Install VirtualBox: https://www.virtualbox.org/wiki/Downloads (VirtualBox 4.2.14 + or later) +4. Install Vagrant: http://www.vagrantup.com/ (Vagrant 1.2.2 or later) +5. Open a terminal +6. Download the project: `git clone git://github.com/edx/edx-platform.git` +7. Enter the project directory: `cd edx-platform/` +8. Start: `vagrant up` The last step might require your administrator password to setup NFS. @@ -24,7 +26,8 @@ Afterwards, it will download an image, install all the dependencies and configur the VM. It will take a while, go grab a coffee. Once completed, hopefully you should see a "Success!" message indicating that the -installation went fine. (If not, refer to the Troubleshooting section below.) +installation went fine. (If not, refer to the +[troubleshooting section](https://github.com/edx/edx-platform/wiki/Simplified-install-with-vagrant#troubleshooting).) Accessing the VM ---------------- @@ -91,34 +94,8 @@ $ vagrant up --no-provision Troubleshooting --------------- -### Reinstalling - -If something goes wrong, you can easily recreate the installation from scratch by -typing: - -``` -$ vagrant destroy -f && vagrant up -``` - -This will delete the current VM, create a new VM, re-install all the dependencies, -and reconfigure. - -### "Mounting NFS shared folders failed" - -If you get the following error message when you run `$ vagrant up`: - -``` -It appears your machine doesn't support NFS, or there is not an -adapter to enable NFS on this machine for Vagrant. Please verify -that `nfsd` is installed on your machine, and try again. If you're -on Windows, NFS isn't supported. -``` - -You need to install NFS. Under Debian/Ubuntu, for example: - -``` -$ sudo apt-get install nfs-common nfs-kernel-server -``` +If anything doesn't work as expected, see the +[troubleshooting section](https://github.com/edx/edx-platform/wiki/Simplified-install-with-vagrant#troubleshooting). Installation - Advanced ======================= From 5db56573d9bcb2b99385d49a2cbc69421087f819 Mon Sep 17 00:00:00 2001 From: Xavier Antoviaque Date: Sun, 7 Jul 2013 13:58:16 -0300 Subject: [PATCH 13/23] vagrant: Remove rvm Ubuntu package installation (triggers rvm bug) --- scripts/install-system-req.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install-system-req.sh b/scripts/install-system-req.sh index 39f1ec9f6f..221b9bb239 100755 --- a/scripts/install-system-req.sh +++ b/scripts/install-system-req.sh @@ -39,7 +39,7 @@ case `uname -s` in cat $APT_REPOS_FILE | xargs -n 1 sudo add-apt-repository -y sudo apt-get -yq update sudo DEBIAN_FRONTEND=noninteractive apt-get -yq install gfortran graphviz \ - libgraphviz-dev graphviz-dev libatlas-dev libblas-dev ruby-rvm + libgraphviz-dev graphviz-dev libatlas-dev libblas-dev # install packages listed in APT_PKGS_FILE cat $APT_PKGS_FILE | xargs sudo DEBIAN_FRONTEND=noninteractive apt-get -yq install ;; From d8c922b3214a6fe58e1526caaffbb52084ccdee4 Mon Sep 17 00:00:00 2001 From: Xavier Antoviaque Date: Sun, 7 Jul 2013 15:33:01 -0300 Subject: [PATCH 14/23] vagrant: Windows - Preserve Unix line return format, added extensions --- .gitattributes | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitattributes b/.gitattributes index dfdb8b771c..e261e654fa 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1 +1,4 @@ *.sh text eol=lf +*.txt text eol=lf +*.py text eol=lf +*.rb text eol=lf From 3364521b329fa452ed20a122fb8266e96229e7c1 Mon Sep 17 00:00:00 2001 From: Xavier Antoviaque Date: Mon, 8 Jul 2013 15:15:04 -0300 Subject: [PATCH 15/23] vagrant: Requirement on VirtualBox 4.2.12 for compatibility with Vagrant --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f7cbc722b5..390dadeae4 100644 --- a/README.md +++ b/README.md @@ -12,8 +12,9 @@ installation process. 1. Make sure you have plenty of available disk space, >5GB 2. Install Git: http://git-scm.com/downloads -3. Install VirtualBox: https://www.virtualbox.org/wiki/Downloads (VirtualBox 4.2.14 - or later) +3. Install VirtualBox: https://www.virtualbox.org/wiki/Download_Old_Builds_4_2 + (you need version 4.2.12, as later/earlier versions might not work well with + Vagrant) 4. Install Vagrant: http://www.vagrantup.com/ (Vagrant 1.2.2 or later) 5. Open a terminal 6. Download the project: `git clone git://github.com/edx/edx-platform.git` From 27c739bbd4f6cd0ad5e7b34bc753738b02350372 Mon Sep 17 00:00:00 2001 From: Xavier Antoviaque Date: Tue, 9 Jul 2013 09:31:23 -0300 Subject: [PATCH 16/23] vagrant: Prevent git from altering line endings altogether --- .gitattributes | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.gitattributes b/.gitattributes index e261e654fa..fa1385d99a 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,4 +1 @@ -*.sh text eol=lf -*.txt text eol=lf -*.py text eol=lf -*.rb text eol=lf +* -text From 2a656d0a9b29f2566acc92fd282392aa5261735d Mon Sep 17 00:00:00 2001 From: Xavier Antoviaque Date: Tue, 9 Jul 2013 17:39:37 -0300 Subject: [PATCH 17/23] vagrant: Windows - Exclude README from ws_migration Windows doesn't differentiate between files with/without executable bit, so this can't be used to exclude the README file from the migrations to be executed, when the sources are accessed from a Windows partition. --- rakelib/workspace.rake | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/rakelib/workspace.rake b/rakelib/workspace.rake index c705899f58..5a928388d5 100644 --- a/rakelib/workspace.rake +++ b/rakelib/workspace.rake @@ -7,10 +7,11 @@ namespace :ws do task :migrate => MIGRATION_MARKER_DIR do Dir['ws_migrations/*'].select{|m| File.executable?(m)}.each do |migration| completion_file = File.join(MIGRATION_MARKER_DIR, File.basename(migration)) - if ! File.exist?(completion_file) + is_excluded = File.basename(migration).start_with?("README") + if ! File.exist?(completion_file) && ! is_excluded sh(migration) File.write(completion_file, "") end end unless SKIP_MIGRATIONS end -end \ No newline at end of file +end From c24807effa3ef9d22c7c6133e906db918a049844 Mon Sep 17 00:00:00 2001 From: Xavier Antoviaque Date: Tue, 9 Jul 2013 17:42:54 -0300 Subject: [PATCH 18/23] vagrant: Windows - Bind node_modules to a ext4 partition for symlinks --- scripts/vagrant-provisioning.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/scripts/vagrant-provisioning.sh b/scripts/vagrant-provisioning.sh index fc87b5b7f0..ddd75027b6 100755 --- a/scripts/vagrant-provisioning.sh +++ b/scripts/vagrant-provisioning.sh @@ -57,7 +57,12 @@ chown vagrant.vagrant ~vagrant/.ssh/known_hosts # edX - Development environment ############################################### -chown vagrant.vagrant /opt/edx +# Node modules require a filesystem with symlinks (Windows support) +mkdir -p /opt/edx/node_modules /opt/edx/edx-platform/node_modules +mount -o bind /opt/edx/node_modules /opt/edx/edx-platform/node_modules + +# Permissions +chown vagrant.vagrant /opt/edx /opt/edx/node_modules /opt/edx/edx-platform/node_modules # For convenience with `vagrant ssh`, the `edx-platform` virtualenv is always # loaded after the first run, so we need to deactivate that behavior to run From 77af84347d332908daffbf4ddb570d4de25cab07 Mon Sep 17 00:00:00 2001 From: Xavier Antoviaque Date: Tue, 9 Jul 2013 18:13:30 -0300 Subject: [PATCH 19/23] vagrant: Installation instruction tweaks from Yarko & Windows testing --- README.md | 34 ++++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 390dadeae4..b2ef689a15 100644 --- a/README.md +++ b/README.md @@ -19,9 +19,11 @@ installation process. 5. Open a terminal 6. Download the project: `git clone git://github.com/edx/edx-platform.git` 7. Enter the project directory: `cd edx-platform/` -8. Start: `vagrant up` +8. (Windows only) Make sure files have the proper line ending: + `git rm --cached -r . && git reset --hard` +9. Start: `vagrant up` -The last step might require your administrator password to setup NFS. +The last step might require your host machine's administrator password to setup NFS. Afterwards, it will download an image, install all the dependencies and configure the VM. It will take a while, go grab a coffee. @@ -30,11 +32,15 @@ Once completed, hopefully you should see a "Success!" message indicating that th installation went fine. (If not, refer to the [troubleshooting section](https://github.com/edx/edx-platform/wiki/Simplified-install-with-vagrant#troubleshooting).) +Note: by default, the VM will get the IP `192.168.20.40`. If you need to use a +different IP, you can edit the file `Vagrantfile`. If you have already started the +VM with `vagrant up`, see "Stopping and restarting the VM" below to take the change +into account. + Accessing the VM ---------------- -Vagrant should automatically log you in the virtual machine once the installation -is finished. You can also type, from another terminal: +Once the installation is finished, to log into the virtual machine: ``` $ vagrant ssh @@ -71,6 +77,26 @@ You can develop by editing the files directly in the `edx-platform/` directory y downloaded before, you don't need to connect to the VM to edit them (the VM uses those files to run edX, mirroring the folder in `/opt/edx/edx-platform`). +You may also want to create a super-user with: + +``` +$ rake django-admin["createsuperuser"] +``` + +Also note that if you register a new user through the web interface, +the activiation email will be posted to your VM's terminal window (search for +lines similar to): + +``` +Subject: Your account for edX Studio +From: registration@edx.org +``` + +and find the activation URL for the account you've created. + +See the [Frequently Asked Questions](https://github.com/edx/edx-platform/wiki/Frequently-Asked-Questions) +for more usage tips. + Stopping & starting ------------------- From a0edbe714b56fffffa6687c6b87b308785646a91 Mon Sep 17 00:00:00 2001 From: Xavier Antoviaque Date: Wed, 10 Jul 2013 08:11:59 -0300 Subject: [PATCH 20/23] vagrant: Fix prereqs update when prereqs had been fetched outside of VM --- scripts/vagrant-provisioning.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/vagrant-provisioning.sh b/scripts/vagrant-provisioning.sh index ddd75027b6..13dcac673b 100755 --- a/scripts/vagrant-provisioning.sh +++ b/scripts/vagrant-provisioning.sh @@ -61,6 +61,9 @@ chown vagrant.vagrant ~vagrant/.ssh/known_hosts mkdir -p /opt/edx/node_modules /opt/edx/edx-platform/node_modules mount -o bind /opt/edx/node_modules /opt/edx/edx-platform/node_modules +# Force rechecking all prerequisites (could have been fetched outside of the VM) +rm -rf /opt/edx/edx-platform/.prereqs_cache + # Permissions chown vagrant.vagrant /opt/edx /opt/edx/node_modules /opt/edx/edx-platform/node_modules From f3a484bd7218b0cc9779d4653944e8e05d6e3b55 Mon Sep 17 00:00:00 2001 From: Xavier Antoviaque Date: Wed, 10 Jul 2013 09:56:21 -0300 Subject: [PATCH 21/23] vagrant: Windows - Additional instructions to deal with symlinks --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b2ef689a15..e533459c8b 100644 --- a/README.md +++ b/README.md @@ -19,8 +19,8 @@ installation process. 5. Open a terminal 6. Download the project: `git clone git://github.com/edx/edx-platform.git` 7. Enter the project directory: `cd edx-platform/` -8. (Windows only) Make sure files have the proper line ending: - `git rm --cached -r . && git reset --hard` +8. (Windows only) Run the commands to + [deal with line endings and symlinks under Windows](https://github.com/edx/edx-platform/wiki/Simplified-install-with-vagrant#dealing-with-line-endings-and-symlinks-under-windows) 9. Start: `vagrant up` The last step might require your host machine's administrator password to setup NFS. From 0a2eda6361c1206da34761013616d0e2ad5823eb Mon Sep 17 00:00:00 2001 From: David Baumgold Date: Mon, 8 Jul 2013 16:04:01 -0400 Subject: [PATCH 22/23] Switch from RVM to rbenv --- scripts/create-dev-env.sh | 131 ++++++++++++-------------------------- 1 file changed, 41 insertions(+), 90 deletions(-) diff --git a/scripts/create-dev-env.sh b/scripts/create-dev-env.sh index 31b369ed14..3083ddadba 100755 --- a/scripts/create-dev-env.sh +++ b/scripts/create-dev-env.sh @@ -65,7 +65,7 @@ info() { cat</dev/null) 2>/dev/null) || echo -n "" @@ -131,9 +131,16 @@ BASE="${PROJECT_HOME:-$(set_base_default)}" # unless you've already got one set up with virtualenvwrapper. PYTHON_DIR=${WORKON_HOME:-"$HOME/.virtualenvs"} -# RVM defaults its install to ~/.rvm, but use the overridden rvm_path -# if that's what's preferred. -RUBY_DIR=${rvm_path:-"$HOME/.rvm"} +# Find rbenv root (~/.rbenv by default) +if [ -z "${RBENV_ROOT}" ]; then + RBENV_ROOT="${HOME}/.rbenv" +else + RBENV_ROOT="${RBENV_ROOT%/}" +fi +# Let the repo override the version of Ruby to install +if [[ -r $BASE/edx-platform/.ruby-version ]]; then + RUBY_VER=`cat $BASE/edx-platform/.ruby-version` +fi LOG="/var/tmp/install-$(date +%Y%m%d-%H%M%S).log" @@ -245,11 +252,11 @@ case `uname -s` in distro=`lsb_release -cs` case $distro in - wheezy|jessie|maya|olivia|nadia|precise|quantal) + wheezy|jessie|maya|olivia|nadia|precise|quantal) if [[ ! $noninteractive ]]; then warning " Debian support is not fully debugged. Assuming you have standard - development packages already working like scipy rvm, the + development packages already working like scipy, the installation should go fine, but this is still a work in progress. Please report issues you have and let us know if you are able to figure @@ -259,7 +266,7 @@ case `uname -s` in read dummy fi - sudo apt-get install -yq git ;; + sudo apt-get install -yq git ;; squeeze|lisa|katya|oneiric|natty|raring) if [[ ! $noninteractive ]]; then warning " @@ -267,14 +274,11 @@ case `uname -s` in While we don't technically support this release, the install script will probably still work. - Raring requires an install of rvm to work correctly as the raring - package manager does not yet include a package for rvm - Press return to continue or control-C to abort" read dummy fi sudo apt-get install -yq git - ;; + ;; *) error "Unsupported distribution - $distro" @@ -318,7 +322,7 @@ EO esac -# Clone MITx repositories +# Clone edx repositories clone_repos @@ -333,90 +337,39 @@ else fi # Install system-level dependencies - -output "Installing RVM, Ruby, and required gems" - -# If we're not installing RVM in the default location, then we'll do some -# funky stuff to make sure that we load in the RVM stuff properly on login. -if [ "$HOME/.rvm" != $RUBY_DIR ]; then - if ! grep -q "export rvm_path=$RUBY_DIR" ~/.rvmrc; then - if [[ -f $HOME/.rvmrc ]]; then - output "Copying existing .rvmrc to .rvmrc.bak" - cp $HOME/.rvmrc $HOME/.rvmrc.bak - fi - output "Creating $HOME/.rvmrc so rvm uses $RUBY_DIR" - echo "export rvm_path=$RUBY_DIR" > $HOME/.rvmrc - fi +if [[ ! -d $RBENV_ROOT ]]; then + output "Installing rbenv" + git clone https://github.com/sstephenson/rbenv.git $RBENV_ROOT +fi +if [[ ! -d $RBENV_ROOT/plugins/ruby-build ]]; then + output "Installing ruby-build" + git clone https://github.com/sstephenson/ruby-build.git $RBENV_ROOT/plugins/ruby-build +fi +shelltype=$(basename $SHELL) +if ! hash rbenv 2>/dev/null; then + output "Adding rbenv to \$PATH in ~/.${shelltype}rc" + echo "export PATH=\"$RBENV_ROOT/bin:\$PATH\"" >> $HOME/.${shelltype}rc + echo 'eval "$(rbenv init -)"' >> $HOME/.${shelltype}rc + export PATH="$RBENV_ROOT/bin:$PATH" + eval "$(rbenv init -)" fi -# Let the repo override the version of Ruby to install -if [[ -r $BASE/edx-platform/.ruby-version ]]; then - RUBY_VER=`cat $BASE/edx-platform/.ruby-version` +if [[ ! -d $RBENV_ROOT/versions/$RUBY_VER ]]; then + output "Installing Ruby $RUBY_VER" + rbenv install $RUBY_VER + rbenv global $RUBY_VER fi -# rvm has issues in debian family, this is taken from stack overflow -case `uname -s` in - Darwin) - curl -sSL get.rvm.io | bash -s -- --version 1.15.7 - ;; - - [Ll]inux) - warning "Setting up rvm on linux. This is a known pain point. If the script fails here - refer to the following stack overflow question: - http://stackoverflow.com/questions/9056008/installed-ruby-1-9-3-with-rvm-but-command-line-doesnt-show-ruby-v/9056395#9056395" - sudo apt-get --purge remove -yq ruby-rvm - sudo rm -rf /usr/share/ruby-rvm /etc/rvmrc /etc/profile.d/rvm.sh - curl -sSL https://get.rvm.io | bash -s stable --ruby=$RUBY_VER --autolibs=enable --auto-dotfiles - ;; -esac - - -# Ensure we have RVM available as a shell function so that it can mess -# with the environment and set everything up properly. The RVM install -# process adds this line to login scripts, so this shouldn't be necessary -# for the user to do each time. -if [[ `type -t rvm` != "function" ]]; then - source $RUBY_DIR/scripts/rvm +if ! hash bundle 2>/dev/null; then + output "Installing gem bundler" + gem install bundler fi - -# Ruby doesn't like to build with clang, which is the default on OS X, so -# use gcc instead. This may not work, since if your gcc was installed with -# XCode 4.2 or greater, you have an LLVM-based gcc, which also doesn't -# always play nicely with Ruby, though it seems to be better than clang. -# You may have to install apple-gcc42 using Homebrew if this doesn't work. -# See `rvm requirements` for more information. -case `uname -s` in - Darwin) - export CC=gcc - ;; -esac - -# Current stable version of RVM (1.19.0) requires the following to build Ruby: -# -# autoconf automake libtool pkg-config libyaml libxml2 libxslt libksba openssl -# -# If we decide to upgrade from the current version (1.15.7), can run -# -# LESS="-E" rvm install $RUBY_VER --autolibs=3 --with-readline -# -# to have RVM look for a package manager like Homebrew and install any missing -# libs automatically. RVM's --autolibs flag defaults to 2, which will fail if -# any required libs are missing. -LESS="-E" rvm install $RUBY_VER --with-readline - -# Create the "edx" gemset -rvm use "$RUBY_VER@edx-platform" --create -rvm rubygems latest - -output "Installing gem bundler" -gem install bundler +rbenv rehash output "Installing ruby packages" bundle install --gemfile $BASE/edx-platform/Gemfile - # Install Python virtualenv - output "Installing python virtualenv" case `uname -s` in @@ -528,7 +481,6 @@ pip install -r $BASE/edx-platform/requirements/edx/pre.txt output "Installing edX requirements" # Install prereqs cd $BASE/edx-platform -rvm use "$RUBY_VER@edx-platform" rake install_prereqs # Final dependecy @@ -559,11 +511,10 @@ if [[ ! $quiet ]]; then Success!! To start using Django you will need to activate the local Python - and Ruby environments. Ensure the following lines are added to your + environment. Ensure the following lines are added to your login script, and source your login script if needed: source `which virtualenvwrapper.sh` - source $RUBY_DIR/scripts/rvm Then, every time you're ready to work on the project, just run From 64835febe6e80dee1c897918d1aa828719f43278 Mon Sep 17 00:00:00 2001 From: David Baumgold Date: Wed, 10 Jul 2013 10:51:28 -0400 Subject: [PATCH 23/23] vagrant: .bash_profile loads .bashrc Otherwise, `vagrant ssh` doesn't load the rbenv shims, because that line is in the .bashrc file. --- scripts/vagrant-provisioning.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scripts/vagrant-provisioning.sh b/scripts/vagrant-provisioning.sh index 13dcac673b..153bc7a879 100755 --- a/scripts/vagrant-provisioning.sh +++ b/scripts/vagrant-provisioning.sh @@ -75,6 +75,11 @@ chown vagrant.vagrant /opt/edx /opt/edx/node_modules /opt/edx/edx-platform/node_ } sudo -u vagrant -i bash -c "cd /opt/edx/edx-platform && PROJECT_HOME=/opt/edx ./scripts/create-dev-env.sh -ynq" +# Load .bashrc ################################################################ +([[ -f ~vagrant/.bash_profile ]] && grep ".bashrc" ~vagrant/.bash_profile) || { + echo -e "\n. /home/vagrant/.bashrc\n" >> ~vagrant/.bash_profile +} + # Virtualenv - Always load ####################################################