Commit cad2f85d by Calen Pennington

Merge pull request #93 from MITx/create-dev-env

Create dev env
parents d294ea23 2931dce9
#!/bin/bash #!/usr/bin/env bash
set -e 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 trap "ouch" ERR
ouch() { ouch() {
...@@ -14,6 +21,7 @@ ouch() { ...@@ -14,6 +21,7 @@ ouch() {
script again with the -v flag. script again with the -v flag.
EOL EOL
printf '\E[0m'
} }
error() { error() {
...@@ -28,6 +36,7 @@ usage() { ...@@ -28,6 +36,7 @@ usage() {
Usage: $PROG [-c] [-v] [-h] Usage: $PROG [-c] [-v] [-h]
-c compile scipy and numpy -c compile scipy and numpy
-s --system-site-packages for virtualenv
-v set -x + spew -v set -x + spew
-h this -h this
...@@ -48,21 +57,45 @@ EO ...@@ -48,21 +57,45 @@ EO
clone_repos() { clone_repos() {
cd "$BASE" cd "$BASE"
output "Cloning mitx"
if [[ -d "$BASE/mitx" ]]; then if [[ -d "$BASE/mitx/.git" ]]; then
mv "$BASE/mitx" "${BASE}/mitx.bak.$$" output "Pulling mitx"
cd "$BASE/mitx"
git pull >>$LOG
else
output "Cloning mitx"
if [[ -d "$BASE/mitx" ]]; then
mv "$BASE/mitx" "${BASE}/mitx.bak.$$"
fi
git clone git@github.com:MITx/mitx.git >>$LOG
fi fi
git clone git@github.com:MITx/mitx.git >>$LOG
output "Cloning askbot-devel" cd "$BASE"
if [[ -d "$BASE/askbot-devel" ]]; then if [[ -d "$BASE/askbot-devel/.git" ]]; then
mv "$BASE/askbot-devel" "${BASE}/askbot-devel.bak.$$" output "Pulling askbot-devel"
cd "$BASE/askbot-devel"
git pull >>$LOG
else
output "Cloning askbot-devel"
if [[ -d "$BASE/askbot-devel" ]]; then
mv "$BASE/askbot-devel" "${BASE}/askbot-devel.bak.$$"
fi
git clone git@github.com:MITx/askbot-devel >>$LOG
fi fi
git clone git@github.com:MITx/askbot-devel >>$LOG
output "Cloning data" cd "$BASE"
if [[ -d "$BASE/data" ]]; then if [[ -d "$BASE/data/.hg" ]]; then
mv "$BASE/data" "${BASE}/data.bak.$$" output "Pulling data"
cd "$BASE/data"
hg pull >>$LOG
hg update >>$LOG
else
output "Cloning data"
if [[ -d "$BASE/data" ]]; then
mv "$BASE/data" "${BASE}/data.bak.$$"
fi
hg clone ssh://hg-content@gp.mitx.mit.edu/data >>$LOG
fi fi
hg clone ssh://hg-content@gp.mitx.mit.edu/data >>$LOG
} }
PROG=${0##*/} PROG=${0##*/}
...@@ -81,7 +114,7 @@ if [[ $EUID -eq 0 ]]; then ...@@ -81,7 +114,7 @@ if [[ $EUID -eq 0 ]]; then
usage usage
exit 1 exit 1
fi fi
ARGS=$(getopt "cvh" "$*") ARGS=$(getopt "cvhs" "$*")
if [[ $? != 0 ]]; then if [[ $? != 0 ]]; then
usage usage
exit 1 exit 1
...@@ -93,6 +126,10 @@ while true; do ...@@ -93,6 +126,10 @@ while true; do
compile=true compile=true
shift shift
;; ;;
-s)
systempkgs=true
shift
;;
-v) -v)
set -x set -x
verbose=true verbose=true
...@@ -123,7 +160,7 @@ cat<<EO ...@@ -123,7 +160,7 @@ cat<<EO
To compile scipy and numpy from source use the -c option To compile scipy and numpy from source use the -c option
STDOUT is redirected to /var/tmp/install.log, run Most of STDOUT is redirected to /var/tmp/install.log, run
$ tail -f /var/tmp/install.log $ tail -f /var/tmp/install.log
to monitor progress to monitor progress
...@@ -211,8 +248,13 @@ esac ...@@ -211,8 +248,13 @@ esac
output "Installing rvm and ruby" output "Installing rvm and ruby"
curl -sL get.rvm.io | bash -s stable curl -sL get.rvm.io | bash -s stable
source $RUBY_DIR/scripts/rvm source $RUBY_DIR/scripts/rvm
rvm install $RUBY_VER # skip the intro
virtualenv "$PYTHON_DIR" LESS="-E" rvm install $RUBY_VER
if [[ -n $systempkgs ]]; then
virtualenv --system-site-packages "$PYTHON_DIR"
else
virtualenv "$PYTHON_DIR"
fi
source $PYTHON_DIR/bin/activate source $PYTHON_DIR/bin/activate
output "Installing gem bundler" output "Installing gem bundler"
gem install bundler gem install bundler
...@@ -251,23 +293,38 @@ mkdir "$BASE/log" || true ...@@ -251,23 +293,38 @@ mkdir "$BASE/log" || true
mkdir "$BASE/db" || true mkdir "$BASE/db" || true
cat<<END cat<<END
Success!! Success!!
To start using Django you will need To start using Django you will need to activate the local Python
to activate the local Python and Ruby and Ruby environment (at this time rvm only supports bash) :
environment:
$ source $RUBY_DIR/scripts/rvm $ source $RUBY_DIR/scripts/rvm
$ source $PYTHON_DIR/bin/activate $ source $PYTHON_DIR/bin/activate
To initialize and start a local instance of Django: To initialize Django
$ cd $BASE/mitx $ cd $BASE/mitx
$ django-admin.py syncdb --settings=envs.dev --pythonpath=. $ rake django-admin[syncdb]
$ django-admin.py migrate --settings=envs.dev --pythonpath=. $ rake django-admin[migrate]
$ django-admin.py runserver --settings=envs.dev --pythonpath=.
To start the Django on port 8000
$ rake lms
Or to start Django on a different <port#>
$ rake django-admin[runserver,lms,dev,<port#>]
If the Django development server starts properly you
should see:
Development server is running at http://127.0.0.1:<port#>/
Quit the server with CONTROL-C.
Connect your browser to http://127.0.0.1:<port#> to
view the Django site.
END END
exit 0 exit 0
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment