Skip to content

Instantly share code, notes, and snippets.

@thewoolleyman
Created May 15, 2011 10:11
Show Gist options
  • Save thewoolleyman/973026 to your computer and use it in GitHub Desktop.
Save thewoolleyman/973026 to your computer and use it in GitHub Desktop.
chef_client_osx_bootstrap.sh
#!/usr/bin/env bash
######
#
# Script to bootstrap an OSX workstation to use chef client (not chef solo)
# via an RVM-installed Ruby interpreter (not the OSX system default ruby)
#
#
# Override RVM version with $rvm_version
# Override RVM Ruby Interpreter install version/options with $ruby_version
#
# After running this, see http://help.opscode.com/kb/start/how-to-get-started
#
######
enable_rvm() {
echo "Enabling RVM in init file $init_file"
rvm_init="if [[ -s $HOME/.rvm/scripts/rvm ]] ; then source $HOME/.rvm/scripts/rvm ; fi"
if [[ -z $(grep '.rvm' $init_file) ]] ; then
echo $rvm_init >> $init_file
echo "Added RVM line to $init_file"
else
echo "Not adding RVM line to $init_file because it already contains references to '.rvm' ..."
fi
}
echo "Downloading RVM installer"
cd /tmp
curl -s https://rvm.beginrescueend.com/install/rvm -o rvm-installer
chmod +x rvm-installer
rvm_version=${rvm_version:-'1.5.4'} # Wayne's having some issues with latest 1.6, heh...
echo "Installing rvm version '$rvm_version'"
./rvm-installer --version $rvm_version
touch $HOME/.bashrc # ensure at least a .bashrc exists
for init_file in $HOME/.bashrc $HOME/.bash_profile
do
if [[ -e $init_file ]] ; then
enable_rvm
fi
done
echo "sourcing $HOME/.bashrc to reload RVM"
source $HOME/.bashrc
ruby_version=${ruby_version:-'1.9.2'}
if [[ -z $(ruby --version | grep $ruby_version) ]] ; then
echo "Installing RVM Ruby interpreter $ruby_version"
rvm install $rvm_install_string
rvm use $rvm_install_string --default
else
echo "Ruby interpreter $ruby_version is already installed, not reinstalling"
fi
for rvm_package in readline autoconf openssl
do
rvm package install $rvm_package
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment