#!/bin/sh

SILENT=""

while getopts “hy” OPTION
do
  case OPTION in
    y)
      SILENT="-y"
      ;;
    *)
      echo
      echo "This script will install Oracle JDK 7 and set JAVA_HOME"
      echo "Usage: $ $0"
      echo
      exit 1
      ;;
  esac
done

if [ "$SILENT" = "-y" ]; then
 sudo apt-get install -y software-properties-common python-software-properties
fi

# print what's going on
set -x

sudo add-apt-repository ${SILENT} ppa:webupd8team/java
if [ $? -ne 0 ]; then
  { set +x; } 2>/dev/null
  echo
  echo "Registering Oracle Java repository failed."
  echo "If the error was about add-apt-repository command not found,"
  echo "try one of the following and retry running this script"
  echo
  echo "$ sudo apt-get install software-properties-common"
  echo "$ sudo apt-get install software-properties-common python-software-properties"
  echo
  exit 1
fi

# fail on error
set -e

sudo apt-get update
sudo apt-get install ${SILENT} oracle-java7-set-default

{ set +x; } 2>/dev/null
echo
echo "Done. You may need to relogin for the environment variable change to take effect."



#!/bin/sh

SILENT=""

while getopts “hy” OPTION
do
  case OPTION in
    y)
      SILENT="-y"
      ;;
    *)
      echo
      echo "This script will install Oracle JDK 7 and set JAVA_HOME"
      echo "Usage: $ $0"
      echo
      exit 1
      ;;
  esac
done

if [ "$SILENT" = "-y" ]; then
 sudo apt-get install -y software-properties-common python-software-properties
fi

# print what's going on
set -x

sudo add-apt-repository ${SILENT} ppa:webupd8team/java
if [ $? -ne 0 ]; then
  { set +x; } 2>/dev/null
  echo
  echo "Registering Oracle Java repository failed."
  echo "If the error was about add-apt-repository command not found,"
  echo "try one of the following and retry running this script"
  echo
  echo "$ sudo apt-get install software-properties-common"
  echo "$ sudo apt-get install software-properties-common python-software-properties"
  echo
  exit 1
fi

# fail on error
set -e

sudo apt-get update
{
  sudo apt-get install ${SILENT} oracle-java7-set-default
} || {
  { set +x; } 2>/dev/null
  echo
  echo "Installing Oracle Java failed."
  echo "This script cannot be used if ubuntu release has reached end of life."
  echo "Check if your ubuntu release is still supported."
  echo " https://wiki.ubuntu.com/Releases"
  echo
  lsb_release -a
  exit 1
}
{ set +x; } 2>/dev/null
echo
echo "Done. You may need to relogin for the environment variable change to take effect."



Print error message when Oracle Java installation failed.
Print error message when Oracle Java installation failed.

 Oracle JDK cannot be installed using launchpad,
if the ubuntu release has reached EOL. (ONOS-1157)
This patch add a message to suggest user to check ubuntu version.

Change-Id: I962fed84fcbf80c3902b3f48e3d45f815ccad3f3
