Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
project
provision
Commits
497eec9e
Commit
497eec9e
authored
Oct 30, 2008
by
Adrian Rossouw
Committed by
adrian
Oct 30, 2008
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support aliases through the --aliases option. Expects a comma seperated list of domains
parent
aa048f47
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
65 additions
and
17 deletions
+65
-17
platform/provision_drupal.module
platform/provision_drupal.module
+44
-1
provision.inc
provision.inc
+5
-2
provision.module
provision.module
+2
-0
web_server/provision_apache_vhost.tpl.php
web_server/provision_apache_vhost.tpl.php
+11
-11
web_server/provision_apache_vhost_redirect.tpl.php
web_server/provision_apache_vhost_redirect.tpl.php
+3
-3
No files found.
platform/provision_drupal.module
View file @
497eec9e
...
...
@@ -217,7 +217,6 @@ function provision_drupal_provision_restore_rollback($url, $data) {
provision_drupal_provision_restore
(
$url
,
$data
);
}
/**
* Force drupal to load the modules it expects to find on an uninstalled site
*/
...
...
@@ -414,6 +413,12 @@ function _provision_find_profiles() {
* This can't be rolled back. so won't even try.
*/
function
provision_drupal_provision_delete
(
$url
,
$data
)
{
if
(
$old_data
=
provision_load_site_data
(
$url
))
{
if
(
sizeof
(
$old_aliases
=
$old_data
[
'aliases'
]))
{
_provision_drupal_delete_aliases
(
$old_aliases
);
}
}
return
_provision_recursive_delete
(
"sites/
$url
"
);
}
...
...
@@ -509,3 +514,41 @@ function _provision_drupal_variable_get($name, $default) {
return
(
$value
)
?
unserialize
(
$value
)
:
$default
;
}
/**
* Create and remove symlinks for each of the possible domain aliases of an existing site
*/
function
_provision_drupal_maintain_aliases
(
$url
,
$data
)
{
if
(
$old_data
=
provision_load_site_data
(
$url
))
{
$old_aliases
=
$old_data
[
'aliases'
];
}
else
{
$old_aliases
=
array
();
}
// Flip the array to make it easier to remove duplicates
$old_aliases
=
array_flip
(
$old_aliases
);
if
(
is_array
(
$data
[
'aliases'
]))
{
foreach
(
$data
[
'aliases'
]
as
$alias
)
{
if
(
isset
(
$old_aliases
[
$alias
]))
{
// We have already created an alias for this site.
unset
(
$old_aliases
[
$alias
]);
}
provision_path
(
"symlink"
,
$url
,
PROVISION_DOCROOT_PATH
.
"/sites/"
.
$alias
,
t
(
"Created symlink for alias @alias"
,
array
(
"@alias"
=>
$alias
)),
t
(
"Could not create symlink for alias @alias"
,
array
(
"@alias"
=>
$alias
)));
}
// Delete existing aliases that are no longer present
_provision_drupal_delete_aliases
(
array_keys
(
$old_aliases
));
}
}
/**
* Delete a list of aliases
*/
function
_provision_drupal_delete_aliases
(
$aliases
)
{
foreach
(
$aliases
as
$alias
)
{
provision_path
(
"unlink"
,
PROVISION_DOCROOT_PATH
.
"/sites/"
.
$alias
,
TRUE
,
t
(
"Removed symlink for alias @alias"
,
array
(
"@alias"
=>
$alias
)),
t
(
"Could not remove symlink for alias @alias"
,
array
(
"@alias"
=>
$alias
)));
}
}
provision.inc
View file @
497eec9e
...
...
@@ -293,10 +293,13 @@ function provision_get_site_data($url) {
$site_data
[
'language'
]
=
$site_data
[
'language'
]
?
$site_data
[
'language'
]
:
'en'
;
if
(
$old_data
=
provision_load_site_data
(
$url
))
{
//Merge previously saved data with the new data. This way,
old
parameters overwrite
new
ones.
//Merge previously saved data with the new data. This way,
new
parameters overwrite
old
ones.
$site_data
=
array_merge
(
$old_data
,
$site_data
);
}
if
(
$site_data
[
'aliases'
])
{
$site_data
[
'aliases'
]
=
explode
(
","
,
$site_data
[
'aliases'
]);
}
return
$site_data
;
}
...
...
provision.module
View file @
497eec9e
...
...
@@ -425,6 +425,7 @@ function _provision_install($url, &$data) {
_provision_drupal_switch_active_site
(
$url
);
# Change headers and db info, also backs up
_provision_drupal_force_load_modules
(
$url
);
_provision_drupal_install_schema
(
$url
,
$data
[
'profile'
],
$data
[
'language'
],
$data
[
'client_email'
]);
_provision_drupal_maintain_aliases
(
$url
,
$data
);
# Create symlinks for site aliases (if any)
_provision_drupal_force_load_modules
();
_provision_drupal_switch_active_site
();
# This *should* bring the site back to where we were before installing
...
...
@@ -478,6 +479,7 @@ function _provision_synch($url = NULL) {
$data
=
provision_get_site_data
(
$url
);
// This is the actual drupal provisioning requirements.
_provision_drupal_create_directories
(
$url
,
$data
[
'profile'
]);
_provision_drupal_maintain_aliases
(
$url
,
$data
);
$rolled_back
=
provision_invoke
(
"synch"
,
$url
,
$data
);
// Requires at least the database settings to complete.
_provision_drupal_create_settings_file
(
$url
,
$data
);
...
...
web_server/provision_apache_vhost.tpl.php
View file @
497eec9e
<VirtualHost
*:80
>
<?php
if
(
$site_mail
)
:
?>
ServerAdmin
<?php
print
$site_mail
;
?>
<?php
endif
;
?>
DocumentRoot
<?php
print
$publish_path
;
?>
<?php
if
(
$site_mail
)
:
?>
ServerAdmin
<?php
print
$site_mail
;
?>
<?php
endif
;
?>
DocumentRoot
<?php
print
$publish_path
;
?>
ServerName
<?php
print
$site_url
;
?>
ServerName
<?php
print
$site_url
;
?>
<?php
if
(
is_array
(
$
site_
aliases
))
:
foreach
(
$
site_
aliases
as
$alias_url
)
:
?>
ServerAlias
<?php
print
$alias_url
;
?>
<?php
endforeach
;
endif
;
?>
<?php
if
(
is_array
(
$aliases
))
:
foreach
(
$aliases
as
$alias_url
)
:
?>
ServerAlias
<?php
print
$alias_url
;
?>
<?php
endforeach
;
endif
;
?>
# Error handler for Drupal > 4.6.7
<Directory
"
<?php
print
$publish_path
;
?>
/
sites
/
<?php
print
trim
(
$site_url
,
'/'
);
?>
/
files
"
>
...
...
web_server/provision_apache_vhost_redirect.tpl.php
View file @
497eec9e
...
...
@@ -10,9 +10,9 @@
# the ? at the end is to remove any query string in the original url
RewriteRule ^(.*)$
<?php
print
$redirect_url
?>
?
<?php
if
(
is_array
(
$
site_
aliases
))
:
foreach
(
$
site_
aliases
as
$alias
_url
)
:
?>
ServerAlias
<?php
print
$alias
_url
;
?>
<?php
if
(
is_array
(
$aliases
))
:
foreach
(
$aliases
as
$alias
)
:
?>
ServerAlias
<?php
print
$alias
;
?>
<?php
endforeach
;
endif
;
?>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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