Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
P
provision
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Custom Issue Tracker
Custom Issue Tracker
Labels
Merge Requests
1
Merge Requests
1
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Analytics
Analytics
Code Review
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
project
provision
Commits
02380f03
Commit
02380f03
authored
Nov 27, 2008
by
Adrian Rossouw
Committed by
adrian
Nov 27, 2008
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Get rid of provision.settings.php. Now use existing drushrc.php loading code. much simpler
parent
9c6a1ea3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
85 additions
and
93 deletions
+85
-93
provision.inc
provision.inc
+27
-0
provision.module
provision.module
+57
-92
provision_errors.inc
provision_errors.inc
+1
-1
No files found.
provision.inc
View file @
02380f03
...
...
@@ -371,6 +371,33 @@ function provision_save_site_data($url, $data) {
*/
/**
* Save the options for the platform to the drushrc.php in the root of the platform.
*/
function
provision_save_platform_data
()
{
global
$args
;
$exclude
=
array
(
'task_id'
);
$conf_file
=
PROVISION_DOCROOT_PATH
.
'/drushrc.php'
;
$fp
=
fopen
(
$conf_file
,
"w"
);
if
(
!
$fp
)
{
provision_log
(
'error'
,
'Platform config file could not be written'
);
provision_set_error
(
PROVISION_PERM_ERROR
);
}
else
{
fwrite
(
$fp
,
"<?php
\n
"
);
$timestamp
=
mktime
();
fwrite
(
$fp
,
"#"
.
format_date
(
$timestamp
,
'large'
));
foreach
(
$args
[
'options'
]
as
$key
=>
$value
)
{
if
(
!
in_array
(
$key
,
$exclude
))
{
$line
=
"
\n\$
options['
$key
'] = "
.
var_export
(
$value
,
TRUE
)
.
';'
;
fwrite
(
$fp
,
$line
);
}
}
fwrite
(
$fp
,
"
\n
"
);
fclose
(
$fp
);
}
}
/**
* @defgroup provisionvalues Value replacement support for the provisioning framework
* @{
...
...
provision.module
View file @
02380f03
...
...
@@ -71,6 +71,10 @@ function provision_load_from_args() {
module_list
(
TRUE
,
FALSE
,
FALSE
,
$loaded
);
// Force to regenerate the stored list of hook implementations.
module_implements
(
''
,
FALSE
,
TRUE
);
// As we have missed the bootstrap phase, we need to run
// our own provision_init hook to initialize modules.
module_invoke_all
(
'provision_init'
);
}
}
...
...
@@ -99,54 +103,51 @@ function provision_init() {
$docroot
=
drush_get_option
(
array
(
"r"
,
"root"
),
$_SERVER
[
'PWD'
]);
$backend
=
drush_get_option
(
array
(
'b'
,
'backend'
),
0
);
define
(
"PROVISION_DRUSH_BACKEND"
,
$backend
);
}
else
{
$docroot
=
$_SERVER
[
'pwd'
];
}
define
(
'PROVISION_DOMAIN'
,
$_SERVER
[
'HTTP_HOST'
]);
// Paths
$path
=
(
$docroot
)
?
$docroot
:
$_SERVER
[
'DOCUMENT_ROOT'
];
define
(
'PROVISION_DOCROOT_PATH'
,
rtrim
(
$path
,
'/'
));
define
(
'PROVISION_SITES_PATH'
,
rtrim
(
$path
,
'/'
)
.
'/sites'
);
define
(
'PROVISION_DRUSH_PATH'
,
'./drush.php'
);
$parts
=
explode
(
"/"
,
rtrim
(
$path
,
'/'
));
array_pop
(
$parts
);
define
(
'PROVISION_PARENT_PATH'
,
rtrim
(
implode
(
"/"
,
$parts
),
'/'
));
define
(
'PROVISION_BACKUP_PATH'
,
drush_get_option
(
'backup_path'
,
PROVISION_PARENT_PATH
.
'/backups'
));
define
(
'PROVISION_CONFIG_PATH'
,
drush_get_option
(
'config_path'
,
PROVISION_PARENT_PATH
.
'/config'
));
define
(
'PROVISION_VHOST_PATH'
,
PROVISION_CONFIG_PATH
.
'/vhost.d'
);
// Commands
define
(
'PROVISION_RESTART_CMD'
,
drush_get_option
(
'restart_cmd'
,
_provision_default_restart_cmd
()));
// System account
$info
=
posix_getgrgid
(
posix_getgid
());
define
(
'PROVISION_WEB_GROUP'
,
drush_get_option
(
'web_group'
,
$info
[
'name'
]
));
define
(
'PROVISION_SCRIPT_USER'
,
drush_get_option
(
'script_user'
,
get_current_user
()
));
// Redirection urls
define
(
'PROVISION_MASTER_URL'
,
drush_get_option
(
'master_url'
,
variable_get
(
'install_url'
,
$GLOBALS
[
'base_url'
])));
define
(
'PROVISION_WEB_DISABLE_URL'
,
PROVISION_MASTER_URL
.
'/provision/disabled'
);
define
(
'PROVISION_WEB_MAINTENENCE_URL'
,
PROVISION_MASTER_URL
.
'/provision/maintenance'
);
// Database
define
(
'PROVISION_MASTER_DB'
,
drush_get_option
(
'master_db'
,
$GLOBALS
[
'db_url'
]));
$db
=
parse_url
(
PROVISION_MASTER_DB
);
define
(
'PROVISION_DB_USER'
,
$db
[
'user'
]);
define
(
'PROVISION_DB_PASSWD'
,
$db
[
'pass'
]);
define
(
'PROVISION_DB_HOST'
,
$db
[
'host'
]);
define
(
'PROVISION_DOMAIN'
,
$_SERVER
[
'HTTP_HOST'
]);
$path
=
(
$docroot
)
?
$docroot
:
$_SERVER
[
'DOCUMENT_ROOT'
];
define
(
'PROVISION_DOCROOT_PATH'
,
rtrim
(
$path
,
'/'
));
define
(
'PROVISION_SITES_PATH'
,
rtrim
(
$path
,
'/'
)
.
'/sites'
);
define
(
'PROVISION_DRUSH_PATH'
,
'./drush.php'
);
$parts
=
explode
(
"/"
,
rtrim
(
$path
,
'/'
));
array_pop
(
$parts
);
define
(
'PROVISION_PARENT_PATH'
,
rtrim
(
implode
(
"/"
,
$parts
),
'/'
));
if
(
file_exists
(
'sites/default/provision.settings.php'
)
&&
is_readable
(
'sites/default/provision.settings.php'
))
{
include_once
(
'sites/default/provision.settings.php'
);
}
else
{
$defaults
=
_provision_config_defaults
();
define
(
'PROVISION_BACKUP_PATH'
,
$defaults
[
'backup_path'
]);
define
(
'PROVISION_CONFIG_PATH'
,
$defaults
[
'config_path'
]);
define
(
'PROVISION_WEB_GROUP'
,
$defaults
[
'web_group'
]);
define
(
'PROVISION_MASTER_DB'
,
$defaults
[
'master_db'
]);
define
(
'PROVISION_SCRIPT_USER'
,
$defaults
[
'script_user'
]);
define
(
'PROVISION_RESTART_CMD'
,
$defaults
[
'restart_cmd'
]);
define
(
'PROVISION_MASTER_URL'
,
$defaults
[
'master_url'
]);
define
(
'PROVISION_MASTER_DB'
,
$defaults
[
'master_db'
]);
// Drupal does not support multiple types of connections in the same session
preg_match
(
"$^([a-z]*)://$"
,
$GLOBALS
[
'db_url'
],
$matches
);
define
(
'PROVISION_DB_TYPE'
,
$matches
[
1
]);
}
# These settings are based on settings in the provision.settings.php file
define
(
'PROVISION_VHOST_PATH'
,
PROVISION_CONFIG_PATH
.
'/vhost.d'
);
define
(
'PROVISION_DRUSHRC_PATH'
,
PROVISION_CONFIG_PATH
.
'/drushrc.d'
);
define
(
'PROVISION_WEB_DISABLE_URL'
,
PROVISION_MASTER_URL
.
'/provision/disabled'
);
define
(
'PROVISION_WEB_MAINTENENCE_URL'
,
PROVISION_MASTER_URL
.
'/provision/maintenance'
);
$db
=
parse_url
(
PROVISION_MASTER_DB
);
define
(
'PROVISION_DB_USER'
,
$db
[
'user'
]);
define
(
'PROVISION_DB_PASSWD'
,
$db
[
'pass'
]);
define
(
'PROVISION_DB_HOST'
,
$db
[
'host'
]);
// Drupal does not support multiple types of connections in the same session
preg_match
(
"$^([a-z]*)://$"
,
$GLOBALS
[
'db_url'
],
$matches
);
define
(
'PROVISION_DB_TYPE'
,
$matches
[
1
]);
}
function
_provision_default_restart_cmd
()
{
...
...
@@ -163,55 +164,19 @@ function _provision_default_restart_cmd() {
return
"sudo
$command
graceful"
;
}
/**
* Provides a set of best guess values for the provision.settings.php file
*/
function
_provision_config_defaults
()
{
$default
=
array
();
$defaults
[
'backup_path'
]
=
defined
(
'PROVISION_BACKUP_PATH'
)
?
PROVISION_BACKUP_PATH
:
PROVISION_PARENT_PATH
.
'/backups'
;
$defaults
[
'config_path'
]
=
defined
(
'PROVISION_CONFIG_PATH'
)
?
PROVISION_CONFIG_PATH
:
PROVISION_PARENT_PATH
.
'/config'
;
$defaults
[
'script_user'
]
=
defined
(
'PROVISION_SCRIPT_USER'
)
?
PROVISION_SCRIPT_USER
:
get_current_user
();
$info
=
posix_getgrgid
(
posix_getgid
());
$defaults
[
'web_group'
]
=
defined
(
'PROVISION_WEB_GROUP'
)
?
PROVISION_WEB_GROUP
:
$info
[
'name'
];
$defaults
[
'master_db'
]
=
defined
(
'PROVISION_MASTER_DB'
)
?
PROVISION_MASTER_DB
:
$GLOBALS
[
'db_url'
];
$defaults
[
'restart_cmd'
]
=
defined
(
'PROVISION_RESTART_CMD'
)
?
PROVISION_RESTART_CMD
:
_provision_default_restart_cmd
();
$master_url
=
variable_get
(
'install_url'
,
$GLOBALS
[
'base_url'
]);
$defaults
[
'master_url'
]
=
defined
(
'PROVISION_MASTER_URL'
)
?
PROVISION_MASTER_URL
:
$master_url
;
return
$defaults
;
}
/**
* Generate a provision.settings.php file to configure provision
*/
function
_provision_generate_config
(
$data
=
array
())
{
provision_log
(
'notice'
,
t
(
"Generating provision.settings.php file"
));
// We are doing a system call here to ensure we can write to the file
// and we don't need logging or the overhead of provision_path on this
system
(
'chmod u+wx sites/default'
);
if
(
provision_path
(
"exists"
,
"sites/default/provision.settings.php"
))
{
provision_path
(
"chmod"
,
"sites/default/provision.settings.php"
,
0600
,
t
(
'Changed permissions of provision.settings.php to @confirm'
),
t
(
'Could not change permissions of provision.settings.php to @confirm'
));
}
$data
=
array_merge
(
_provision_config_defaults
(),
$data
);
$fp
=
fopen
(
"sites/default/provision.settings.php"
,
"w"
);
$text
=
file_get_contents
(
drupal_get_path
(
'module'
,
'provision'
)
.
'/provision_settings.tpl.php'
);
fwrite
(
$fp
,
"<?php
\n
"
.
provision_render_config
(
$text
,
$data
));
fclose
(
$fp
);
# Change the permissions of the file
provision_path
(
"chmod"
,
"sites/default/provision.settings.php"
,
0400
,
t
(
'Changed permissions of provision.settings.php to @confirm'
),
t
(
'Could not change permissions of provision.settings.php to @confirm'
));
function
_provision_generate_config
()
{
provision_log
(
'notice'
,
t
(
"Generating drushrc.php file"
));
provision_path
(
"chmod"
,
PROVISION_DOCROOT_PATH
.
'/drushrc.php'
,
0600
,
t
(
'Changed permissions of drushrc.php to @confirm'
),
t
(
'Could not change permissions of drushrc.php to @confirm'
));
provision_save_platform_data
();
provision_path
(
"chmod"
,
PROVISION_DOCROOT_PATH
.
'/drushrc.php'
,
0400
,
t
(
'Changed permissions of drushrc.php to @confirm'
),
t
(
'Could not change permissions of drushrc.php to @confirm'
));
return
TRUE
;
}
...
...
provision_errors.inc
View file @
02380f03
...
...
@@ -36,7 +36,7 @@ define('PROVISION_DB_ERROR', 128);
global
$provision_errors
;
$provision_errors
=
array
(
PROVISION_SUCCESS
=>
t
(
"Successful"
),
PROVISION_QUEUED
=>
t
(
"
To be process
ed"
),
PROVISION_QUEUED
=>
t
(
"
Queu
ed"
),
PROVISION_DB_ERROR
=>
t
(
"Database error"
),
PROVISION_INSTALL_ERROR
=>
t
(
"Drupal installation error"
),
PROVISION_PERM_ERROR
=>
t
(
"File permission error"
),
...
...
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