Improved audit script #696

Merged
merged 1 commit into from Dec 5, 2012
+713 −246
View
959 setup/install.sh
@@ -1,266 +1,733 @@
#!/bin/bash
-# audit system and check dependencies
-# We aren't installing anything in this script, we're only checking your system for you and reporting back.
-
-# logic
-# 1 = installed, correct version.
-# 0 = not installed.
-# 2 = installed, wrong version.
-
-
-# Requirements (versions required for yeoman)
-reqnode=0.8.0
-reqruby=1.8.7
-reqcompass=0.12.1
-
-# Check os
-os=$(uname -s)
-
-if [[ "$os" == "Darwin" ]]; then
- mac=1
-elif [[ "$os" == "Linux" || "$os" == "FreeBSD" ]]; then
- linux=1
-else
- echo "Windows is not officially supported, currently."
- exit 1
-fi
-
-# Dependency checks
- curlfile=$(command -v curl)
- gitfile=$(command -v git)
- rubyfile=$(command -v ruby)
- nodefile=$(command -v node)
- gemfile=$(command -v gem)
- compassfile=$(command -v compass)
- brewfile=$(command -v brew)
-phantomjsfile=$(command -v phantomjs)
-jpegturbofile=$(command -v jpegtran)
- optipngfile=$(command -v optipng)
- clangfile=$(command -v clang)
- yeomanfile=$(command -v yeoman)
- npmfile=$(command -v npm)
-
-# Check if installed.
-check_set(){
- [[ -x "$1" ]] && echo 1 || echo 0
-}
+# ******************************************************************************
+# * YEOMAN AUDIT SCRIPT *
+# ******************************************************************************
+
+# We aren't installing anything in this script, we're
+# only checking your system for you and reporting back
+
+# Dependencies check codes
+brew=0
+clang=0
+compass=0
+curl=0
+git=0
+gem=0
+jpegtran=0
+node=0
+npm=0
+optipng=0
+phantomjs=0
+ruby=0
+yeoman=0
+
+# OS information
+os=""
+distro=""
+
+# Version requirements
+declare -r reqcompass=0.12.1
+declare -r reqnode=0.8.0
+declare -r reqnpm=1.1
+declare -r reqruby=1.8.7
+
+#M------------------------------------------------------------------------------
+# | Audit & Dependencies Checks |
+# ------------------------------------------------------------------------------
+audit() {
+ declare -i all_check=0
+ declare -i none_check=0
-# This prints the ✘ in red,
-# rest in bold.
-sad_print(){
- printf '\e[31m%s\e[0m \e[1m%s\e[0m %s\n' "" "$1" "$2"
-}
+ echo -e "\n Before I can assist you I will need to confirm you have the necessary requirements."
+ echo -e "\n Below you will find the results of my short system audit:\n"
+
+ check_dep
+
+ if (( ( "$os" == "linux" || "$os" == "freebsd" ) && $curl == 1 )) ||
+ (( "$os" == "mac" && $brew == 1 && $clang == 1 )) &&
+ (( $compass == 1 && $git == 1 && $jpegtran == 1 && $node == 1 &&
+ $npm == 1 && $optipng == 1 && $phantomjs == 1 && $ruby == 1 &&
+ $gem == 1 && $yeoman == 1 )); then
+ all_check=1
+ fi
-# This prints ✓ in green,
-# rest in bold.
-happy_print(){
- printf '\e[32m%s\e[0m \e[1m%s\e[0m %s\n' "" "$1" "$2"
+ if (( ( "$os" == "linux" || "$os" == "freebsd" ) && $curl != 1 )) ||
+ (( "$mac" == "mac" && $brew != 1 && $clang != 1 )) &&
+ (( $compass != 1 && $git != 1 && $jpegtran != 1 && $node != 1 &&
+ $npm != 1 && $optipng != 1 && $phantomjs != 1 && $ruby != 1 &&
+ $gem != 1 && $yeoman != 1 )); then
+ none_check=1
+ fi
+
+ for i in "successful" "unsuccessful"; do
+
+ if [ "$os" == "mac" ]; then
+ dep_print "brew" "$i"
+ dep_print "clang" "$i"
+ elif [[ "$os" == "linux" ||
+ "$os" == "freebsd" ]]; then
+ dep_print "curl" "$i"
+ fi
+
+ dep_print "compass" "$i"
+ dep_print "git" "$i"
+ dep_print "jpegtran" "$i"
+ dep_print "node" "$i"
+ dep_print "npm" "$i"
+ dep_print "optipng" "$i"
+ dep_print "phantomjs" "$i"
+ dep_print "ruby" "$i"
+ dep_print "gem" "$i"
+ dep_print "yeoman" "$i"
+
+ # "optimize" the print process
+ if [ "$i" == "successful" ]; then
+
+ # if all dependencies are installed and have the required version,
+ # there is no need to continue with the unsuccessful prints
+ if [ $all_check -eq 1 ]; then
+ echo -e " \n Wicked mate! Type yeoman at your prompt to summon me.\n"
+ break
+
+ # if there are both satisfied and unsatisfied
+ # dependencies, separate them by an empty line
+ elif [ $none_check -eq 0 ]; then
+ echo
+ fi
+
+ # there are unsatisfied dependencies
+ else
+
+ # if none of the dependencies are satisfied
+ if [ $none_check -eq 1 ]; then
+ echo -e "\n Bloody hell, we've got some work to do."
+ fi
+
+ echo -e "\n Areas I have not scored with a tick indicate I did not \
+find your system satisfactory. You will need to correct these before I can be \
+of service to you. Troubled? Consider reading http://goo.gl/XoyWI"
+ echo -e "\n Once all of my audit items are confirmed, we can begin.\n"
+ fi
+
+ done
}
-# print extra descriptions for failure states
-desc_print(){
- printf "\t%s \e[47m\e[0;35m%s\e[0m %s\n" "$1" "$2" "$3"
+check() {
+
+ # Check codes:
+ # 1 = installed, correct version
+ # 0 = not installed
+ # 2 = installed, wrong version
+
+ declare -i result=0
+
+ # Check if installed
+ result=$( [[ -x "$(command -v "$1")" ]] && echo 1 || echo 0 )
+
+ # Check if correct version
+ if [ $result -eq 1 ]; then
+ if [[ "$1" == "node" && "$(node -e 'console.log(process.versions.node);')" < "$reqnode" ||
+ "$1" == "npm" && "$(npm --version)" < "$reqnpm" ||
+ "$1" == "ruby" && "$(ruby -e 'print RUBY_VERSION')" < "$reqruby" ||
+ "$1" == "compass" && "$(compass -qv)" < "$reqcompass" ]]; then
+ result=2
+ fi
+ fi
+
+ echo $result
}
-# audit \o/
+check_dep() {
-audit() {
- echo ""
- echo "Before I can assist you I will need to confirm you have the necessary requirements. "
- echo ""
- echo "Below you will find the results of my short system audit:"
-
- if [[ $mac = 1 ]]; then
- # xcode cli test.
- cli=$(check_set $clangfile)
-
- # brew test.
- brew=$(check_set $brewfile)
- fi
-
- if [[ $linux = 1 ]]; then
- # curl test.
- curl=$(check_set $curlfile)
- fi
-
- # node test
- node=$(check_set $nodefile)
- if [[ $node == 1 ]]; then
- nodever=$(node -e 'console.log(process.versions.node);')
- # node version check
- if [[ "$nodever" < "$reqnode" ]]; then
- node=2
+ if [ "$os" == "mac" ]; then
+ brew=$(check "brew")
+ clang=$(check "clang")
+ elif [[ "$os" == "linux" ||
+ "$os" == "freebsd" ]]; then
+ curl=$(check "curl")
fi
- fi
-
- # ruby test
- ruby=$(check_set $rubyfile)
- if [[ $ruby == 1 ]]; then
- rubyver=$(ruby -e 'print RUBY_VERSION')
- # ruby version check
- if [[ "$rubyver" < "$reqruby" ]]; then
- ruby=2
+
+ compass=$(check "compass")
+ gem=$(check "gem")
+ git=$(check "git")
+ jpegtran=$(check "jpegtran")
+ node=$(check "node")
+ npm=$(check "npm")
+ optipng=$(check "optipng")
+ phantomjs=$(check "phantomjs")
+ ruby=$(check "ruby")
+ yeoman=$(check "yeoman")
+
+}
+
+dep_print() {
+ local val=${!1} # dependency check value (obtained using indirection)
+ local f="msgs_$1" # appropriate messages function
+
+ if [[ "$2" == "successful" && $val == 1 ||
+ "$2" == "unsuccessful" && $val != 1 ]]; then
+ $f $val
fi
- fi
+}
+# ------------------------------------------------------------------------------
+# | Messages |
+# ------------------------------------------------------------------------------
+
+msgs_brew() {
+ local outputName="${2:-"Homebrew"}"
+
+ case $1 in
+ 0 ) sad_print "$outputName" "[not installed]"
+
+ if [ "$os" == "mac" ]; then # only for Mac, but just to be sure :)
+ if [[ $curl == 1 && $ruby == 1 ]]; then
+ desc_print "To install $outputName use:" \
+ "ruby -e \"$(curl -fsSkL raw.github.com/mxcl/homebrew/go)\""
+ else
+ desc_print "Visit" \
+ "https://github.com/mxcl/homebrew/wiki/Installation" \
+ "for $outputName installation instructions"
+ fi
+ desc_print "For best results, after install, be sure to run" \
+ "brew doctor" \
+ "and follow the recommendations"
+ fi
+
+ ;;
+ 1 ) happy_print "$outputName" "check." ;;
+ esac
+}
+
+msgs_clang() {
+ local outputName="${2:-"Command Line Tools for Xcode"}"
+ case $1 in
+ 0 ) sad_print "$outputName" "[not installed]"
+
+ if [ "$os" == "mac" ]; then # only for Mac, but just to be sure :)
+ desc_print "Visit" \
+ "http://stackoverflow.com/a/9329325" \
+ "for $outputName installation instructions"
+ fi
+
+ ;;
+ 1 ) happy_print "$outputName" "check." ;;
+ esac
+}
+
+msgs_compass() {
+ local outputName="${2:-"Compass"}"
+
+ case $1 in
+ 0 ) sad_print "$outputName" "[not installed]"
+
+ if [ $gem -eq 1 ]; then
+ desc_print "To install $outputName use:" \
+ "sudo gem install compass"
+ else
+ desc_print "To install $outputName you need to have" \
+ "ruby" \
+ "installed first"
+ fi
+
+ ;;
+ 1 ) happy_print "$outputName" "check." ;;
+ 2 ) sad_print "$outputName" "[newer version required ≥ $reqcompass]"
+
+ if [ $gem -eq 1 ]; then
+ desc_print "To update $outputName use:" \
+ "sudo gem update compass"
+ fi
+
+ ;;
+ esac
+}
+
+msgs_curl() {
+ local outputName="${2:-"cURL"}"
+
+ case $1 in
+ 0 ) sad_print "$outputName" "[not installed]"
+
+ case $os in
+
+ linux )
+ case $distro in
+ ubuntu|debian ) desc_print "To install $outputName use:" \
+ "sudo apt-get install curl" ;;
+ * ) desc_print "Visit" \
+ "http://curl.haxx.se/docs/install.html" \
+ "for $outputName installation instructions" ;;
+ esac
+ ;;
+
+ freebsd )
+ desc_print "Visit" \
+ "http://curl.haxx.se/docs/install.html" \
+ "for $outputName installation instructions"
+ ;;
+
+ esac
+
+ ;;
+ 1 ) happy_print "$outputName" "is present, phew." ;;
+ esac
+}
- # compass test
- compass=$(check_set $compassfile)
- if [[ $compass == 1 ]];then
- compassver=$(compass -qv)
- # compass version check
- if [[ "$compassver" < "$reqcompass" ]]; then
- compass=2
+msgs_gem() {
+ local outputName="${2:-"RubyGems"}"
+
+ case $1 in
+ 0 ) sad_print "$outputName" "[not installed]"
+ desc_print "You'll acquire $outputName with your" "ruby" "installation."
+ ;;
+ 1 ) happy_print "$outputName" "check." ;;
+ esac
+}
+
+msgs_git() {
+ local outputName="${2:-"Git"}"
+
+ case $1 in
+ 0 ) sad_print "$outputName" "[not installed]"
+
+ case $os in
+
+ mac )
+ if [ $brew -eq 1 ]; then
+ desc_print "To install $outputName use:" \
+ "brew install git"
+ else
+ desc_print "Visit" \
+ "http://git-scm.com/download/mac" \
+ "for $outputName installation instructions"
+ fi
+ ;;
+
+ linux )
+ case $distro in
+ ubuntu|debian ) desc_print "To install $outputName use:" \
+ "sudo apt-get install git" ;;
+ fedora ) desc_print "To install $outputName use:" \
+ "yum install git" ;;
+ gentoo ) desc_print "To install $outputName use:" \
+ "emerge --ask --verbose dev-vcs/git" ;;
+ * ) desc_print "Visit" \
+ "http://git-scm.com/download/linux." \
+ "for $outputName installation instructions" ;;
+ esac
+ ;;
+
+ freebsd )
+ desc_print "To install $outputName use:" \
+ "cd /usr/ports/devel/git && make install clean"
+ ;;
+
+ esac
+
+ ;;
+ 1 ) happy_print "$outputName" "smashing!" ;;
+ esac
+}
+
+msgs_jpegtran() {
+ local outputName="${2:-"JPEGTran"}"
+
+ case $1 in
+ 0 ) sad_print "$outputName" "[not installed]"
+
+ case $os in
+
+ mac )
+ if [ $brew -eq 1 ]; then
+ desc_print "To install $outputName use:" \
+ "brew install jpeg-turbo && brew link jpeg-turbo"
+ else
+ desc_print "Download $outputName from:" \
+ "http://jpegclub.org/jpegtran/"
+ fi
+ ;;
+
+ linux )
+ case $distro in
+ ubuntu ) desc_print "To install $outputName use:" \
+ "sudo apt-get install libjpeg-turbo-progs" ;;
+ * ) desc_print "Download $outputName from:" \
+ "http://jpegclub.org/jpegtran/" ;;
+ esac
+ ;;
+
+ esac
+
+ ;;
+ 1 ) happy_print "$outputName" "check." ;;
+ esac
+}
+
+msgs_node() {
+ local outputName="${2:-"NodeJS"}"
+
+ case $1 in
+ 0 ) sad_print "$outputName" "[not installed]"
+
+ case $os in
+
+ mac )
+ desc_print "Visit" \
+ "https://github.com/joyent/node/wiki/Installing-Node.js-via-package-manager" \
+ "for $outputName installation instructions"
+ ;;
+
+ linux )
+ case $distro in
+ ubuntu ) desc_print "To install $outputName use:"
+ code_print ""
+ code_print "sudo apt-get install python-software-properties"
+ code_print "sudo add-apt-repository ppa:chris-lea/node.js"
+ code_print "sudo apt-get update"
+ code_print "sudo apt-get install nodejs"
+ code_print "" ;;
+ * ) desc_print "Visit" \
+ "https://github.com/joyent/node/wiki/Installing-Node.js-via-package-manager" \
+ "for $outputName installation instructions" ;;
+ esac
+ ;;
+
+ freebsd )
+ desc_print "To install $outputName use:" \
+ "cd /usr/ports/www/node && make install clean"
+ ;;
+
+ esac
+ ;;
+ 1 ) happy_print "$outputName" "check." ;;
+ 2 ) sad_print "$outputName" "[newer version required ≥ $reqnode]"
+ desc_print "I recommend you grab a fresh $outputName install (≥ $reqnode) from:" \
+ "http://nodejs.org/download/"
+ ;;
+ esac
+}
+
+msgs_npm() {
+ local outputName="${2:-"npm"}"
+
+ # npm comes with node nowadays:
+ # - https://npmjs.org/doc/README.html#Super-Easy-Install
+
+ case $1 in
+ 0 ) sad_print "$outputName" "[not installed]"
+
+ if [ $node -eq 0 ]; then
+ desc_print "You'll acquire $outputName with your" \
+ "NodeJS" \
+ "installation."
+ elif [ $node -eq 2 ]; then
+ desc_print "You'll acquire $outputName after your install" \
+ "NodeJS (≥ $reqnode)"
+ elif [ $node -eq 1 ]; then
+ case $os in
+
+ linux )
+ case $distro in
+ ubuntu ) desc_print "To install $outputName use:"
+ code_print ""
+ code_print "sudo apt-get install python-software-properties"
+ code_print "sudo add-apt-repository ppa:chris-lea/node.js"
+ code_print "sudo apt-get update"
+ code_print "sudo apt-get install npm"
+ code_print "" ;;
+ * ) desc_print "Visit" \
+ "https://github.com/isaacs/npm#fancy-install-unix" \
+ "for $outputName installation instructions" ;;
+ esac
+ ;;
+
+ freebsd )
+ desc_print "To install $outputName use:" \
+ "cd /usr/ports/www/npm && make install clean"
+ ;;
+
+ esac
+ fi
+
+ ;;
+ 1 ) happy_print "$outputName" "check." ;;
+ 2 ) sad_print "$outputName" "[newer version required ≥ $reqnpm]"
+
+ if [ $node -eq 0 ]; then
+ desc_print "I recommend you install NodeJS (≥ $reqnode) so that" \
+ "$outputName" \
+ "is updated"
+ elif [ $node -eq 2 ]; then
+ desc_print "I recommend you grab a fresh NodeJS install (≥ $reqnode) from:" \
+ "http://nodejs.org/download/" \
+ "so that $outputName is updated"
+ fi
+
+ ;;
+ esac
+}
+
+msgs_optipng() {
+ local outputName="${2:-"OptiPNG"}"
+
+ case $1 in
+ 0 ) sad_print "$outputName" "[not installed]"
+
+ case $os in
+
+ mac )
+ if [ $brew -eq 1 ]; then
+ desc_print "To install $outputName use:" \
+ "brew install optipng"
+ else
+ desc_print "Download $outputName from:" \
+ "http://optipng.sourceforge.net/"
+ fi
+ ;;
+
+ linux )
+ case $distro in
+ ubuntu ) desc_print "To install $outputName use:" \
+ "sudo apt-get install optipng" ;;
+ *) desc_print "Download $outputName from:" \
+ "http://optipng.sourceforge.net/" ;;
+ esac
+ ;;
+
+ freebsd )
+ desc_print "To install $outputName use:" \
+ "cd /usr/ports/graphics/optipng && make install clean"
+ ;;
+
+ esac
+
+ ;;
+ 1 ) happy_print "$outputName" "check." ;;
+ esac
+}
+
+msgs_phantomjs() {
+ local outputName="${2:-"PhantomJS"}"
+
+ case $1 in
+ 0 ) sad_print "$outputName" "[not installed]"
+
+ case $os in
+
+ mac )
+ if [ $brew -eq 1 ]; then
+ esc_print "To install $outputName use:" \
+ "brew install phantomjs"
+ else
+ desc_print "Download the $outputName binary package from:" \
+ "http://phantomjs.org/download.html#mac"
+ desc_print "Visit" \
+ "http://phantomjs.org/build.html#mac" \
+ "for instructions on how to compiling $outputName from source (takes a long time!)"
+ fi
+ ;;
+
+ linux )
+ case $distro in
+ ubuntu ) desc_print "Download the $outputName binary package from:" \
+ "http://phantomjs.org/download.html#linux"
+ desc_print "Compile from source -" \
+ "http://phantomjs.org/build.html#linux" \
+ "(takes a long time!):"
+ code_print ""
+ code_print "sudo apt-get install build-essential chrpath git-core libssl-dev libfontconfig1-dev"
+ code_print "git clone git://github.com/ariya/phantomjs.git"
+ code_print "cd phantomjs"
+ code_print "git checkout 1.7"
+ code_print "./build.sh && deploy/package.sh"
+ code_print "" ;;
+ * ) desc_print "Visit" \
+ "http://phantomjs.org/download.html#linux" \
+ "to download the $outputName binary package" ;;
+ esac
+ ;;
+
+ freebsd )
+ desc_print "To install $outputName use (takes a long time!):" \
+ "cd /usr/ports/lang/phantomjs && make install clean"
+ ;;
+
+ esac
+
+ ;;
+ 1 ) happy_print "$outputName" "check." ;;
+ esac
+}
+
+msgs_ruby() {
+ local outputName="${2:-"Ruby"}"
+
+ case $1 in
+ 0 ) sad_print "$outputName" "[not installed]"
+
+ case $os in
+
+ mac )
+ desc_print "Visit" \
+ "http://www.ruby-lang.org/en/downloads/" \
+ "for $outputName installation instructions"
+ ;;
+
+ linux )
+ case $distro in
+ ubuntu ) desc_print "To install $outputName use:" \
+ "sudo apt-get install ruby1.9.3" ;;
+ * ) desc_print "Visit" \
+ "http://www.ruby-lang.org/en/downloads/" \
+ "for $outputName installation instructions" ;;
+ esac
+ ;;
+
+ esac
+
+ ;;
+ 1 ) happy_print "$outputName" "check." ;;
+ 2 ) sad_print "$outputName" "[newer version required ≥ $reqruby]" ;;
+ esac
+}
+
+msgs_yeoman() {
+ local outputName="${2:-"Yeoman"}"
+
+ case $1 in
+ 0 ) sad_print "$outputName" "[not installed]"
+
+ if [[ $node -eq 1 && $npm -eq 1 ]]; then
+ desc_print "You're missing yeoman!" \
+ "sudo npm install -g yeoman" \
+ "will correct this atrocity."
+ elif [ $node -ne 1 ]; then
+ desc_print "To install $outputName you need to have" \
+ "NodeJS (≥ $reqnode)" \
+ "installed first"
+ elif [ $npm -ne 1 ]; then
+ desc_print "To install $outputName you need to have" \
+ "npm (≥ $reqnpm)" \
+ "installed first"
+ fi
+
+ ;;
+ 1 ) happy_print "$outputName" "extraordinary!" ;;
+ esac
+}
+
+# ------------------------------------------------------------------------------
+# | OS |
+# ------------------------------------------------------------------------------
+
+check_linux_release() {
+ [ -e "/etc/$1" ] && echo "$2"
+}
+
+get_os_info() {
+ local osname="$(uname -s)"
+
+ if [ "$osname" == "Darwin" ]; then
+ os="mac"
+ elif [ "$osname" == "Linux" ]; then
+ os="linux"
+
+ # Get Linux distribution
+ # (list of release: http://linuxmafia.com/faq/Admin/release-files.html)
+ distro=$(check_linux_release "lsb-release" "ubuntu") ||
+ $(check_linux_release "debian_version" "debian") ||
+ $(check_linux_release "debian_release" "debian") ||
+ $(check_linux_release "gentoo-release" "gentoo") ||
+ $(check_linux_release "fedora-release" "fedora")
+
+ elif [ "$os" == "FreeBSD" ]; then
+ os="freebsd"
+ else
+ # TODO: better detect Windows as other OSes can get this message
+ # echo "Windows is not officially supported, currently."
+ echo "Your OS is not supported. :("
+ exit 1
fi
- fi
-
-
- git=$(check_set $gitfile)
- gem=$(check_set $gemfile)
- phantomjs=$(check_set $phantomjsfile)
- jpegturbo=$(check_set $jpegturbofile)
- optipng=$(check_set $optipngfile)
- yeoman=$(check_set $yeomanfile)
-
- # node npm test
- npm=$(check_set $npmfile)
-
- # display results
- #
- # results logic
- # passes first
- # fails second
-
- echo ""
-
- # passes
- if [[ "$mac" = 1 ]]; then
- [ "$cli" -eq 1 ] && happy_print "Command Line Tools for Xcode" "check."
- [ "$brew" -eq 1 ] && happy_print "Homebrew" "check."
- fi
-
- if [[ "$linux" = 1 ]]; then
- [ "$curl" -eq 1 ] && happy_print "curl" "is present, phew."
- fi
-
- [ "$git" -eq 1 ] && happy_print "git" "smashing!"
- [ "$node" -eq 1 ] && happy_print "NodeJS" "check."
- [ "$npm" -eq 1 ] && happy_print "NodeJS NPM" "check."
- [ "$ruby" -eq 1 ] && happy_print "ruby" "check."
- [ "$gem" -eq 1 ] && happy_print "RubyGems" "check."
- [ "$compass" -eq 1 ] && happy_print "Compass" "check."
- [ "$phantomjs" -eq 1 ] && happy_print "PhantomJS" "check."
- [ "$jpegturbo" -eq 1 ] && happy_print "jpegtran" "check."
- [ "$optipng" -eq 1 ] && happy_print "optipng" "check."
- [ "$yeoman" -eq 1 ] && happy_print "yeoman global npm module" "extraordinary!"
-
- # failures
- if [[ "$mac" = 1 ]]; then
- [ "$cli" -eq 0 ] && \
- sad_print "Command Line Tools for Xcode" "" && \
- desc_print "Visit http://stackoverflow.com/a/9329325/89484 for installation options."
- [ "$brew" -eq 0 ] && \
- sad_print "Homebrew" "" && \
- desc_print "Install Homebrew from the instructions at https://github.com/mxcl/homebrew/wiki/Installation " && \
- desc_print "For best results, after install, be sure to run" "brew doctor" "and follow the recommendations."
- fi
-
- if [[ "$linux" = 1 ]]; then
- [ "$curl" -eq 0 ] && sad_print "curl"
- fi
-
- [ "$git" -eq 0 ] && \
- sad_print "git" "" && \
- desc_print "Install through your package manager. " && \
- desc_print "For example, with homebrew:" "brew install git"
- [ "$node" -eq 0 ] && \
- sad_print "NodeJS" "" && \
- desc_print "I recommend you grab a fresh NodeJS install (>= 0.8.x) from http://nodejs.org/download/ "
- [ "$npm" -eq 0 ] && \
- sad_print "NPM" "" && \
- desc_print "I recommend you grab a fresh NodeJS install (>= 0.8.x) from http://nodejs.org/download/ as NPM Package manager is missing "
- [ "$ruby" -eq 0 ] && \
- sad_print "ruby" "" && \
- desc_print "Check your ruby version is adequate with" "ruby -v" "(>= 1.8.7 required) and install http://www.ruby-lang.org/en/downloads/"
- [ "$gem" -eq 0 ] && \
- sad_print "RubyGems" "" && \
- desc_print "You'll acquire this with your ruby installation. "
- [ "$compass" -eq 0 ] && \
- sad_print "Compass" "" && \
- desc_print "is not installed: http://compass-style.org/install/ "
- [ "$phantomjs" -eq 0 ] && \
- sad_print "PhantomJS" "" && \
- desc_print "Follow instructions at http://phantomjs.org/download.html - the binary installs are quick! " && \
- desc_print "On Mac," "brew install phantomjs" "should do the trick."
- [ "$jpegturbo" -eq 0 ] && \
- sad_print "jpegtran" "" && \
- desc_print "On Mac," "brew install jpeg-turbo && brew link jpeg-turbo" "should do the trick. " && \
- desc_print "On Ubuntu," "sudo apt-get install libjpeg-turbo-progs" "should do the trick."
- [ "$optipng" -eq 0 ] && \
- sad_print "optipng" "" && \
- desc_print "On Mac," "brew install optipng" "will sort you out. " && \
- desc_print "On Ubuntu," "sudo apt-get install optipng" "should do the trick."
- [ "$yeoman" -eq 0 ] && \
- sad_print "yeoman" "" && \
- desc_print "You're missing yeoman!" "npm install -g yeoman" "will correct this atrocity. You may need sudo."
-
-
-
- echo ""
- echo "Areas I have not scored with a tick indicate I did not find your system satisfactory. You will need to correct these before I can be of service to you. Troubled? Consider reading http://goo.gl/XoyWI "
- echo ""
- printf "%s \e[47m\e[0;35m%s\e[0m %s\n" "Once all of my audit items are confirmed, we can begin. Type" "yeoman" "at your prompt to summon me."
- echo ""
}
-# yeoman art.
-
-art() {
- echo "                                                                                
-                                                                                 
-                                                                                 
-                                                                                 
-                                                                                 
-                                                                                 
-                                                                                 
-                                                                                 
-                                                                                 
-                                                                                 
-                                                                                 
-                                                                                 
-                                                                                 
-                                                                                 
-                                                                                 
-                                                                                 
-                                                                                 
-                                                                                 
-                                                                                 
-                                                                                 
-                                                                                 
-                                                                                 
-                                                                                 
-                                                                                 
-                                                                                 
-                                                                                 
-                                                                                 
-                                                                                 
-                                                                                 
-                                                                                 
-                                                                                 
-                                                                                 
-                                                                                 
-                                                                                 
-                                                                                 
-                                                                                 
-                                                                                 
-                                                                                 
-                                                                                 
-                                                                                 
+# ------------------------------------------------------------------------------
+# | Print |
+# ------------------------------------------------------------------------------
+
+# Print extra descriptions for failure
+desc_print() {
+ echo -e " * $1 $2 $3"
+}
+
+code_print() {
+ echo -e " $1"
+}
+
+# Print all in green and the ✔ and $1 in bold
+happy_print() {
+ echo -e " ✔ $1 $2"
+}
+
+# Print all in red and the ✖ and $1 in bold
+sad_print() {
+ echo -e " ✖ $1 $2"
+}
+
+yeoman_logo() {
+ echo "
+                                                      
+                                                          
+                                                            
+                                                              
+                                                              
+                                                             
+                                                             
+                                                             
+                                                            
+                                                            
+                                                           
+                                                                 
+                                                                
+                                                              
+                                                                
+                                                                 
+                                                                
+                                                               
+                                                            
+                                                             
+                                                                 
+                                                                
+                                                                
+                                                          
+                                                          
+                                                          
+                                                         
+                                                         
+                                                         
+                                                             
+                                                               
+                                                                  
+                                                                    
+                                                                   
+                                                                 
+                                                               
+                                                            
+                                                         
+                                                    
"
}
-# function calls.
-art
-audit
+# ------------------------------------------------------------------------------
+# | Main |
+# ------------------------------------------------------------------------------
+
+main() {
+ get_os_info
+ yeoman_logo
+ audit
+}
+
+main