1
0
mirror of https://github.com/hauke68/Magallanes.git synced 2025-08-26 05:10:17 +02:00
Magallanes/Mage/Task/BuiltIn/Deployment/Releases.php
Andrs Montaez 3f0efc1a42 New version. Added getters to config and task.
New concept of "stage" where the task runs.
2012-02-24 13:39:40 -02:00

39 lines
1.3 KiB
PHP

<?php
class Mage_Task_BuiltIn_Deployment_Releases
extends Mage_Task_TaskAbstract
implements Mage_Task_Releases_BuiltIn
{
public function getName()
{
return 'Releasing [built-in]';
}
public function run()
{
if ($this->_config->release('enabled', false) == true) {
$releasesDirectory = $this->_config->release('directory', 'releases');
$symlink = $this->_config->release('symlink', 'current');
$currentCopy = $releasesDirectory . '/' . $this->_config->getReleaseId();
// Fetch the user and group from base directory
$userGroup = '33:33';
$resultFetch = $this->_runRemoteCommand('ls -ld . | awk \'{print \$3\":\"\$4}\'', $userGroup);
// Remove symlink if exists; create new symlink and change owners
$command = 'rm -f ' . $symlink
. ' ; '
. 'ln -sf ' . $currentCopy . ' ' . $symlink
. ' && '
. 'chown -h ' . $userGroup . ' ' . $symlink
. ' && '
. 'chown -R ' . $userGroup . ' ' . $currentCopy;
$result = $this->_runRemoteCommand($command);
return $result;
} else {
return false;
}
}
}