Skip to content

Instantly share code, notes, and snippets.

@seeker815
Created June 16, 2017 10:01
Show Gist options
  • Save seeker815/a3931ba3afd2757374134008533098d8 to your computer and use it in GitHub Desktop.
Save seeker815/a3931ba3afd2757374134008533098d8 to your computer and use it in GitHub Desktop.
Installs Chef
#!/bin/bash
# Ensure we're not running as root
if [ $EUID -eq 0 ] ; then
echo "Do not run as root!" 1>&2
exit 1
fi
# Install base packages
which lsb_release
rc=$?
set -x
if [ $rc -eq 0 ] ; then
# Ubuntu
sudo apt-get update
sudo apt-get install -y python-software-properties software-properties-common
sudo apt-add-repository -y ppa:brightbox/ruby-ng
sudo apt-get update
sudo apt-get install -y virtualbox curl ruby2.3 ruby2.3-dev build-essential libqtcore4 libqtgui4 libqt4-dev libboost-dev zlib1g-dev jq
sudo update-alternatives --set ruby /usr/bin/ruby2.3
sudo update-alternatives --set gem /usr/bin/gem2.3
pushd /tmp
curl -O -sLf https://releases.hashicorp.com/vagrant/1.9.5/vagrant_1.9.5_x86_64.deb
sudo dpkg -i vagrant_1.9.5_x86_64.deb
rm vagrant_1.9.5_x86_64.deb
OS=$(lsb_release -sr)
curl -O -sLf "https://packages.chef.io/files/stable/chefdk/1.4.3/ubuntu/$OS/chefdk_1.4.3-1_amd64.deb"
sudo dpkg -i chefdk_1.4.3-1_amd64.deb
rm chefdk_1.4.3-1_amd64.deb
curl -O -sLf "http://us.archive.ubuntu.com/ubuntu/pool/universe/g/gecode/libgecode30_3.7.1-3_amd64.deb"
curl -O -sLf "http://us.archive.ubuntu.com/ubuntu/pool/universe/g/gecode/libgecode-dev_3.7.1-3_amd64.deb"
curl -O -sLf "http://us.archive.ubuntu.com/ubuntu/pool/universe/g/gecode/libgecodegist30_3.7.1-3_amd64.deb"
curl -O -sLf "http://us.archive.ubuntu.com/ubuntu/pool/universe/g/gecode/libgecodeflatzinc30_3.7.1-3_amd64.deb"
sudo dpkg -i libgecode30_3.7.1-3_amd64.deb libgecodegist30_3.7.1-3_amd64.deb libgecodeflatzinc30_3.7.1-3_amd64.deb libgecode-dev_3.7.1-3_amd64.deb
export USE_SYSTEM_GECODE=1
popd
else
# Mac OS X
sudo chown -R "$(whoami):staff" /usr/local
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew tap homebrew/versions
brew install libxml2 libxslt jq
brew tap caskroom/cask
brew install brew-cask
brew cask install virtualbox
pushd /tmp
curl -O -sLf https://releases.hashicorp.com/vagrant/1.9.5/vagrant_1.9.5_x86_64.dmg
hdiutil attach vagrant_1.9.5_x86_64.dmg
sudo installer -pkg /Volumes/Vagrant/Vagrant.pkg -target /
hdiutil detach vagrant_1.9.5_x86_64.dmg
rm vagrant_1.9.5_x86_64.dmg
curl -O -sLf https://packages.chef.io/files/stable/chefdk/1.4.3/mac_os_x/10.12/chefdk-1.4.3-1.dmg
hdiutil attach chefdk-1.4.3-1.dmg
sudo installer -pkg '/Volumes/Chef Development Kit/chefdk-1.4.3.1.pkg' -target /
hdiutil detach chefdk-1.4.3-1.dmg
rm chefdk-1.4.3-1.dmg
popd
fi
# Install gems, plugins, configs, &c.
cd /vagrant
sudo gem install bundler
bundle
vagrant plugin install vagrant-berkshelf
vagrant plugin install vagrant-hostmanager
vagrant plugin install vagrant-omnibus
vagrant plugin install vagrant-cachier
mkdir -p ~/.berkshelf
cat << END > ~/.berkshelf/config.json
{
"chef": {
"client_key": "/dev/null"
}
}
END
echo "Enter your gitlab token. It can be found here: http://git.bjn.io/profile/account"
read token
cat << END > ~/.bourdain.json
{
"gitlab": {
"token": "$token"
}
}
END
echo "If you need to change the token, you can edit ~/.bourdain.json"
bundle exec tony check
# GTFO
cat << END
===============
Done! You may want to add the following alias to your profile, so you can run "bundle exec" more simply
alias bx="bundle exec"
END
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment