augustash/capistrano-ash — Issue #18: add methods for fixing permissions on files and directories
Author: grafikchaos
Created: 2012-02-23 18:06:51+00:00
State: open
Labels: feature request

move the innards of the ash:fixperms to their own separate methods for fixing permissions on files and directories

so instead of this:

```ruby
# in lib/ash/base.rb
namespace :ash do
desc "Set standard permissions for Ash servers"
task :fixperms, :roles => :web, :except => { :no_release => true } do
# chmod the files and directories.
try_sudo "find #{latest_release} -type d -exec chmod 755 {} \\;"
try_sudo "find #{latest_release} -type f -exec chmod 644 {} \\;"
end
end
```

we could do something like this:

```ruby
# in lib/ash/base.rb
namespace :ash do
desc "Set standard permissions for Ash servers"
task :fixperms, :roles => :web, :except => { :no_release => true } do
# chmod the files and directories.
fix_perms_files("#{latest_release}")
fix_perms_dirs("#{latest_release}")
end
end
```

```ruby
# in lib/ash/common.rb

# recursively fix file permissions
# defaults to the the current working directory
# and normal file permissions of 644
def fix_perms_files(path_to_directory = ".", permissions = 644)
try_sudo "find #{path_to_directory} -type f -exec chmod #{permissions} {} \\;"
end

# recursively fix directory permissions
# defaults to the the current working directory
# and normal directory permissions of 755
def fix_perms_dirs(path_to_directory = ".", permissions = 755)
try_sudo "find #{path_to_directory} -type d -exec chmod #{permissions} {} \\;"
end
```