Last active
April 15, 2016 19:34
-
-
Save andrewkroh/b6d7dbf691db2ffd78df115ffb3a12fa to your computer and use it in GitHub Desktop.
Beats Vagrant Files
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 | |
set -e | |
# Require these variables to be set. | |
: ${GO_VERSION?"Need to set GO_VERSION"} | |
: ${GOOS?"Need to set GOOS"} | |
: ${GOARCH?"Need to set GOARCH"} | |
function setup_bash_profile() { | |
profile=$1 | |
if [ ! -e "$profile" ]; then touch $profile; fi | |
cat << 'EOF' >> $profile | |
export GO15VENDOREXPERIMENT=1 | |
export GOROOT=/go | |
export GOPATH=$HOME/go | |
export PATH=$GOPATH/bin:$GOROOT/bin:$PATH | |
[ ! -d "$GOPATH" ] && mkdir $GOPATH | |
EOF | |
} | |
function setup_csh_profile() { | |
profile=$1 | |
if [ ! -e "$profile" ]; then touch $profile; fi | |
cat << 'EOF' >> $profile | |
setenv GO15VENDOREXPERIMENT 1 | |
setenv GOROOT /go | |
setenv GOPATH $HOME/go | |
setenv PATH $GOPATH/bin:$GOROOT/bin:$PATH | |
[ ! -d "$GOPATH" ] && mkdir $GOPATH | |
EOF | |
} | |
cd / | |
# Wait for network | |
echo Waiting for network to be available... | |
while [ 1 ]; do curl --silent http://google.com > /dev/null && break; sleep 1; done | |
echo Installing Go | |
if [ ! -e "/go" ]; then | |
base_url="https://storage.googleapis.com/golang" | |
if [ "$GOOS" == "solaris" ]; then | |
base_url="https://s3.amazonaws.com/beats-files/golang" | |
fi | |
curl --silent -O ${base_url}/go${GO_VERSION}.${GOOS}-${GOARCH}.tar.gz | |
gzip -d < go${GO_VERSION}.${GOOS}-${GOARCH}.tar.gz | tar xf - | |
fi | |
echo Configuring golang environment for vagrant and root | |
case $GOOS in | |
solaris) | |
setup_bash_profile /root/.profile | |
setup_bash_profile /export/home/vagrant/.profile | |
pkg install /developer/gcc-48 python-27 virtualenv pip | |
pushd /usr/bin > /dev/null | |
ln -sf 2to3-2.7 2to3 | |
ln -sf cherryd2.7 cherryd | |
ln -sf easy_install-2.7 easy_install | |
ln -sf idle-2.7 idle | |
ln -sf pip-2.7 pip | |
ln -sf pydoc-2.7 pydoc | |
ln -sf python2.7 python | |
ln -sf python2.7-config python-config | |
ln -sf virtualenv-2.7 virtualenv | |
popd > /dev/null | |
;; | |
freebsd) | |
setup_csh_profile /etc/csh.cshrc | |
pkg install -y gcc git py27-virtualenv gmake | |
pushd /usr/local/bin > /dev/null | |
ln -sf python2.7 python | |
popd > /dev/null | |
;; | |
esac | |
echo Done |
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
# -*- mode: ruby -*- | |
# vi: set ft=ruby : | |
# Version of go to download from ports. http://ports.su/lang/go,-main | |
go_version = '1.5.3' | |
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing! | |
VAGRANTFILE_API_VERSION = "2" | |
# Source: https://atlas.hashicorp.com/kaorimatz/boxes/openbsd-5.9-amd64/versions/20160402.0.0 | |
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| | |
config.vm.box = "kaorimatz/openbsd-5.9-amd64" | |
config.vm.synced_folder ".", "/vagrant", type: "rsync" | |
config.vm.provider :virtualbox do |vbox| | |
vbox.check_guest_additions = false | |
vbox.functional_vboxsf = false | |
end | |
config.vm.provider :virtualbox do |vb| | |
vb.customize ["modifyvm", :id, "--memory", "1024"] | |
vb.customize ["modifyvm", :id, "--cpus", "1"] | |
end | |
config.ssh.shell = 'sh' | |
config.vm.provision "shell", inline: "pkg_add -i bash curl go-#{go_version}" | |
config.vm.provision "shell", inline: "chsh -s /usr/local/bin/bash root" | |
config.vm.provision "shell", inline: "chsh -s /usr/local/bin/bash vagrant" | |
config.vm.provision "shell" do |s| | |
s.path = "../provision.sh" | |
s.env = { | |
"INSTALL_GO" => "0", | |
"GOROOT" => "/usr/local/go", | |
"GO_VERSION" => go_version, | |
"GOOS" => "openbsd", | |
"GOARCH" => "amd64", | |
} | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment