augustash / capistrano-ash

August Ash recipes for Capistrano
http://augustash.com
MIT License
73 stars 12 forks source link

add methods for fixing permissions on files and directories #18

Closed grafikchaos closed 12 years ago

grafikchaos commented 12 years ago

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

so instead of this:

# 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:

# 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
# 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
grafikchaos commented 12 years ago

closed with 901dd8e38b8678ab52531a639347bfffb46bc7f0