#!/bin/bash

# Java
function oracle-java {
	# Variables
	PACKAGE=oracle-java8-installer
	PPANAME=ppa:webupd8team/java
	NAME="Oracle Java 8"
	# Start
	show_header 'Begin '$NAME' installation'
	# Check if already installed
	echo 'Checking if '$NAME' is already installed...'
	PKGCHECK=$(dpkg-query -W --showformat='${Status}\n' $PACKAGE|grep "install ok installed")
	if [ "" == "$PKGCHECK" ]; then
		echo $NAME 'is not installed. Proceeding'
		# Add repository
		show_info 'Adding '$NAME' repository to software sources...'
		show_warning 'Requires root privileges'
		sudo add-apt-repository -y $PPANAME
		# Update repository information
		show_info 'Updating repository information...'
		sudo apt update -y
		show_success 'Done.'
		# Install
		show_info 'Installing '$NAME'...'
		sudo apt install -y $PACKAGE
		# Done
		show_success 'Done.'
		whiptail --title "Finished" --msgbox "Installation of $NAME complete." 8 78
		thirdparty
	else
		# Already installed
		show_success $NAME 'already installed.'
		whiptail --title "Finished" --msgbox "$NAME is already installed." 8 78
		thirdparty
	fi
}