Commit e288ec9a authored by Adrian Rossouw's avatar Adrian Rossouw Committed by adrian

Simplify verify code by creating _provision_create_dir function. Removed...

Simplify verify code by creating _provision_create_dir function. Removed duplicate code from other modules. Need this in hosting_setup too.
parent d235dfa4
......@@ -330,25 +330,8 @@ function _provision_drupal_install_schema($profile) {
function provision_drupal_provision_verify($url, &$data) {
provision_path("writable", "sites", true, t("Drupal sites directory is writable by the provisioning script"),
t("Drupal sites directory is not writable by the provisioning script"), PROVISION_PERM_ERROR);
$exists = _provision_create_dir(PROVISION_DRUSHRC_PATH, t('Drush configuration path'), 0700);
$exists = provision_path("exists", PROVISION_DRUSHRC_PATH, true ,
t("Virtual Host configuration path exists."),
t("Virtual Host configuration path does not exist."));
if (!$exists) {
$made = provision_path("mkdir", PROVISION_DRUSHRC_PATH, true,
t("Virtual host configuration path has been created."),
t("Virtual host configuration path could not be created."),
PROVISION_PERM_ERROR | PROVISION_FRAMEWORK_ERROR);
}
else {
$writable = provision_path("writable", PROVISION_DRUSHRC_PATH, true ,
t("Virtual host configuration path is writable."),
t("Virtual host configuration path is not writable."),
PROVISION_PERM_ERROR | PROVISION_FRAMEWORK_ERROR);
if (!$writable) {
chmod($path, 0770);
}
}
$profiles = file_scan_directory('./profiles', '\.profile$', array('.', '..', 'CVS', '.svn'), 0, TRUE, 'name', 0);
$data['profiles'] = $profiles;
......
......@@ -522,57 +522,8 @@ function _provision_import($url = null) {
* Will exit with a PROVISION_SITE_NOT_FOUND error if the site does not exist.
*/
function _provision_verify($url = '') {
$exists = provision_path("exists",PROVISION_CONFIG_PATH, true ,
t("Provision configuration path exists."),
t("Provision configuration path does not exist."));
if (!$exists) {
$made = provision_path("mkdir", PROVISION_CONFIG_PATH, true,
t("Provision configuration path has been created."),
t("Provision configuration could not be created."),
PROVISION_PERM_ERROR | PROVISION_FRAMEWORK_ERROR);
}
provision_path("writable", PROVISION_CONFIG_PATH, true ,
t("Provision configuration path is writable."),
t("Provision configuration path is not writable."),
PROVISION_PERM_ERROR | PROVISION_FRAMEWORK_ERROR);
provision_path("chown", PROVISION_CONFIG_PATH, PROVISION_SCRIPT_USER,
t("Changed ownership of <code>@path</code>"),
t("Could not change ownership <code>@path</code>"),
PROVISION_PERM_ERROR | PROVISION_FRAMEWORK_ERROR );
provision_path("chmod", PROVISION_CONFIG_PATH, 0700,
t("Changed permissions of <code>@path</code> to @confirm"),
t("Could not change ownership <code>@path</code> to @confirm"),
PROVISION_PERM_ERROR | PROVISION_FRAMEWORK_ERROR );
$exists = provision_path("exists", PROVISION_BACKUP_PATH, true ,
t("Provision backup path exists."),
t("Provision backup path does not exist."));
if (!$exists) {
$made = provision_path("mkdir", PROVISION_BACKUP_PATH, true,
t("Provision backup path has been created."),
t("Provision backup could not be created."),
PROVISION_PERM_ERROR | PROVISION_FRAMEWORK_ERROR);
}
provision_path("writable", PROVISION_BACKUP_PATH, true ,
t("Provision backup path is writable."),
t("Provision backup path is not writable."),
PROVISION_PERM_ERROR | PROVISION_FRAMEWORK_ERROR);
provision_path("chown", PROVISION_BACKUP_PATH, PROVISION_SCRIPT_USER,
t("Changed ownership of <code>@path</code>"),
t("Could not change ownership <code>@path</code>"),
PROVISION_PERM_ERROR | PROVISION_FRAMEWORK_ERROR );
provision_path("chmod", PROVISION_BACKUP_PATH, 0700,
t("Changed permissions of <code>@path</code> to @confirm"),
t("Could not change ownership <code>@path</code> to @confirm"),
PROVISION_PERM_ERROR | PROVISION_FRAMEWORK_ERROR );
_provision_create_dir(PROVISION_CONFIG_PATH, t('Provision configuration'), 0700);
_provision_create_dir(PROVISION_BACKUP_PATH, t('Web server configuration'), 0700);
$data = array();
$rolled_back = provision_invoke("verify", $url, $data);
......
......@@ -237,3 +237,42 @@ function provision_path_extract($path, &$target, &$reason) {
/**
*@} end filegroup
*/
/**
* Small helper function for creation of configuration directories.
*/
function _provision_create_dir($path, $name, $perms) {
$exists = provision_path("exists",$path, true ,
$name . ' ' . t("path exists."),
$name . ' ' . t("path does not exist.")
);
if (!$exists) {
$exists = provision_path("mkdir", $path, true,
$name . ' ' . t("path has been created."),
$name . ' ' . t("path could not be created."),
PROVISION_PERM_ERROR | PROVISION_FRAMEWORK_ERROR);
}
if ($exists) {
provision_path("chown", $path, PROVISION_SCRIPT_USER,
$name . ' ' . t("ownership of path has been changed to @confirm."),
$name . ' ' . t("ownership of path could not be changed to @confirm."),
PROVISION_PERM_ERROR | PROVISION_FRAMEWORK_ERROR);
provision_path("chmod", $path, $perms,
$name . ' ' . t("permissions of path have been changed to @confirm."),
$name . ' ' . t("permissions of path could not be changed to @confirm."),
PROVISION_PERM_ERROR | PROVISION_FRAMEWORK_ERROR );
$writable = provision_path("writable", $path, true,
$name . ' ' . t("path is writeable."),
$name . ' ' . t("path is not writeable."),
PROVISION_PERM_ERROR | PROVISION_FRAMEWORK_ERROR);
}
return ($exists && $writable);
}
......@@ -286,33 +286,7 @@ function _provision_apache_restart_apache() {
}
function provision_apache_provision_verify() {
$exists = provision_path("exists", PROVISION_VHOST_PATH, true ,
t("Virtual Host configuration path exists."),
t("Virtual Host configuration path does not exist."));
if (!$exists) {
$made = provision_path("mkdir", PROVISION_VHOST_PATH, true,
t("Virtual host configuration path has been created."),
t("Virtual host configuration path could not be created."),
PROVISION_PERM_ERROR | PROVISION_FRAMEWORK_ERROR);
}
else {
$writable = provision_path("writable", PROVISION_VHOST_PATH, true ,
t("Virtual host configuration path is writable."),
t("Virtual host configuration path is not writable."),
PROVISION_PERM_ERROR | PROVISION_FRAMEWORK_ERROR);
if (!$writable) {
provision_path("chown", PROVISION_VHOST_PATH, PROVISION_SCRIPT_USER,
t("Changed ownership of <code>@path</code>"),
t("Could not change ownership <code>@path</code>"),
PROVISION_PERM_ERROR);
provision_path("chmod", PROVISION_VHOST_PATH, 0700,
t("Changed permissions of <code>@path</code> to @confirm"),
t("Could not change ownership <code>@path</code> to @confirm"),
PROVISION_PERM_ERROR );
}
}
$exists = _provision_create_dir(PROVISION_VHOST_PATH, t("Virtual host configuration"), 0700);
}
/**
......
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