#!/bin/bash
############################################
# dtb-overview
#
# Information script about the DTB status
# Usage: ./dtb-overview
# 
# Copyright (c) 2016 Unify GmbH & Co. KG
# Demeter Aron, Kemenes Robert 
# aron.demeter.ext@unify.com, robert.kemenes.ext@unify.com
#
# Last modification: 11.04.2016
############################################

# The status is checked every time, so don't fulfill the logs.

yesorno()
{
	if [ $1 -eq 0 ]
	then
		echo -e $YES
	else
		echo -e $NO
	fi
}

red='\033[0;31m'
green='\033[0;32m'
NC='\033[0m' # No Color
YES="${green}yes${NC}"
NO="${red}no${NC}"

echo "Quick status of dtb application:"
echo

APPLS="DTBMaster DTBServer"
for APPL in $APPLS
do
	/opt/dtb/bin/dtb-installer $APPL status 1>/dev/null 2>/dev/null
	install_state=$?
	/opt/dtb/bin/dtb-wrapper $APPL status 1>/dev/null 2>/dev/null
	run_state=$?

	echo $APPL
	echo "--------"
	echo -n "installed: "
	yesorno $install_state
	echo -n "running:   "
	yesorno $run_state
	echo
done
