#!/usr/bin/env ruby
# Download Files at: http://www.oracle.com/technetwork/java/javase/downloads/java-se-jdk-7-download-432154.html
if ARGV[0].nil?
puts "Usage #{$0} <path of downloaded oracle tgz file>"
else
update_file = ARGV[0]
if File.extname(update_file) == ".tgz" || File.basename(update_file)[-6..-1] == "tar.gz"
java_root = `tar -tzf #{update_file}`.split("\/")[0]
update_root = "/usr/lib/jvm"
system("tar -xzvf #{update_file}") unless Dir.exists?("#{update_root}/#{java_root}")
first_time_installing_java = false
unless Dir.exists?("/usr/lib/jvm")
`mkdir /usr/lib/jvm`
first_time_installing_java = true
end
`mv #{java_root} #{update_root}` unless Dir.exists?("#{update_root}/#{java_root}")
if first_time_installing_java
system("update-alternatives --install '/usr/bin/java' 'java' '#{update_root}/#{java_root}/bin/java' 1")
system("update-alternatives --install '/usr/bin/javac' 'javac' '#{update_root}/#{java_root}/bin/javac' 1")
system("update-alternatives --install '/usr/bin/javaws' 'javaws' '#{update_root}/#{java_root}/bin/javaws' 1")
else
system("update-alternatives --config java")
system("update-alternatives --config javac")
system("update-alternatives --config javaws")
end
print "Populate Username that Will Use the Mozilla Firefox Java Plugin: "
username = STDIN.gets.chomp
if username != "root"
mozilla_java_plugin_dir = "/home/#{username}"
else
mozilla_java_plugin_dir = "/root/.mozilla/plugins"
end
puts "MOZILLA PLUGIN HOME DIR = #{mozilla_java_plugin_dir}/libnpjp2.so"
`mkdir #{mozilla_java_plugin_dir}` unless Dir.exists?(mozilla_java_plugin_dir)
`ln -sf #{update_root}/#{java_root}/jre/lib/amd64/libnpjp2.so #{mozilla_java_plugin_dir}`
`ln -sf #{update_root}/#{java_root}`
else
puts "ERROR!!! This script only support .tgz or tar.gz Oracle Java files..."
exit
end
end
This script means one less thing to worry about in my Ubuntu environments!
ReplyDelete