Advertisement
Guest User

Untitled

a guest
Jan 30th, 2015
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.71 KB | None | 0 0
  1. class Php7dev
  2. def Php7dev.configure(config, settings)
  3. # Configure The Box
  4. config.vm.box = "rasmus/php7dev"
  5. config.vm.hostname = "php7dev"
  6.  
  7. # Configure A Private Network IP
  8. config.vm.network :private_network, ip: settings["ip"] ||= "192.168.7.7"
  9.  
  10. if settings["networking"]["public"]
  11. config.vm.network "public_network", type: "dhcp"
  12. end
  13.  
  14. # Configure A Few VirtualBox Settings
  15. config.vm.provider "virtualbox" do |vb|
  16. vb.name = 'php7dev'
  17. vb.customize ["modifyvm", :id, "--memory", settings["memory"] ||= "2048"]
  18. vb.customize ["modifyvm", :id, "--cpus", settings["cpus"] ||= "1"]
  19. vb.customize ["modifyvm", :id, "--natdnsproxy1", "on"]
  20. vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
  21. vb.customize ["modifyvm", :id, "--ostype", "Debian_64"]
  22. end
  23.  
  24. # Configure Port Forwarding To The Box
  25. config.vm.network "forwarded_port", guest: 80, host: 8000
  26. config.vm.network "forwarded_port", guest: 443, host: 44300
  27. config.vm.network "forwarded_port", guest: 3306, host: 33060
  28.  
  29. # Add Custom Ports From Configuration
  30. if settings.has_key?("ports")
  31. settings["ports"].each do |port|
  32. config.vm.network "forwarded_port", guest: port["guest"], host: port["host"], protocol: port["protocol"] ||= "tcp"
  33. end
  34. end
  35.  
  36. # Configure The Public Key For SSH Access
  37. config.vm.provision "shell" do |s|
  38. s.inline = "echo $1 | grep -xq \"$1\" /home/vagrant/.ssh/authorized_keys || echo $1 | tee -a /home/vagrant/.ssh/authorized_keys"
  39. s.args = [File.read(File.expand_path(settings["authorize"]))]
  40. end
  41.  
  42. # Copy The SSH Private Keys To The Box
  43. settings["keys"].each do |key|
  44. config.vm.provision "shell" do |s|
  45. s.privileged = false
  46. s.inline = "echo \"$1\" > /home/vagrant/.ssh/$2 && chmod 600 /home/vagrant/.ssh/$2"
  47. s.args = [File.read(File.expand_path(key)), key.split('/').last]
  48. end
  49. end
  50.  
  51. # Register All Of The Configured Shared Folders
  52. settings["folders"].each do |folder|
  53. config.vm.synced_folder folder["map"], folder["to"], type: folder["type"] ||= nil
  54. end
  55.  
  56. # Install All The Configured Nginx Sites
  57. settings["sites"].each do |site|
  58. config.vm.provision "shell" do |s|
  59. s.inline = "bash /vagrant/scripts/serve.sh $1 \"$2\""
  60. s.args = [site["map"], site["to"]]
  61. end
  62. end
  63.  
  64. # Configure All Of The Configured Databases
  65. settings["databases"].each do |db|
  66. config.vm.provision "shell" do |s|
  67. s.path = "./scripts/create-mysql.sh"
  68. s.args = [db]
  69. end
  70. end
  71.  
  72. # Update Composer On Every Provision
  73. config.vm.provision "shell" do |s|
  74. s.inline = "/usr/local/bin/composer self-update"
  75. end
  76. end
  77. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement