mirror of
				https://github.com/hauke68/Magallanes.git
				synced 2025-11-04 09:00:18 +01:00 
			
		
		
		
	
		
			
	
	
		
			51 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
		
		
			
		
	
	
			51 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
| 
								 | 
							
								<?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;
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								}
							 |