#!/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 postremove script template for 11.X patches.                  #
#------------------------------------------------------------------#
# This file is optional for all 11.X patches.  The purpose of this #
# script is to perform any necessary cleanup actions after the     #
# patch's files have been removed.                                 #
#------------------------------------------------------------------#

_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


#
# Re-link the below commands with the pre-patch versions of /sbin/lvchange
# or /usr/sbin/lvchange
#

safelink() 
{
   rm -f $2
   ln $1 $2
}

typeset file=
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


#
# Remove formatted man pages cached in the usr/share/man/cat1m.Z
# directory. Note that the following list must be updated whenever
# a new LVM man page (not in this list) gets changed.
#
MAN_PAGE_LIST="lvchange.1m lvcreate.1m lvdisplay.1m lvextend.1m lvreduce.1m \
               pvcreate.1m pvremove.1m vgexport.1m vgreduce.1m \
	       vgchgid.1m vgcreate.1m vgextend.1m vgimport.1m vgscan.1m"

typeset cached_man_page=
for cached_man_page in $MAN_PAGE_LIST
do
	rm -f ${SW_ROOT_DIRECTORY}usr/share/man/cat1m.Z/$cached_man_page
done

#
# End inserted code
#

exit $exitval


