|
39 | 39 | end
|
40 | 40 | end
|
41 | 41 |
|
42 |
| -ruby_block "update-java-alternatives" do |
43 |
| - block do |
44 |
| - if platform?("ubuntu", "debian") and version == 6 |
45 |
| - run_context = Chef::RunContext.new(node, {}) |
46 |
| - r = Chef::Resource::Execute.new("update-java-alternatives", run_context) |
47 |
| - r.command "update-java-alternatives -s java-6-openjdk" |
48 |
| - r.returns [0,2] |
49 |
| - r.run_action(:create) |
50 |
| - else |
51 |
| - # have to do this on ubuntu for version 7 because Ubuntu does |
52 |
| - # not currently set jdk 7 as the default jvm on installation |
53 |
| - require "fileutils" |
54 |
| - arch = node['kernel']['machine'] =~ /x86_64/ ? "x86_64" : "i386" |
55 |
| - Chef::Log.debug("glob is #{java_home_parent}/java*#{version}*openjdk*") |
56 |
| - jdk_home = Dir.glob("#{java_home_parent}/java*#{version}*openjdk{,[-\.]#{arch}}")[0] |
57 |
| - Chef::Log.debug("jdk_home is #{jdk_home}") |
58 |
| - # delete the symlink if it already exists |
59 |
| - if File.exists? java_home |
60 |
| - FileUtils.rm_f java_home |
61 |
| - end |
62 |
| - FileUtils.ln_sf jdk_home, java_home |
63 |
| - |
64 |
| - cmd = Chef::ShellOut.new( |
65 |
| - %Q[ update-alternatives --install /usr/bin/java java #{java_home}/bin/java 1; |
| 42 | +if platform?("ubuntu","debian","redhat","centos","fedora","scientific","amazon") |
| 43 | + ruby_block "update-java-alternatives" do |
| 44 | + block do |
| 45 | + if platform?("ubuntu", "debian") and version == 6 |
| 46 | + run_context = Chef::RunContext.new(node, {}) |
| 47 | + r = Chef::Resource::Execute.new("update-java-alternatives", run_context) |
| 48 | + r.command "update-java-alternatives -s java-6-openjdk" |
| 49 | + r.returns [0,2] |
| 50 | + r.run_action(:create) |
| 51 | + else |
| 52 | + # have to do this on ubuntu for version 7 because Ubuntu does |
| 53 | + # not currently set jdk 7 as the default jvm on installation |
| 54 | + require "fileutils" |
| 55 | + arch = node['kernel']['machine'] =~ /x86_64/ ? "x86_64" : "i386" |
| 56 | + Chef::Log.debug("glob is #{java_home_parent}/java*#{version}*openjdk*") |
| 57 | + jdk_home = Dir.glob("#{java_home_parent}/java*#{version}*openjdk{,[-\.]#{arch}}")[0] |
| 58 | + Chef::Log.debug("jdk_home is #{jdk_home}") |
| 59 | + # delete the symlink if it already exists |
| 60 | + if File.exists? java_home |
| 61 | + FileUtils.rm_f java_home |
| 62 | + end |
| 63 | + FileUtils.ln_sf jdk_home, java_home |
| 64 | + |
| 65 | + cmd = Chef::ShellOut.new( |
| 66 | + %Q[ update-alternatives --install /usr/bin/java java #{java_home}/bin/java 1; |
66 | 67 | update-alternatives --set java #{java_home}/bin/java ]
|
67 |
| - ).run_command |
68 |
| - unless cmd.exitstatus == 0 or cmd.exitstatus == 2 |
69 |
| - Chef::Application.fatal!("Failed to update-alternatives for openjdk!") |
| 68 | + ).run_command |
| 69 | + unless cmd.exitstatus == 0 or cmd.exitstatus == 2 |
| 70 | + Chef::Application.fatal!("Failed to update-alternatives for openjdk!") |
| 71 | + end |
70 | 72 | end
|
71 | 73 | end
|
| 74 | + action :nothing |
72 | 75 | end
|
73 |
| - action :nothing |
74 | 76 | end
|
75 |
| - |
| 77 | + |
76 | 78 | pkgs.each do |pkg|
|
77 | 79 | package pkg do
|
78 | 80 | action :install
|
79 |
| - notifies :create, "ruby_block[update-java-alternatives]" |
| 81 | + notifies :create, "ruby_block[update-java-alternatives]" if platform?("ubuntu","debian","redhat","centos","fedora","scientific","amazon") |
80 | 82 | end
|
81 | 83 | end
|
0 commit comments