10up/varying-vagrant-vagrants — pull request #100 by westonruter (2013-07-17 23:39:35+00:00)
Title: Auto site setup

I've been working up ways to make it easier to get sites automatically loaded up into VVV without having to touch any indexed files in the repo, manually edit any sample files—to let all site data and configuration remain within the projects themselves under `/srv/www` instead of spreading project info into `database/backups/`, `database/init-custom.sql`, or `config/nginx-config/sites`, and lastly also to automate the addition of the `hosts` records.

Consider a WordPress project that exists in a repo, placed under `/srv/www/example.com/`, which contains:

```
/wp-cli.yml # indicates that path: docroot
/docroot/ # the WordPress install
/database/ # database dumps
/database/vvv-init.sql # create DB and user
/database/vvv-data.sql # populate DB with dev data
/config/
/config/vvv-nginx.conf # Nginx conf that gets symlinked
/config/vvv-domains # list of domains that need to be added to the hosts file
```

I've updated the provision script to automatically execute any `vvv-init.sql` files found under `/var/www`, to `wp db import` any `vvv-data.sql` files which exist in projects for which WordPress is not installed, symlinking of any `vvv-nginx.conf` to be read by Nginx, and also to append to the `hosts` file any domains listed in `vvv-domains` (which also get appended to the `vagrant up` output and additionally get written out to a `config/hosts-hosts` for easy copying).

I've also included a `bin/init-site.sh` which automates the creation of a new site for development. Given the domain on which to do development as an argument (e.g. `example.com`), it creates a repo with the above structure, and sets up the configuration for a `vvv.example.com` site. It also creates a `bin/` directory with shortcut scripts `dump-db-vvv` and `load-db-vvv` which facilitate the frequent dumping and loading of a database to share among developers. Note that the `wp-config.php` does not contain any configuration values in itself, rather it fetches the config array which corresponds to the current environment (identified by `config/active-env`). These env config arrays are extended and overridden through array merges. This `init-site.sh` roughly outlines the standard WordPress project layout we use at @x-team, so it's probably not going to match what others do, but at least it provides a script for getting a new site set up in VVV quickly, which is not straightfoward in its current state.

I'm submitting this pull request expecting it to be an ongoing discussion, not necessarily that it would get merged soon (though I'd certainly be happy with that too).