blob: b4eed0aae5c458c09ecbd4198de8ec7ed8279fc8 [file] [log] [blame]
Yuta HIGUCHI328acd82014-03-27 12:51:42 -07001#!/bin/sh
2
3SILENT=""
4
5while getopts hy OPTION
6do
7 case OPTION in
8 y)
9 SILENT="-y"
10 ;;
11 *)
12 echo
13 echo "This script will install Oracle JDK 7 and set JAVA_HOME"
14 echo "Usage: $ $0"
15 echo
16 exit 1
17 ;;
18 esac
19done
20
21if [ "$SILENT" = "-y" ]; then
22 sudo apt-get install -y software-properties-common python-software-properties
23fi
24
25# print what's going on
26set -x
27
28sudo add-apt-repository ${SILENT} ppa:webupd8team/java
29if [ $? -ne 0 ]; then
30 { set +x; } 2>/dev/null
31 echo
32 echo "Registering Oracle Java repository failed."
33 echo "If the error was about add-apt-repository command not found,"
34 echo "try one of the following and retry running this script"
35 echo
36 echo "$ sudo apt-get install software-properties-common"
37 echo "$ sudo apt-get install software-properties-common python-software-properties"
38 echo
39 exit 1
40fi
41
42# fail on error
43set -e
44
45sudo apt-get update
Yuta HIGUCHId4793b22014-04-07 19:35:21 -070046{
47 sudo apt-get install ${SILENT} oracle-java7-set-default
48} || {
49 { set +x; } 2>/dev/null
50 echo
51 echo "Installing Oracle Java failed."
52 echo "This script cannot be used if ubuntu release has reached end of life."
53 echo "Check if your ubuntu release is still supported."
54 echo " https://wiki.ubuntu.com/Releases"
55 echo
56 lsb_release -a
57 exit 1
58}
Yuta HIGUCHI328acd82014-03-27 12:51:42 -070059{ set +x; } 2>/dev/null
60echo
61echo "Done. You may need to relogin for the environment variable change to take effect."
62
63