Commit 4595b415 authored by drumm's avatar drumm Committed by Neil Drumm

Write alias files for web servers

parent 8ac783e3
......@@ -25,6 +25,12 @@ function http_drush_init($url = null) {
}
}
function http_drush_exit() {
if (PROVISION_CONTEXT_SERVER) {
provision_service('http')->write_alias();
}
}
class provisionService_http extends provisionService {
/**
* Set defaults
......@@ -109,7 +115,6 @@ class provisionService_http extends provisionService {
*/
function create_server_config() {
return TRUE;
}
/**
......@@ -118,4 +123,16 @@ class provisionService_http extends provisionService {
function delete_server_config() {
return TRUE;
}
/**
* Write out server's drushrc alias file.
*/
function write_alias() {
$data = array();
foreach (array('web_id', 'web_host', 'web_ports', 'web_group', 'restart_cmd') as $key) {
$data[$key] = drush_get_option($key);
}
$config = new provisionConfig_drushrc_alias(drush_get_option('web_host'), $data);
$config->write();
}
}
......@@ -61,6 +61,14 @@ class provisionConfig {
function write() {
$filename = $this->filename();
// Make directory structure if it does not exist.
if (!provision_service('file')->exists(dirname($filename))->status()) {
provision_service('file')->mkdir(dirname($filename))
->succeed('Created directory @path.')
->fail('Could not create directory @path.');
}
if ($filename && is_writeable(dirname($filename))) {
// manipulate data before passing to template.
$this->process();
......@@ -131,13 +139,18 @@ class provisionConfig_drushrc extends provisionConfig {
// class to read and write an alias record
class provisionConfig_drushrc_alias extends provisionConfig_drushrc {
public $template = 'provision_drushrc_alias.tpl.php';
function __construct($aliasname, $data = array()) {
parent::construct($data);
$this->alias_name = $aliasname;
$this->aliasname = $aliasname;
parent::__construct($data);
}
function load_data() {
// do something about alias_load_data
$this->data = array(
'aliasname' => $this->aliasname,
'alias' => $this->data,
);
}
function filename() {
......
<?php print "<?php \n"; ?>
$aliases['<?php print $aliasname; ?>'] = <?php print var_export($alias, TRUE); ?>;
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