I want to use drush to set up drupal on a new host.
The public_html folder is already there: how can I use 'drush dl' to put drupal core files directly into this?
Using the --destination option just puts a 'drupal-6.12' folder inside public_html.

Comments

moshe weitzman’s picture

what different behavior do you want?

joachim’s picture

An extra option to download files to the current directory bare, or to a given directory, if this is not already possible?

If the folder "public_html" already exists, the commands to issue might be:
$ cd public_html/
$ drush dl --bare

or standing in the parent directory:
$ drush dl --destination="public_html" --bare

moshe weitzman’s picture

Status: Active » Closed (works as designed)

oh. thats only useful for core itself. i think we can expect users to use the mv command for this.

joachim’s picture

It would be nice if installing a fresh drupal could be as simple as:

$ drush dl
$ drush install

Isn't the mv step a bit fiddly?

moshe weitzman’s picture

We don't support install. That would be a duplicate feature request.

joachim’s picture

...yet :)
A bunch of us at DrupalCampUK last weekend were talking about writing a drush command for install.
Is there already an issue for that?

psynaptic’s picture

I think we'll need to make a new drush hook then.

ethanw’s picture

Issue tags: +drush, +script, +bash

In the meantime, I'm currently using rsync and temp folders to install drush into a given directory (eg. one checked out from an existing repo):

# install core
tempdir=`mktemp -d -t drupal-new`
drush.php dl drupal --destination=$tempdir
# get drupal version dir name
tempdir_contents=`ls $tempdir`
drupal_dir=${tempdir_contents##*/}
# move drupal core files to current directory
rsync -r $tempdir/$drupal_dir/ ./
# delete tempdir
rm -rf $tempdir

you can put this into a bash script, something like "new-drupal.sh" and run it from any directory.

kenorb’s picture

Component: Code » PM (dl, en, up ...)

The same problem.
Can't install Drupal into current directory.

kenorb’s picture

Tried:

drush dl -v --drupal-project-rename="../$(basename `pwd`)"

But it removes the current dir.

kenorb’s picture

Another try:


kenorbs-MacBook-Air:zgi kenorb$ drush dl -v --destination=".." --drupal-project-rename="$(basename `pwd`)"
Executing: wget --version
Downloading release history from http://updates.drupal.org/release-history/drupal/7.x                                                                                                             [notice]
Executing: mkdir '/tmp/drush_tmp_1317839104'
Downloading project drupal to /tmp/drush_tmp_1317839104 ...                                                                                                                                       [notice]
Calling chdir(/tmp/drush_tmp_1317839104)
Executing: wget -P . 'http://ftp.drupal.org/files/projects/drupal-7.8.tar.gz'
Downloading drupal-7.8.tar.gz was successful.                                                                                                                                                     [notice]
Calling md5_file(drupal-7.8.tar.gz)
Md5 checksum of drupal-7.8.tar.gz verified.                                                                                                                                                       [notice]
Executing: gzip -d 'drupal-7.8.tar.gz'
Executing: tar -xf 'drupal-7.8.tar'
Executing: tar -tf 'drupal-7.8.tar'
Calling is_readable(/tmp/drush_tmp_1317839104/drupal-7.8)
Calling is_writable(/tmp/drush_tmp_1317839104)
Calling rename(/tmp/drush_tmp_1317839104/drupal-7.8, /tmp/drush_tmp_1317839104/zgi)
Calling unlink(drupal-7.8.tar)
Calling chdir(/Users/kenorb/Sites/zgi)
Executing: svn info '..'
Executing: bzr root '..'
Install location ../zgi already exists. Do you want to overwrite it? (y/n): y
Calling drush_delete_dir(../zgi)
Calling is_readable(/tmp/drush_tmp_1317839104/zgi)
Calling is_writable(..)
Calling rename(/tmp/drush_tmp_1317839104/zgi, ../zgi)
Project drupal (7.8) downloaded to ../zgi.                                                                                                                                                     [success]
Project drupal contains:                                                                                                                                                                       [success]
 - 3 profiles: testing, standard, minimal
...

But the current dir is empty;/

Debug:


Calling is_readable(/tmp/drush_tmp_1317839222/drupal-7.8)
Calling is_writable(/tmp/drush_tmp_1317839222)
Calling rename(/tmp/drush_tmp_1317839222/drupal-7.8, /tmp/drush_tmp_1317839222/zgi)
Calling unlink(drupal-7.8.tar)
Calling chdir()
chdir(): No such file or directory (errno 2) drush.inc:1164 [11.08 sec, 6.73 MB]                                                                                                               [warning]
Verifying signature for svn version control engine. [11.08 sec, 6.63 MB]                                                                                                                           [debug]
Executing: svn info '..'
  svn: Path '..' ends in '..', which is unsupported for this operation
kenorb’s picture

Status: Closed (works as designed) » Fixed

It works, great stuff!

drush dl -v -d --destination=".." --drupal-project-rename="$(basename `pwd`)"

Where: $(basename `pwd`) should return the name of current directory.

If you do 'ls -la', the current dir will be empty, but it's not: 'ls -al `pwd`'. If you re-enter the same folder, the files are there.
But remember, all files in current folder will be removed and overridden by Drupal core! Please be careful by adding '-y'!

kenorb’s picture

Some simple script for downloading and installing Drupal site from scratch:

#!/bin/sh -x

# basic Drupal configuration
DRUPAL_DIR="zgi" # which directory to install Drupal
DB_URL="mysql://root:root@localhost:zgi"

# modules to enable
CONTRIB_MODULES="  date calendar admin_menu"
CONTRIB_MODULES+=" pathauto" # base modules
CONTRIB_MODULES+=" captcha recaptcha" # security modules
CONTRIB_MODULES+=" variable token pathauto" # API modules
CONTRIB_MODULES+=" votingapi fivestar" # voting modules
CONTRIB_MODULES+=" wysiwyg" # WYSIWYG modules
CONTRIB_MODULES+=" i18n" # language modules
CONTRIB_MODULES+=" google_analytics" # statistics modules

OTHER_MODULES="admin_menu"
NEW_DIRS="sites/default/files sites/all/modules/contrib sites/all/modules/custom sites/all/modules/admin"

# commands
DRUSH="drush -v"

# download Drupal core
$DRUSH dl drupal --drupal-project-rename="$DRUPAL_DIR"
cd "$DRUPAL_DIR" || exit 1 # go to directory (create if doesn't exist)

# configure and install
mkdir -v $NEW_DIRS # create proper folder structure
cp -v sites/default/default.settings.php sites/default/settings.php # create config file
$DRUSH site-install --db-url="$DB_URL"

# change permissions
# chmod 777 "sites/default/files"

# download content modules
$DRUSH -y dl $CONTRIB_MODULES

Status: Fixed » Closed (fixed)
Issue tags: -drush, -script, -bash

Automatically closed -- issue fixed for 2 weeks with no activity.

murz’s picture

Issue summary: View changes

Here is Linux Bash one-liner cli script for download and extract Drupal via Drush to current folder directly, without creating additional directory like in #12:
drush dl drupal --drupal-project-rename="../${PWD##*/}" -y

murz’s picture

But why this issue is marked as fixed? Hacks via providing current folder name with .. is not the good way - please provide standard command line argument for Drush script, that download Drupal directly to current folder! I can't reopen this issue, so I create a new feature request: https://www.drupal.org/project/drush/issues/2947845

swathiyernagula’s picture

drush dl drupal --drupal-project-rename=projectname

Above command is to download drupal core files in the above mentioned projectname folder

drush dl drupal --destination=path

Also, you can just type in drush help pm-download to see all the available options