#!/bin/sh
# If you would like to do some extra provisioning you may
# add any commands you wish to this file and they will
# be run after the Homestead machine is provisioned.
echo "Updating machine software"
locale-gen en_GB.UTF-8
# Updating composer
composer self-update
# Updating and upgrading dependencies
apt-get update && apt-get upgrade -y
# Installing PHPUnit
apt-get install phpunit -y
echo "Configuring extra machine software"
# Adding configuration params to xdebug.ini
xdebug="zend_extension=xdebug.so
xdebug.max_nesting_level=300
xdebug.remote_enable=1
xdebug.remote_connect_back=0
xdebug.remote_port=9000
xdebug.scream=0
xdebug.cli_color=1
xdebug.remote_host=192.168.33.1
xdebug.remote_autostart=1
xdebug.show_local_vars=1
xdebug.idekey=PHPSTORM
xdebug.remote_log=/tmp/xdebug.log
xdebug.remote_handler=dbgp
"
echo "$xdebug" > "/etc/php5/mods-available/xdebug.ini"
# Adding configuration to ~/.profile file
profile='export PHP_IDE_CONFIG="serverName=vagrant"
export XDEBUG_CONFIG="idekey=PHPSTORM remote_host=192.168.33.1 profiler_enable=1"'
echo "$profile" >> "/home/vagrant/.profile"
echo "Disabling/Enabling things that will make this work"
# Disabling Blackfire PHP module
sudo php5dismod blackfire
# Enabling Xdebug PHP module
sudo php5enmod xdebug
# Generating a appliying proper permissions to xdebug log file
sudo touch /tmp/xdebug.log
sudo chown vagrant:vagrant /tmp/xdebug.log
sudo chmod 777 /tmp/xdebug.log
# Restarting PHP-FPM
service php5-fpm restart