blob: bbefbee0208ec9659efb240f42478361b8a44005 [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
46sudo apt-get install ${SILENT} oracle-java7-set-default
47
48{ set +x; } 2>/dev/null
49echo
50echo "Done. You may need to relogin for the environment variable change to take effect."
51
52