#!/sbin/sh
#------------------------------------------------------------------#
#
# HPUX_ID: @(#) $Revision: 17.3 $ generated on Mon Jun 25 13:50:05 PDT 2001
#
# (c)Copyright 1983-2001 Hewlett-Packard Co.,  All Rights Reserved.
#
#------------------------------------------------------------------#
# SD postinstall script template for 11.X patches.                 #
#------------------------------------------------------------------#
# This file is optional for all 11.X patches.  The purpose of this #
# script is to prepare for a kernel build when required by the     #
# install conditions.  The script can also drive events that must  #
# occur before a system reboot occurs.                             #
#------------------------------------------------------------------#

_PATCHID=PHCO_24437


UTILS="/usr/lbin/sw/control_utils"

if [ ! -f $UTILS ]; then
    echo "ERROR:   Cannot find $UTILS"
    exit 1
fi

. $UTILS
exitval=$SUCCESS

#####
##### Insert any code you may require at this point in the script.
##### Pay attention to the exitval variable and set appropriately
##### in your code.  If you are unsure as to what types of operations
##### are legal in this file and what types aren't, consult the 
##### "Guidelines for SD Control Scripts" document.
#####
##### START_CUSTOMIZATION_HERE


#
# Check if LVM-MIRROR-RUN is installed on the system.
#
typeset MIRROR=

if swlist $remote_opt -lfileset LVM.LVM-MIRROR-RUN @ ${SW_ROOT_DIRECTORY} \
       2>/dev/null | grep -q LVM-MIRROR-RUN ; then
   MIRROR=1;
else
   MIRROR=0;
fi

#
# IF LVM-MIRROR-RUN is installed on the customer's system, they
# should get the mirror files.  In either case, remove them from
# /usr/newconfig, and call swmodify to update the IPD for /sbin/lvchange
# and /usr/sbin/lvchange
#

if (( MIRROR == 1 )) ; then
   cp ${SW_ROOT_DIRECTORY}usr/newconfig/sbin/lvchange.mir \
	   ${SW_ROOT_DIRECTORY}sbin/lvchange
   cp ${SW_ROOT_DIRECTORY}usr/newconfig/usr/sbin/lvchange.mir \
	   ${SW_ROOT_DIRECTORY}usr/sbin/lvchange

   chmog 4555 root sys ${SW_ROOT_DIRECTORY}sbin/lvchange
   chmog 4555 root sys ${SW_ROOT_DIRECTORY}usr/sbin/lvchange

   swmodify $remote_opt -xfiles='/sbin/lvchange /usr/sbin/lvchange' LVM.LVM-RUN @ $SW_ROOT_DIRECTORY


fi


#
# Re-Link associated lvm commands
#
safelink()
{
     rm -f $2
     ln $1 $2
}

while read file ; do
	if [ -f ${SW_ROOT_DIRECTORY}sbin/lvchange ] ; then
		safelink ${SW_ROOT_DIRECTORY}sbin/lvchange \
					${SW_ROOT_DIRECTORY}$file
        fi
	if [ -f ${SW_ROOT_DIRECTORY}usr/sbin/lvchange ]; then
		safelink ${SW_ROOT_DIRECTORY}usr/sbin/lvchange \
					 ${SW_ROOT_DIRECTORY}usr/$file
        fi

done <<- EOF
        sbin/lvcreate
	sbin/lvmerge
	sbin/lvsplit
	sbin/lvsync
	sbin/vgsync
	sbin/nomwcsyncd
	sbin/lvdisplay
	sbin/lvextend
	sbin/lvlnboot
	sbin/lvreduce
	sbin/lvremove
	sbin/lvrmboot
	sbin/pvck
	sbin/pvchange
	sbin/pvcreate
	sbin/pvremove
	sbin/pvdisplay
	sbin/pvmove
	sbin/vgcfgbackup
	sbin/vgcfgrestore
	sbin/vgchange
	sbin/vgchgid
	sbin/vgcreate
	sbin/vgdisplay
	sbin/vgexport
	sbin/vgextend
	sbin/vgimport
	sbin/vgreduce
	sbin/vgremove
	sbin/vgscan
EOF

if (( MIRROR == 0 )) ; then
   while read file ; do
      if [ -f ${SW_ROOT_DIRECTORY}$file ] ; then
	 rm -f ${SW_ROOT_DIRECTORY}$file

      fi
      if [ -f ${SW_ROOT_DIRECTORY}usr/$file ] ; then
	 rm -f ${SW_ROOT_DIRECTORY}usr/$file
      fi
   done <<-EOF
	sbin/lvmerge
	sbin/lvsplit
	sbin/lvsync
	sbin/vgsync
	sbin/nomwcsyncd
EOF
fi

#
# End inserted code.
#


exit $exitval

