From 5e222d435123333fb4b7278f5e70dd77a6de37cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Almeida?= Date: Mon, 6 May 2019 13:42:14 -0700 Subject: [PATCH] Add Vagrantfile --- Vagrantfile | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 Vagrantfile diff --git a/Vagrantfile b/Vagrantfile new file mode 100644 index 0000000..b0d2ae5 --- /dev/null +++ b/Vagrantfile @@ -0,0 +1,42 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : + +Vagrant.configure("2") do |config| + config.vm.box = "scotch/box" + config.vm.network "private_network", ip: "192.168.33.10" + config.vm.hostname = "scotchbox" + config.vm.synced_folder "./", "/var/www", :mount_options => ["dmode=777", "fmode=666"] + + config.vm.provision "shell", inline: <<-SHELL + # Edit just VagrantDomain: + + # Domain + VagrantDomain=( "app1.dev" "app2.dev" ) + + # ------------ # + + sudo rm -rf /etc/apache2/sites-available/*.dev.conf + sudo rm -rf /etc/apache2/sites-enabled/*.dev.conf + + # Loop through all sites + for ((i=0; i < ${#VagrantDomain[@]}; i++)); do + + ## Current Domain + DOMAIN=${VagrantDomain[$i]} + mkdir -p /var/www/$DOMAIN/public + + echo "Creating vhost config for $DOMAIN..." + sudo cp /etc/apache2/sites-available/scotchbox.local.conf /etc/apache2/sites-available/$DOMAIN.conf + + sudo sed -i s,scotchbox.local,$DOMAIN,g /etc/apache2/sites-available/$DOMAIN.conf + sudo sed -i s,/var/www/public,/var/www/$DOMAIN/public,g /etc/apache2/sites-available/$DOMAIN.conf + + sudo a2ensite $DOMAIN.conf + done + + echo "So let's restart apache..." + sudo service apache2 restart + + SHELL + +end \ No newline at end of file