Path: | lib/capistrano/recipes/deploy.rb |
Last Update: | Thu Nov 27 16:11:15 +0000 2008 |
# File lib/capistrano/recipes/deploy.rb, line 5 5: def _cset(name, *args, &block) 6: unless exists?(name) 7: set(name, *args, &block) 8: end 9: end
Auxiliary helper method for the `deploy:check’ task. Lets you set up your own dependencies.
# File lib/capistrano/recipes/deploy.rb, line 75 75: def depend(location, type, *args) 76: deps = fetch(:dependencies, {}) 77: deps[location] ||= {} 78: deps[location][type] ||= [] 79: deps[location][type] << args 80: set :dependencies, deps 81: end
Same as sudo, but tries sudo with :as set to the value of the :runner variable (which defaults to "app").
# File lib/capistrano/recipes/deploy.rb, line 125 125: def try_runner(*args) 126: options = args.last.is_a?(Hash) ? args.pop : {} 127: args << options.merge(:as => fetch(:runner, "app")) 128: try_sudo(*args) 129: end
If a command is given, this will try to execute the given command, as described below. Otherwise, it will return a string for use in embedding in another command, for executing that command as described below.
If :run_method is :sudo (or :use_sudo is true), this executes the given command via sudo. Otherwise is uses run. If :as is given as a key, it will be passed as the user to sudo as, if using sudo. If the :as key is not given, it will default to whatever the value of the :admin_runner variable is, which (by default) is unset.
THUS, if you want to try to run something via sudo, and what to use the root user, you‘d just to try_sudo(‘something’). If you wanted to try_sudo as someone else, you‘d just do try_sudo(‘something’, :as => "bob"). If you always wanted sudo to run as a particular user, you could do set(:admin_runner, "bob").
# File lib/capistrano/recipes/deploy.rb, line 107 107: def try_sudo(*args) 108: options = args.last.is_a?(Hash) ? args.pop : {} 109: command = args.shift 110: raise ArgumentError, "too many arguments" if args.any? 111: 112: as = options.fetch(:as, fetch(:admin_runner, nil)) 113: via = fetch(:run_method, :sudo) 114: if command 115: invoke_command(command, :via => via, :as => as) 116: elsif via == :sudo 117: sudo(:as => as) 118: else 119: "" 120: end 121: end