SlideShare une entreprise Scribd logo
1  sur  29
Télécharger pour lire hors ligne
Drush. Secrets come out.
Alexander Schedrov

DrupalCafe №5, Donetsk, 2013
DRUPAL SHELL
Most helpful commands
Core
•

cc - clear-cache

•

Contrib

sql-dump

•

sql-cli

•

Apache Solr
•

solr-index, solr-mark-all,
solr-delete-index

Localization Update
•

l10n-update, l10n-updaterefresh, l10n-update-status

make

Registry Rebuild

•

updb, up, upc

•

vget, vset

•

•

image-flush

Devel

•

Features

dl, en, dis, pm-uninstall

•

upwd

•

uli

registry-rebuild(rr)

•

features-list(fl)

•

features-diff(fd)

•

devel-reinstall (dre)

•

features-revert(fr)

•

fn-hook(fnh, hook)

•

etc.
Installation on Windows
•

download drush. Using c:drush as location in this example

•

install gzip, tar, wget command line binaries

•

set PATH environment variables

c:drush;d:xamppphp;d:xamppmysqlbin;C:Program FilesGnuWin32bin

•

MsysGit

https://drupal.org/node/594744
Installation on *nix
•

download drush. Using home folder as location in this
example

•

create symlink

sudo ln -s ~/drush/drush /usr/local/bin/drush
!

https://drupal.org/node/1791676
Configuration, code sync, sql
sync.
aliases.drushrc.php
drush -r ~/Sites/drupal.dev/ status
!

drush ~/Sites/drupal.dev/#default status
!

aliases.drush.php:
$aliases['dev'] = array(
'root' => '~/Sites/drupal.dev',
);
!
!

drush @dev status
blog.aliases.drushrc.php:
$aliases['dev'] = array(
'root' => '~/Sites/blog',
'uri' => 'blog.dev',
);
$aliases['live'] = array(
'root' => '~/Sites/blog-live',
'uri' => 'blog-live.dev',
);
!

drush @blog status
drush @blog.dev status
drush @blog.live status
!

$aliases['all-blog'] = array(
'site-list' => array('@dev', '@live'),
);
!

drush site-alias(sa)
SSH
Important: remote server must have Drush
!

$aliases['live'] = array(
'remote-host' => 'bitbucket.org',
'remote-user' => 'sanchiz',
'root' => '/var/www',
'uri' => 'default',
);
!

ssh-keygen
ssh-copy-id -i ~/.ssh/id_rsa.pub sanchiz@bitbucket.org

equals
!

drush dl drush_extras
drush pushkey @live
Remote host with special
configuration
!

$aliases['live'] = array(
'remote-host' => 'dev.project.de',
'remote-user' => 'dev_alex_sh',
'root' => '/home/dev_alex_sh/www',
'php' => '/usr/bin/php',
'path-aliases' => array(
'%drush-script' => '/home/dev_alex_sh/
drush/drush.php',
),
);
Code and database sync
If you do not use Git, this section for you =)
Code sync
!
drush rsync(core-rsync) @live @dev --include-conf
!
drush rsync @live:sites @dev:sites
!

$aliases['live'] = array(
'command-specific' => array(
'core-rsync' => array(
'exclude' => '*.sql',
'exclude' => '.svn',
'exclude' => '.git',
'exclude' => "sites/default/files/",
),
),
);
Sql-sync
drush sql-sync @live @dev
!

drush sql-sync @live @dev --create-db
!
!

$aliases['live'] = array(
'path-aliases' => array(
'%dump-dir' => ‘/home/dev_alex_sh/dump’,
),
);
!
!
Selective sync
drush sql-sync @live @dev --structure-tables-key=common
drushrc.php:

!

$options['structure-tables']['custom'] = array(
'cache',
'cache_*',
'search_*',
'watchdog'
);

!

drush sql-sync @live @dev --structure-tables-key=custom --no-cache=true

!

drush sql-sync @live @dev --sanitize

!

emails => user+%uid@localhost
passwords => password
Sql-sync without Drush on
server
drush @live sql-conf --all --show=passwords

!

$aliases['live'] = array(
'databases' => array(
'default' =>
array(
'default' =>
array(
'driver' => 'mysql',
'username' => 'username',
'password' => 'password',
'port' => '',
'host' => '127.0.0.1',
'database' => 'live_database',
),
),
),
);

!
$aliases['live'] = array(
'remote-host' => 'dev.project.de',
'remote-user' => 'default_alex_sh',
'root' => '/home/default_alex_sh/www',
'php' => '/usr/bin/php',
'php-options' => '-d error_reporting="E_ALL^E_DEPRECATED"',
'variables' => array('mail_system' => array('default-system' => 'DevelMailLog')),
'databases' => array(
'default' =>
array(
'default' =>
array(
'driver' => 'mysql',
'username' => 'username',
'password' => 'password',
'port' => '',
'host' => '127.0.0.1',
'database' => 'live_database',
),
),
),

!

!
);

'path-aliases' => array(
'%drush-script' => '/home/default_alex_sh/drush/drush.php',
'%files' => '/home/default_alex_sh/www/sites/default/files',
'%drush' => '/home/default_alex_sh/drush',
'%dump-dir' => '/home/default_alex_sh/www/dump',
),
'command-specific' => array(
'core-rsync' => array(
'exclude' => '*.sql',
'exclude' => '.svn',
'exclude' => '.git',
'exclude' => "sites/default/files/",
),
),
'ssh-options' => '-p 2222',
Development
DRUSH make
What can drush make do?
•

Download modules

•

Clone modules from git

•

Apply patches

•

Download libraries

•

Download core
core = 7.x
api = 2

!

; core
projects[drupal][version] = 7.23

!

; modules
projects[views][version] = 3.7
projects[views][subdir] = "contrib"

!

projects[views][version] = 3.7
projects[views][subdir] = "contrib"
projects[views][patch][] = "https://drupal.org/files/views_join_condition_increment_5.patch"

!
!

projects[views][type] = module
projects[views][download][type] = git
projects[views][download][revision] = 6920ff71c0bf3a75fc769658ba0dabb42ffcd357
projects[views][download][branch] = 7.x-3.x
projects[views][subdir] = "contrib"

!

; libraries
libraries[ckeditor][download][type] = get
libraries[ckeditor][download][url] = "http://download.cksource.com/CKEditor/CKEditor/CKEditor
4.3/ckeditor_4.3_full.zip"

!

libraries[colorbox][download][type] = get
libraries[colorbox][download][url] = "https://github.com/jackmoore/colorbox/archive/
master.zip"

drush make make_file.make --no-core
http://drushmake.me
Extensions Drush

•

A .drush folder in your HOME folder.

•

Anywhere in module

•

Drupal's /drush or /sites/all/drush folders.
function usertools_drush_command() {
$items = array();

!

!

$items['last-registration'] = array(
'description' => 'Show last registration.',
'arguments' => array(
'role' => 'Specific role.',
),
'options' => array(
'count' => array(
'description' => 'Count rows.',
'example-value' => '5',
),
),
'examples' => array(
'drush utl admin --count=5' => 'Show the last 5 registrations of admin.',
),
'aliases' => array('utl'),
'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_FULL,
);
return $items;

}

!

function usertools_drush_help($section) {
switch ($section) {
case 'drush:last-registration':
return dt('This command will show you last registrations.');
}
}
function drush_usertools_last_registration_validate($role = 'all') {
$count = drush_get_option('count');
if (!empty($count) && !is_numeric($count)) {
return drush_set_error('Count should be numeric.');
}
}

!

function drush_usertools_last_registration($role = 'all') {
$count = drush_get_option('count');
if (empty($count)) {
$count = 10;
}

!
!

!

!

}

$query = db_select('users', 'u');
// Condition by role.
if ($role != 'all') {
$rid = drush_usertools_get_role_by_name($role);
$query->innerJoin('users_roles', 'ur', 'u.uid = ur.uid');
$query->condition('ur.rid', $rid);
}
$query->fields('u', array('uid', 'name', 'mail', 'access', 'created'));
$query->condition('u.uid', 0, '<>');
$query->range(0, $count);
$query->orderBy('u.created', 'DESC');
$result = $query->execute();
$items[] = array('uid', dt('Name'), dt('email'), dt('Last login'));
foreach ($result as $user) {
$items[] = array(
$user->uid,
$user->name,
$user->mail,
$user->access == 0 ? dt('Never') : format_interval(time() - $user->access) . ' ago',
);
}
drush_print_table($items, TRUE);
Usage
drush utl --count=5
drush utl administrator --count=10
function usertools_drush_command() {
$items = array();
$items['wipe-users'] = array(
'description' => 'Wipe user tables.',
'examples' => array(
'drush utw' => 'Wipe users.'
),
'aliases' => array('utw'),
'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_ROOT,
);
return $items;
}

!

function drush_usertools_wipe_users() {
if (drush_confirm(dt('You want to delete all users? Are you sure?'))) {
$query = db_select('users', 'u');
$query->fields('u', array('uid', 'name'));
$query->condition('u.uid', 1, '>');
$result = $query->execute();
foreach ($result as $user) {
drush_log(dt('Deleting user') . ' ' . $user->name . '...',
'warning');
user_delete($user->uid);
drush_log(dt('Succes deleting') . ' ' . $user->name, 'success');
}
}
else {
drush_user_abort();
}
}
Usage
drush utw
function drush_usertools_disable_role() {
$query = db_select('role', 'r');
$query->fields('r', array('rid', ‘name'));
$query->condition('r.rid', 1, '<>');
$query->orderBy('r.rid');
$result = $query->execute();

!

!
!
!
}

!
!
!
!
!
!
!
!
!

$options = array();
foreach ($result as $role) {
$options[$role->rid] = array($role->name);
}
$rid = drush_choice($options, dt('Select role:'));
// SQL queries.
drush_log('All users of role ' . $options[$rid][0] . ' disabled.', 'success');
Links
•

https://drupal.org/node/594744 - Drush on Windows

•

https://drupal.org/node/1791676 - Drush on *nix

•

http://drushmake.me - Drush make

•

http://drush.ws

•

https://gist.github.com/Sanchiz/7627657
Thank you!
!

Email: alexander.schedrov@gmail.com
Twitter: @alexschedrov
FB: schedrov
http://sanchiz.net

Contenu connexe

Tendances

Yy
YyYy
Yyyygh
 
Nouveau document texte
Nouveau document texteNouveau document texte
Nouveau document texteSai Ef
 
Introduction to CloudForecast / YAPC::Asia 2010 Tokyo
Introduction to CloudForecast / YAPC::Asia 2010 TokyoIntroduction to CloudForecast / YAPC::Asia 2010 Tokyo
Introduction to CloudForecast / YAPC::Asia 2010 TokyoMasahiro Nagano
 
DrupalCamp Foz - Novas APIs Drupal 7
DrupalCamp Foz - Novas APIs Drupal 7DrupalCamp Foz - Novas APIs Drupal 7
DrupalCamp Foz - Novas APIs Drupal 7chuvainc
 
PHP Static Code Review
PHP Static Code ReviewPHP Static Code Review
PHP Static Code ReviewDamien Seguy
 
Drush Productivity FTW - DUG @ Krimson
Drush Productivity FTW - DUG @ KrimsonDrush Productivity FTW - DUG @ Krimson
Drush Productivity FTW - DUG @ KrimsonKristof Van Roy
 
The Origin of Lithium
The Origin of LithiumThe Origin of Lithium
The Origin of LithiumNate Abele
 
Adventures in Optimization
Adventures in OptimizationAdventures in Optimization
Adventures in OptimizationDavid Golden
 
Future of HTTP in CakePHP
Future of HTTP in CakePHPFuture of HTTP in CakePHP
Future of HTTP in CakePHPmarkstory
 
How to stand on the shoulders of giants
How to stand on the shoulders of giantsHow to stand on the shoulders of giants
How to stand on the shoulders of giantsIan Barber
 

Tendances (18)

Perl Web Client
Perl Web ClientPerl Web Client
Perl Web Client
 
C99
C99C99
C99
 
Cod
CodCod
Cod
 
Yy
YyYy
Yy
 
Nouveau document texte
Nouveau document texteNouveau document texte
Nouveau document texte
 
Introduction to CloudForecast / YAPC::Asia 2010 Tokyo
Introduction to CloudForecast / YAPC::Asia 2010 TokyoIntroduction to CloudForecast / YAPC::Asia 2010 Tokyo
Introduction to CloudForecast / YAPC::Asia 2010 Tokyo
 
DrupalCamp Foz - Novas APIs Drupal 7
DrupalCamp Foz - Novas APIs Drupal 7DrupalCamp Foz - Novas APIs Drupal 7
DrupalCamp Foz - Novas APIs Drupal 7
 
PHP Static Code Review
PHP Static Code ReviewPHP Static Code Review
PHP Static Code Review
 
Drush Productivity FTW - DUG @ Krimson
Drush Productivity FTW - DUG @ KrimsonDrush Productivity FTW - DUG @ Krimson
Drush Productivity FTW - DUG @ Krimson
 
dotCloud and go
dotCloud and godotCloud and go
dotCloud and go
 
zinno
zinnozinno
zinno
 
The Origin of Lithium
The Origin of LithiumThe Origin of Lithium
The Origin of Lithium
 
Php 101: PDO
Php 101: PDOPhp 101: PDO
Php 101: PDO
 
Agile database access with CakePHP 3
Agile database access with CakePHP 3Agile database access with CakePHP 3
Agile database access with CakePHP 3
 
Adventures in Optimization
Adventures in OptimizationAdventures in Optimization
Adventures in Optimization
 
C99.php
C99.phpC99.php
C99.php
 
Future of HTTP in CakePHP
Future of HTTP in CakePHPFuture of HTTP in CakePHP
Future of HTTP in CakePHP
 
How to stand on the shoulders of giants
How to stand on the shoulders of giantsHow to stand on the shoulders of giants
How to stand on the shoulders of giants
 

En vedette

Ansible is the simplest way to automate. SymfonyCafe, 2015
Ansible is the simplest way to automate. SymfonyCafe, 2015Ansible is the simplest way to automate. SymfonyCafe, 2015
Ansible is the simplest way to automate. SymfonyCafe, 2015Alex S
 
Getting started with Ansible. Be efficient.
Getting started with Ansible. Be efficient.Getting started with Ansible. Be efficient.
Getting started with Ansible. Be efficient.Alex S
 
DrupalGap. How to create native application for mobile devices based on Drupa...
DrupalGap. How to create native application for mobile devices based on Drupa...DrupalGap. How to create native application for mobile devices based on Drupa...
DrupalGap. How to create native application for mobile devices based on Drupa...Alex S
 
Drupal and diversity of Single sign-on systems
Drupal and diversity of Single sign-on systemsDrupal and diversity of Single sign-on systems
Drupal and diversity of Single sign-on systemsAlex S
 
Getting Started with DrupalGap
Getting Started with DrupalGapGetting Started with DrupalGap
Getting Started with DrupalGapAlex S
 
Building mobile applications with DrupalGap
Building mobile applications with DrupalGapBuilding mobile applications with DrupalGap
Building mobile applications with DrupalGapAlex S
 
Ansible is the simplest way to automate. MoldCamp, 2015
Ansible is the simplest way to automate. MoldCamp, 2015Ansible is the simplest way to automate. MoldCamp, 2015
Ansible is the simplest way to automate. MoldCamp, 2015Alex S
 
Feeds. использование и создание плагинов. Feeds API
Feeds. использование и создание плагинов. Feeds APIFeeds. использование и создание плагинов. Feeds API
Feeds. использование и создание плагинов. Feeds APIAlex S
 
DrupalGap. How to create native application for mobile devices based on Drupa...
DrupalGap. How to create native application for mobile devices based on Drupa...DrupalGap. How to create native application for mobile devices based on Drupa...
DrupalGap. How to create native application for mobile devices based on Drupa...DrupalCampDN
 
Drush - use full power - Alexander Schedrov
Drush - use full power - Alexander SchedrovDrush - use full power - Alexander Schedrov
Drush - use full power - Alexander SchedrovDrupalCampDN
 
Build your application in seconds and optimize workflow as much as you can us...
Build your application in seconds and optimize workflow as much as you can us...Build your application in seconds and optimize workflow as much as you can us...
Build your application in seconds and optimize workflow as much as you can us...Alex S
 

En vedette (11)

Ansible is the simplest way to automate. SymfonyCafe, 2015
Ansible is the simplest way to automate. SymfonyCafe, 2015Ansible is the simplest way to automate. SymfonyCafe, 2015
Ansible is the simplest way to automate. SymfonyCafe, 2015
 
Getting started with Ansible. Be efficient.
Getting started with Ansible. Be efficient.Getting started with Ansible. Be efficient.
Getting started with Ansible. Be efficient.
 
DrupalGap. How to create native application for mobile devices based on Drupa...
DrupalGap. How to create native application for mobile devices based on Drupa...DrupalGap. How to create native application for mobile devices based on Drupa...
DrupalGap. How to create native application for mobile devices based on Drupa...
 
Drupal and diversity of Single sign-on systems
Drupal and diversity of Single sign-on systemsDrupal and diversity of Single sign-on systems
Drupal and diversity of Single sign-on systems
 
Getting Started with DrupalGap
Getting Started with DrupalGapGetting Started with DrupalGap
Getting Started with DrupalGap
 
Building mobile applications with DrupalGap
Building mobile applications with DrupalGapBuilding mobile applications with DrupalGap
Building mobile applications with DrupalGap
 
Ansible is the simplest way to automate. MoldCamp, 2015
Ansible is the simplest way to automate. MoldCamp, 2015Ansible is the simplest way to automate. MoldCamp, 2015
Ansible is the simplest way to automate. MoldCamp, 2015
 
Feeds. использование и создание плагинов. Feeds API
Feeds. использование и создание плагинов. Feeds APIFeeds. использование и создание плагинов. Feeds API
Feeds. использование и создание плагинов. Feeds API
 
DrupalGap. How to create native application for mobile devices based on Drupa...
DrupalGap. How to create native application for mobile devices based on Drupa...DrupalGap. How to create native application for mobile devices based on Drupa...
DrupalGap. How to create native application for mobile devices based on Drupa...
 
Drush - use full power - Alexander Schedrov
Drush - use full power - Alexander SchedrovDrush - use full power - Alexander Schedrov
Drush - use full power - Alexander Schedrov
 
Build your application in seconds and optimize workflow as much as you can us...
Build your application in seconds and optimize workflow as much as you can us...Build your application in seconds and optimize workflow as much as you can us...
Build your application in seconds and optimize workflow as much as you can us...
 

Similaire à Drush secrets revealed: Helpful Drush commands and development tips

The History of PHPersistence
The History of PHPersistenceThe History of PHPersistence
The History of PHPersistenceHugo Hamon
 
Good Evils In Perl (Yapc Asia)
Good Evils In Perl (Yapc Asia)Good Evils In Perl (Yapc Asia)
Good Evils In Perl (Yapc Asia)Kang-min Liu
 
The State of Lithium
The State of LithiumThe State of Lithium
The State of LithiumNate Abele
 
Zend Framework Study@Tokyo #2
Zend Framework Study@Tokyo #2Zend Framework Study@Tokyo #2
Zend Framework Study@Tokyo #2Shinya Ohyanagi
 
Can't Miss Features of PHP 5.3 and 5.4
Can't Miss Features of PHP 5.3 and 5.4Can't Miss Features of PHP 5.3 and 5.4
Can't Miss Features of PHP 5.3 and 5.4Jeff Carouth
 
Lithium: The Framework for People Who Hate Frameworks
Lithium: The Framework for People Who Hate FrameworksLithium: The Framework for People Who Hate Frameworks
Lithium: The Framework for People Who Hate FrameworksNate Abele
 
Drupal - dbtng 25th Anniversary Edition
Drupal - dbtng 25th Anniversary EditionDrupal - dbtng 25th Anniversary Edition
Drupal - dbtng 25th Anniversary Editionddiers
 
PHP Data Objects
PHP Data ObjectsPHP Data Objects
PHP Data ObjectsWez Furlong
 
Php update and delet operation
Php update and delet operationPhp update and delet operation
Php update and delet operationsyeda zoya mehdi
 
Virtual Madness @ Etsy
Virtual Madness @ EtsyVirtual Madness @ Etsy
Virtual Madness @ EtsyNishan Subedi
 
R57shell
R57shellR57shell
R57shellady36
 
jQuery UI Widgets, Drag and Drop, Drupal 7 Javascript
jQuery UI Widgets, Drag and Drop, Drupal 7 JavascriptjQuery UI Widgets, Drag and Drop, Drupal 7 Javascript
jQuery UI Widgets, Drag and Drop, Drupal 7 JavascriptDarren Mothersele
 
Absolute Beginners Guide to Puppet Through Types - PuppetConf 2014
Absolute Beginners Guide to Puppet Through Types - PuppetConf 2014Absolute Beginners Guide to Puppet Through Types - PuppetConf 2014
Absolute Beginners Guide to Puppet Through Types - PuppetConf 2014Puppet
 
The Zen of Lithium
The Zen of LithiumThe Zen of Lithium
The Zen of LithiumNate Abele
 
Debugging in drupal 8
Debugging in drupal 8Debugging in drupal 8
Debugging in drupal 8Allie Jones
 
Bag Of Tricks From Iusethis
Bag Of Tricks From IusethisBag Of Tricks From Iusethis
Bag Of Tricks From IusethisMarcus Ramberg
 

Similaire à Drush secrets revealed: Helpful Drush commands and development tips (20)

The History of PHPersistence
The History of PHPersistenceThe History of PHPersistence
The History of PHPersistence
 
Good Evils In Perl (Yapc Asia)
Good Evils In Perl (Yapc Asia)Good Evils In Perl (Yapc Asia)
Good Evils In Perl (Yapc Asia)
 
Fatc
FatcFatc
Fatc
 
The State of Lithium
The State of LithiumThe State of Lithium
The State of Lithium
 
Zend Framework Study@Tokyo #2
Zend Framework Study@Tokyo #2Zend Framework Study@Tokyo #2
Zend Framework Study@Tokyo #2
 
Can't Miss Features of PHP 5.3 and 5.4
Can't Miss Features of PHP 5.3 and 5.4Can't Miss Features of PHP 5.3 and 5.4
Can't Miss Features of PHP 5.3 and 5.4
 
Perl basics for Pentesters
Perl basics for PentestersPerl basics for Pentesters
Perl basics for Pentesters
 
Lithium: The Framework for People Who Hate Frameworks
Lithium: The Framework for People Who Hate FrameworksLithium: The Framework for People Who Hate Frameworks
Lithium: The Framework for People Who Hate Frameworks
 
Drupal - dbtng 25th Anniversary Edition
Drupal - dbtng 25th Anniversary EditionDrupal - dbtng 25th Anniversary Edition
Drupal - dbtng 25th Anniversary Edition
 
PHP Data Objects
PHP Data ObjectsPHP Data Objects
PHP Data Objects
 
Php update and delet operation
Php update and delet operationPhp update and delet operation
Php update and delet operation
 
Virtual Madness @ Etsy
Virtual Madness @ EtsyVirtual Madness @ Etsy
Virtual Madness @ Etsy
 
R57shell
R57shellR57shell
R57shell
 
jQuery UI Widgets, Drag and Drop, Drupal 7 Javascript
jQuery UI Widgets, Drag and Drop, Drupal 7 JavascriptjQuery UI Widgets, Drag and Drop, Drupal 7 Javascript
jQuery UI Widgets, Drag and Drop, Drupal 7 Javascript
 
Absolute Beginners Guide to Puppet Through Types - PuppetConf 2014
Absolute Beginners Guide to Puppet Through Types - PuppetConf 2014Absolute Beginners Guide to Puppet Through Types - PuppetConf 2014
Absolute Beginners Guide to Puppet Through Types - PuppetConf 2014
 
The Zen of Lithium
The Zen of LithiumThe Zen of Lithium
The Zen of Lithium
 
Debugging in drupal 8
Debugging in drupal 8Debugging in drupal 8
Debugging in drupal 8
 
Database api
Database apiDatabase api
Database api
 
Php functions
Php functionsPhp functions
Php functions
 
Bag Of Tricks From Iusethis
Bag Of Tricks From IusethisBag Of Tricks From Iusethis
Bag Of Tricks From Iusethis
 

Dernier

GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 

Dernier (20)

GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 

Drush secrets revealed: Helpful Drush commands and development tips

  • 1. Drush. Secrets come out. Alexander Schedrov DrupalCafe №5, Donetsk, 2013
  • 3. Most helpful commands Core • cc - clear-cache • Contrib sql-dump • sql-cli • Apache Solr • solr-index, solr-mark-all, solr-delete-index Localization Update • l10n-update, l10n-updaterefresh, l10n-update-status make Registry Rebuild • updb, up, upc • vget, vset • • image-flush Devel • Features dl, en, dis, pm-uninstall • upwd • uli registry-rebuild(rr) • features-list(fl) • features-diff(fd) • devel-reinstall (dre) • features-revert(fr) • fn-hook(fnh, hook) • etc.
  • 4. Installation on Windows • download drush. Using c:drush as location in this example • install gzip, tar, wget command line binaries • set PATH environment variables c:drush;d:xamppphp;d:xamppmysqlbin;C:Program FilesGnuWin32bin • MsysGit https://drupal.org/node/594744
  • 5. Installation on *nix • download drush. Using home folder as location in this example • create symlink sudo ln -s ~/drush/drush /usr/local/bin/drush ! https://drupal.org/node/1791676
  • 7. aliases.drushrc.php drush -r ~/Sites/drupal.dev/ status ! drush ~/Sites/drupal.dev/#default status ! aliases.drush.php: $aliases['dev'] = array( 'root' => '~/Sites/drupal.dev', ); ! ! drush @dev status
  • 8. blog.aliases.drushrc.php: $aliases['dev'] = array( 'root' => '~/Sites/blog', 'uri' => 'blog.dev', ); $aliases['live'] = array( 'root' => '~/Sites/blog-live', 'uri' => 'blog-live.dev', ); ! drush @blog status drush @blog.dev status drush @blog.live status ! $aliases['all-blog'] = array( 'site-list' => array('@dev', '@live'), ); ! drush site-alias(sa)
  • 9. SSH Important: remote server must have Drush ! $aliases['live'] = array( 'remote-host' => 'bitbucket.org', 'remote-user' => 'sanchiz', 'root' => '/var/www', 'uri' => 'default', ); ! ssh-keygen ssh-copy-id -i ~/.ssh/id_rsa.pub sanchiz@bitbucket.org equals ! drush dl drush_extras drush pushkey @live
  • 10. Remote host with special configuration ! $aliases['live'] = array( 'remote-host' => 'dev.project.de', 'remote-user' => 'dev_alex_sh', 'root' => '/home/dev_alex_sh/www', 'php' => '/usr/bin/php', 'path-aliases' => array( '%drush-script' => '/home/dev_alex_sh/ drush/drush.php', ), );
  • 11. Code and database sync If you do not use Git, this section for you =)
  • 12. Code sync ! drush rsync(core-rsync) @live @dev --include-conf ! drush rsync @live:sites @dev:sites ! $aliases['live'] = array( 'command-specific' => array( 'core-rsync' => array( 'exclude' => '*.sql', 'exclude' => '.svn', 'exclude' => '.git', 'exclude' => "sites/default/files/", ), ), );
  • 13. Sql-sync drush sql-sync @live @dev ! drush sql-sync @live @dev --create-db ! ! $aliases['live'] = array( 'path-aliases' => array( '%dump-dir' => ‘/home/dev_alex_sh/dump’, ), ); ! !
  • 14. Selective sync drush sql-sync @live @dev --structure-tables-key=common drushrc.php: ! $options['structure-tables']['custom'] = array( 'cache', 'cache_*', 'search_*', 'watchdog' ); ! drush sql-sync @live @dev --structure-tables-key=custom --no-cache=true ! drush sql-sync @live @dev --sanitize ! emails => user+%uid@localhost passwords => password
  • 15. Sql-sync without Drush on server drush @live sql-conf --all --show=passwords ! $aliases['live'] = array( 'databases' => array( 'default' => array( 'default' => array( 'driver' => 'mysql', 'username' => 'username', 'password' => 'password', 'port' => '', 'host' => '127.0.0.1', 'database' => 'live_database', ), ), ), ); !
  • 16. $aliases['live'] = array( 'remote-host' => 'dev.project.de', 'remote-user' => 'default_alex_sh', 'root' => '/home/default_alex_sh/www', 'php' => '/usr/bin/php', 'php-options' => '-d error_reporting="E_ALL^E_DEPRECATED"', 'variables' => array('mail_system' => array('default-system' => 'DevelMailLog')), 'databases' => array( 'default' => array( 'default' => array( 'driver' => 'mysql', 'username' => 'username', 'password' => 'password', 'port' => '', 'host' => '127.0.0.1', 'database' => 'live_database', ), ), ), ! ! ); 'path-aliases' => array( '%drush-script' => '/home/default_alex_sh/drush/drush.php', '%files' => '/home/default_alex_sh/www/sites/default/files', '%drush' => '/home/default_alex_sh/drush', '%dump-dir' => '/home/default_alex_sh/www/dump', ), 'command-specific' => array( 'core-rsync' => array( 'exclude' => '*.sql', 'exclude' => '.svn', 'exclude' => '.git', 'exclude' => "sites/default/files/", ), ), 'ssh-options' => '-p 2222',
  • 18. DRUSH make What can drush make do? • Download modules • Clone modules from git • Apply patches • Download libraries • Download core
  • 19. core = 7.x api = 2 ! ; core projects[drupal][version] = 7.23 ! ; modules projects[views][version] = 3.7 projects[views][subdir] = "contrib" ! projects[views][version] = 3.7 projects[views][subdir] = "contrib" projects[views][patch][] = "https://drupal.org/files/views_join_condition_increment_5.patch" ! ! projects[views][type] = module projects[views][download][type] = git projects[views][download][revision] = 6920ff71c0bf3a75fc769658ba0dabb42ffcd357 projects[views][download][branch] = 7.x-3.x projects[views][subdir] = "contrib" ! ; libraries libraries[ckeditor][download][type] = get libraries[ckeditor][download][url] = "http://download.cksource.com/CKEditor/CKEditor/CKEditor 4.3/ckeditor_4.3_full.zip" ! libraries[colorbox][download][type] = get libraries[colorbox][download][url] = "https://github.com/jackmoore/colorbox/archive/ master.zip" drush make make_file.make --no-core
  • 21. Extensions Drush • A .drush folder in your HOME folder. • Anywhere in module • Drupal's /drush or /sites/all/drush folders.
  • 22. function usertools_drush_command() { $items = array(); ! ! $items['last-registration'] = array( 'description' => 'Show last registration.', 'arguments' => array( 'role' => 'Specific role.', ), 'options' => array( 'count' => array( 'description' => 'Count rows.', 'example-value' => '5', ), ), 'examples' => array( 'drush utl admin --count=5' => 'Show the last 5 registrations of admin.', ), 'aliases' => array('utl'), 'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_FULL, ); return $items; } ! function usertools_drush_help($section) { switch ($section) { case 'drush:last-registration': return dt('This command will show you last registrations.'); } }
  • 23. function drush_usertools_last_registration_validate($role = 'all') { $count = drush_get_option('count'); if (!empty($count) && !is_numeric($count)) { return drush_set_error('Count should be numeric.'); } } ! function drush_usertools_last_registration($role = 'all') { $count = drush_get_option('count'); if (empty($count)) { $count = 10; } ! ! ! ! } $query = db_select('users', 'u'); // Condition by role. if ($role != 'all') { $rid = drush_usertools_get_role_by_name($role); $query->innerJoin('users_roles', 'ur', 'u.uid = ur.uid'); $query->condition('ur.rid', $rid); } $query->fields('u', array('uid', 'name', 'mail', 'access', 'created')); $query->condition('u.uid', 0, '<>'); $query->range(0, $count); $query->orderBy('u.created', 'DESC'); $result = $query->execute(); $items[] = array('uid', dt('Name'), dt('email'), dt('Last login')); foreach ($result as $user) { $items[] = array( $user->uid, $user->name, $user->mail, $user->access == 0 ? dt('Never') : format_interval(time() - $user->access) . ' ago', ); } drush_print_table($items, TRUE);
  • 24. Usage drush utl --count=5 drush utl administrator --count=10
  • 25. function usertools_drush_command() { $items = array(); $items['wipe-users'] = array( 'description' => 'Wipe user tables.', 'examples' => array( 'drush utw' => 'Wipe users.' ), 'aliases' => array('utw'), 'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_ROOT, ); return $items; } ! function drush_usertools_wipe_users() { if (drush_confirm(dt('You want to delete all users? Are you sure?'))) { $query = db_select('users', 'u'); $query->fields('u', array('uid', 'name')); $query->condition('u.uid', 1, '>'); $result = $query->execute(); foreach ($result as $user) { drush_log(dt('Deleting user') . ' ' . $user->name . '...', 'warning'); user_delete($user->uid); drush_log(dt('Succes deleting') . ' ' . $user->name, 'success'); } } else { drush_user_abort(); } }
  • 27. function drush_usertools_disable_role() { $query = db_select('role', 'r'); $query->fields('r', array('rid', ‘name')); $query->condition('r.rid', 1, '<>'); $query->orderBy('r.rid'); $result = $query->execute(); ! ! ! ! } ! ! ! ! ! ! ! ! ! $options = array(); foreach ($result as $role) { $options[$role->rid] = array($role->name); } $rid = drush_choice($options, dt('Select role:')); // SQL queries. drush_log('All users of role ' . $options[$rid][0] . ' disabled.', 'success');
  • 28. Links • https://drupal.org/node/594744 - Drush on Windows • https://drupal.org/node/1791676 - Drush on *nix • http://drushmake.me - Drush make • http://drush.ws • https://gist.github.com/Sanchiz/7627657
  • 29. Thank you! ! Email: alexander.schedrov@gmail.com Twitter: @alexschedrov FB: schedrov http://sanchiz.net