Summary     	: hp Lights-Out Drivers and Agents
Name        	: hprsm
Version     	: 7.2.0
Release     	: custom 
Group       	: System Environment/Kernel
Source		: hprsm.tar.gz	
Copyright   	: commercial 
Packager    	: Hewlett-Packard 
Vendor		: Hewlett-Packard 
URL         	: http://www.hp.com/linux
BuildRoot   	: /var/tmp/%{name}
AutoReqProv	: no
PreReq		: /bin/sh, /bin/bash
Requires	: hpasm 

%description

The HP Lights-Out Drivers and Agents for Linux combines the drivers for the hp ProLiant Remote Insight Board, hp ProLiant Integrated Lights Out Management, and the RILO and rack agents.

The hp ProLiant Remote Insight Board Driver ensures data flow between the hp ProLiant Integrated Management Log and the Remote Insight Board. It also routes SNMP packets out of the integrated Network Interface Card so that no additional network connection has to be burdened with management traffic. The Remote Insight Board will work without this driver, however, some functionality will not be available.

The ProLiant Integrated Lights Out Management Driver (cpqci.o) is a replacement to the ProLiant Remote Insight Board Driver (cpqrib.o) that enables Remote Manageability. 

hp Server Agents for Linux provide a full spectrum of management data including RILO information for hp Servers. This information is available using the 
hp Insight Manager Console, the hp Web Agent, or other management
applications using SNMP.

The ProLiant Rack Infrastructure Interface Service enables IPMI communication through the integrated Lights Out Management Component.

%prep
%setup -n hprsm

%build

%pre
if [ "$1" = "2" ]; then
   /etc/init.d/hprsm stop
   sh /opt/compaq/hprsm/hprsm end 
fi

if [ ! -d /var/spool/compaq/server/registry ]; then
   mkdir -p /var/spool/compaq/server/registry
   chmod 700 /var/spool/compaq
   chmod 700 /var/spool/compaq/server
   chmod 700 /var/spool/compaq/server/registry
fi

%install
if [ $RPM_BUILD_ROOT != "/" ]; then
	rm -rf $RPM_BUILD_ROOT
fi
mkdir -p $RPM_BUILD_ROOT

#Everything over
cp -a * $RPM_BUILD_ROOT/.

#Make sure that no brp-strip script gets executed after this section.
%define __os_install_post %{nil}

%post
#Conditionally copy some files around
sh /opt/compaq/hprsm/addon/condcopy /opt/compaq/hprsm/addon/condcopy.txt
#Change file permissions
chmod go-rwx /opt/compaq
chmod go-rwx /opt/compaq/server
chmod go-rwx /opt/compaq/server/bin
chmod go-rwx /opt/compaq/server/etc
chmod go-rwx /var/spool/compaq


# this is to turn off the kmod induced messages in /var/log/message

if [ -e /etc/modules.conf ]; then
	cp -f /etc/modules.conf /etc/modules.temp$$
	echo "alias char-major-237 off" > /etc/modules.conf
	grep -v "char-major-237" /etc/modules.temp$$ >> /etc/modules.conf
	rm -f /etc/modules.temp$$
fi

sync
sh /opt/compaq/hprsm/hprsm init verbose
if [ $? -eq 0 ]; then
	echo -e "\n"
	echo "The hprsm RPM has installed successfully."
	echo
	echo    "==================================================================="
        echo    "NOTE: If you have not previously run the 'hpasm activate' "
        echo    "command you must type 'hpasm activate' as 'root' user "
        echo    "to activate the agent software in this package."
	echo    "==================================================================="
	echo
else
	echo "The hprsm RPM installation failed!"
fi
    
%preun
if [ "$1" = "0" ]; then
   sync
   /etc/init.d/hprsm stop
   sh /opt/compaq/hprsm/hprsm end 

   BUSY=`lsmod |egrep "cpqrid [ ]*[0-9][0-9]* [ ]*[1-9][0-9]*"`
   if [ ${#BUSY} -ne 0 ]; then
        echo "cpqrid driver is busy and can not be removed."
        exit 1
   fi 
   BUSY=`lsmod |egrep "cpqci [ ]*[0-9][0-9]* [ ]*[1-9][0-9]*"`
   if [ ${#BUSY} -ne 0 ]; then
        echo "cpqci driver is busy and can not be removed."
        exit 1
   fi 
   
   for OS_VER in `ls -d /lib/modules/*`; do
        #Now wipe all occurences of cpqrid and cpqci in the current directory.
        if [ -f $OS_VER/misc/cpqrid.o ]; then
                rm -f $OS_VER/misc/cpqrid.o
        fi
        if [ -f $OS_VER/kernel/drivers/char/cpqrid.o ]; then
                rm -f $OS_VER/kernel/drivers/char/cpqrid.o
        fi
        if [ -f $OS_VER/misc/cpqci.o ]; then
                rm -f $OS_VER/misc/cpqci.o
        fi
        if [ -f $OS_VER/kernel/drivers/char/cpqci.o ]; then
                rm -f $OS_VER/kernel/drivers/char/cpqci.o
        fi
   done;

   #remove the conditionally copied files
   sh /opt/compaq/hprsm/addon/condrem /opt/compaq/hprsm/addon/condcopy.txt
fi

%postun
if [ "$1" = "0" ]; then
  rmdir /opt/compaq/server/bin 2>/dev/null
  rmdir /opt/compaq/server/etc 2>/dev/null
  rmdir /opt/compaq/server 2>/dev/null
  rmdir /opt/compaq 2>/dev/null
  rmdir /opt 2>/dev/null

  rm -rf /opt/compaq/cpqrid
  rm -rf /opt/compaq/cpqci
  rm -rf /opt/compaq/hprsm

  # Remove /opt/compaq/server/etc/cimsvrobjects.conf from /opt/compaq/cmaobjects.conf
  CONFFILE=/opt/compaq/cmaobjects.conf
  OBJSFILE="/opt/compaq/server/etc/cmasvrbjects.conf"
  if [ ! -f "$OBJSFILE" ]; then
    if [ -f "$CONFFILE" ]; then
      #check if the entry is already there
      grep $OBJSFILE $CONFFILE >/dev/null
      if [ "$?" = 0 ]; then
        grep -v "$OBJSFILE" $CONFFILE >$CONFFILE.$$
        cp $CONFFILE.$$ $CONFFILE
        rm -f $CONFFILE.$$
      fi
    fi
  fi
fi


%clean
rm -fR $RPM_BUILD_ROOT
