#!/bin/bash 

function Install_Yum {
	query=$(rpm -qi "$1" 2>/dev/null | grep "Install Date")
	if [ -z "$query" ]
	then
		Write_Log "The [$1] package is not yet installed"
		Write_Log "Installing..."
		install_out=$(Run_Command "REMOVE_COLIBRI_DB=1 yum install $1 -y")
		install_rc=$?
		if [ $install_rc -ne 0 ]
		then
			Write_Log "Installation $1 was failed: [$install_out]" "ERROR"
			return $install_rc
		fi
		return 0
	else
		Write_Log "The [$1] package was installed before, reinstall.."
		if ! Run_Command "REMOVE_COLIBRI_DB=1 yum remove -y $1"
		then
			return 1
		fi
		Install_Yum "$1"
		return $?
	fi
}
