2014-08-08 19:30:06 +00:00
|
|
|
# This Vagrantfile can be used to develop Vagrant. Note that VirtualBox
|
|
|
|
# doesn't run in VirtualBox so you can't actually _run_ Vagrant within
|
|
|
|
# the VM created by this Vagrantfile, but you can use it to develop the
|
|
|
|
# Ruby, run unit tests, etc.
|
|
|
|
|
|
|
|
Vagrant.configure("2") do |config|
|
2019-09-22 16:07:46 +00:00
|
|
|
config.vm.box = "hashicorp/bionic64"
|
2015-07-08 16:12:31 +00:00
|
|
|
config.vm.hostname = "vagrant"
|
|
|
|
config.ssh.shell = "bash -c 'BASH_ENV=/etc/profile exec bash'"
|
|
|
|
|
2019-09-22 16:07:46 +00:00
|
|
|
["vmware_desktop", "virtualbox", "hyperv"].each do |provider|
|
2015-07-08 16:12:31 +00:00
|
|
|
config.vm.provider provider do |v, override|
|
2019-08-09 02:11:52 +00:00
|
|
|
v.memory = "2048"
|
2015-07-08 16:12:31 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
config.vm.provision "shell", inline: $shell
|
|
|
|
|
|
|
|
config.push.define "www", strategy: "local-exec" do |push|
|
|
|
|
push.script = "scripts/website_push_www.sh"
|
|
|
|
end
|
|
|
|
|
|
|
|
config.push.define "docs", strategy: "local-exec" do |push|
|
|
|
|
push.script = "scripts/website_push_docs.sh"
|
2014-12-12 08:53:50 +00:00
|
|
|
end
|
2014-08-08 19:30:06 +00:00
|
|
|
end
|
2015-07-08 16:12:31 +00:00
|
|
|
|
2016-07-26 23:51:40 +00:00
|
|
|
$shell = <<-'CONTENTS'
|
2015-07-08 16:12:31 +00:00
|
|
|
export DEBIAN_FRONTEND=noninteractive
|
|
|
|
MARKER_FILE="/usr/local/etc/vagrant_provision_marker"
|
2016-07-26 23:51:40 +00:00
|
|
|
RUBY_VER_REQ=$(awk '$1 == "s.required_ruby_version" { print $4 }' /vagrant/vagrant.gemspec | tr -d '"')
|
2015-07-08 16:12:31 +00:00
|
|
|
|
|
|
|
# Only provision once
|
|
|
|
if [ -f "${MARKER_FILE}" ]; then
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2019-08-08 22:31:14 +00:00
|
|
|
# Add ubuntu_rvm repo
|
|
|
|
apt-add-repository -y ppa:rael-gc/rvm
|
|
|
|
|
2015-07-08 16:12:31 +00:00
|
|
|
# Update apt
|
2016-07-26 23:51:40 +00:00
|
|
|
apt-get update --quiet
|
2015-07-08 16:12:31 +00:00
|
|
|
|
2019-08-08 22:31:14 +00:00
|
|
|
# Add vagrant user to sudo group:
|
|
|
|
# ubuntu_rvm only adds users in group sudo to group rvm
|
|
|
|
usermod -a -G sudo vagrant
|
|
|
|
|
|
|
|
# Install basic dependencies and RVM
|
|
|
|
apt-get install -qy build-essential bsdtar rvm
|
2015-07-08 16:12:31 +00:00
|
|
|
|
|
|
|
# Import the mpapis public key to verify downloaded releases
|
2016-07-26 23:51:40 +00:00
|
|
|
su -l -c 'gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3' vagrant
|
2015-07-08 16:12:31 +00:00
|
|
|
|
2019-08-08 22:42:45 +00:00
|
|
|
# Install next-to-last Ruby that complies with Vagrant's version constraint
|
|
|
|
RUBY_VER=$(su -l -c 'rvm list known' vagrant | tr '[]-' ' ' | awk "/^ ruby ${RUBY_VER_REQ:0:1}\./ { print \$2 }" | sort -r | sed -n '2p')
|
|
|
|
su -l -c "rvm install ${RUBY_VER}" vagrant
|
|
|
|
su -l -c "rvm --default use ${RUBY_VER}" vagrant
|
2015-07-08 16:12:31 +00:00
|
|
|
|
|
|
|
# Output the Ruby version (for sanity)
|
|
|
|
su -l -c 'ruby --version' vagrant
|
|
|
|
|
|
|
|
# Install Git
|
2016-07-26 23:51:40 +00:00
|
|
|
apt-get install -qy git
|
2015-07-08 16:12:31 +00:00
|
|
|
|
2016-07-26 23:51:40 +00:00
|
|
|
# Upgrade Rubygems
|
2019-08-08 22:42:45 +00:00
|
|
|
su -l -c "rvm ${RUBY_VER} do gem update --system" vagrant
|
2016-07-26 23:51:40 +00:00
|
|
|
|
2019-08-08 22:53:03 +00:00
|
|
|
# Prepare to run unit tests
|
2016-07-26 23:51:40 +00:00
|
|
|
su -l -c 'cd /vagrant; bundle install' vagrant
|
2016-07-25 16:39:30 +00:00
|
|
|
|
2015-07-08 16:12:31 +00:00
|
|
|
# Automatically move into the shared folder, but only add the command
|
|
|
|
# if it's not already there.
|
2019-08-08 22:55:46 +00:00
|
|
|
grep -q 'cd /vagrant' /home/vagrant/.bash_profile 2>/dev/null || echo 'cd /vagrant' >> /home/vagrant/.bash_profile
|
2015-07-08 16:12:31 +00:00
|
|
|
|
|
|
|
# Touch the marker file so we don't do this again
|
|
|
|
touch ${MARKER_FILE}
|
|
|
|
CONTENTS
|