Commit 9cdcc9df by Slater-Victoroff

Bringing the create-dev-env.sh script up to date and generalizing for mac and debian-based systems

parent 72377e1a
#!/usr/bin/env bash #!/usr/bin/env bash
#Exit if any commands return a non-zero status
set -e set -e
# posix compliant sanity check # posix compliant sanity check
...@@ -27,10 +29,17 @@ EOL ...@@ -27,10 +29,17 @@ EOL
} }
#Setting error color to red before reset
error() { error() {
printf '\E[31m'; echo "$@"; printf '\E[0m' printf '\E[31m'; echo "$@"; printf '\E[0m'
} }
#Setting warning color to magenta before reset
warning() {
printf '\E[35m'; echo "$@"; printf '\E[0m'
}
#Setting output color to cyan before reset
output() { output() {
printf '\E[36m'; echo "$@"; printf '\E[0m' printf '\E[36m'; echo "$@"; printf '\E[0m'
} }
...@@ -51,7 +60,7 @@ EO ...@@ -51,7 +60,7 @@ EO
info() { info() {
cat<<EO cat<<EO
MITx base dir : $BASE edX base dir : $BASE
Python virtualenv dir : $PYTHON_DIR Python virtualenv dir : $PYTHON_DIR
Ruby RVM dir : $RUBY_DIR Ruby RVM dir : $RUBY_DIR
Ruby ver : $RUBY_VER Ruby ver : $RUBY_VER
...@@ -59,22 +68,37 @@ info() { ...@@ -59,22 +68,37 @@ info() {
EO EO
} }
change_git_push_defaults() {
#Set git push defaults to upstream rather than master
output "Changing git defaults"
git config --global push.default upstream
}
clone_repos() { clone_repos() {
change_git_push_defaults
cd "$BASE" cd "$BASE"
if [[ -d "$BASE/mitx/.git" ]]; then if [[ -d "$BASE/edx_platform/.git" ]]; then
output "Pulling mitx" output "Pulling edx platform"
cd "$BASE/mitx" cd "$BASE/edx_platform"
git pull git pull
else else
output "Cloning mitx" output "Cloning edx platform"
if [[ -d "$BASE/mitx" ]]; then if [[ -d "$BASE/edx_platform" ]]; then
mv "$BASE/mitx" "${BASE}/mitx.bak.$$" output "Creating backup for existing edx platform"
mv "$BASE/edx_platform" "${BASE}/edx_platform.bak.$$"
fi fi
git clone git@github.com:MITx/mitx.git git clone https://github.com/edx/edx-platform.git
fi fi
# By default, dev environments start with a copy of 6.002x # By default, dev environments start with a copy of 6.002x
# Not certain if these are making it in to the open source release.
# If there's a github permissions error, remove this section of code.
# You should get a working environment sans a demo course.
cd "$BASE" cd "$BASE"
mkdir -p "$BASE/data" mkdir -p "$BASE/data"
REPO="content-mit-6002x" REPO="content-mit-6002x"
...@@ -85,10 +109,11 @@ clone_repos() { ...@@ -85,10 +109,11 @@ clone_repos() {
else else
output "Cloning $REPO" output "Cloning $REPO"
if [[ -d "$BASE/data/$REPO" ]]; then if [[ -d "$BASE/data/$REPO" ]]; then
output "Creating backup for existing demo course"
mv "$BASE/data/$REPO" "${BASE}/data/$REPO.bak.$$" mv "$BASE/data/$REPO" "${BASE}/data/$REPO.bak.$$"
fi fi
cd "$BASE/data" cd "$BASE/data"
git clone git@github.com:MITx/$REPO git clone https://github.com/MITx/content-mit-6002x.git
fi fi
} }
...@@ -98,7 +123,7 @@ clone_repos() { ...@@ -98,7 +123,7 @@ clone_repos() {
PROG=${0##*/} PROG=${0##*/}
# Adjust this to wherever you'd like to place the codebase # Adjust this to wherever you'd like to place the codebase
BASE="${PROJECT_HOME:-$HOME}/mitx_all" BASE="${PROJECT_HOME:-$HOME}/edx_all"
# Use a sensible default (~/.virtualenvs) for your Python virtualenvs # Use a sensible default (~/.virtualenvs) for your Python virtualenvs
# unless you've already got one set up with virtualenvwrapper. # unless you've already got one set up with virtualenvwrapper.
...@@ -161,7 +186,7 @@ done ...@@ -161,7 +186,7 @@ done
cat<<EO cat<<EO
This script will setup a local MITx environment, this This script will setup a local edX environment, this
includes includes
* Django * Django
...@@ -202,9 +227,19 @@ case `uname -s` in ...@@ -202,9 +227,19 @@ case `uname -s` in
distro=`lsb_release -cs` distro=`lsb_release -cs`
case $distro in case $distro in
maya|lisa|natty|oneiric|precise|quantal) wheezy|jessie|maya|olivia|nadia|natty|precise|quantal|raring)
sudo apt-get install git sudo apt-get install git
;; ;;
case $distro in
squeeze|lisa|katya|oneiric|natty)
warning "It seems like you're using $distro which has been deprecated.
While we don't technically support this release, the install
script will probably still work.
Press return to continue or control-C to abort"
read dummy
sudo apt-get install git
;;
*) *)
error "Unsupported distribution - $distro" error "Unsupported distribution - $distro"
exit 1 exit 1
...@@ -241,7 +276,7 @@ EO ...@@ -241,7 +276,7 @@ EO
;; ;;
*) *)
error "Unsupported platform" error "Unsupported platform. Try switching to either Mac or a Debian-based linux distribution (Ubuntu or Mint)"
exit 1 exit 1
;; ;;
esac esac
...@@ -251,10 +286,10 @@ esac ...@@ -251,10 +286,10 @@ esac
clone_repos clone_repos
# Install system-level dependencies # Install system-level dependencies
if [[ -d $BASE/edx_platform/scripts/install-system-req.sh]]; then
bash $BASE/mitx/install-system-req.sh
bash $BASE/edx_platform/scripts/install-system-req.sh
output "Installing RVM, Ruby, and required gems" output "Installing RVM, Ruby, and required gems"
......
...@@ -30,8 +30,9 @@ case `uname -s` in ...@@ -30,8 +30,9 @@ case `uname -s` in
distro=`lsb_release -cs` distro=`lsb_release -cs`
case $distro in case $distro in
maya|lisa|natty|oneiric|precise|quantal) #Tries to install the same
output "Installing Ubuntu requirements" 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 # DEBIAN_FRONTEND=noninteractive is required for silent mysql-server installation
export DEBIAN_FRONTEND=noninteractive export DEBIAN_FRONTEND=noninteractive
......
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