mirror of
https://github.com/hauke68/Magallanes.git
synced 2025-08-26 13:20:17 +02:00
Merge pull request #57 from freshcells/new-bunch-of-tasks
Added three new tasks.
This commit is contained in:
commit
23b59869ec
40
Mage/Task/BuiltIn/Composer/GenerateAutoload.php
Normal file
40
Mage/Task/BuiltIn/Composer/GenerateAutoload.php
Normal file
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
namespace Mage\Task\BuiltIn\Composer;
|
||||
|
||||
use Exception;
|
||||
use Mage\Task\AbstractTask;
|
||||
use Mage\Task\ErrorWithMessageException;
|
||||
use Mage\Task\SkipException;
|
||||
|
||||
class GenerateAutoload extends AbstractTask
|
||||
{
|
||||
/**
|
||||
* Returns the Title of the Task
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return 'Generating autoload files via composer [built-in]';
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs the task
|
||||
*
|
||||
* @return boolean
|
||||
* @throws Exception
|
||||
* @throws ErrorWithMessageException
|
||||
* @throws SkipException
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
$releasesDirectory = $this->getConfig()->release('directory', 'releases');
|
||||
$releasesDirectory = rtrim($this->getConfig()->deployment('to'), '/') . '/' . $releasesDirectory;
|
||||
$currentCopy = $releasesDirectory . '/' . $this->getConfig()->getReleaseId();
|
||||
|
||||
$sharedFolderName = $this->getParameter('shared', 'shared');
|
||||
$sharedFolderName = rtrim($this->getConfig()->deployment('to'), '/') . '/' . $sharedFolderName;
|
||||
|
||||
$composerPath = $this->getParameter('composer', "$sharedFolderName/composer.phar");
|
||||
return $this->runCommandRemote("/usr/bin/env php $composerPath --working-dir=$currentCopy dumpautoload --optimize", $output);
|
||||
}
|
||||
}
|
50
Mage/Task/BuiltIn/Filesystem/ApplyFacls.php
Normal file
50
Mage/Task/BuiltIn/Filesystem/ApplyFacls.php
Normal file
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
namespace Mage\Task\BuiltIn\Filesysten;
|
||||
|
||||
use Exception;
|
||||
use Mage\Task\AbstractTask;
|
||||
use Mage\Task\ErrorWithMessageException;
|
||||
use Mage\Task\SkipException;
|
||||
use Mage\Task\Releases\IsReleaseAware;
|
||||
|
||||
class ApplyFacls extends AbstractTask implements IsReleaseAware
|
||||
{
|
||||
/**
|
||||
* Returns the Title of the Task
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return 'Set file ACLs on remote system [built-in]';
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs the task
|
||||
*
|
||||
* @return boolean
|
||||
* @throws Exception
|
||||
* @throws ErrorWithMessageException
|
||||
* @throws SkipException
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
$releasesDirectory = $this->getConfig()->release('directory', 'releases');
|
||||
$releasesDirectory = rtrim($this->getConfig()->deployment('to'), '/') . '/' . $releasesDirectory;
|
||||
$currentCopy = $releasesDirectory . '/' . $this->getConfig()->getReleaseId();
|
||||
|
||||
|
||||
$aclParam = $this->getParameter('acl_param', '');
|
||||
if (empty($aclParam)) {
|
||||
throw new SkipException('Parameter acl_param not set.');
|
||||
}
|
||||
|
||||
$folders = $this->getParameter('folders', []);
|
||||
$recursive = $this->getParameter('recursive', false) ? ' -R ' : ' ';
|
||||
|
||||
foreach ($folders as $folder) {
|
||||
$this->runCommandRemote("setfacl$recursive-m $aclParam $currentCopy/$folder", $output);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
53
Mage/Task/BuiltIn/Filesystem/LinkSharedFiles.php
Normal file
53
Mage/Task/BuiltIn/Filesystem/LinkSharedFiles.php
Normal file
@ -0,0 +1,53 @@
|
||||
<?php
|
||||
namespace Mage\Task\BuiltIn\Filesysten;
|
||||
use Mage\Task\AbstractTask;
|
||||
use Mage\Task\Releases\IsReleaseAware;
|
||||
use Mage\Task\SkipException;
|
||||
|
||||
class LinkSharedFiles extends AbstractTask implements IsReleaseAware
|
||||
{
|
||||
|
||||
/**
|
||||
* Returns the Title of the Task
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return 'Linking files/folders from the shared folder into the current release [built-in]';
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs the task
|
||||
*
|
||||
* @return boolean
|
||||
* @throws Exception
|
||||
* @throws \Mage\Task\ErrorWithMessageException
|
||||
* @throws SkipException
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
$linkedFiles = $this->getParameter('linked_files', []);
|
||||
$linkedFolders = $this->getParameter('linked_folders', []);
|
||||
if (sizeof($linkedFiles) == 0 && sizeof($linkedFolders) == 0) {
|
||||
throw new SkipException('No files and folders configured for sym-linking.');
|
||||
}
|
||||
|
||||
$sharedFolderName = $this->getParameter('shared', 'shared');
|
||||
$sharedFolderName = rtrim($this->getConfig()->deployment('to'), '/') . '/' . $sharedFolderName;
|
||||
$releasesDirectory = $this->getConfig()->release('directory', 'releases');
|
||||
$releasesDirectory = rtrim($this->getConfig()->deployment('to'), '/') . '/' . $releasesDirectory;
|
||||
|
||||
$currentCopy = $releasesDirectory . '/' . $this->getConfig()->getReleaseId();
|
||||
foreach ($linkedFolders as $folder) {
|
||||
$command = "ln -nfs $sharedFolderName/$folder $currentCopy/$folder";
|
||||
$this->runCommandRemote($command);
|
||||
}
|
||||
|
||||
foreach ($linkedFiles as $folder) {
|
||||
$command = "ln -nfs $sharedFolderName/$folder $currentCopy/$folder";
|
||||
$this->runCommandRemote($command);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user