From dbcef7d7439a6ce43bc407e8b6714c834311d35f Mon Sep 17 00:00:00 2001 From: yarko Date: Fri, 31 May 2013 23:18:38 -0500 Subject: [PATCH] create-dev-env.sh: if run from repo, set $BASE appropriately 2 changes: [1] If PROJECT_HOME is not set, AND create-dev-env.sh is run from a cloned repo, then set BASE to that repo; else: (and only finally) set BASE to a default of "$HOME/edx_all" [2] if PROJECT_HOME is set, or if this is from a repo, don't add edx_all to the BASE name (no need;) --- scripts/create-dev-env.sh | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/scripts/create-dev-env.sh b/scripts/create-dev-env.sh index 520ce05b5c..a13fec3850 100755 --- a/scripts/create-dev-env.sh +++ b/scripts/create-dev-env.sh @@ -96,13 +96,27 @@ clone_repos() { fi } +set_base_default() { # if PROJECT_HOME not set + # 2 possibilities: this is from cloned repo, or not + # this script is in "./scripts" if a git clone + this_repo=$(cd "${BASH_SOURCE%/*}/.." && pwd) + if [[ "${this_repo##*/}" = "edx-platform" && -d "$this_repo/.git" ]]; then + # set BASE one-up from this_repo; + echo "${this_repo%/*}" + else + echo "$HOME/edx_all" + fi +} + + + ### START PROG=${0##*/} # Adjust this to wherever you'd like to place the codebase -BASE="${PROJECT_HOME:-$HOME}/edx_all" +BASE="${PROJECT_HOME:-$(set_base_default)}" # Use a sensible default (~/.virtualenvs) for your Python virtualenvs # unless you've already got one set up with virtualenvwrapper.