magallanes/Mage/Task/BuiltIn/Deployment/Release.php

44 lines
1.5 KiB
PHP
Raw Normal View History

<?php
class Mage_Task_BuiltIn_Deployment_Release
extends Mage_Task_TaskAbstract
implements Mage_Task_Releases_BuiltIn, Mage_Task_Releases_SkipOnOverride
{
public function getName()
{
return 'Releasing [built-in]';
}
public function run()
{
if ($this->getConfig()->release('enabled', false) == true) {
$releasesDirectory = $this->getConfig()->release('directory', 'releases');
$symlink = $this->getConfig()->release('symlink', 'current');
if (substr($symlink, 0, 1) == '/') {
$releasesDirectory = rtrim($this->getConfig()->deployment('to'), '/') . '/' . $releasesDirectory;
}
$currentCopy = $releasesDirectory . '/' . $this->getConfig()->getReleaseId();
// Fetch the user and group from base directory
$userGroup = '33:33';
2012-10-24 23:52:29 +02:00
$resultFetch = $this->_runRemoteCommand('ls -ld . | awk \'{print \$3":"\$4}\'', $userGroup);
// Remove symlink if exists; create new symlink and change owners
2012-01-01 21:10:25 +01:00
$command = 'rm -f ' . $symlink
. ' ; '
2012-01-01 21:10:25 +01:00
. 'ln -sf ' . $currentCopy . ' ' . $symlink
. ' && '
. 'chown -h ' . $userGroup . ' ' . $symlink
. ' && '
2012-03-31 04:51:17 +02:00
. 'chown -R ' . $userGroup . ' ' . $currentCopy;
2012-01-01 21:10:25 +01:00
$result = $this->_runRemoteCommand($command);
2012-03-31 04:51:17 +02:00
return $result;
} else {
return false;
}
}
}