Skip to content
GitLab
About GitLab
GitLab: the DevOps platform
Explore GitLab
Install GitLab
How GitLab compares
Get started
GitLab docs
GitLab Learn
Pricing
Talk to an expert
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Projects
Groups
Snippets
Sign up now
Login
Sign in
Toggle navigation
Menu
Open sidebar
project
provision
Commits
2e916fbd
Commit
2e916fbd
authored
Sep 06, 2014
by
Grazyna Jaworska
Browse files
Remove legacy subdir code and update checks.
parent
3c9a4d0d
Changes
10
Hide whitespace changes
Inline
Side-by-side
http/Provision/Config/Apache/subdir_sites.tpl.php
View file @
2e916fbd
...
...
@@ -48,8 +48,12 @@ print "<?php \n"; ?>
$aliases
=
d
()
->
aliases
;
// Fix our subdir aliases.
foreach
(
$aliases
as
$alias
)
{
$records
[
str_replace
(
'/'
,
'.'
,
$alias
)]
=
$records
[
$alias
];
unset
(
$records
[
$alias
]);
// Only replace the records[] array key if the alias is a subdir alias
// Patch for https://drupal.org/node/2213387
if
(
strpos
(
$alias
,
"/"
))
{
$records
[
str_replace
(
'/'
,
'.'
,
$alias
)]
=
$records
[
$alias
];
unset
(
$records
[
$alias
]);
}
}
?>
$sites =
<?php
print
var_export
(
$records
,
TRUE
)
?>
;
http/Provision/Config/Apache/vhost.tpl.php
View file @
2e916fbd
...
...
@@ -86,7 +86,14 @@ if ($this->redirection || $ssl_redirection) {
<?php
$if_subsite
=
$this
->
data
[
'http_subdird_path'
]
.
'/'
.
$this
->
uri
;
if
(
subdirs_drush_load
()
&&
provision_file
()
->
exists
(
$if_subsite
)
->
status
())
{
$if_subdirs
=
drush_get_option
(
'hosting_features'
,
array
());
if
((
array_key_exists
(
'subdirs'
,
$if_subdirs
)
&&
$if_subdirs
[
'subdirs'
]))
{
$subdirs_support
=
TRUE
;
}
else
{
$subdirs_support
=
FALSE
;
}
if
(
$subdirs_support
&&
provision_file
()
->
exists
(
$if_subsite
)
->
status
())
{
print
" Include "
.
$if_subsite
.
"/*.conf
\n
"
;
}
?>
...
...
http/Provision/Config/Nginx/subdir_sites.tpl.php
View file @
2e916fbd
...
...
@@ -48,8 +48,12 @@ print "<?php \n"; ?>
$aliases
=
d
()
->
aliases
;
// Fix our subdir aliases.
foreach
(
$aliases
as
$alias
)
{
$records
[
str_replace
(
'/'
,
'.'
,
$alias
)]
=
$records
[
$alias
];
unset
(
$records
[
$alias
]);
// Only replace the records[] array key if the alias is a subdir alias
// Patch for https://drupal.org/node/2213387
if
(
strpos
(
$alias
,
"/"
))
{
$records
[
str_replace
(
'/'
,
'.'
,
$alias
)]
=
$records
[
$alias
];
unset
(
$records
[
$alias
]);
}
}
?>
$sites =
<?php
print
var_export
(
$records
,
TRUE
)
?>
;
http/Provision/Config/Nginx/vhost.tpl.php
View file @
2e916fbd
...
...
@@ -68,7 +68,14 @@ else {
print
" include "
.
$server
->
include_path
.
"/nginx_vhost_common.conf;
\n
"
;
}
$if_subsite
=
$this
->
data
[
'http_subdird_path'
]
.
'/'
.
$this
->
uri
;
if
(
subdirs_drush_load
()
&&
provision_file
()
->
exists
(
$if_subsite
)
->
status
())
{
$if_subdirs
=
drush_get_option
(
'hosting_features'
,
array
());
if
((
array_key_exists
(
'subdirs'
,
$if_subdirs
)
&&
$if_subdirs
[
'subdirs'
]))
{
$subdirs_support
=
TRUE
;
}
else
{
$subdirs_support
=
FALSE
;
}
if
(
$subdirs_support
&&
provision_file
()
->
exists
(
$if_subsite
)
->
status
())
{
print
" include "
.
$if_subsite
.
"/*.conf;
\n
"
;
}
?>
...
...
http/Provision/Service/http/apache.php
View file @
2e916fbd
...
...
@@ -17,8 +17,14 @@ class Provision_Service_http_apache extends Provision_Service_http_public {
$this
->
configs
[
'server'
][]
=
'Provision_Config_Apache_Server'
;
$this
->
configs
[
'platform'
][]
=
'Provision_Config_Apache_Platform'
;
$this
->
configs
[
'site'
][]
=
'Provision_Config_Apache_Site'
;
$features
=
drush_get_option
(
'hosting_features'
,
array
());
if
(
array_key_exists
(
'subdirs'
,
$features
)
&&
$features
[
'subdirs'
])
{
$if_subdirs
=
drush_get_option
(
'hosting_features'
,
array
());
if
((
array_key_exists
(
'subdirs'
,
$if_subdirs
)
&&
$if_subdirs
[
'subdirs'
]))
{
$subdirs_support
=
TRUE
;
}
else
{
$subdirs_support
=
FALSE
;
}
if
(
$subdirs_support
)
{
$this
->
configs
[
'site'
][]
=
'Provision_Config_Apache_Subdir'
;
$this
->
configs
[
'site'
][]
=
'Provision_Config_Apache_SubdirVhost'
;
}
...
...
http/Provision/Service/http/nginx.php
View file @
2e916fbd
...
...
@@ -22,13 +22,26 @@ class Provision_Service_http_nginx extends Provision_Service_http_public {
$this
->
server
->
setProperty
(
'nginx_has_gzip'
,
FALSE
);
$this
->
server
->
setProperty
(
'provision_db_cloaking'
,
TRUE
);
$this
->
server
->
setProperty
(
'phpfpm_mode'
,
'port'
);
if
(
subdirs_drush_load
())
{
$this
->
server
->
setProperty
(
'subdirs_support'
,
FALSE
);
$if_subdirs
=
drush_get_option
(
'hosting_features'
,
array
());
if
((
array_key_exists
(
'subdirs'
,
$if_subdirs
)
&&
$if_subdirs
[
'subdirs'
]))
{
$subdirs_support
=
TRUE
;
}
else
{
$subdirs_support
=
FALSE
;
}
if
(
$subdirs_support
)
{
$this
->
server
->
subdirs_support
=
TRUE
;
$this
->
configs
[
'site'
][]
=
'Provision_Config_Nginx_Subdir'
;
$this
->
configs
[
'site'
][]
=
'Provision_Config_Nginx_SubdirVhost'
;
}
}
function
save_server
()
{
// Set correct provision_db_cloaking value on server save.
$this
->
server
->
provision_db_cloaking
=
TRUE
;
// Find nginx executable.
if
(
provision_file
()
->
exists
(
'/usr/local/sbin/nginx'
)
->
status
())
{
$path
=
"/usr/local/sbin/nginx"
;
...
...
@@ -42,6 +55,7 @@ class Provision_Service_http_nginx extends Provision_Service_http_public {
else
{
return
;
}
// Check if some nginx features are supported and save them for later.
$this
->
server
->
shell_exec
(
$path
.
' -V'
);
$this
->
server
->
nginx_is_modern
=
preg_match
(
"/nginx\/1\.((1\.(8|9|(1[0-9]+)))|((2|3|4|5|6|7|8|9)\.))/"
,
implode
(
''
,
drush_shell_exec_output
()),
$match
);
...
...
@@ -67,9 +81,25 @@ class Provision_Service_http_nginx extends Provision_Service_http_public {
$this
->
server
->
phpfpm_mode
=
'port'
;
drush_log
(
dt
(
'PHP-FPM port mode detected -SAVE- NO socket found @path.'
,
array
(
'@path'
=>
'/var/run/php5-fpm.sock'
)));
}
// Set correct subdirs_support value on server save
$if_subdirs
=
drush_get_option
(
'hosting_features'
,
array
());
if
((
array_key_exists
(
'subdirs'
,
$if_subdirs
)
&&
$if_subdirs
[
'subdirs'
]))
{
$subdirs_support
=
TRUE
;
}
else
{
$subdirs_support
=
FALSE
;
}
if
(
$subdirs_support
)
{
$this
->
server
->
subdirs_support
=
TRUE
;
}
}
function
verify_server_cmd
()
{
// Set correct provision_db_cloaking value on server verify.
$this
->
server
->
provision_db_cloaking
=
TRUE
;
// Find nginx executable.
if
(
provision_file
()
->
exists
(
'/usr/local/sbin/nginx'
)
->
status
())
{
$path
=
"/usr/local/sbin/nginx"
;
...
...
@@ -109,6 +139,18 @@ class Provision_Service_http_nginx extends Provision_Service_http_public {
drush_log
(
dt
(
'PHP-FPM port mode detected -VERIFY- NO socket found @path.'
,
array
(
'@path'
=>
'/var/run/php5-fpm.sock'
)));
}
// Set correct subdirs_support value on server verify
$if_subdirs
=
drush_get_option
(
'hosting_features'
,
array
());
if
((
array_key_exists
(
'subdirs'
,
$if_subdirs
)
&&
$if_subdirs
[
'subdirs'
]))
{
$subdirs_support
=
TRUE
;
}
else
{
$subdirs_support
=
FALSE
;
}
if
(
$subdirs_support
)
{
$this
->
server
->
subdirs_support
=
TRUE
;
}
// Call the parent at the end. it will restart the server when it finishes.
parent
::
verify_server_cmd
();
}
...
...
subdirs/Provision/Config/domain_vhost.tpl.php
deleted
100644 → 0
View file @
3c9a4d0d
<VirtualHost
*:
<?php
print
$http_port
;
?>
>
ServerName
<?php
print
$uri
;
?>
Include
<?php
print
$subdirs_path
;
?>
/
<?php
print
$uri
;
?>
/*.conf
</VirtualHost>
subdirs/Provision/Config/subdirs_drupal_sites.tpl.php
deleted
100644 → 0
View file @
3c9a4d0d
<?php
/**
* @file
* Template file to generate a D7 style sites.php for subdirectories.
*/
print
"<?php
\n
"
;
?>
/**
* @file
* Configuration file for Drupal's multi-site directory aliasing feature.
*
* Drupal searches for an appropriate configuration directory based on the
* website's hostname and pathname. A detailed description of the rules for
* discovering the configuration directory can be found in the comment
* documentation in 'sites/default/default.settings.php'.
*
* This file allows you to define a set of aliases that map hostnames and
* pathnames to configuration directories. These aliases are loaded prior to
* scanning for directories, and they are exempt from the normal discovery
* rules. The aliases are defined in an associative array named $sites, which
* should look similar to the following:
*
* $sites = array(
* 'devexample.com' => 'example.com',
* 'localhost.example' => 'example.com',
* );
*
* The above array will cause Drupal to look for a directory named
* "example.com" in the sites directory whenever a request comes from
* "example.com", "devexample.com", or "localhost/example". That is useful
* on development servers, where the domain name may not be the same as the
* domain of the live server. Since Drupal stores file paths into the database
* (files, system table, etc.) this will ensure the paths are correct while
* accessed on development servers.
*
* To use this file, copy and rename it such that its path plus filename is
* 'sites/sites.php'. If you don't need to use multi-site directory aliasing,
* then you can safely ignore this file, and Drupal will ignore it too.
*/
/**
* Multi-site directory aliasing:
*
* Edit the lines below to define directory aliases. Remove the leading hash
* signs to enable.
*/
<?php
$aliases
=
d
()
->
aliases
;
// Fix our subdir aliases.
foreach
(
$aliases
as
$alias
)
{
// Only replace the records[] array key if the alias is a subdir alias
// Patch for https://drupal.org/node/2213387
if
(
strpos
(
$alias
,
"/"
))
{
$records
[
str_replace
(
'/'
,
'.'
,
$alias
)]
=
$records
[
$alias
];
unset
(
$records
[
$alias
]);
}
}
?>
$sites =
<?php
print
var_export
(
$records
,
TRUE
)
?>
;
subdirs/subdirs.drush.inc
deleted
100644 → 0
View file @
3c9a4d0d
<?php
/**
* Implements hook_drush_init().
*/
function
subdirs_drush_init
()
{
subdirs_provision_register_autoload
();
}
/**
* Register our directory as a place to find Provision classes.
*
* This allows Provision to autoload our classes, so that we don't need to
* specifically include the files before we use the class.
*/
function
subdirs_provision_register_autoload
()
{
static
$loaded
=
FALSE
;
if
(
!
$loaded
)
{
$loaded
=
TRUE
;
provision_autoload_register_prefix
(
'Provision_'
,
dirname
(
__FILE__
));
}
}
/**
* Implements drush_hook_pre_provision_install().
*/
function
drush_subdirs_pre_provision_install
()
{
_subdirs_create_symlinks
();
}
/**
* Implements drush_hook_pre_provision_install_rollback().
*/
function
drush_subdirs_pre_provision_install_rollback
()
{
_subdirs_remove_symlinks
();
}
/**
* Implementation of drush_hook_pre_provision_verify()
*/
function
drush_subdirs_pre_provision_verify
()
{
_subdirs_create_symlinks
();
}
/**
* Implementation of drush_hook_post_provision_deploy()
*/
function
drush_subdirs_pre_provision_deploy
()
{
_subdirs_create_symlinks
();
}
/**
* Implementation of drush_hook_provision_delete()
*/
function
drush_subdirs_pre_provision_delete
()
{
_subdirs_remove_symlinks
();
}
/**
* Implements hook_provision_config_load_templates().
*/
function
subdirs_provision_config_load_templates
(
$config
)
{
if
(
$config
->
template
==
'provision_drupal_sites.tpl.php'
)
{
$context
=
d
();
$use_subdirs_tpl
=
FALSE
;
foreach
(
$context
->
aliases
as
$alias
)
{
if
(
strpos
(
$alias
,
'/'
))
{
$use_subdirs_tpl
=
TRUE
;
}
}
if
(
$use_subdirs_tpl
)
{
drush_log
(
'Generating sites.php for use with subdirectories.'
,
'notice'
);
return
dirname
(
__FILE__
)
.
'/Provision/Config/subdirs_drupal_sites.tpl.php'
;
}
}
}
/**
* Create subdirectory symlinks
*
* This create a sites/example.com.foo symlink pointing to the main
* URL of the site.
*/
function
_subdirs_create_symlinks
()
{
if
(
d
()
->
type
==
'site'
)
{
$aliases
=
d
()
->
aliases
;
if
(
count
(
$aliases
))
{
foreach
(
$aliases
as
$alias
)
{
if
(
strpos
(
$alias
,
'/'
))
{
drush_log
(
"Subdirectory alias `
$alias
` found. Creating magic symlinks."
,
'notice'
);
provision_file
()
->
symlink
(
d
()
->
uri
,
'sites/'
.
str_replace
(
'/'
,
'.'
,
$alias
))
->
succeed
(
'symlinked @path to @target'
)
->
fail
(
'failed to symlink @path to @target'
);
}
}
}
}
}
/**
* Delete subdirectory symlinks
*
* This deletes the symlinks created by _subdirs_create_symlinks().
*/
function
_subdirs_remove_symlinks
()
{
if
(
d
()
->
type
==
'site'
)
{
$aliases
=
d
()
->
aliases
;
if
(
count
(
$aliases
))
{
foreach
(
$aliases
as
$alias
)
{
provision_file
()
->
unlink
(
'sites/'
.
str_replace
(
'/'
,
'.'
,
$alias
))
->
succeed
(
'removed @path symlink'
)
->
fail
(
'failed to remove @path symlink'
);
}
}
}
}
subdirs/subdirs.drush.load.inc
deleted
100644 → 0
View file @
3c9a4d0d
<?php
/**
* Implements hook_drush_load().
*
* Checks if the corresponsing Hosting Feature is installed and enabled.
*/
function
subdirs_drush_load
()
{
$features
=
drush_get_option
(
'hosting_features'
,
array
());
return
array_key_exists
(
'subdirs'
,
$features
)
&&
$features
[
'subdirs'
];
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment