# copy config from example if local config not exists FileUtils.cp config[:example], config[:local] unless File.exist?(config[:local]) # read config options = YAML.load_file config[:local]
# check github token if options['github_token'].nil? || options['github_token'].to_s.length != 40 puts "You must place REAL GitHub token into configuration:\n/yii2-app-advancded/vagrant/config/vagrant-local.yml" exit end
# vagrant configurate Vagrant.configure(2) do |config| # select the box config.vm.box = 'ubuntu/trusty64'
# should we ask about box updates? config.vm.box_check_update = options['box_check_update']
config.vm.provider 'virtualbox' do |vb| # machine cpus count vb.cpus = options['cpus'] # machine memory size vb.memory = options['memory'] # machine name (for VirtualBox UI) vb.name = options['machine_name'] end
# machine name (for vagrant console) config.vm.define options['machine_name']
# machine name (for guest machine console) config.vm.hostname = options['machine_name']
info "Configure composer" composer config --global github-oauth.github.com ${github_token} echo "Done!"
info "Install plugins for composer" composer global require "fxp/composer-asset-plugin:~1.1.1" --no-progress
info "Install codeception" composer global require "codeception/codeception=2.0.*" "codeception/specify=*" "codeception/verify=*" --no-progress echo 'export PATH=/home/vagrant/.config/composer/vendor/bin:$PATH' | tee -a /home/vagrant/.profile
info "Install project dependencies" cd /app composer --no-progress --prefer-dist install
info "Init project" ./init --env=Development --overwrite=y
info "Apply migrations" ./yii migrate <<< "yes"
info "Create bash-alias 'app' for vagrant user" echo 'alias app="cd /app"' | tee /home/vagrant/.bash_aliases
info "Enabling colorized prompt for guest console" sed -i "s/#force_color_prompt=yes/force_color_prompt=yes/" /home/vagrant/.bashrc
info "Configure MySQL" sed -i "s/.*bind-address.*/bind-address = 0.0.0.0/" /etc/mysql/my.cnf echo "Done!"
info "Configure PHP-FPM" sed -i 's/user = www-data/user = vagrant/g' /etc/php5/fpm/pool.d/www.conf sed -i 's/group = www-data/group = vagrant/g' /etc/php5/fpm/pool.d/www.conf sed -i 's/owner = www-data/owner = vagrant/g' /etc/php5/fpm/pool.d/www.conf echo "Done!"
info "Configure NGINX" sed -i 's/user www-data/user vagrant/g' /etc/nginx/nginx.conf echo "Done!"
info "Enabling site configuration" ln -s /app/vagrant/nginx/app.conf /etc/nginx/sites-enabled/app.conf echo "Done!"
info "Initailize databases for MySQL" mysql -uroot <<< "CREATE DATABASE yii2advanced" mysql -uroot <<< "CREATE DATABASE yii2_advanced_tests" echo "Done!"