Moving from sites/all

Submitted by Erik on Mon, 05/23/2011 - 16:46

Recently, we have been moving away from using sites/all to store modules and themes because we heavily use multisite setups and need to keep the sites contained and independent.

To change a site away from using sites/all, I djinn'ed up a drush command that looks to see what's being invoked from sites/all.

drush sql-query "select filename from system where status=1 and filename like 'sites/all%'"

which will give a return delimited list of the filenames of modules that are enabled:

sites/all/modules/cck/content.module
sites/all/modules/cck/modules/text/text.module
sites/all/modules/date/date/date.module
sites/all/modules/date/date_api.module
sites/all/modules/date/date_popup/date_popup.module
sites/all/modules/date/date_timezone/date_timezone.module
sites/all/modules/devel/devel_generate.module
sites/all/modules/devel/devel.module
sites/all/modules/admin_menu/admin_menu.module

From this we can see that CCK, Date, Devel, and Admin Menu are the Drupal projects that need to be downloaded into the subsite directory.

We really just need to get the arg(3) to know which projects to grab. I did this with awk and then changed the newlines to spaces to get a space delimited set of values to pass to drush dl

drush sql-query "select filename from system where status=1 and filename like 'sites/all%'" | awk -F/ '{print $4}' | sort -u | tr '\n' ' '

This leaves us with the following:

admin_menu cck date devel

A nice space delimited set of projects to download.

drush dl `drush sql-query "select filename from system where status=1 and filename like 'sites/all%'" | awk -F/ '{print $4}' | sort -u | tr '\n' ' '`

which when run in the subsite directory (or with a site alias or uri parameter to drush) will get all of the projects necessary. Then simply running

drush cc all

seems to do the trick.

Comments

How do you host multiple sites and manage it through single installation ? It would be nice for me to learn it too. I have like 8-9 user edited websites but need a central administration facility.

-----------------------------
nteditor

Add new comment

The content of this field is kept private and will not be shown publicly.

Filtered HTML

  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <img src alt height width> <pre>
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • Lines and paragraphs break automatically.
CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.