#!/bin/bash

prefix=ela
PATH="/sbin:$PATH"
export PATH

FACILITY=""
EVENT_TYPE=""
SEVERITY=""
RUNCMD=""

ELA_SCRIPTS_DIR=/usr/share/evlog
. $ELA_SCRIPTS_DIR/ela_funcs

recid=${1}

#echo $recid > $OUTPUT


#
# begin_rec_get - Capture the event record with this recid and 
# put it in our temporary storage - Subsequent get_* will work
# of this temporary storage.
# 
begin_rec_get $prefix $recid

#
# get the runcmd from event record template
#
RUNCMD=$(get_event_none_std_att "$prefix" "$recid" "runcmd")

#echo "$RUNCMD"
#
# If run command is empty then just exit
#
if [ -z "$RUNCMD" ]; then
	echo "There is no runcmd string from template."
	exit 0
fi

#
#
# Verify that the runcmd script  exist and invoke the runcmd script.
#

if [ ! -f "$RUNCMD" ]; then
	echo "Command not found."
	end_rec_get $prefix $recid
	exit 1
fi
$RUNCMD $recid

#
# end_rec_get - We are done with getting information in this rec
# remove temporary storage
#
end_rec_get $prefix $recid

