|
|
|
@ -247,4 +247,64 @@ abstract class AbstractTask
|
|
|
|
|
|
|
|
|
|
return $command; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @param $releasesDirectory |
|
|
|
|
* @param $releaseId |
|
|
|
|
* @return bool |
|
|
|
|
*/ |
|
|
|
|
protected function tarRelease($releaseId) |
|
|
|
|
{ |
|
|
|
|
$result = true; |
|
|
|
|
// for given release, check if tarred |
|
|
|
|
$output = ''; |
|
|
|
|
$releasesDirectory = $this->getConfig()->release('directory', 'releases'); |
|
|
|
|
|
|
|
|
|
$currentReleaseDirectory = $releasesDirectory . '/' . $releaseId; |
|
|
|
|
$currentReleaseDirectoryTemp = $currentReleaseDirectory . '_tmp/'; |
|
|
|
|
$currentRelease = $currentReleaseDirectory . '/' . $releaseId . '.tar.gz'; |
|
|
|
|
|
|
|
|
|
$command = 'test -e ' . $currentRelease . ' && echo "true" || echo ""'; |
|
|
|
|
$this->runCommandRemote($command, $output); |
|
|
|
|
|
|
|
|
|
// if not, do so |
|
|
|
|
if (!$output) { |
|
|
|
|
$commands = array(); |
|
|
|
|
$commands[] = 'mv ' . $currentReleaseDirectory . ' ' . $currentReleaseDirectoryTemp; |
|
|
|
|
$commands[] = 'mkdir ' . $currentReleaseDirectory; |
|
|
|
|
$commands[] = 'tar cfz ' . $currentRelease . ' ' . $currentReleaseDirectoryTemp; |
|
|
|
|
$commands[] = 'rm -rf ' . $currentReleaseDirectoryTemp; |
|
|
|
|
$command = implode(' && ', $commands); |
|
|
|
|
$result = $this->runCommandRemote($command, $output); |
|
|
|
|
return $result; |
|
|
|
|
} |
|
|
|
|
return $result; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
protected function untarRelease($releaseId) |
|
|
|
|
{ |
|
|
|
|
$result = true; |
|
|
|
|
// for given release, check if tarred |
|
|
|
|
$output = ''; |
|
|
|
|
$releasesDirectory = $this->getConfig()->release('directory', 'releases'); |
|
|
|
|
|
|
|
|
|
$currentReleaseDirectory = $releasesDirectory . '/' . $releaseId; |
|
|
|
|
$currentReleaseDirectoryTemp = $currentReleaseDirectory . '_tmp/'; |
|
|
|
|
$currentRelease = $currentReleaseDirectory . '/' . $releaseId . '.tar.gz'; |
|
|
|
|
|
|
|
|
|
$command = 'test -e ' . $currentRelease . ' && echo "true" || echo ""'; |
|
|
|
|
$this->runCommandRemote($command, $output); |
|
|
|
|
|
|
|
|
|
// if tarred, untar now |
|
|
|
|
if ($output) { |
|
|
|
|
$commands = array(); |
|
|
|
|
$commands[] = 'tar xfz ' . $currentRelease; |
|
|
|
|
$commands[] = 'rm -rf ' . $currentReleaseDirectory; |
|
|
|
|
$commands[] = 'mv ' .$currentReleaseDirectoryTemp . ' ' . $currentReleaseDirectory; |
|
|
|
|
$command = implode(' && ', $commands); |
|
|
|
|
$result = $this->runCommandRemote($command, $output); |
|
|
|
|
return $result; |
|
|
|
|
} |
|
|
|
|
return $result; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|