Skip to content

Instantly share code, notes, and snippets.

@mdaniel
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mdaniel/9776375 to your computer and use it in GitHub Desktop.
Save mdaniel/9776375 to your computer and use it in GitHub Desktop.
Vagrantfile for provisioning Sandstorm.io on Ubuntu 13.10
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = '2'
$script = <<SCRIPT1
## be aware this script runs as root
set -e
CAPNPROTO_GITROOT="https://github.com/kentonv/capnproto.git"
## must use the "file:" protocol in order to get shallow clones
if [ -f /vagrant/capnproto/.git/config ]; then
CAPNPROTO_GITROOT="file:///vagrant/capnproto/.git"
fi
LIBSODIUM_GITROOT="https://github.com/jedisct1/libsodium.git"
if [ -f /vagrant/libsodium/.git/config ]; then
LIBSODIUM_GITROOT="file:///vagrant/libsodium/.git"
fi
SANDSTORM_GITROOT="https://github.com/kentonv/sandstorm.git"
if [ -f /vagrant/sandstorm/.git/config ]; then
SANDSTORM_GITROOT="file:///vagrant/sandstorm/.git"
fi
function chown_vagrant() {
chown -R vagrant:vagrant ~vagrant
}
trap chown_vagrant EXIT
if [ -f /vagrant/var_cache_apt.tar ]; then
# prevent re-downloading all the things
# during development recycles of the vm
tar xf /vagrant/var_cache_apt.tar -C /
fi
cat >/etc/apt/sources.list.d/llvm.list<<LLVM1
deb http://llvm.org/apt/saucy/ llvm-toolchain-saucy main
deb-src http://llvm.org/apt/saucy/ llvm-toolchain-saucy main
# 3.4
deb http://llvm.org/apt/saucy/ llvm-toolchain-saucy-3.4 main
deb-src http://llvm.org/apt/saucy/ llvm-toolchain-saucy-3.4 main
LLVM1
if [ -f /vagrant/llvm.gpg.key ]; then
cat f /vagrant/llvm.gpg.key | apt-key add -
else
curl --silent http://llvm.org/apt/llvm-snapshot.gpg.key | apt-key add -
fi
apt-get update
apt-get install -y \
autoconf automake libtool make build-essential pkg-config \
clang-3.4 libcap-dev git subversion \
nodejs-dev npm
cd ~vagrant
git clone --depth 1 "$CAPNPROTO_GITROOT" capn
cd capn/c++
./setup-autotools.sh
autoreconf -i
./configure
make -j6 check
make install
cd ~vagrant
git clone --depth 1 "$LIBSODIUM_GITROOT" libsodium
cd libsodium
./autogen.sh
./configure
make
make test
make install
## libsodium does not make (or install) its .pc file by default
## it's commented out in the Makefile
make libsodium.pc
cp ./libsodium.pc /usr/local/lib/pkgconfig/
cd ~vagrant
git clone --depth 1 "$SANDSTORM_GITROOT" sandstorm
cd sandstorm
make "NODE_INCLUDE=/usr/include/nodejs/src -I/usr/include/nodejs/deps/uv/include"
make install SANDSTORM_USER=vagrant:vagrant
## Ubuntu calls their executable "nodejs" which makes meteor angry
ln -s nodejs /usr/bin/node
npm install -g meteorite
npm install -g es6-promise
cat >/home/vagrant/sand_setup.sh<<SANDSETUP
curl --silent https://install.meteor.com | /bin/sh
# for some reason, the "-g" version is not honored as vagrant
npm install es6-promise
# must change to the shell directory because we are
# updating _its_ copy of meteor
cd /home/vagrant/sandstorm/shell
meteor update
mrt install
SANDSETUP
# ensure vagrant can write all that meteor and npm stuff
chown -R vagrant:vagrant ~vagrant
su -c "bash -x /home/vagrant/sand_setup.sh" vagrant
rm /home/vagrant/sand_setup.sh
echo 'Ready to run; change to ~vagrant/sandstorm/shell and issue "meteor"'
echo 'Good luck!'
SCRIPT1
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = 'saucy-server-cloudimg-amd64-vagrant-disk1'
config.vm.box_url = 'http://cloud-images.ubuntu.com/vagrant/saucy/current/saucy-server-cloudimg-amd64-vagrant-disk1.box'
config.vm.hostname = 'sandy'
# you will likely want this if you wish to communicate from outside
# your VM to the server on port 3000; the default Vagrant networking
# configuration is NAT
## config.vm.network :private_network, ip: '192.168.56.103'
config.vm.provider :virtualbox do |vb|
# vb.gui = true
vb.customize ['modifyvm', :id, '--memory', '1024']
end
config.vm.provision :shell, :inline => $script
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment