drush – das sackmesser für die kommandozeile

15

Click here to load reader

Upload: florian-latzel

Post on 27-May-2015

1.971 views

Category:

Technology


1 download

DESCRIPTION

Präsentation auf dem DrupalMediaCamp 2009, Aarau, Schweiz Zusammenfassung: -------------------------- Drush steht für Drupal Shell und ist die Schnittstelle für Drupal auf der Kommandozeile. Mittlerweile ist Drush kein Modul mehr, daß heißt Drush benötigt auch nicht mehr zwangsweise eine Drupal-Installation und läuft wenn unabhängig von der Drupal-Version(5.x, 6.x, 7.x). Mit Drush kann man alles machen, was aus Drupal heraus auch möglich ist. Wer die Kommandozeile mag, wird Drush lieben. Themen ----------- 1. whatis drush.php Über drush 2. man drush.php Die drush-Hilfe 3. define('DRUSH_BOOTSTRAP_DRUSH', 0); Drush ohne Drupal * Drush-Optionen * Drush-Kommandos 4. define('DRUSH_BOOTSTRAP_DRUPAL_ROOT', 1); Drush mit einer Drupal-Installation 5. define('DRUSH_BOOTSTRAP_DRUPAL_SITE', 2); Drush mit einer Drupal-Site * Drupal-Kommandos * Paketmanagement und Updates 6. define('DRUSH_BOOTSTRAP_DRUPAL_CONFIGURATION', 3); Drush mit Zugriff auf eine settings.php * SQL-Kommandos 7. ~/.drushrc.php Die Konfigurtionsdatei von drush 8. ~/.drush Eigene drush-Skripte

TRANSCRIPT

Page 1: Drush – Das Sackmesser für die Kommandozeile

ISL Individuelle System Lösungen | DrupalMediaCamp.CH 2009 | 2009-05-09 | Florian Latzel 1

Drush – Das Sackmesser für die Kommandozeile

Florian Latzel

Page 2: Drush – Das Sackmesser für die Kommandozeile

ISL Individuelle System Lösungen | DrupalMediaCamp.CH 2009 | 2009-05-09 | Florian Latzel 2

whoami

Florian „fl3a“ Latzel

Staatl. gepr. Informatiker, LPIC Level 2

IT-Berater(„ISL Individuelle System Lösungen“)

● Schwerpunkt: Open Source Software

● Content Management Systeme

● Analyse, Beratung, Konzeption, Training

● Web-Entwicklung

Page 3: Drush – Das Sackmesser für die Kommandozeile

ISL Individuelle System Lösungen | DrupalMediaCamp.CH 2009 | 2009-05-09 | Florian Latzel 3

ls ­lia drush

Inhalt● whatis drush.php● man drush.php● define('DRUSH_BOOTSTRAP_DRUSH', 0);

● Drush Optionen● Drush Kommandos

● define('DRUSH_BOOTSTRAP_DRUPAL_ROOT', 1);● define('DRUSH_BOOTSTRAP_DRUPAL_SITE', 2);

● Drupal-Kommandos● Paketmanagement und Updates

● define('DRUSH_BOOTSTRAP_DRUPAL_CONFIGURATION', 3);● SQL-Kommandos

● ~/.drushrc.php● ~/.drush

Page 4: Drush – Das Sackmesser für die Kommandozeile

ISL Individuelle System Lösungen | DrupalMediaCamp.CH 2009 | 2009-05-09 | Florian Latzel 4

whatis drush.php

Drupal Shell● Projektseite: http://drupal.org/project/drush

● Bevorzugt auf unixoiden Systemen

● PHP-CLI Skript● Kein Drupal-Modul

● Benötigt keine Drupal-Installation

● Unabhängig von Drupal-Version(5.x, 6.x, 7.x)

Installation von drushwget http://ftp.drupal.org/files/projects/drush­HEAD­all­versions.tar.gz

Page 5: Drush – Das Sackmesser für die Kommandozeile

ISL Individuelle System Lösungen | DrupalMediaCamp.CH 2009 | 2009-05-09 | Florian Latzel 5

man drush.php

RTFM oder die Drush-Hilfedrush.php [­r drupal_root] [­l site_url] help [command]

Page 6: Drush – Das Sackmesser für die Kommandozeile

ISL Individuelle System Lösungen | DrupalMediaCamp.CH 2009 | 2009-05-09 | Florian Latzel 6

define('DRUSH_BOOTSTRAP_DRUSH', 0);

Drush Optionen­r <path>, ­­root=<path> Drupal root directory to use

(default: current directory)

­l <uri> , ­­uri=<uri> URI of the drupal site to use (only needed in multisite environments)

­v, ­­verbose Display all available output

­q, ­­quiet Hide all output

­y, ­­yes Assume 'yes' as answer to all prompts

­s, ­­simulate Simulate all relevant actions (don't actually change the system)

­i, ­­include                A list of paths to search for drush commands

­c, ­­config                 Specify a config file to use.          See example.drushrc.php

­u, ­­user Specify a user to login with. May be                                          a name or a number.

­b, ­­backend Hide all output and return structured data(internal use only).

Page 7: Drush – Das Sackmesser für die Kommandozeile

ISL Individuelle System Lösungen | DrupalMediaCamp.CH 2009 | 2009-05-09 | Florian Latzel 7

define('DRUSH_BOOTSTRAP_DRUSH', 0);

Drush-Kommandoshelp                Print this help message. Use ­­filter to

                  limit command list to one command file                  (e.g. ­­filter=pm)

              

dl                  Download core Drupal and projects like CCK, Zen, etc.

Page 8: Drush – Das Sackmesser für die Kommandozeile

ISL Individuelle System Lösungen | DrupalMediaCamp.CH 2009 | 2009-05-09 | Florian Latzel 8

define('DRUSH_BOOTSTRAP_DRUPAL_ROOT', 1);

Drush mit einer Drupal-Installation(Drupal-Root)

status Provides a birds­eye view of thecurrent Drupal installation, if any. 

Page 9: Drush – Das Sackmesser für die Kommandozeile

ISL Individuelle System Lösungen | DrupalMediaCamp.CH 2009 | 2009-05-09 | Florian Latzel 9

define('DRUSH_BOOTSTRAP_DRUPAL_SITE', 2);

Drupal-Kommandoscron Run all cron hooks.

script                 Run php script(s).

cache clear            Clear all caches.

watchdog show          Shows recent watchdog log messages.Optionally filter for a specific type.

watchdog delete        Delete all messages or only those of aspecified type.

sync                   Rsync the Drupal tree to/from another                     server using ssh.

eval                   Evaluate arbitrary php code after                      bootstrapping Drupal.

Page 10: Drush – Das Sackmesser für die Kommandozeile

ISL Individuelle System Lösungen | DrupalMediaCamp.CH 2009 | 2009-05-09 | Florian Latzel 10

define('DRUSH_BOOTSTRAP_DRUPAL_SITE', 2);

Paket-Management und Updatesrefresh               Refresh update status information

enable                Enable one or more modules.

disable               Disable one or more modules.

uninstall             Uninstall one or more modules.

statusmodules         Show module enabled/disabled status

refresh               Refresh update status information

updatecode            Update your project code

update                Update your project code and apply anydatabase updates required (update.php)

info                  Release information for a project

updatedb Execute the update.php process from the                          command line.

Page 11: Drush – Das Sackmesser für die Kommandozeile

ISL Individuelle System Lösungen | DrupalMediaCamp.CH 2009 | 2009-05-09 | Florian Latzel 11

define('DRUSH_BOOTSTRAP_DRUPAL_CONFIGURATION',3);

Drush mit Zugriff auf eine settings.php(SQL)sql conf Print database connection details.

sql connect A string for connecting to the DB.

sql dump Exports the Drupal DB as SQL usingmysqldump.

sql query Execute a query against the site database.

sql load Copy source database to target database.

sql cli Open a SQL command­line interface usingDrupal’s credentials.

Page 12: Drush – Das Sackmesser für die Kommandozeile

ISL Individuelle System Lösungen | DrupalMediaCamp.CH 2009 | 2009-05-09 | Florian Latzel 12

~/.drushrc.php

Die Konfigurationsdatei von drush

Orte der Plazierung:

1. Ordner einer Drupal-Site

2. Wurzel der Drupal Installation

3. Im Home-Verzeichnis(~/.drushrc.php)

4. Im Ordner der Drush-Installation

oder Spezifizierung durch ­c oder --config

Page 13: Drush – Das Sackmesser für die Kommandozeile

ISL Individuelle System Lösungen | DrupalMediaCamp.CH 2009 | 2009-05-09 | Florian Latzel 13

~/.drushrc.php

Die Konfigurationsdatei für Drush<?php

 $options['r'] = '/home/florian/drupal/6.x'; $options['v'] = 1;    

 $options['skip­tables'] = array(   'common' => array('accesslog', 'cache', 'cache_block',          'cache_filter', 'cache_form', 'cache_menu',    'cache_page', 'cache_update', 'history',                        'search_dataset', 'search_index',    'search_total', 'sessions', 'watchdog'), );

 $options['handler'] = 'wget';

Beispiel

● example.drushrc.php

Page 14: Drush – Das Sackmesser für die Kommandozeile

ISL Individuelle System Lösungen | DrupalMediaCamp.CH 2009 | 2009-05-09 | Florian Latzel 14

~/.drush

Eigene Drush-Erweiterungen

Location

● Ordner .drush im Heimatverzeichnis

● Spezifizierung durch ­i oder ­­include

Beispiel

● example.drush.inc

Page 15: Drush – Das Sackmesser für die Kommandozeile

ISL Individuelle System Lösungen | DrupalMediaCamp.CH 2009 | 2009-05-09 | Florian Latzel 15

which; whatis; who >/dev/null

Fragen?

Kontakt

ISL Individuelle System Lösungenhttp://[email protected]

Netzaffe (Blog)http://[email protected]