From 9d1e6aba6f996440a137753fda3c56744e03d736 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Huet?= Date: Sat, 13 Dec 2014 15:57:33 +0100 Subject: [PATCH] Allow for changing permissions on local host too depending on the stage --- .../BuiltIn/Filesystem/PermissionsTask.php | 28 +++++++++++++------ .../PermissionsWritableByApacheTask.php | 8 +++++- 2 files changed, 26 insertions(+), 10 deletions(-) diff --git a/Mage/Task/BuiltIn/Filesystem/PermissionsTask.php b/Mage/Task/BuiltIn/Filesystem/PermissionsTask.php index ee4a91a..ab924af 100644 --- a/Mage/Task/BuiltIn/Filesystem/PermissionsTask.php +++ b/Mage/Task/BuiltIn/Filesystem/PermissionsTask.php @@ -5,7 +5,14 @@ use Mage\Task\AbstractTask; use Mage\Task\SkipException; /** - * Task for setting permissions on given paths. + * Task for setting permissions on given paths. Change will be done on local or + * remote host depending on the stage of the deployment. + * + * Usage : + * pre-deploy: + * - filesystem/permissions: {paths: /var/www/myapp/app/cache:/var/www/myapp/app/cache, checkPathsExist: true, owner: www-data, group: www-data, rights: 775} + * on-deploy: + * - filesystem/permissions: {paths: app/cache:app/logs, checkPathsExist: true, owner: www-data, group: www-data, rights: 775} * * @author Jérémy Huet */ @@ -14,12 +21,15 @@ class PermissionsTask extends AbstractTask /** * Paths to change of permissions separated by PATH_SEPARATOR. * + * If the stage is on local host you should give full paths. If on remote + * you may give full or relative to the current release directory paths. + * * @var string */ private $paths; /** - * If set to true, will check existance of given paths on remote host and + * If set to true, will check existance of given paths on the host and * throw SkipException if at least one does not exist. * * @var boolean @@ -105,7 +115,7 @@ class PermissionsTask extends AbstractTask $command .= 'chmod -R ' . $this->rights . ' ' . $this->getPathsForCmd() . ';'; } - $result = $this->runCommandRemote($command); + $result = $this->runCommand($command); return $result; } @@ -126,7 +136,7 @@ class PermissionsTask extends AbstractTask } /** - * Set paths. Will check if they exist on remote host depending on + * Set paths. Will check if they exist on the host depending on * checkPathsExist flag. * * @param array $paths @@ -142,8 +152,8 @@ class PermissionsTask extends AbstractTask } $command = implode(' && ', $commands); - if (! $this->runCommandRemote($command)) { - throw new SkipException('Make sure all paths given exist on remote host : ' . $this->getPathsForCmd($paths)); + if (! $this->runCommand($command)) { + throw new SkipException('Make sure all paths given exist on the host : ' . $this->getPathsForCmd($paths)); } } @@ -184,7 +194,7 @@ class PermissionsTask extends AbstractTask /** * Set owner. * - * @todo check existance of $owner on remote, might be different ways depending on OS. + * @todo check existance of $owner on host, might be different ways depending on OS. * * @param string $owner * @return PermissionsTask @@ -207,7 +217,7 @@ class PermissionsTask extends AbstractTask /** * Set group. * - * @todo check existance of $group on remote, might be different ways depending on OS. + * @todo check existance of $group on host, might be different ways depending on OS. * * @param string $group * @return PermissionsTask @@ -253,4 +263,4 @@ class PermissionsTask extends AbstractTask { return $this->rights; } -} \ No newline at end of file +} diff --git a/Mage/Task/BuiltIn/Filesystem/PermissionsWritableByApacheTask.php b/Mage/Task/BuiltIn/Filesystem/PermissionsWritableByApacheTask.php index 57d45da..c786e5e 100644 --- a/Mage/Task/BuiltIn/Filesystem/PermissionsWritableByApacheTask.php +++ b/Mage/Task/BuiltIn/Filesystem/PermissionsWritableByApacheTask.php @@ -4,6 +4,12 @@ namespace Mage\Task\BuiltIn\Filesystem; /** * Task for giving Apache write permissions on given paths. * + * Usage : + * pre-deploy: + * - filesystem/permissions-writable-by-apache: {paths: /var/www/myapp/app/cache:/var/www/myapp/app/cache, checkPathsExist: true} + * on-deploy: + * - filesystem/permissions-writable-by-apache: {paths: app/cache:app/logs, checkPathsExist: true} + * * @author Jérémy Huet */ class PermissionsWritableByApacheTask extends PermissionsTask @@ -23,4 +29,4 @@ class PermissionsWritableByApacheTask extends PermissionsTask { return "Gives write permissions to Apache user for given paths [built-in]"; } -} \ No newline at end of file +}