Skip to content

Instantly share code, notes, and snippets.

@esparkman
Forked from therubymug/the_install.sh
Last active October 1, 2015 05:48
Show Gist options
  • Save esparkman/1932717 to your computer and use it in GitHub Desktop.
Save esparkman/1932717 to your computer and use it in GitHub Desktop.
Ruby development environment for OS X (Lion)
test -f /tmp/the_install.sh && rm /tmp/the_install.sh
curl -s\
https://gist.github.com/esparkman/1932717/raw/a9fd42b5d0667ac0965d413e6099527d422d2143/the_install.sh\
-o /tmp/the_install.sh
chmod 0700 /tmp/the_install.sh
. /tmp/the_install.sh
#!/usr/bin/env sh
# Title: Ruby development environment for OS X (Lion)
# Author: Rogelio J. Samour
# Warning:
# While it is unlikely any code below might damage your system,
# it’s always a good idea to back up everything that matters to you
# before running this script! Just in case. I am not responsible for
# anything that may result from running this script. Proceed at
# your own risk.
# License: See below
OSX_VERSION=$(sw_vers | grep ProductVersion | awk -F: '{print $2}')
JAVA_FOR_LION_URL=http://support.apple.com/downloads/DL1572/en_US/JavaForOSX2013-001.dmg
JAVA_PACKAGE=$(pkgutil --pkgs=com.apple.pkg.JavaForMacOSX107)
if [[ $OSX_VERSION =~ "10.7*" ]]; then
echo "You're not running OS X 10.7 (Lion)"
read -p "This script is meant to be run on Lion!"
exit 0
fi
if [ -f "/Developer/Library/uninstall-tools" ]; then
echo -p "Xcode pre-4.3 detected."
elif
[ -f "/usr/bin/gcc" ]; then
echo "Xcode 4.3+ detected."
else
read -p "Please install Xcode and re-run this script"
exit 0
fi
if [[ $JAVA_PACKAGE != "com.apple.pkg.JavaForMacOSX107" && $OSX_VERSION =~ "10.7*" ]]; then
echo 'Installing java, believe it or not!'
curl -L $JAVA_FOR_LION_URL -o /tmp/java.dmg
sudo hdid /tmp/java.dmg
sudo installer -pkg "/Volumes/Java for Mac OS X 10.7/JavaForMacOSX10.7.pkg" -target /
sudo hdiutil detach "/Volumes/Java for Mac OS X 10.7"
else
echo 'java already installed'
fi
if [ ! -f "$HOME/.ssh/id_rsa.pub" ]; then
echo "Please enter your email: "
read email
ssh-keygen -t rsa -C "$email"
cat $HOME/.ssh/id_rsa.pub
cat $HOME/.ssh/id_rsa.pub | pbcopy
read -p "Your public ssh key is in your pasteboard. Add it to github.com and hit Return"
fi
if ! command -v brew > /dev/null; then
echo "Installing homebrew"
sudo mkdir /usr/local > /dev/null
sudo chown -R `whoami` /usr/local
curl -L https://github.com/mxcl/homebrew/tarball/master | tar xz --strip 1 -C /usr/local
fi
brew list git > /dev/null
if [[ "$?" -eq "1" ]]; then
brew install git
fi
echo "Fixing samba streams on OS X"
echo "[default]" > $HOME/Library/Preferences/nsmb.conf
echo "streams=no" >> $HOME/Library/Preferences/nsmb.conf
echo "Removing system gems"
sudo gem update --system > /dev/null
sudo gem clean > /dev/null
echo "Making .bash_profile source .bashrc"
echo '. "$HOME/.bashrc"' > $HOME/.bash_profile
echo "Homebrew is installing ack, ctags-exuberant, imagemagick, macvim, markdown, proctools and wget"
for app in ack ctags-exuberant imagemagick macvim markdown proctools wget; do
brew list $app > /dev/null
if [[ "$?" -eq "1" ]]; then
brew install $app
fi
done
echo "Preparing system for dotmatrix"
mkdir $HOME/hashrocket
cd $HOME/hashrocket
if [ ! -d "$HOME/hashrocket/dotmatrix" ]; then
git clone https://github.com/hashrocket/dotmatrix.git
else
cd dotmatrix
git pull --rebase
fi
echo "Symlinking dotmatrix dotfiles"
test -f $HOME/.bashrc && mv $HOME/.bashrc{,.bak}
test -f $HOME/.vim && mv $HOME/.vim{,.bak}
test -f $HOME/.vimrc && mv $HOME/.vimrc{,.bak}
ln -nfs $HOME/hashrocket/dotmatrix/.bashrc $HOME/
ln -nfs $HOME/hashrocket/dotmatrix/.hashrc $HOME/
ln -nfs $HOME/hashrocket/dotmatrix/.vim $HOME/
ln -nfs $HOME/hashrocket/dotmatrix/.vimrc $HOME/
sh $HOME/hashrocket/dotmatrix/bin/vimbundles.sh
if [ ! -d $HOME/.rvm ]; then
echo "Building rvm"
\curl -L https://get.rvm.io | bash -s stable --ruby
fi
grep 'rvm_project_rvmrc_default' $HOME/.rvmrc > /dev/null
if [[ "$?" -ne "0" ]]; then
echo "rvm: Enable switching to default / system ruby when leaving a directory"
echo 'rvm_project_rvmrc_default=1' > $HOME/.rvmrc
fi
echo "Declare global gems"
cat > $HOME/.rvm/gemsets/global.gems <<GLOBALGEMS
hitch
dirty
github
GLOBALGEMS
rvm list strings | grep ruby-1.9.3 > /dev/null
if [[ "$?" -ne "0" ]]; then
echo "rvm is installing ruby 1.9.3"
rvm install 1.9.3 -C --enable-shared=yes
rvm use 1.9.3 --default
fi
echo "Writing .gemrc"
cat > $HOME/.gemrc <<GEMRC
---
:benchmark: false
gem: --no-ri --no-rdoc
:update_sources: true
:bulk_threshold: 1000
:verbose: true
:sources:
- https://rubygems.org
:backtrace: false
GEMRC
echo "Downloading Postgresapp"
curl -L http://postgres-app.s3.amazonaws.com/PostgresApp-9-2-2-0.zip -o ~/Downloads/Postgresapp.zip
#brew list postgresql > /dev/null
#if [[ "$?" -eq "1" ]]; then
# echo "Installing PostgreSQL"
# brew install postgresql
# brew cleanup; brew prune
# POSTGRESQL_VERSION=$(brew list postgresql | awk -F/ '{print $6}' | head -n 1)
# test -d /usr/local/var/postgres || initdb /usr/local/var/postgres
# test -d $HOME/Library/LaunchAgents || mkdir -p $HOME/Library/LaunchAgents
# test -f $HOME/Library/LaunchAgents/org.postgresql.postgres.plist &&
# launchctl unload -w $HOME/Library/LaunchAgents/org.postgresql.postgres.plist
# cp -f /usr/local/Cellar/postgresql/$POSTGRESQL_VERSION/org.postgresql.postgres.plist $HOME/Library/LaunchAgents/
# launchctl load -w $HOME/Library/LaunchAgents/org.postgresql.postgres.plist
#else
# echo "PostgreSQL already installed"
#fi
# Follow the same pattern for MySQL if you feel inclined.
# Here's how you'd install Mongo:
brew list mongodb > /dev/null
if [[ "$?" -eq "1" ]]; then
echo "Installing MongoDB"
brew install mongodb # if you want the latest version 2.x
# brew install https://raw.github.com/mxcl/homebrew/6d46eec8cb6bdf6d6575f8272f12937ea64b8284/Library/Formula/mongodb.rb # if you want version 1.8.3
brew cleanup; brew prune
MONGODB_VERSION=$(brew list mongodb | awk -F/ '{print $6}' | head -n 1)
test -d $HOME/Library/LaunchAgents || mkdir -p $HOME/Library/LaunchAgents
test -f $HOME/Library/LaunchAgents/org.mongodb.mongod.plist &&
launchctl unload -w $HOME/Library/LaunchAgents/org.mongodb.mongod.plist
cp /usr/local/Cellar/mongodb/$MONGODB_VERSION/org.mongodb.mongod.plist $HOME/Library/LaunchAgents/
launchctl load -w $HOME/Library/LaunchAgents/org.mongodb.mongod.plist
else
echo "MongoDB already installed"
fi
echo "Finished."
# Copyright (c) 2011 Rogelio J. Samour
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment