Skip to content

Instantly share code, notes, and snippets.

@jehadassaf
Last active May 30, 2016 11:07
Show Gist options
  • Save jehadassaf/8752200 to your computer and use it in GitHub Desktop.
Save jehadassaf/8752200 to your computer and use it in GitHub Desktop.
My Vagrant Setup
#!/usr/bin/env bash
echo "--- Good morning, master! This may take a while, why don't you go grab a cup of coffee? ---"
echo "--- Updating packages list ---"
sudo apt-get update
echo "--- MySQL password time ---"
sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password password root'
sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password_again password root'
echo "--- Installing base packages ---"
sudo apt-get install -y vim curl python-software-properties
echo "--- Installing PHP ---"
sudo add-apt-repository -y ppa:ondrej/php5
echo "--- Updating packages list ---"
sudo apt-get update
echo "--- Installing PHP-specific packages ---"
sudo apt-get install -y php5 apache2 libapache2-mod-php5 php5-curl php5-gd php5-mcrypt php5-readline mysql-server-5.5 php5-mysql git-core php5-xdebug php5-cli
echo "--- Configuring Xdebug ---"
cat << EOF | sudo tee -a /etc/php5/mods-available/xdebug.ini
xdebug.scream=1
xdebug.cli_color=1
xdebug.show_local_vars=1
EOF
echo "--- What developer codes without errors turned on? Not you, master. ---"
sed -i "s/error_reporting = .*/error_reporting = E_ALL/" /etc/php5/apache2/php.ini
sed -i "s/display_errors = .*/display_errors = On/" /etc/php5/apache2/php.ini
echo "--- Restarting Apache ---"
sudo service apache2 restart
echo "--- Composer is the future. But you knew that, did you master? Nice job. ---"
curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer
echo "--- Updating packages list ---"
sudo apt-get update
echo "--- All set to go! Would you like to play a game? ---"
require 'json'
require 'yaml'
VAGRANTFILE_API_VERSION = "2"
confDir = $confDir ||= File.expand_path("~/.homestead")
homesteadYamlPath = confDir + "/Homestead.yaml"
homesteadJsonPath = confDir + "/Homestead.json"
afterScriptPath = confDir + "/after.sh"
aliasesPath = confDir + "/aliases"
require File.expand_path(File.dirname(__FILE__) + '/scripts/homestead.rb')
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
if File.exists? aliasesPath then
config.vm.provision "file", source: aliasesPath, destination: "~/.bash_aliases"
end
if Vagrant.has_plugin?("vagrant-proxyconf")
config.proxy.http = "http://web-proxy.uk.hpicorp.net:8080/"
config.proxy.https = "http://web-proxy.uk.hpicorp.net:8080/"
config.proxy.no_proxy = "localhost,127.0.0.1"
end
if File.exists? homesteadYamlPath then
settings = YAML::load(File.read(homesteadYamlPath))
elsif File.exists? homesteadJsonPath then
settings = JSON.parse(File.read(homesteadJsonPath))
end
Homestead.configure(config, settings)
if File.exists? afterScriptPath then
config.vm.provision "shell", path: afterScriptPath
end
if defined? VagrantPlugins::HostsUpdater
config.hostsupdater.aliases = settings['sites'].map { |site| site['map'] }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment