Created
August 9, 2012 14:58
-
-
Save clooth/3304927 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Paths | |
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | |
VIRTUALENV_DIR="${DIR}/venv" | |
APPLICATION_DIR="${DIR}/Source/bender" | |
REQUIREMENTS_DIR="${APPLICATION_DIR}/requirements" | |
# Text formatting variables | |
UNDERLINE=$(tput sgr 0 1) | |
BOLD=$(tput bold) | |
RED=$(tput setaf 1) | |
GREEN=$(tput setaf 2) | |
YELLOW=$(tput setaf 3) | |
BLUE=$(tput setaf 4) | |
MAGENTA=$(tput setaf 5) | |
CYAN=$(tput setaf 6) | |
WHITE=$(tput setaf 7) | |
RESET=$(tput sgr0) | |
# | |
# Helper functions | |
# | |
error () { | |
echo "${RED}ERROR: $1${RESET}" | |
} | |
warn () { | |
echo "${YELLOW}WARNING: $1${RESET}" | |
} | |
success () { | |
echo "${GREEN}SUCCESS: $1${RESET}" | |
} | |
log () { | |
echo "${WHITE}$1${RESET}" | |
} | |
echo | |
echo "${MAGENTA}Bender.fi${RESET}" | |
echo "${GREEN}Development Environment Installer Script${RESET}" | |
echo | |
# | |
# Checks dependancies | |
# | |
check_dependancy() { | |
if [ -z "$1" ]; then | |
error "Must provide dependancy name." | |
fi | |
command -v $1 >/dev/null 2>&1 || { error "$1 is required. Aborting."; exit 1; } | |
} | |
dependancies=('python' 'virtualenv') | |
for idx in ${!dependancies[*]}; do | |
check_dependancy ${dependancies[$idx]} | |
done | |
# | |
# Sets up virtualenv for the project | |
# | |
# Shortcut to checking for virtualenv | |
virtualenv_exists() { | |
[ -d VIRTUALENV_DIR ] | |
} | |
# Set up virtualenv | |
setup_virtualenv() { | |
if virtualenv_exists; then | |
# Attempt to create virtualenv with the `virtualenv` command | |
output = virtualenv 'venv' | |
# Check success | |
if [ ! virtualenv_exists ]; then | |
error "Failed to create virtualenv:\n${WHITE}${output}" | |
else | |
success "Created virtualenv at ${WHITE}${VIRTUALENV_DIR}" | |
fi | |
else | |
success "Virtualenv already exists, moving forward ..." | |
fi | |
} | |
setup_virtualenv | |
# | |
# Installs requirements | |
# |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment