#!/usr/bin/bash
#
# Copyright C 2001-2007 by Isilon Systems, Inc. All rights not expressly
# granted herein are reserved.
# Created in the United States of America.
# 
# This digital media is protected by U.S. and international copyright and
# intellectual property laws. Unless otherwise specified, all information
# and screens appearing as part of this digital medium, including
# software, services, documents, text, images, icons, and logos design;
# the selection, assembly, arrangement, and design thereof; and the code
# that enables its presentation, are the sole property of Isilon Systems,
# Inc.
# 
# Except as otherwise required by applicable law, no part of any
# copyrighted material may be reproduced, modified, translated,
# distributed, published, or transmitted by any means, electronic or
# mechanical, for any purpose, without the prior written consent of Isilon
# Systems. 
#  
# Isilon and Isilon Systems are registered trademarks of Isilon Systems,
# Inc.  Legion is a trademark of Isilon Systems, Inc.  All other
# trademarks and registered trademarks are the property of their
# respective holders.
#


#This script is for bug75813, to facilitate sending ABRs via CLI.
#It is meant in lieu of special casing IGI transport mechanisms
# just for ABR group, which is heavy impact to an already over-extended IGI.
#This is intended to be lightweight and piggyback on Axeda bash Scripts, 
# instead of introducing new code, to minimize linkages that can fail. 

#is support_iq enabled?
enabled=`isi services -a supportiq | grep -ic "enabled"`

#first try IGI 
logger -si "Attempting ABR transport via isi_gather_info."
`/usr/bin/isi_gather_info --nologs --group abr &>/dev/null`

if [ $? -eq 1 ]; then
    #IGI transport failed!
    logger -si "isi_gather_info ABR transport failed."
    if [ ${enabled} -eq 1 ]; then
	#SupportIQ is enabled!    
	logger -si  "SupportIQ is enabled. Trying SupportIQ"
        `/usr/local/SupportIQ/Scripts/GetData-abr.sh &>/dev/null`
	if [ $? -eq 1 ]; then
	    #SupportIQ transport Failed.
            logger -si "ABR transport via SupportIQ failed."
	    exit 1	
	else
	    #Success!!	
	    logger -si "ABR was successfully sent via SupportIQ."
	    exit 0
	fi
    else
	#SupportIQ disabled.    
        logger -si "SupportIQ is not enabled. ABR transport failed."
	exit 1
    fi
else
    #Success!!	
    logger -si "ABR was successfully sent via isi_gather_info."
fi
exit 0

