Advertisement
Guest User

Untitled

a guest
Jan 11th, 2018
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.14 KB | None | 0 0
  1. # -*- mode: ruby -*-
  2. # vi: set ft=ruby :
  3.  
  4. require 'json'
  5. require 'yaml'
  6.  
  7. VAGRANTFILE_API_VERSION = "2"
  8. confDir = $confDir ||= File.expand_path(File.dirname(__FILE__))
  9.  
  10. homesteadYamlPath = confDir + "/Homestead.yaml"
  11. homesteadJsonPath = confDir + "/Homestead.json"
  12. afterScriptPath = confDir + "/after.sh"
  13. aliasesPath = confDir + "/aliases"
  14.  
  15. require File.expand_path(File.dirname(__FILE__) + '/scripts/homestead.rb')
  16.  
  17. Vagrant.require_version '>= 1.9.0'
  18.  
  19. Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  20. config.vm.provider 'virtualbox' do |vb|
  21. vb.customize ['modifyvm', :id, '--cableconnected1', 'on']
  22. end
  23.  
  24. config.ssh.username = 'vagrant'
  25. config.ssh.password = 'vagrant'
  26. config.ssh.insert_key = 'true'
  27. config.ssh.forward_agent = true
  28.  
  29. config.vm.provider :virtualbox do |vb|
  30. vb.name = "supercool"
  31. vb.customize ["modifyvm", :id, "--memory", "768"]
  32. vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
  33. end
  34.  
  35. if File.exist? aliasesPath then
  36. config.vm.provision "file", source: aliasesPath, destination: "/tmp/bash_aliases"
  37. config.vm.provision "shell" do |s|
  38. s.inline = "awk '{ sub(\"\r$\", \"\"); print }' /tmp/bash_aliases > /home/vagrant/.bash_aliases"
  39. end
  40. end
  41.  
  42. if File.exist? homesteadYamlPath then
  43. settings = YAML::load(File.read(homesteadYamlPath))
  44. elsif File.exist? homesteadJsonPath then
  45. settings = JSON::parse(File.read(homesteadJsonPath))
  46. else
  47. abort "Homestead settings file not found in #{confDir}"
  48. end
  49.  
  50. Homestead.configure(config, settings)
  51.  
  52. if File.exist? afterScriptPath then
  53. config.vm.provision "shell", path: afterScriptPath, privileged: false, keep_color: true
  54. end
  55.  
  56. if Vagrant.has_plugin?('vagrant-hostsupdater')
  57. config.hostsupdater.aliases = settings['sites'].map { |site| site['map'] }
  58. elsif Vagrant.has_plugin?('vagrant-hostmanager')
  59. config.hostmanager.enabled = true
  60. config.hostmanager.manage_host = true
  61. config.hostmanager.aliases = settings['sites'].map { |site| site['map'] }
  62. end
  63. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement