#!/usr/bin/env bash set -e # posix compliant sanity check if [ -z $BASH ] || [ $BASH = "/bin/sh" ]; then echo "Please use the bash interpreter to run this script" exit 1 fi trap "ouch" ERR ouch() { printf '\E[31m' cat< >(tee $LOG) exec 2>&1 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 mkdir -p $BASE case `uname -s` in [Ll]inux) command -v lsb_release &>/dev/null || { error "Please install lsb-release." exit 1 } distro=`lsb_release -cs` case $distro in maya|lisa|natty|oneiric|precise) output "Installing ubuntu requirements" sudo apt-get -y update sudo apt-get -y install $APT_PKGS clone_repos ;; *) error "Unsupported distribution - $distro" exit 1 ;; esac ;; Darwin) if [[ ! -w /usr/local ]]; then cat</dev/null || { output "Installing brew" /usr/bin/ruby <(curl -fsSkL raw.github.com/mxcl/homebrew/go) } command -v git &>/dev/null || { output "Installing git" brew install git } clone_repos output "Installing OSX requirements" if [[ ! -r $BREW_FILE ]]; then error "$BREW_FILE does not exist, needed to install brew deps" exit 1 fi # brew errors if the package is already installed for pkg in $(cat $BREW_FILE); do grep $pkg <(brew list) &>/dev/null || { output "Installing $pkg" brew install $pkg } done command -v pip &>/dev/null || { output "Installing pip" sudo easy_install pip } if ! grep -Eq ^1.7 <(virtualenv --version 2>/dev/null); then output "Installing virtualenv >1.7" sudo pip install 'virtualenv>1.7' virtualenvwrapper fi command -v coffee &>/dev/null || { output "Installing coffee script" curl --insecure https://npmjs.org/install.sh | sh npm install -g coffee-script } ;; *) error "Unsupported platform" exit 1 ;; esac output "Installing rvm and ruby" curl -sL get.rvm.io | bash -s stable source $RUBY_DIR/scripts/rvm # skip the intro LESS="-E" rvm install $RUBY_VER if [[ $systempkgs ]]; then virtualenv --system-site-packages "$PYTHON_DIR" else # default behavior for virtualenv>1.7 is # --no-site-packages virtualenv "$PYTHON_DIR" fi source $PYTHON_DIR/bin/activate output "Installing gem bundler" gem install bundler output "Installing ruby packages" # hack :( cd $BASE/mitx || true bundle install cd $BASE 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 tar xf numpy.tar.gz tar xf scipy.tar.gz rm -f numpy.tar.gz scipy.tar.gz output "Compiling numpy" cd "$BASE/numpy-${NUMPY_VER}" python setup.py install output "Compiling scipy" cd "$BASE/scipy-${SCIPY_VER}" python setup.py install cd "$BASE" rm -rf numpy-${NUMPY_VER} scipy-${SCIPY_VER} fi output "Installing MITx pre-requirements" pip install -r mitx/pre-requirements.txt # Need to be in the mitx dir to get the paths to local modules right output "Installing MITx requirements" cd mitx pip install -r requirements.txt output "Installing askbot requirements" pip install -r askbot/askbot_requirements.txt pip install -r askbot/askbot_requirements_dev.txt mkdir "$BASE/log" || true mkdir "$BASE/db" || true cat< $ rake django-admin[runserver,lms,dev,] If the Django development server starts properly you should see: Development server is running at http://127.0.0.1:/ Quit the server with CONTROL-C. Connect your browser to http://127.0.0.1: to view the Django site. END exit 0