Last active
March 29, 2017 17:25
-
-
Save joefitzgerald/92e5d4e42f6764583642 to your computer and use it in GitHub Desktop.
Tech Summit Pre-Requisites Checker
This file contains hidden or 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 --login | |
set -o nounset | |
export EXPECTED_RUBY_VERSION="1.9.3" | |
export EXPECTED_RBENV_RUBY_VERSION="1.9.3-p545" | |
logError () { | |
logCustom 1 "ERROR: $1" | |
echo ">>>>>>>>>> End time: $(date) <<<<<<<<<<<<" | |
exit 1 | |
} | |
logSuccess () { | |
logCustom 2 "SUCCESS: $1" | |
} | |
logInfo () { | |
logCustom 3 "INFO: $1" | |
} | |
logCustom () { | |
tput setaf $1 | |
echo "$2" | |
tput sgr 0 | |
} | |
# Verify if Homebrew is installed | |
BREW_INSTALLED=`which brew` | |
if [ -z $BREW_INSTALLED ]; then | |
logError "Looks like you haven't started the work to satisfy pre-requisites!" | |
else | |
BREW_VERSION=`brew -v` | |
logInfo "Homebrew found. Version: $BREW_VERSION" | |
fi | |
# Verify if XCode is installed | |
XCODE_INSTALLED=`xcode-select -p` | |
if [ -z $XCODE_INSTALLED ]; then | |
logError "You should have downloaded Xcode; its a 2GB file - better get moving" | |
else | |
logInfo "Xcode is installed. Great!" | |
fi | |
# Verify if Git is installed | |
GIT_INSTALLED=`which git` | |
if [ -z $GIT_INSTALLED ]; then | |
logError "Please run 'brew install git'" | |
else | |
logInfo "Git is installed. Good work." | |
fi | |
# Verify if ruby is installed using rvm | |
RVM_INSTALLED=`which rvm` | |
if [ -z $RVM_INSTALLED ]; then | |
logInfo "You're not using rvm. This is expected." | |
else | |
logInfo "rvm is installed; it may be save to ignore subsequent messages that show errors because you're not using rbenv" | |
fi | |
# Verify if ruby is installed using rbenv | |
RB_ENV_INSTALLED=`which rbenv` | |
if [ -z $RB_ENV_INSTALLED ]; then | |
logInfo "Rbenv is not found, please install it using 'brew install rbenv'" | |
else | |
logInfo "Rbenv is installed" | |
fi | |
# Verify if Ruby is on the path | |
RUBY_VERSION_INSTALLED=`ruby -v` | |
if echo "$RUBY_VERSION_INSTALLED" | grep -q "$EXPECTED_RUBY_VERSION"; then | |
logInfo "Yay!! You have Ruby 1.9.3 installed" | |
else | |
logInfo "Your Ruby version is: $RUBY_VERSION_INSTALLED" | |
fi | |
# Verify if Ruby 1.9.3-p545 is installed using rbenv | |
RUBY_VERSION_INSTALLED=`rbenv versions | grep 1.9.3-p545` | |
if echo "$RUBY_VERSION_INSTALLED" | grep -q "$EXPECTED_RUBY_VERSION"; then | |
logInfo "Yay!! You have Ruby 1.9.3-p545 installed via rbenv" | |
else | |
logError "Ruby 1.9.3-p545 not found. Please run 'rbenv install 1.9.3-p545'" | |
fi | |
logInfo "Thanks! You have installed all the pre-requisites." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment