lib/ash/wordpress.rb in capistrano-ash-1.3.6 vs lib/ash/wordpress.rb in capistrano-ash-1.3.7

- old
+ new

@@ -7,10 +7,25 @@ Capistrano.configuration(:must_exist) configuration.load do # -------------------------------------------- + # try_sudo configuration + # -------------------------------------------- + set :use_sudo, true # allow try_sudo methods to actually run via sudo + # set(:admin_runner) {"#{user}"} # specify the :admin_runner if you need to run it as another user other than root + + # Clear out the default prompt (i.e., `sudo -p 'sudo password: '`) to fall back + # to just using `sudo` due to the concatenation in the sudo method. + # + # This assumes that you have set up your SSH user to have passwordless sudo + # setup for common commands (e.g., mv, cp, ln, mkdir, chown, chmod, rm, etc.) + # + # (see: https://github.com/capistrano/capistrano/blob/legacy-v2/lib/capistrano/configuration/actions/invocation.rb#L229-L237) + set :sudo_prompt, '' + + # -------------------------------------------- # Setting defaults # -------------------------------------------- set :uploads_path, "wp-content/uploads" # -------------------------------------------- @@ -41,11 +56,11 @@ # create shared directories run "mkdir -p #{shared_path}/uploads" run "mkdir -p #{shared_path}/cache" # set correct permissions - run "chmod -R 777 #{shared_path}/*" + run "#{try_sudo} chmod -R 777 #{shared_path}/*" end desc "[internal] Touches up the released code. This is called by update_code after the basic deploy finishes." task :finalize_update, :roles => :web, :except => { :no_release => true } do # remove shared directories @@ -94,10 +109,10 @@ run "mysql -u #{dbuser} -p #{dbpass} #{dbname} -e 'UPDATE #{dbprefix}options SET option_value = \"#{application}\" WHERE option_name = \"siteurl\" OR option_name = \"home\"'" end desc "Protect system files" task :protect, :except => { :no_release => true } do - run "chmod 440 #{latest_release}/wp-config.php*" + run "#{try_sudo} chmod 440 #{latest_release}/wp-config.php*" end end end