Drush
Drush is a command line shell and scripting interface for Drupal, a veritable Swiss Army knife designed to make life easier for those of us who spend some of our working hours hacking away at the command prompt.
Installation
[PHP#PEAR pear] channel-discover pear.drush.org pear install drush/drush
Commands
I have dr
as an alias for drush
.
drush help alll the commands! drush help --filter choose which help category to echo
drush cc all clear cache
drush pml list installed and enabled modules drush dl [project] download project drush dl sasson-7.x-3.x-dev download sasson dev release drush updb run upgrade.php
drush en [project] -y enable project without confirmation drush dis [project] -y disable project drush pm-uninstall [project] remove project from db
drush sql-cli < example.sql
drush php-eval 'echo drush_get_context("DRUSH_DRUPAL_ROOT");' drush php-eval 'echo drush_locate_root() . "/" . drupal_get_path('theme', 'sasson');' drush eval 'echo theme_get_setting('sasson_compiler') . "\n" ;' otherwise gives trailing issue?
drush vset --yes site_offline_message "This site is being maintained"; drush vset --yes site_offline 1;
In Drupal 7 to simply put the site into maintenance mode:
drush vset --yes maintenance_mode 1;
drush user-login ryan displays a one-time login link for the user ryan. open `drush user-login ryan` open said link in browser dr uli
Site aliases
Drush uses site alias files to store context data. (Aegir still uses Drush 4)
drush help site-alias
Copy to ~/.drush, rename aliases.drushrc.php or further.
drush ev 'print_r(array_keys(drush_sitealias_get_record("@server_master")))' drush ev '$a = drush_sitealias_get_record("@gk.dev"); print_r($a["path-aliases"]);'
- http://api.drush.ws/api/drush/commands!sql!sync.sql.inc/function/drush_sql_sync/4.x
- http://api.drush.ws/api/drush/includes%21sitealias.inc/function/drush_sitealias_get_record/4.x
Deployment
To sort with Aegir#Remote
- drupal.org: Using drush to synchronize and deploy sites
drush help rsync drush help sql-sync
- http://www.prometsource.com/blog/using-sql-sync-rsync-drush
- vimeo: Synchronising drupal sites from local to remote using drush site aliases
- youtube: Drush Tip: Use sql-sync to Quickly Move a Database
- http://drupalcode.org/project/drush.git/blob/HEAD:/examples/sync_enable.drush.inc
- http://drupalcode.org/project/drush.git/blob/HEAD:/examples/sync_via_http.drush.inc
Make
Drush Make is part of Drush as of Jan 2012.
.make files specify a recipe for modules, themes and libraries to be downloaded by Drush. Make files are used along with an install profile to make a distribution.
- Drush Make readme
- http://drupalcode.org/project/profiler.git/blob/refs/heads/7.x-2.x:/README.txt#l87
- Drush Make theory for happy profile development
- Using drush_make to optimize workflow - Basics of make/profile management from mig5's first article
drush make-generate filename.make generate make from a platform/site
Examples
- http://drushmake.me/ - automatic generation demo
projects[drupal][version] = "7.16" projects[drupal][patch][] = "http://drupal.org/files/1356276-base-profile-d7-39-do-not-test.patch"
projects[sasson][type] = theme projects[sasson][version] = 3.x-dev projects[sasson][download][type] = git projects[sasson][download][url] = http://git.drupal.org/project/sasson.git
local files;
- Include a "directory" download method to "download" from local directories
- http://drupal.org/files/0001-Issue-1837808-by-fgm-Include-a-directory-download-me.patch
Libraries
.make files can specify external libraries to be downloaded using the Libraries API module.
; CKEditor libraries[ckeditor][download][type]= "get" libraries[ckeditor][download][url] = "[ckeditor zip url goes here]" libraries[ckeditor][directory_name] = "ckeditor" libraries[ckeditor][destination] = "libraries"
Sandbox
core = 7.x api = 2 ; Sandbox module projects[range_field][type] = module projects[range_field][download][type] = git projects[range_field][download][branch] = "7.x-1.x" projects[range_field][download][url] = http://git.drupal.org/sandbox/Taran2L/1848632.git projects[range_field][download][revision] = a1cc04da3c1dd957e6808b7e6a381c5970904863
Git
You can get things from git, specify branches, etc.
Also;
- http://drupal.org/node/1206340 - options array