Commit 35e21e82 authored by anarcat's avatar anarcat Committed by anarcat

factor directory all directory creation into a single function

parent 4ae1d0ca
......@@ -217,24 +217,29 @@ function _provision_drupal_create_settings_file($url = NULL) {
* Also maintains permissions on existing directories.
*/
function _provision_drupal_create_directories($url, $profile = NULL) {
$paths = array(
$readonly = array(
"sites/$url" => 0755,
"sites/$url/files" => 02770,
"sites/$url/files/tmp" => 02770,
"sites/$url/files/images" => 02770,
"sites/$url/files/pictures" => 02770,
"sites/$url/themes" => 0755,
"sites/$url/modules" => 0755,
"sites/$url/libraries" => 0755, # http://drupal.org/node/496240
);
$grps = array(
"sites/$url/files",
"sites/$url/files/tmp",
"sites/$url/files/images",
"sites/$url/files/pictures",
);
// special case: platform. do not create files dir
if ($url == 'all') {
$readwrite = array();
} else {
$readonly["sites/$url/files"] = 02770;
$readonly["sites/$url/files/tmp"] = 02770;
$readonly["sites/$url/files/images"] = 02770;
$readonly["sites/$url/files/pictures"] = 02770;
$readwrite = array(
"sites/$url/files",
"sites/$url/files/tmp",
"sites/$url/files/images",
"sites/$url/files/pictures",
);
}
foreach ($paths as $path => $perm) {
foreach ($readonly as $path => $perm) {
if (!is_dir($path)) {
provision_path("mkdir", $path, TRUE,
dt("Created <code>@path</code>"),
......@@ -247,8 +252,8 @@ function _provision_drupal_create_directories($url, $profile = NULL) {
dt("Could not change permissions <code>@path</code> to @confirm")
);
}
foreach ($grps as $path) {
provision_path("chown_recursive", $path, drush_get_option('script_user'),
foreach ($readwrite as $path) {
provision_path("chown_recursive", $path, drush_get_option('script_user'),
dt("Changed ownership of <code>@path</code>"),
dt("Could not change ownership <code>@path</code>"),
'DRUSH_PERM_ERROR' );
......
......@@ -44,23 +44,7 @@ function drush_provision_drupal_provision_verify($url = null) {
drush_set_option('sites', array_keys((array) provision_drupal_find_sites()), 'drupal');
drush_log(dt("This platform is running @short_name @version", array('@short_name' => 'drupal', '@version' => VERSION)));
drush_set_option('packages', _scrub_object(provision_find_packages()), 'drupal');
$paths = array(
"sites/all/themes" => 0755,
"sites/all/modules" => 0755,
"sites/all/libraries" => 0755, # http://drupal.org/node/496240
);
foreach ($paths as $path => $perm) {
if (!is_dir($path)) {
provision_path("mkdir", $path, TRUE,
dt("Created <code>@path</code>"),
dt("Could not create <code>@path</code>"),
'DRUSH_PERM_ERROR');
}
provision_path("chmod_recursive", $path, $perm,
dt("Changed permissions of <code>@path</code> to @confirm"),
dt("Could not change permissions of <code>@path</code> to @confirm"),
'DRUSH_PERM_ERROR');
}
_provision_drupal_create_directories('all');
}
else {
drush_set_option('packages', _scrub_object(provision_drupal_system_map()), 'site');
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment