#!/bin/bash 

function Install_Alt {
	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 apt-get --yes install $1")
		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 apt-get --yes remove $1"
		then
			return 1
		fi
		Install_Alt "$1"
		return $?
	fi
}
