Skip to content

Commit

Permalink
Merge pull request #103 from jgawor/ibm_tar
Browse files Browse the repository at this point in the history
[COOK-4109] set alternatives when using ibm_tar recipe
  • Loading branch information
carmstrong committed Dec 17, 2013
2 parents b54d329 + ad97af7 commit b172308
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
5 changes: 5 additions & 0 deletions providers/alternatives.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@
alt_path = "#{new_resource.java_location}/bin/#{cmd}"
priority = new_resource.priority

if !::File.exist?(alt_path)
Chef::Log.debug "Skipping setting alternative for #{cmd}. Command #{alt_path} does not exist."
next
end

# install the alternative if needed
alternative_exists = shell_out("update-alternatives --display #{cmd} | grep #{alt_path}").exitstatus == 0
unless alternative_exists
Expand Down
12 changes: 12 additions & 0 deletions recipes/ibm_tar.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,21 @@
recursive true
end

java_alternatives 'set-java-alternatives' do
java_location node['java']['java_home']
case node['java']['jdk_version']
when "6"
bin_cmds node['java']['ibm']['6']['bin_cmds']
when "7"
bin_cmds node['java']['ibm']['7']['bin_cmds']
end
action :nothing
end

execute "untar-ibm-java" do
cwd Chef::Config[:file_cache_path]
command "tar xzf ./#{jdk_filename} -C #{node['java']['java_home']} --strip 1"
notifies :set, 'java_alternatives[set-java-alternatives]', :immediately
creates "#{node['java']['java_home']}/jre/bin/java"
end

Expand Down

0 comments on commit b172308

Please sign in to comment.