Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Php7dev
- def Php7dev.configure(config, settings)
- # Configure The Box
- config.vm.box = "rasmus/php7dev"
- config.vm.hostname = "php7dev"
- # Configure A Private Network IP
- config.vm.network :private_network, ip: settings["ip"] ||= "192.168.7.7"
- if settings["networking"]["public"]
- config.vm.network "public_network", type: "dhcp"
- end
- # Configure A Few VirtualBox Settings
- config.vm.provider "virtualbox" do |vb|
- vb.name = 'php7dev'
- vb.customize ["modifyvm", :id, "--memory", settings["memory"] ||= "2048"]
- vb.customize ["modifyvm", :id, "--cpus", settings["cpus"] ||= "1"]
- vb.customize ["modifyvm", :id, "--natdnsproxy1", "on"]
- vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
- vb.customize ["modifyvm", :id, "--ostype", "Debian_64"]
- end
- # Configure Port Forwarding To The Box
- config.vm.network "forwarded_port", guest: 80, host: 8000
- config.vm.network "forwarded_port", guest: 443, host: 44300
- config.vm.network "forwarded_port", guest: 3306, host: 33060
- # Add Custom Ports From Configuration
- if settings.has_key?("ports")
- settings["ports"].each do |port|
- config.vm.network "forwarded_port", guest: port["guest"], host: port["host"], protocol: port["protocol"] ||= "tcp"
- end
- end
- # Configure The Public Key For SSH Access
- config.vm.provision "shell" do |s|
- s.inline = "echo $1 | grep -xq \"$1\" /home/vagrant/.ssh/authorized_keys || echo $1 | tee -a /home/vagrant/.ssh/authorized_keys"
- s.args = [File.read(File.expand_path(settings["authorize"]))]
- end
- # Copy The SSH Private Keys To The Box
- settings["keys"].each do |key|
- config.vm.provision "shell" do |s|
- s.privileged = false
- s.inline = "echo \"$1\" > /home/vagrant/.ssh/$2 && chmod 600 /home/vagrant/.ssh/$2"
- s.args = [File.read(File.expand_path(key)), key.split('/').last]
- end
- end
- # Register All Of The Configured Shared Folders
- settings["folders"].each do |folder|
- config.vm.synced_folder folder["map"], folder["to"], type: folder["type"] ||= nil
- end
- # Install All The Configured Nginx Sites
- settings["sites"].each do |site|
- config.vm.provision "shell" do |s|
- s.inline = "bash /vagrant/scripts/serve.sh $1 \"$2\""
- s.args = [site["map"], site["to"]]
- end
- end
- # Configure All Of The Configured Databases
- settings["databases"].each do |db|
- config.vm.provision "shell" do |s|
- s.path = "./scripts/create-mysql.sh"
- s.args = [db]
- end
- end
- # Update Composer On Every Provision
- config.vm.provision "shell" do |s|
- s.inline = "/usr/local/bin/composer self-update"
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement