Skip to content

Commit

Permalink
Merge pull request #298 from cmluciano/drag00n/gpguserinstall
Browse files Browse the repository at this point in the history
Add gpg-check to user_install recipe.
  • Loading branch information
cmluciano committed Mar 6, 2015
2 parents edf7df3 + 9aefc99 commit fe59ff3
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions recipes/user_install.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,27 @@
# if user hash is not a hash (i.e. set to true), init an empty Hash
opts = Hash.new if opts == true

ruby_block "Conditionally add RVM gpg key #{user}" do
block do
cmd = Mixlib::ShellOut.new('which gpg2 || which gpg')
cmd.run_command

if cmd.exitstatus == 0
gpg_command = cmd.stdout.chomp

exec = Chef::Resource::Execute.new 'Add RVM gpg key', run_context
exec.command "#{gpg_command} --keyserver hkp://keys.gnupg.net --recv-keys #{node['rvm']['gpg_key']}"
exec.user rvm_user['user']
exec.environment 'HOME' => rvm_prefix
exec.guard_interpreter :bash
exec.not_if "#{gpg_command} -k #{node['rvm']['gpg_key']} > /dev/null", user: rvm_user['user'], environment: { 'HOME' => rvm_prefix }
exec.run_action :run
else
Chef::Log.info 'Skipping adding RVM key because gpg/gpg2 not installed'
end
end
end

rvm_installation(user.to_s) do
%w(installer_url installer_flags install_pkgs rvmrc_template_source
rvmrc_template_cookbook rvmrc_env action
Expand Down

0 comments on commit fe59ff3

Please sign in to comment.