#!/bin/bash
#
# (C) Copyright 2002-2005 Hewlett-Packard Development Company, L.P.
#
# init file for hp RIB agent
#
# processname: cmasm2d

NAME="RIB agent"
PNAME="cmasm2d"

#is X installed
if [ -f /etc/X11/xorg.conf ]; then
   XCONF="/etc/X11/xorg.conf"
elif [ -f /etc/X11/XF86Config ]; then
   XCONF="/etc/X11/XF86Config"
fi

#is hpmouse installed and configured
if [ -n "$XCONF" ]; then
   HPMOUSEINSTALLED=`grep -i "HP ILO X MOUSE DRIVER" $XCONF |wc -l`
else
   HPMOUSEINSTALLED=0
fi

if [ $HPMOUSEINSTALLED -gt 0 ]; then
   MOUSEFLAGS="-m ENABLE"
fi

PFLAGS="-p 30 $MOUSEFLAGS -l /var/log/hp-snmp-agents/cma.log"

if [ "x$CMAINCLUDE" = "x" ]; then
   if [ -d /opt/hp/hp-snmp-agents ]; then
        CMAINCLUDE=/opt/hp/hp-snmp-agents/server/etc/cmad
   else
	CMAINCLUDE=/opt/compaq/foundation/etc/cmad
   fi
fi

# Check for presence of PL100 generation 5 and higher servers.
# If Servers are not PL100 generation 5 or higher server, then do
# not do check for presence of 'hp-ilo' driver.
    PL100G5HIGHER=0
    PRODNAME=`dmidecode | grep "Product Name" | cut -d" " -f4 | head -n1`
    GENERATION=`dmidecode | grep "Product Name" | cut -d" " -f5 | head -n1`
    #Remove the Server Type Tag from Product Name
    PRODNUM=`echo $PRODNAME | sed s/[a-zA-Z]//g`
    if [ "$PRODNUM" ] ; then
      if [ "$PRODNUM" -ge 100 -a "$PRODNUM" -lt 200 ] ; then  # TRUE only if the server is 100 series
          if [ "$GENERATION" = "G5" -o "$GENERATION" \> "G5" ]; then  # TRUE only if the server is G5 or higher
	      PL100G5HIGHER=1
	  fi
      fi
    fi
if [ "$PL100G5HIGHER" -eq 0 ]; then
    STARTADDON="checkformodule hpilo /etc/init.d/hp-ilo"
fi

. $CMAINCLUDE
