Last active
August 29, 2015 14:07
-
-
Save caferrari/28dc9dcdb2da48f91973 to your computer and use it in GitHub Desktop.
Vagrant provision script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PACKAGE_FILE="/home/vagrant/packages.ok" | |
CONFIGS_FILE="/home/vagrant/config.ok" | |
ES_FILE="/home/vagrant/es.ok" | |
echo "America/Sao_Paulo" | sudo tee /etc/timezone | |
sudo dpkg-reconfigure --frontend noninteractive tzdata | |
if [ ! -f "$PACKAGE_FILE" ] | |
then | |
sudo sed -i -e "/http:\/\/archive.ubuntu.com/ s/archive.ubuntu.com/ubuntu.c3sl.ufpr.br/" /etc/apt/sources.list | |
sudo aptitude update -y | |
sudo aptitude upgrade -y | |
sudo locale-gen en_US en_US.UTF-8 pt_BR pt_BR.UTF-8 | |
sudo dpkg-reconfigure locales | |
sudo aptitude install htop git php5-xdebug libapache2-mod-php5 php5-imagick php5-pgsql php5-intl php5-curl php5-memcached php5-cli php5-mongo php-apc php5-gearman gearman postgresql mongodb -y | |
touch $PACKAGE_FILE | |
fi | |
# Ajusta as configurações | |
if [ ! -f "$CONFIGS_FILE" ] | |
then | |
sudo sed -i -e "/listen_addresses/ s/.*/listen_addresses='*'/" /etc/postgresql/9.3/main/postgresql.conf | |
sudo sed -i -e "/127.0.0.1/ s/32.*/0\t\ttrust"/ /etc/postgresql/9.3/main/pg_hba.conf | |
sudo sed -i -e "/DocumentRoot/ s/ .*/ \/var\/www\/public/" /etc/apache2/sites-enabled/000-default.conf | |
sudo sed -i -e "/AllowOverride/ s/ .*/ all/" /etc/apache2/apache2.conf | |
sudo sed -i -e "/APACHE_RUN_USER/ s/=.*/=vagrant/" /etc/apache2/envvars | |
sudo sed -i -e "/APACHE_RUN_GROUP/ s/=.*/=vagrant/" /etc/apache2/envvars | |
sudo sed -i -e "/^error_reporting/ s/ .*/ = -1/" /etc/php5/apache2/php.ini | |
sudo sed -i -e "/^display_errors/ s/ .*/ = on/" /etc/php5/apache2/php.ini | |
sudo a2enmod rewrite | |
touch $CONFIGS_FILE | |
fi | |
# Instala o elastic search | |
if [ ! -f "$ES_FILE" ] | |
then | |
[ -f elasticsearch-1.3.4.deb ] || wget --progress=bar https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-1.3.4.deb | |
sudo aptitude install openjdk-7-jre -y | |
sudo dpkg -i elasticsearch-1.3.4.deb | |
sudo update-rc.d elasticsearch defaults | |
touch $ES_FILE | |
fi | |
# Reinicia todos os serviços | |
sudo service apache2 restart | |
sudo service postgresql restart | |
sudo service elasticsearch restart | |
# Cria o user e a base de dados | |
sudo su -c 'psql -c "CREATE ROLE bomdebusca LOGIN ENCRYPTED PASSWORD '"'"'md5bd93f434fd24c20d63d6ca9178c2f142'"'"' NOSUPERUSER INHERIT NOCREATEDB NOCREATEROLE NOREPLICATION;"' -s /bin/sh postgres | |
sudo su -c 'psql -c "CREATE DATABASE bomdebusca WITH OWNER = bomdebusca ENCODING = '"'"'UTF8'"'"' TABLESPACE = pg_default CONNECTION LIMIT = -1;"' -s /bin/sh postgres | |
# Instala o composer | |
if [ ! -f "/usr/bin/composer.phar" ] | |
then | |
curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/bin | |
[ -f "/usr/bin/cpz" ] || sudo ln -s /usr/bin/composer.phar /usr/bin/cpz | |
[ -f "/usr/bin/composer" ] || sudo ln -s /usr/bin/composer.phar /usr/bin/composer | |
else | |
sudo /usr/bin/cpz self-update | |
fi | |
# Configura o projeto | |
cd /var/www | |
cpz update --prefer-source --no-interaction | |
# Cria estrutura da base de dados | |
/var/www/vendor/bin/doctrine orm:schema-tool:update --force | |
echo "Configurando Elastic Search" | |
/var/www/elastic.sh | |
# Inicializa base de dados | |
cd /var/www/scripts | |
echo "Importando cidades, aguarde..." | |
php importcities.php | |
echo "Importando imobiliárias" | |
php importimob.php | |
echo "Importando planos" | |
php plans.php | |
echo "Indexando database" | |
php reindex.php |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- mode: ruby -*- | |
VAGRANTFILE_API_VERSION = "2" | |
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| | |
config.vm.box = "trusty" | |
config.vm.network "private_network", ip: "192.168.33.10" | |
config.vm.synced_folder "../", "/var/www", id: "vagrant-root", mount_options: ["dmode=775,fmode=774"] | |
config.vm.provider "virtualbox" do |v| | |
v.memory = 2024 | |
v.cpus = 4 | |
end | |
config.vm.network "forwarded_port", guest: 80, host: 8080, auto_correct: true | |
config.vm.network "forwarded_port", guest: 5432, host: 5433, auto_correct: true | |
config.vm.network "forwarded_port", guest: 9200, host: 9200, auto_correct: true | |
config.vm.provision "shell", path: "provision.sh" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment