Skip to content

Instantly share code, notes, and snippets.

@allebb
Last active August 29, 2015 13:56
Show Gist options
  • Save allebb/9217648 to your computer and use it in GitHub Desktop.
Save allebb/9217648 to your computer and use it in GitHub Desktop.
Bash Script for auto provisioning of the Supportly Applicaiton.
#!/usr/bin/env bash
echo ">>> Installing Supportly Customisations..."
laravel_root_folder="/vagrant"
# Test if Composer is installed
composer --version > /dev/null 2>&1
COMPOSER_IS_INSTALLED=$?
if [ $COMPOSER_IS_INSTALLED -gt 0 ]; then
echo "ERROR: The Laravel framework requires Composer"
exit 1
fi
# Test if Apache or Nginx is installed
nginx -v > /dev/null 2>&1
NGINX_IS_INSTALLED=$?
if [ $NGINX_IS_INSTALLED -eq 0 ]; then
nginx_root=$(echo "$laravel_root_folder/public" | sed 's/\//\\\//g')
# Change default vhost created
sed -i "s/root \/vagrant/root $nginx_root/" /etc/nginx/sites-available/vagrant
sudo service nginx reload
fi
# Create a new 'supportly' development database...
mysql -u root -proot -e "CREATE DATABASE supportly;"
# Create a testing account and DB for when unit tests are executed, this matches our PHPCI.yml config...
mysql -uroot -proot -e "CREATE USER 'test'@'localhost' IDENTIFIED BY 'test'";
mysql -uroot -proot -e "CREATE DATABASE test_supportly";
mysql -uroot -proot -e "GRANT ALL ON test_supportly.* TO 'test'@'localhost'";
# Lets change into the application directory ready to run the final bits...
cd $laravel_root_folder
# Lets now install our dependencies...
composer install
# Lets also migrate and seed our development database...
php artisan migrate --seed
echo ">>> Provisioning complete! "
echo ""
echo "You can now access the application at: http(s)://dev.autono.de"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment