#define MESSAGE TMF_Types::XOpenMessage

TaskLibrary "SunMC Task Library" {

	Version = "1.0";
	Context = "TEC";
	Distribute = "ALI";

	HelpMessage = (_help_, "SunMC Task Library - Please choose a task to execute...", 1);

	ArgLayout SimpleText { Text };

	Task HostDetails {

		Description = (_desc_, "Launch SunMC HostDetails", 1);
		HelpMessage = (_help_, "This task launches the SunMC Host Details screen for the Hostname specified in the selected event. Enter the hostname of the machine where you want SunMC to be displayed.  This assumes that SunMC is installed on the same server as Tivoli - if it is not, SunMC cannot be lauched from the Tivoli console, it must be done manually if desired.", 1);
		Roles = "super:senior:admin";
		Argument (_arg_, "Hostname for SunMC display: ", 1) {
			Layout = "SimpleText";
		};
		
		Implementation ("solaris2")

			.#!/bin/sh
			.displayhost="$1"
			.syserver=noserver
			.syport=noport
                        .DISPLAY=$displayhost
                        .export DISPLAY
			.for SLOT in $SLOTS; do
			.	if [ $SLOT = detailHost ]; then
			.	  eval targethost='"'\$"${SLOT}"'"'
			.	fi
		
			.	if [ $SLOT = sserver ]; then
			.	  eval syserver='"'\$"${SLOT}"'"'
			.	fi

			.	if [ $SLOT = sport ]; then
			.	  eval syport='"'\$"${SLOT}"'"'
			.	fi
			.done
			.if [ $syserver = noserver ]; then
			.	echo "No SunMC server name has been set in this event, so it's probably not SunMC-generated.  Cannot launch HostDetails screen."
			.	exit 1
			.fi
			.if [ $syport = noport ]; then
			.	echo "No SunMC port number has been set in this event, so it's probably not SunMC-generated.  Cannot launch HostDetails screen."
			.	exit 1
			.fi
			.echo " "
			.echo "Launching the HostDetails screen for $targethost..."  
			.echo " "
			.exec 1<&- 2<&-
			.unset CHILD_OF_OSERV
			.rootdir=`pkgparam SUNWescon BASEDIR`
			.${rootdir}/SUNWsymon/SunMC-Tivoli/sbin/LaunchHDBean.sh -s $syserver -p $syport -t $targethost &
			.exit 0
		;}
;
};
