mirror of
https://github.com/andres-montanez/Magallanes
synced 2024-06-18 13:35:05 +02:00
55 lines
1.3 KiB
PHP
55 lines
1.3 KiB
PHP
<?php
|
|
namespace Mage\Task\BuiltIn\Filesystem;
|
|
|
|
use Mage\Task\AbstractTask;
|
|
use Mage\Task\SkipException;
|
|
use Mage\Task\Releases\IsReleaseAware;
|
|
|
|
class ApplyFaclsTask 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 SkipException
|
|
*/
|
|
public function run()
|
|
{
|
|
$releasesDirectory = $this->getConfig()->release('directory', 'releases');
|
|
$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', []);
|
|
|
|
$flags = array();
|
|
if ($this->getParameter('default', false)) {
|
|
$flags[] = 'd';
|
|
}
|
|
if ($this->getParameter('recursive', false)) {
|
|
$flags[] = 'R';
|
|
}
|
|
|
|
$flagStr = ($flags) ? ' -'.implode('', $flags).' ' : ' ';
|
|
|
|
foreach ($folders as $folder) {
|
|
$this->runCommandRemote("setfacl$flagStr-m $aclParam $currentCopy/$folder", $output);
|
|
}
|
|
|
|
return true;
|
|
}
|
|
}
|