Automatic Drush multisite alias creation and synchronization between remote and local systems

Get the Dropbucket code!

I am perpetually lazy (when it comes to things I shouldn’t have to do), and you should be too! As a result I give you a drush alias listing that self populates on-demand. This video talks through how the code works that can be found on Dropbucket and shows a demonstration of what it can net you. This is a script to locate and generate your group. aliases. drushrc.php for you based on walking through a multisite and looking for settings.php records. It then takes these records and writes the aliases array automatically.

Some additional craziness this provides:

  • Support for multiple multisite stacks
  • Support for requesting the remote script to act as your local one
  • Should work with multiple stacks / systems based on tweaking a few settings

This is necessary for the work I’m doing because I don’t actually know all the sites that will be out on my server. I have a request mechanism in place where faculty / staff will be able to plug certain information into a Drupal site and have it spit out another Drupal site (watch Using Drupal to Transform Education). In fact it has the potential to kick out multiple Drupal sites based on the type of request you submit; so as a result, I very quickly will lose a handle on how many sites are out there without a lot of solid automation. This script is a large part of that effort.

In addition to needing automation for maintaining security and managing an unknown, theoretical number of sites down different directory trees; I am also quite lazy. I don’t want to go through the *hassle* of logging into a machine or writing files that have the locations of everything. I want it to happen automatically, no matter where I am. As a result, The last part of the script allows for executing the same script from a remote location (most likely your development environment).

This provides you with the ability to not only not have to know how many sites are out there, but also not have to be on the server to execute these commands as drush can pipe things out via ssh on a per-site basis. If you have any improvements please let me know on Dropbucket!