Advertisement
Guest User

Untitled

a guest
Jan 12th, 2017
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 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.join(Dir.home, ".homestead"))
  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.8.4'
  18.  
  19. Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  20.  
  21.  
  22. if File.exist? aliasesPath then
  23. config.vm.provision "file", source: aliasesPath, destination: "/tmp/bash_aliases"
  24. config.vm.provision "shell" do |s|
  25. s.inline = "awk '{ sub(\"\r$\", \"\"); print }' /tmp/bash_aliases > /home/vagrant/.bash_aliases"
  26. end
  27. end
  28.  
  29. if File.exist? homesteadYamlPath then
  30. settings = YAML::load(File.read(homesteadYamlPath))
  31. elsif File.exist? homesteadJsonPath then
  32. settings = JSON.parse(File.read(homesteadJsonPath))
  33. end
  34.  
  35. Homestead.configure(config, settings)
  36.  
  37. if File.exist? afterScriptPath then
  38. config.vm.provision "shell", path: afterScriptPath, privileged: false
  39. end
  40.  
  41. if defined? VagrantPlugins::HostsUpdater
  42. config.hostsupdater.aliases = settings['sites'].map { |site| site['map'] }
  43. end
  44. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement