| 1 |
<?php
|
| 2 |
|
| 3 |
/**
|
| 4 |
* Provision verify command
|
| 5 |
*
|
| 6 |
* Disable an enabled and installed site
|
| 7 |
*/
|
| 8 |
function drush_provision_drupal_provision_verify_validate($url = null) {
|
| 9 |
if ($url) {
|
| 10 |
drush_bootstrap(DRUSH_BOOTSTRAP_DRUPAL_SITE);
|
| 11 |
$fields = array('db_type', 'db_host', 'db_user', 'db_passwd', 'db_name');
|
| 12 |
foreach ($fields as $key) {
|
| 13 |
$_SERVER[$key] = drush_get_option($key, null, 'site');
|
| 14 |
}
|
| 15 |
|
| 16 |
_provision_drupal_create_settings_file($url);
|
| 17 |
drush_errors_on();
|
| 18 |
drush_bootstrap(DRUSH_BOOTSTRAP_DRUPAL_FULL);
|
| 19 |
}
|
| 20 |
|
| 21 |
// This will not have an effect if you are running it on a platform, just tests that if a site is provided it is an existing one
|
| 22 |
_provision_drupal_valid_site();
|
| 23 |
}
|
| 24 |
|
| 25 |
|
| 26 |
/**
|
| 27 |
* implementation of provision_verify
|
| 28 |
*/
|
| 29 |
function drush_provision_drupal_provision_verify($url = null) {
|
| 30 |
if (PROVISION_CONTEXT_PLATFORM) {
|
| 31 |
_provision_create_dir(drush_get_option('config_path'), dt('Provision configuration'), 0711);
|
| 32 |
_provision_create_dir(drush_get_option('config_path') . '/includes', dt('Provision PHP configuration'), 0711);
|
| 33 |
if (!provision_path('exists', drush_get_option('config_path') . '/includes/global.inc', TRUE, dt("Global configuration file exists"))) {
|
| 34 |
# create an empty global.inc so the include doesn't fail with
|
| 35 |
# open_basedir restrictions
|
| 36 |
if (!$file = fopen(drush_get_option('config_path') . '/includes/global.inc', 'a')) {
|
| 37 |
drush_set_error('PROVISION_FRAMEWORK_ERROR', dt('Cannot create global settings configuration'));
|
| 38 |
} else {
|
| 39 |
fwrite($file, "<?php # global settings.php");
|
| 40 |
fclose($file);
|
| 41 |
}
|
| 42 |
}
|
| 43 |
_provision_create_dir(drush_get_option('backup_path'), dt('Backup'), 0700);
|
| 44 |
provision_path("writable", drush_get_option('sites_path'), TRUE, dt("Drupal sites directory is writable by the provisioning script"),
|
| 45 |
dt("Drupal sites directory is not writable by the provisioning script"), 'PROVISION_SITES_DIR_NOT_WRITABLE');
|
| 46 |
|
| 47 |
drush_set_option('sites', array_keys((array) provision_drupal_find_sites()), 'drupal');
|
| 48 |
drush_log(dt("This platform is running @short_name @version", array('@short_name' => 'drupal', '@version' => VERSION)));
|
| 49 |
drush_set_option('packages', _scrub_object(provision_find_packages()), 'drupal');
|
| 50 |
}
|
| 51 |
else {
|
| 52 |
drush_set_option('packages', _scrub_object(provision_drupal_system_map()), 'site');
|
| 53 |
// This is the actual drupal provisioning requirements.
|
| 54 |
_provision_drupal_create_directories($url);
|
| 55 |
_provision_drupal_maintain_aliases($url);
|
| 56 |
// Requires at least the database settings to complete.
|
| 57 |
_provision_drupal_create_settings_file($url);
|
| 58 |
}
|
| 59 |
|
| 60 |
}
|
| 61 |
|
| 62 |
|
| 63 |
/**
|
| 64 |
* Implementation of hook_provision_post_verify
|
| 65 |
*/
|
| 66 |
function drush_provision_drupal_post_provision_verify($url = NULL) {
|
| 67 |
if (PROVISION_CONTEXT_SITE) {
|
| 68 |
_provision_drupal_rebuild_caches($url);
|
| 69 |
drush_set_option('aliases', drush_get_option('aliases'), 'site');
|
| 70 |
drush_set_option('redirection', drush_get_option('redirection'), 'site');
|
| 71 |
drush_set_option('installed', TRUE, 'site');
|
| 72 |
}
|
| 73 |
}
|
| 74 |
|
| 75 |
/**
|
| 76 |
* Inject the relevant .htacces configuration into the global apache configuration
|
| 77 |
*/
|
| 78 |
function provision_drupal_provision_apache_dir_config($data = null) {
|
| 79 |
return <<<EOF
|
| 80 |
#
|
| 81 |
# Apache/PHP/Drupal settings:
|
| 82 |
#
|
| 83 |
|
| 84 |
# Protect files and directories from prying eyes.
|
| 85 |
<FilesMatch "\.(engine|inc|info|install|module|profile|test|po|sh|.*sql|theme|tpl(\.php)?|xtmpl|svn-base)$|^(code-style\.pl|Entries.*|Repository|Root|Tag|Template|all-wcprops|entries|format)$">
|
| 86 |
Order allow,deny
|
| 87 |
</FilesMatch>
|
| 88 |
|
| 89 |
# Don't show directory listings for URLs which map to a directory.
|
| 90 |
Options -Indexes
|
| 91 |
|
| 92 |
# Follow symbolic links in this directory.
|
| 93 |
Options +FollowSymLinks
|
| 94 |
|
| 95 |
# Make Drupal handle any 404 errors.
|
| 96 |
ErrorDocument 404 /index.php
|
| 97 |
|
| 98 |
# Force simple error message for requests for non-existent favicon.ico.
|
| 99 |
<Files favicon.ico>
|
| 100 |
# There is no end quote below, for compatibility with Apache 1.3.
|
| 101 |
ErrorDocument 404 "The requested file favicon.ico was not found.
|
| 102 |
</Files>
|
| 103 |
|
| 104 |
# Set the default handler.
|
| 105 |
DirectoryIndex index.php
|
| 106 |
|
| 107 |
# Override PHP settings. More in sites/default/settings.php
|
| 108 |
# but the following cannot be changed at runtime.
|
| 109 |
|
| 110 |
# PHP 4, Apache 1.
|
| 111 |
<IfModule mod_php4.c>
|
| 112 |
php_value magic_quotes_gpc 0
|
| 113 |
php_value register_globals 0
|
| 114 |
php_value session.auto_start 0
|
| 115 |
php_value mbstring.http_input pass
|
| 116 |
php_value mbstring.http_output pass
|
| 117 |
php_value mbstring.encoding_translation 0
|
| 118 |
</IfModule>
|
| 119 |
|
| 120 |
# PHP 4, Apache 2.
|
| 121 |
<IfModule sapi_apache2.c>
|
| 122 |
php_value magic_quotes_gpc 0
|
| 123 |
php_value register_globals 0
|
| 124 |
php_value session.auto_start 0
|
| 125 |
php_value mbstring.http_input pass
|
| 126 |
php_value mbstring.http_output pass
|
| 127 |
php_value mbstring.encoding_translation 0
|
| 128 |
</IfModule>
|
| 129 |
|
| 130 |
# PHP 5, Apache 1 and 2.
|
| 131 |
<IfModule mod_php5.c>
|
| 132 |
php_value magic_quotes_gpc 0
|
| 133 |
php_value register_globals 0
|
| 134 |
php_value session.auto_start 0
|
| 135 |
php_value mbstring.http_input pass
|
| 136 |
php_value mbstring.http_output pass
|
| 137 |
php_value mbstring.encoding_translation 0
|
| 138 |
</IfModule>
|
| 139 |
|
| 140 |
# Requires mod_expires to be enabled.
|
| 141 |
<IfModule mod_expires.c>
|
| 142 |
# Enable expirations.
|
| 143 |
ExpiresActive On
|
| 144 |
|
| 145 |
# Cache all files for 2 weeks after access (A).
|
| 146 |
ExpiresDefault A1209600
|
| 147 |
|
| 148 |
# Do not cache dynamically generated pages.
|
| 149 |
ExpiresByType text/html A1
|
| 150 |
</IfModule>
|
| 151 |
|
| 152 |
# Various rewrite rules.
|
| 153 |
<IfModule mod_rewrite.c>
|
| 154 |
RewriteEngine on
|
| 155 |
|
| 156 |
# Rewrite URLs of the form 'x' to the form 'index.php?q=x'.
|
| 157 |
RewriteCond %{REQUEST_FILENAME} !-f
|
| 158 |
RewriteCond %{REQUEST_FILENAME} !-d
|
| 159 |
RewriteCond %{REQUEST_URI} !=/favicon.ico
|
| 160 |
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
|
| 161 |
</IfModule>
|
| 162 |
|
| 163 |
# Do not read the platform's .htaccess
|
| 164 |
AllowOverride none
|
| 165 |
|
| 166 |
EOF;
|
| 167 |
}
|