Created
January 3, 2014 22:53
-
-
Save corbinbs/8248245 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
#!/usr/bin/env bash | |
# | |
# superpack.sh: | |
# | |
# Define components you need to do work. | |
# Quickly. | |
# Superpack downloads/installs stuff so you don't have to. | |
# Blast new developers into productivity on their first day. | |
# | |
# Usage: | |
# superpack.sh [options] | |
# | |
# Options: | |
# -d: The working development directory. Defaults to $HOME/SuperPack. | |
# -h: Displays well meaning, but not entirely helpful, help message. | |
# | |
# Function Definitions | |
# | |
function install_disk_image { | |
# Downloads and installs an OS X Disk Image from the Interwebs. | |
# Parameters: | |
# $1: The image URL | |
# $2: The download directory | |
echo | |
echo "Downloading image from $1" | |
echo | |
DISK_IMAGE_URL="$1" | |
DOWNLOAD_DIRECTORY="$2" | |
cd $DOWNLOAD_DIRECTORY && curl -fLO $DISK_IMAGE_URL && cd - | |
echo | |
echo "Attaching/Mounting Disk Image" | |
echo | |
DISK_IMAGE_FILE=${DISK_IMAGE_URL##*/} | |
VOLUME=`hdiutil attach $DOWNLOAD_DIRECTORY/$DISK_IMAGE_FILE` | |
VOLUME=${VOLUME##* } | |
echo | |
echo "attached volume: $VOLUME" | |
echo "preparing to install $DISK_IMAGE_FILE" | |
echo | |
INSTALL_PKG=`ls $VOLUME/*.pkg` | |
echo | |
echo "Installing $INSTALL_PKG" | |
echo | |
sudo installer -pkg $INSTALL_PKG -target /Volumes/Macintosh\ HD | |
echo | |
echo "Detaching volume: $VOLUME" | |
echo | |
hdiutil detach $VOLUME | |
echo | |
echo "Deleting $DOWNLOAD_DIRECTORY/$DISK_IMAGE_FILE" | |
echo | |
rm $DOWNLOAD_DIRECTORY/$DISK_IMAGE_FILE | |
} | |
# parse script options | |
OPTIND=1 | |
while getopts "h?d:?" opt; do | |
case "$opt" in | |
h|\?) | |
echo | |
echo 'superpack.sh prepares an OS X machine for PokitDok development.' | |
echo | |
echo 'Usage:' | |
echo 'superpack.sh [OPTIONS]' | |
echo | |
echo 'Available options:' | |
echo '-d The working development directory. Defaults to $HOME/Superpack.' | |
echo '-h print this help message' | |
echo | |
exit 0 | |
;; | |
d) DEV_DIR=${OPTARG} | |
;; | |
esac | |
done | |
# | |
# Constants | |
# | |
ANACONDA_LOCATION="$HOME/anaconda" | |
DEFAULT_DIR="$HOME/SuperPack" | |
DOWNLOAD_DIR="$HOME/Downloads" | |
HOMEBREW_LOCATION="$HOME/usr/local/bin/brew" | |
PACKER_LOCATION="$HOME/packer" | |
RVM_LOCATION="$HOME/.rvm" | |
VAGRANT_URL="http://files.vagrantup.com/packages/a40522f5fabccb9ddabad03d836e120ff5d14093/Vagrant-1.3.5.dmg" | |
VAGRANT_CMD="vagrant" | |
VIRTUAL_BOX_CMD="virtualbox" | |
VIRTUAL_BOX_URL="http://download.virtualbox.org/virtualbox/4.3.2/VirtualBox-4.3.2-90405-OSX.dmg" | |
XCODE_VERSION=`xcode-select -v` | |
# Use the default location, if necessary | |
if [ -z $DEV_DIR ]; then | |
DEV_DIR=$DEFAULT_DIR | |
fi | |
echo | |
echo "Target directory = $DEV_DIR" | |
echo | |
mkdir -p $DEV_DIR | |
if [ ! -d $DEV_DIR ]; then | |
echo "Target directory $DEV_DIR does not exist" | |
exit 1 | |
fi | |
# X-Code | |
if [ -z "$XCODE_VERSION" ]; then | |
xcode-select --install | |
read -p "Press enter when the XCode installation is complete" | |
fi | |
# Homebrew | |
# Homebrew needs to be installed prior to RVM so that RVM can use brew to download dependencies | |
if [ ! -a $HOMEBREW_LOCATION ]; then | |
ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go/install)" | |
fi | |
brew update | |
# RVM and associated Ruby Blargity | |
if [ ! -d $RVM_LOCATION ]; then | |
\curl -L https://get.rvm.io | bash -s stable --auto-dotfiles | |
source $HOME/.rvm/scripts/rvm | |
rvm install ruby 2.0.0 | |
rvm docs generate-ri | |
else | |
source $HOME/.rvm/scripts/rvm | |
fi | |
rvm gemset use global | |
gem install chef ohai | |
# Virtual Box | |
hash $VIRTUAL_BOX_CMD 2>/dev/null || { install_disk_image $VIRTUAL_BOX_URL $DOWNLOAD_DIR;} | |
# Vagrant | |
hash $VAGRANT_CMD 2>/dev/null || { install_disk_image $VAGRANT_URL $DOWNLOAD_DIR;} | |
curl -L -O https://rubygems.org/downloads/vagrant-vbguest-0.10.0.pre1.gem | |
vagrant plugin install vagrant-vbguest-0.10.0.pre1.gem | |
rm vagrant-vbguest-0.10.0.pre1.gem | |
vagrant plugin install vagrant-berkshelf | |
vagrant plugin install vagrant-vbox-snapshot | |
vagrant plugin install vagrant-aws | |
# Anaconda | |
if [ ! -d $ANACONDA_LOCATION ]; then | |
curl http://09c8d0b2229f813c1b93-c95ac804525aac4b6dba79b00b39d1d3.r79.cf1.rackcdn.com/Anaconda-1.8.0-MacOSX-x86_64.sh -o anaconda.sh | |
chmod +x anaconda.sh | |
./anaconda.sh -b | |
echo "export PATH="'$HOME/anaconda/bin:$PATH' >> $HOME/.bashrc | |
export PATH="$HOME/anaconda/bin:$PATH" | |
echo 'y' | conda update conda | |
rm anaconda.sh | |
fi | |
# Packer | |
if [ ! -d $PACKER_LOCATION ]; then | |
brew tap homebrew/binary | |
brew install homebrew/binary/packer | |
packer --version | |
fi | |
# Check out projects | |
cd $DEV_DIR | |
#git clone any/all of your projects | |
#then run 'vagrant up' for each of them | |
echo "-----------------------------------------" | |
echo "virtual machines running" | |
echo "You may now 'vagrant ssh' to each VM " | |
echo "-----------------------------------------" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment