From 3e6dc3a041854afeaa622b952e221192b5c5335c Mon Sep 17 00:00:00 2001 From: Ivan Malison Date: Mon, 25 Aug 2014 20:31:11 -0700 Subject: [PATCH] Tweaks to brew and setup scripts. --- dotfiles/lib/shellrc/brew.sh | 11 +++++++++++ setup.sh | 20 ++++++++++++++------ web_start.sh | 1 + 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/dotfiles/lib/shellrc/brew.sh b/dotfiles/lib/shellrc/brew.sh index 6bb235cb..b08219ca 100755 --- a/dotfiles/lib/shellrc/brew.sh +++ b/dotfiles/lib/shellrc/brew.sh @@ -1,3 +1,14 @@ +function get_brew() { + hash make &>/dev/null + if [ $? -ne 0 ] + then + echo "Make not found. Please install xcode developer tools." + return -1 + fi + hash brew &>/dev/null && echo "Homebrew found!" || ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)" + brew update +} + function brew_install_items() { for package_install_string in $@; do diff --git a/setup.sh b/setup.sh index b0022ff4..1146e526 100755 --- a/setup.sh +++ b/setup.sh @@ -63,23 +63,30 @@ function setup_help() { -h display this help message." } +function get_command_line_tools() { + hash gcc 2> /dev/null || xcode-select --install +} + function setup() { if [[ $# -eq 0 ]] ; then setup_help exit 0 fi - while getopts "aosbpev" OPTCHAR; + while getopts "acosbpev" OPTCHAR; do case $OPTCHAR in a) source resources/apt-get.sh ;; b) - do_the_brew_help - read -p "Enter flags for brew package installation: + get_command_line_tools + if get_brew; then + do_the_brew_help + read -p "Enter flags for brew package installation: " - [[ $REPLY[0] != '-' ]] && REPLY="-$REPLY" - do_the_brew $REPLY + [[ $REPLY[0] != '-' ]] && REPLY="-$REPLY" + do_the_brew $REPLY + fi ;; o) sudo -v @@ -99,7 +106,8 @@ function setup() { e) case uname in Darwin) - do_the_brew -au + get_command_line_tools + get_brew && do_the_brew -au ;; Linux) apt-get diff --git a/web_start.sh b/web_start.sh index b63cebab..ffd05581 100755 --- a/web_start.sh +++ b/web_start.sh @@ -28,3 +28,4 @@ esac git clone git@github.com:IvanMalison/dotfiles.git cd dotfiles +./setup.sh -e