oglimmer/fulgens

View on GitHub
classes/core/Vagrant.tmpl

Summary

Maintainability
Test Coverage

if [ "$VAGRANT" == "YES" -a "$VAGRANT_IGNORE" != "YES" ]; then
  mkdir -p localrun
  cd localrun
  cat <<-EOF > Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|
  config.vm.box = "{{Vagrant.Box}}"
  config.vm.network "forwarded_port", guest: 8080, host: 8080
  config.vm.synced_folder "../", "/share_host"
  {% if UseHomeM2 %}
  config.vm.synced_folder "$HOME/.m2", "/root/.m2"
  {% endif %}
  config.vm.provider "virtualbox" do |vb|
    vb.memory = "1536"
    vb.cpus = 4
  end
  config.vm.provision "shell", inline: <<-SHELL
      {% for line in Vagrant.BeforeInstall %}{{line}}
    {% endfor %}
    apt-get update    
    {{dependencyManager.getAptBuild()}}
    {% for line in Vagrant.AfterInstall %}{{line}}
    {% endfor %}
    {{dependencyManager.getNpmBuild()}}
    echo "Now continue with..."
    echo "\$ cd /share_host"
    echo "\$ sudo ./run_local.sh -f"
    echo "...then browse to {{accessUrl}}"
  SHELL
end
EOF
  vagrant up
  if [ -f "../run_local.sh" ]; then
    vagrant ssh -c "cd /share_host && sudo ./run_local.sh -f"
  else
    echo "Save the fulgens output into a bash script (e.g. run_local.sh) and use it inside the new VM"
  fi
  exit 1
fi