Permalink
Browse files

Remove linux-prereq script by switching to Bash

Required changes:

* Change #!
* Move pre-req actions directly into linux
* Switch uses of $+command for which (zsh-ism)
* Don't source ~/.zshrc to pickup new exports
* Add setting of zsh as $SHELL
* Update README

Ancillary changes:

* Switch [ with [[ (best practice)
* Switch if-newline-then with if; then (style)
* Use $( ) and $(( )) (best practice)
* Switch wget with curl (consistency)
  • Loading branch information...
1 parent 499c816 commit 5d749c0aed643770d8f806734b38b0a55bea3999 @pbrisbin pbrisbin committed Nov 26, 2013
View
3 Manifest.linux
@@ -1,11 +1,12 @@
-common-components/zsh-shebang
+common-components/bash-shebang
common-components/header
common-components/exit-trap
common-components/check-home-bin
common-components/shared-functions
linux-components/distro-check
linux-components/debian-package-update
linux-components/debian-derivative-packages
+common-components/zsh
linux-components/silver-searcher-from-source
linux-components/rbenv
common-components/ruby-environment
View
7 Manifest.linux-prerequisites
@@ -1,7 +0,0 @@
-common-components/sh-shebang
-common-components/header
-common-components/exit-trap
-common-components/shared-functions
-linux-components/distro-check
-linux-components/debian-package-update
-linux-components/debian-prerequisites
View
3 Manifest.mac
@@ -1,8 +1,9 @@
-common-components/zsh-shebang
+common-components/bash-shebang
common-components/header
common-components/exit-trap
common-components/check-home-bin
common-components/shared-functions
+common-components/zsh
mac-components/zsh-fix
mac-components/homebrew
mac-components/packages
View
15 README.md
@@ -8,7 +8,7 @@ Requirements
### Mac OS X
-1) Install a C compiler.
+Install a C compiler:
For Snow Leopard (10.6): use [OS X GCC
Installer](https://github.com/kennethreitz/osx-gcc-installer/).
@@ -20,10 +20,6 @@ For Mavericks (10.9): run `sudo xcodebuild -license` and follow the instructions
to accept the XCode agreement. Then run `xcode-select --install` in your
terminal and then click "Install".
-2) Set zsh as your login shell:
-
- chsh -s /bin/zsh
-
### Linux
We support:
@@ -35,28 +31,25 @@ We support:
* Debian stable (currently [wheezy](http://www.debian.org/releases/stable/)).
* Debian testing (currently [jessie](http://www.debian.org/releases/testing/)).
-1) Install zsh and set it as your login shell:
-
- bash <(wget -qO- https://raw.github.com/thoughtbot/laptop/master/linux-prerequisites)
-
Install
-------
### Mac OS X
Read, then run the script:
- zsh <(curl -s https://raw.github.com/thoughtbot/laptop/master/mac)
+ bash <(curl -s https://raw.github.com/thoughtbot/laptop/master/mac)
### Linux
Read, then run the script:
- zsh <(wget -qO- https://raw.github.com/thoughtbot/laptop/master/linux)
+ bash <(wget -qO- https://raw.github.com/thoughtbot/laptop/master/linux)
What it sets up
---------------
+* Zsh as your shell
* Bundler gem for managing Ruby libraries
* Exuberant Ctags for indexing files for vim tab completion
* Foreman gem for serving Rails apps locally
View
1 common-components/bash-shebang
@@ -0,0 +1 @@
+#!/usr/bin/env bash
View
4 common-components/check-home-bin
@@ -1,4 +1,4 @@
-if [ ! -d "$HOME/.bin/" ]; then
+if [[ ! -d "$HOME/.bin/" ]]; then
mkdir "$HOME/.bin"
fi
@@ -8,5 +8,5 @@ fi
if [[ ":$PATH:" != *":$HOME/.bin:"* ]]; then
echo 'export PATH="$HOME/.bin:$PATH"' >> ~/.zshrc
- source ~/.zshrc
+ export PATH="$HOME/.bin:$PATH"
fi
View
2 common-components/zsh
@@ -0,0 +1,2 @@
+fancy_echo "Changing your shell to zsh ..."
+ chsh -s $(which zsh)
View
1 common-components/zsh-shebang
@@ -1 +0,0 @@
-#!/usr/bin/env zsh
View
33 linux
@@ -1,5 +1,5 @@
-#!/usr/bin/env zsh
-### end common-components/zsh-shebang
+#!/usr/bin/env bash
+### end common-components/bash-shebang
# Welcome to the thoughtbot laptop script! Be prepared to turn your laptop (or
# desktop, no haters here) into an awesome development machine.
@@ -13,7 +13,7 @@ trap 'ret=$?; test $ret -ne 0 && printf "failed\n\n" >&2; exit $ret' EXIT
set -e
### end common-components/exit-trap
-if [ ! -d "$HOME/.bin/" ]; then
+if [[ ! -d "$HOME/.bin/" ]]; then
mkdir "$HOME/.bin"
fi
@@ -23,7 +23,7 @@ fi
if [[ ":$PATH:" != *":$HOME/.bin:"* ]]; then
echo 'export PATH="$HOME/.bin:$PATH"' >> ~/.zshrc
- source ~/.zshrc
+ export PATH="$HOME/.bin:$PATH"
fi
### end common-components/check-home-bin
@@ -32,8 +32,7 @@ fancy_echo() {
}
### end common-components/shared-functions
-if ! grep -qiE 'precise|quantal|wheezy|raring|jessie|saucy' /etc/os-release
-then
+if ! grep -qiE 'precise|quantal|wheezy|raring|jessie|saucy' /etc/os-release; then
fancy_echo "Sorry! we don't currently support that distro."
exit 1
fi
@@ -46,6 +45,7 @@ fancy_echo "Updating system packages ..."
fancy_echo "Installing aptitude ..."
sudo apt-get install -y aptitude
fi
+
sudo aptitude update
### end linux-components/debian-package-update
@@ -78,9 +78,19 @@ fancy_echo "Installing ImageMagick, to crop and resize images ..."
fancy_echo "Installing watch, to execute a program periodically and show the output ..."
sudo aptitude install -y watch
+
+fancy_echo "Installing curl ..."
+ sudo aptitude install -y curl
+
+fancy_echo "Installing zsh ..."
+ sudo aptitude install -y zsh
### end linux-components/debian-derivative-packages
-if [[ $+commands[ag] -ne 1 ]]; then
+fancy_echo "Changing your shell to zsh ..."
+ chsh -s $(which zsh)
+### end common-components/zsh
+
+if ! which ag &>/dev/null; then
fancy_echo "Installing The Silver Searcher (better than ack or grep) to search the contents of files ..."
git clone git://github.com/ggreer/the_silver_searcher.git /tmp/the_silver_searcher
sudo aptitude install -y automake pkg-config libpcre3-dev zlib1g-dev liblzma-dev
@@ -103,7 +113,8 @@ if [[ ! -d "$HOME/.rbenv" ]]; then
echo 'eval "$(rbenv init - --no-rehash)"' >> ~/.zshrc
fi
- source ~/.zshrc
+ export PATH="$HOME/.rbenv/bin:$PATH"
+ eval "$(rbenv init -)"
fi
if [[ ! -d "$HOME/.rbenv/plugins/rbenv-gem-rehash" ]]; then
@@ -138,16 +149,16 @@ fancy_echo "Installing GitHub CLI client ..."
### end common-components/ruby-environment
fancy_echo "Configuring Bundler for faster, parallel gem installation ..."
- number_of_cores=`nproc`
- bundle config --global jobs `expr $number_of_cores - 1`
+ number_of_cores=$(nproc)
+ bundle config --global jobs $((number_of_cores - 1))
### end linux-components/bundler
fancy_echo "Installing Rails ..."
gem install rails --no-document
### end common-components/default-gems
fancy_echo "Installing Heroku CLI client ..."
- wget -qO- https://toolbelt.heroku.com/install-ubuntu.sh | sh
+ curl -s https://toolbelt.heroku.com/install-ubuntu.sh | sh
fancy_echo "Installing the heroku-config plugin to pull config variables locally to be used as ENV variables ..."
heroku plugins:install git://github.com/ddollar/heroku-config.git
View
4 linux-components/bundler
@@ -1,3 +1,3 @@
fancy_echo "Configuring Bundler for faster, parallel gem installation ..."
- number_of_cores=`nproc`
- bundle config --global jobs `expr $number_of_cores - 1`
+ number_of_cores=$(nproc)
+ bundle config --global jobs $((number_of_cores - 1))
View
6 linux-components/debian-derivative-packages
@@ -27,3 +27,9 @@ fancy_echo "Installing ImageMagick, to crop and resize images ..."
fancy_echo "Installing watch, to execute a program periodically and show the output ..."
sudo aptitude install -y watch
+
+fancy_echo "Installing curl ..."
+ sudo aptitude install -y curl
+
+fancy_echo "Installing zsh ..."
+ sudo aptitude install -y zsh
View
1 linux-components/debian-package-update
@@ -5,4 +5,5 @@ fancy_echo "Updating system packages ..."
fancy_echo "Installing aptitude ..."
sudo apt-get install -y aptitude
fi
+
sudo aptitude update
View
17 linux-components/debian-prerequisites
@@ -1,17 +0,0 @@
-fancy_echo "Installing curl ..."
- sudo aptitude install -y curl
-
-fancy_echo "Installing zsh ..."
- sudo aptitude install -y zsh
-
-ZSH_PATH=`which zsh`
-
-if [[ $SHELL == $ZSH_PATH ]]; then
- fancy_echo "Already using zsh as your login shell. Huzzah!"
-else
- fancy_echo "Changing your shell to zsh ..."
- chsh -s $ZSH_PATH
-
- fancy_echo "Your shell will now restart to apply changes."
- exec $ZSH_PATH -l
-fi
View
3 linux-components/distro-check
@@ -1,5 +1,4 @@
-if ! grep -qiE 'precise|quantal|wheezy|raring|jessie|saucy' /etc/os-release
-then
+if ! grep -qiE 'precise|quantal|wheezy|raring|jessie|saucy' /etc/os-release; then
fancy_echo "Sorry! we don't currently support that distro."
exit 1
fi
View
2 linux-components/heroku
@@ -1,5 +1,5 @@
fancy_echo "Installing Heroku CLI client ..."
- wget -qO- https://toolbelt.heroku.com/install-ubuntu.sh | sh
+ curl -s https://toolbelt.heroku.com/install-ubuntu.sh | sh
fancy_echo "Installing the heroku-config plugin to pull config variables locally to be used as ENV variables ..."
heroku plugins:install git://github.com/ddollar/heroku-config.git
View
3 linux-components/rbenv
@@ -8,7 +8,8 @@ if [[ ! -d "$HOME/.rbenv" ]]; then
echo 'eval "$(rbenv init - --no-rehash)"' >> ~/.zshrc
fi
- source ~/.zshrc
+ export PATH="$HOME/.rbenv/bin:$PATH"
+ eval "$(rbenv init -)"
fi
if [[ ! -d "$HOME/.rbenv/plugins/rbenv-gem-rehash" ]]; then
View
2 linux-components/silver-searcher-from-source
@@ -1,4 +1,4 @@
-if [[ $+commands[ag] -ne 1 ]]; then
+if ! which ag &>/dev/null; then
fancy_echo "Installing The Silver Searcher (better than ack or grep) to search the contents of files ..."
git clone git://github.com/ggreer/the_silver_searcher.git /tmp/the_silver_searcher
sudo aptitude install -y automake pkg-config libpcre3-dev zlib1g-dev liblzma-dev
View
56 linux-prerequisites
@@ -1,56 +0,0 @@
-#!/bin/sh
-### end common-components/sh-shebang
-
-# Welcome to the thoughtbot laptop script! Be prepared to turn your laptop (or
-# desktop, no haters here) into an awesome development machine.
-
-# This file is auto-generated. Do not edit it by hand unless you know what
-# you're doing. Please see 'CONTRIBUTING.md' for more information.
-### end common-components/header
-
-trap 'ret=$?; test $ret -ne 0 && printf "failed\n\n" >&2; exit $ret' EXIT
-
-set -e
-### end common-components/exit-trap
-
-fancy_echo() {
- printf "\n%b\n" "$1"
-}
-### end common-components/shared-functions
-
-if ! grep -qiE 'precise|quantal|wheezy|raring|jessie|saucy' /etc/os-release
-then
- fancy_echo "Sorry! we don't currently support that distro."
- exit 1
-fi
-### end linux-components/distro-check
-
-fancy_echo "Updating system packages ..."
- if command -v aptitude >/dev/null; then
- fancy_echo "Using aptitude ..."
- else
- fancy_echo "Installing aptitude ..."
- sudo apt-get install -y aptitude
- fi
- sudo aptitude update
-### end linux-components/debian-package-update
-
-fancy_echo "Installing curl ..."
- sudo aptitude install -y curl
-
-fancy_echo "Installing zsh ..."
- sudo aptitude install -y zsh
-
-ZSH_PATH=`which zsh`
-
-if [[ $SHELL == $ZSH_PATH ]]; then
- fancy_echo "Already using zsh as your login shell. Huzzah!"
-else
- fancy_echo "Changing your shell to zsh ..."
- chsh -s $ZSH_PATH
-
- fancy_echo "Your shell will now restart to apply changes."
- exec $ZSH_PATH -l
-fi
-### end linux-components/debian-prerequisites
-
View
23 mac
@@ -1,5 +1,5 @@
-#!/usr/bin/env zsh
-### end common-components/zsh-shebang
+#!/usr/bin/env bash
+### end common-components/bash-shebang
# Welcome to the thoughtbot laptop script! Be prepared to turn your laptop (or
# desktop, no haters here) into an awesome development machine.
@@ -13,7 +13,7 @@ trap 'ret=$?; test $ret -ne 0 && printf "failed\n\n" >&2; exit $ret' EXIT
set -e
### end common-components/exit-trap
-if [ ! -d "$HOME/.bin/" ]; then
+if [[ ! -d "$HOME/.bin/" ]]; then
mkdir "$HOME/.bin"
fi
@@ -23,7 +23,7 @@ fi
if [[ ":$PATH:" != *":$HOME/.bin:"* ]]; then
echo 'export PATH="$HOME/.bin:$PATH"' >> ~/.zshrc
- source ~/.zshrc
+ export PATH="$HOME/.bin:$PATH"
fi
### end common-components/check-home-bin
@@ -32,13 +32,17 @@ fancy_echo() {
}
### end common-components/shared-functions
+fancy_echo "Changing your shell to zsh ..."
+ chsh -s $(which zsh)
+### end common-components/zsh
+
if [[ -f /etc/zshenv ]]; then
fancy_echo "Fixing OSX zsh environment bug ..."
sudo mv /etc/{zshenv,zshrc}
fi
### end mac-components/zsh-fix
-if (( ! $+commands[brew] )); then
+if ! which brew &>/dev/null; then
fancy_echo "Installing Homebrew, a good OS X package manager ..."
ruby <(curl -fsS https://raw.github.com/Homebrew/homebrew/go/install)
brew update
@@ -47,7 +51,7 @@ if (( ! $+commands[brew] )); then
fancy_echo "Put Homebrew location earlier in PATH ..."
echo "\n# recommended by brew doctor" >> ~/.zshrc
echo "export PATH=\"/usr/local/bin:\$PATH\"\n" >> ~/.zshrc
- source ~/.zshrc
+ export PATH="/usr/local/bin:$PATH"
fi
else
fancy_echo "Homebrew already installed. Skipping ..."
@@ -89,13 +93,14 @@ fancy_echo "Installing rbenv, to change Ruby versions ..."
brew install rbenv
if ! grep -qs "rbenv init" ~/.zshrc; then
+ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.zshrc
echo 'eval "$(rbenv init - --no-rehash)"' >> ~/.zshrc
fancy_echo "Enable shims and autocompletion ..."
eval "$(rbenv init -)"
fi
- source ~/.zshrc
+ export PATH="$HOME/.rbenv/bin:$PATH"
fancy_echo "Installing rbenv-gem-rehash so the shell automatically picks up binaries after installing gems with binaries..."
brew install rbenv-gem-rehash
@@ -135,8 +140,8 @@ fancy_echo "Installing GitHub CLI client ..."
### end common-components/ruby-environment
fancy_echo "Configuring Bundler for faster, parallel gem installation ..."
- number_of_cores=`sysctl -n hw.ncpu`
- bundle config --global jobs `expr $number_of_cores - 1`
+ number_of_cores=$(sysctl -n hw.ncpu)
+ bundle config --global jobs $((number_of_cores - 1))
### end mac-components/bundler
fancy_echo "Installing Rails ..."
View
4 mac-components/bundler
@@ -1,3 +1,3 @@
fancy_echo "Configuring Bundler for faster, parallel gem installation ..."
- number_of_cores=`sysctl -n hw.ncpu`
- bundle config --global jobs `expr $number_of_cores - 1`
+ number_of_cores=$(sysctl -n hw.ncpu)
+ bundle config --global jobs $((number_of_cores - 1))
View
4 mac-components/homebrew
@@ -1,4 +1,4 @@
-if (( ! $+commands[brew] )); then
+if ! which brew &>/dev/null; then
fancy_echo "Installing Homebrew, a good OS X package manager ..."
ruby <(curl -fsS https://raw.github.com/Homebrew/homebrew/go/install)
brew update
@@ -7,7 +7,7 @@ if (( ! $+commands[brew] )); then
fancy_echo "Put Homebrew location earlier in PATH ..."
echo "\n# recommended by brew doctor" >> ~/.zshrc
echo "export PATH=\"/usr/local/bin:\$PATH\"\n" >> ~/.zshrc
- source ~/.zshrc
+ export PATH="/usr/local/bin:$PATH"
fi
else
fancy_echo "Homebrew already installed. Skipping ..."
View
3 mac-components/rbenv
@@ -2,13 +2,14 @@ fancy_echo "Installing rbenv, to change Ruby versions ..."
brew install rbenv
if ! grep -qs "rbenv init" ~/.zshrc; then
+ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.zshrc
echo 'eval "$(rbenv init - --no-rehash)"' >> ~/.zshrc
fancy_echo "Enable shims and autocompletion ..."
eval "$(rbenv init -)"
fi
- source ~/.zshrc
+ export PATH="$HOME/.rbenv/bin:$PATH"
fancy_echo "Installing rbenv-gem-rehash so the shell automatically picks up binaries after installing gems with binaries..."
brew install rbenv-gem-rehash
View
13 test/runner.sh
@@ -28,22 +28,17 @@ for vagrantfile in test/Vagrantfile.*; do
# TODO: Create a Vagrantfile.mac that uses VMWare Fusion to run OSX
if echo "$vagrantfile" | grep -q '\.mac$'; then
- vagrant ssh -c 'echo vagrant | zsh /vagrant/mac' \
+ vagrant ssh -c 'echo vagrant | bash /vagrant/mac' \
|| failure 'Installation script failed to run'
else
- vagrant ssh -c 'echo vagrant | sh /vagrant/linux-prerequisites' \
- || failure 'Prerequisite script failed to run'
-
- vagrant ssh -c 'zsh /vagrant/linux' \
+ vagrant ssh -c 'echo vagrant | bash /vagrant/linux' \
|| failure 'Installation script failed to run'
fi
- [ "$(vagrant ssh -c 'echo $SHELL')" = '/usr/bin/zsh' ] \
+ vagrant ssh -c '[ "$SHELL" = "/usr/bin/zsh" ]' \
|| failure 'Installation did not set $SHELL to ZSH'
- ruby="$(vagrant ssh -c 'zsh -i -l -c "ruby --version" | cut -d" " -f 1-2')"
-
- [ "$ruby" = 'ruby 2.0.0p247' ] \
+ vagrant ssh -c 'zsh -i -l -c "ruby --version" | grep -Fq "ruby 2.1.0"' \
|| failure 'Installation did not install the correct ruby'
message "$vagrantfile tested successfully, shutting down VM"

0 comments on commit 5d749c0

Please sign in to comment.