/
TaskAbstract.php
56 lines (45 loc) · 1.7 KB
/
TaskAbstract.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
abstract class Mage_Task_TaskAbstract
{
protected $_config = null;
protected $_inRollback = false;
public abstract function getName();
public abstract function run();
public final function __construct(Mage_Config $config, $inRollback = false)
{
$this->_config = $config;
$this->_inRollback = $inRollback;
}
public function inRollback()
{
return $this->_inRollback;
}
public function init()
{
}
protected final function _runLocalCommand($command, &$output = null)
{
return Mage_Console::executeCommand($command, $output);
}
protected final function _runRemoteCommand($command, &$output = null)
{
if ($this->_config->release('enabled', false) == true) {
if ($this instanceOf Mage_Task_Releases_BuiltIn) {
$releasesDirectory = '';
} else {
$releasesDirectory = '/'
. $this->_config->release('directory', 'releases')
. '/'
. $this->_config->getReleaseId();
}
} else {
$releasesDirectory = '';
}
$localCommand = 'ssh -p ' . $this->_config->getHostPort() . ' '
. '-q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no '
. $this->_config->deployment('user') . '@' . $this->_config->getHost() . ' '
. '"cd ' . rtrim($this->_config->deployment('to'), '/') . $releasesDirectory . ' && '
. $command . '"';
return $this->_runLocalCommand($localCommand, $output);
}
}