From ad97af76d927089307fedaaca5e1447f44bd9ae8 Mon Sep 17 00:00:00 2001 From: Jarek Gawor Date: Mon, 16 Dec 2013 11:29:48 -0500 Subject: [PATCH] set alternatives when using ibm_tar recipe --- providers/alternatives.rb | 5 +++++ recipes/ibm_tar.rb | 12 ++++++++++++ 2 files changed, 17 insertions(+) diff --git a/providers/alternatives.rb b/providers/alternatives.rb index fe1fcb6f..713f1313 100644 --- a/providers/alternatives.rb +++ b/providers/alternatives.rb @@ -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 diff --git a/recipes/ibm_tar.rb b/recipes/ibm_tar.rb index 7f5abdc8..984ccaf0 100644 --- a/recipes/ibm_tar.rb +++ b/recipes/ibm_tar.rb @@ -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