Permalink
Browse files

make sure deplying user is added to rvm group, fix #43

  • Loading branch information...
1 parent b349bb0 commit 59fa58b06e70b79e6e7477ef2783dab25163991a @mpapis mpapis committed Dec 16, 2012
Showing with 23 additions and 6 deletions.
  1. +22 −5 lib/rvm/capistrano.rb
  2. +1 −1 lib/rvm/capistrano/version.rb
View
@@ -79,6 +79,9 @@ def _cset(name, *args, &block)
# Additional rvm packages to install.
_cset(:rvm_install_pkgs, '')
+ # By default system installations add deploying user to rvm group. also try :all
+ _cset(:rvm_add_to_group, "#{user}")
+
namespace :rvm do
command_curl_start = <<-EOF.gsub(/^\s*/, '')
@@ -115,6 +118,10 @@ def _cset(name, *args, &block)
''
end
command_install << "#{rvm_install_shell} -s #{rvm_install_type} --path #{rvm_path}"
+ case rvm_type
+ when :root, :system
+ command_install << " --add-to-rvm-group #{[rvm_add_to_group].flatten.map(&:to_s).join(",")}"
+ end
_command = <<-EOF
#{command_curl_start};
#{command_fetch} | #{command_install};
@@ -123,6 +130,15 @@ def _cset(name, *args, &block)
run "#{_command}".gsub(/[\s\n]+/, ' '), :shell => "#{rvm_install_shell}"
end
+ def with_rvm_group(command)
+ case rvm_type
+ when :root, :system
+ "sg rvm -c \"#{command}\""
+ else
+ command
+ end
+ end
+
desc <<-EOF
Install RVM ruby to the server, create gemset if needed.
By default ruby is installed, you can reinstall with:
@@ -142,9 +158,10 @@ def _cset(name, *args, &block)
if %w( release_path default ).include? "#{ruby}"
raise "ruby can not be installed when using :rvm_ruby_string => :#{ruby}"
else
- command_install = "#{File.join(rvm_bin_path, "rvm")} #{rvm_install_ruby} #{ruby} -j #{rvm_install_ruby_threads} #{rvm_install_ruby_params}"
+ command_install = with_rvm_group("#{File.join(rvm_bin_path, "rvm")} #{rvm_install_ruby} #{ruby} -j #{rvm_install_ruby_threads} #{rvm_install_ruby_params}")
if gemset
- command_install << "; #{File.join(rvm_bin_path, "rvm")} #{ruby} do rvm gemset create #{gemset}"
+ command_install << "; "
+ command_install << with_rvm_group("#{File.join(rvm_bin_path, "rvm")} #{ruby} do rvm gemset create #{gemset}")
end
_command = <<-EOF
#{command_curl_start};
@@ -155,11 +172,11 @@ def _cset(name, *args, &block)
end
end
- desc <<-EOF
+ desc <<-EOF
Install RVM packages to the server.
This must come before the 'rvm:install_ruby' task is called.
-
+
The package list is empty by default. Specifiy the packages to install with:
set :rvm_install_pkgs, %w[libyaml curl]
@@ -179,7 +196,7 @@ def _cset(name, *args, &block)
raise "gemset can not be created when using :rvm_ruby_string => :#{ruby}"
else
if gemset
- run "#{File.join(rvm_bin_path, "rvm")} #{ruby} do rvm gemset create #{gemset}", :shell => "#{rvm_install_shell}"
+ run with_rvm_group("#{File.join(rvm_bin_path, "rvm")} #{ruby} do rvm gemset create #{gemset}", :shell => "#{rvm_install_shell}")
@baburdick

baburdick Feb 15, 2013

While it wasn't introduced in this change, this line breaks for me when running cap rvm:create_gemset: https://gist.github.com/baburdick/39e299a82be029421b93 . It looks like #with_rvm_group takes only one arg. But this line hands it a string and a hash.

end
end
end
@@ -1,5 +1,5 @@
module RVM
class Capistrano
- VERSION="1.3.0.rc1"
+ VERSION="1.3.0.rc2"
end
end

0 comments on commit 59fa58b

Please sign in to comment.