#!/bin/sh
#
## NetBackup Sun postpatch script
# $Revision:1.1$
#***************************************************************************
#* $Copyright: Copyright 1993 - 2005 VERITAS Software Corporation, All Rights Reserved $ *
#***************************************************************************
#

#####################################################################
## Server Side driver update, from cp_update_to_client
if [ -x $PKG_INSTALL_ROOT/usr/openv/volmgr/bin/driver/sg.install ] ; then
	$PKG_INSTALL_ROOT/usr/openv/volmgr/bin/driver/sg.install
else 
	/bin/echo "
 Problem with installation of NetBackup binaries.
 $PKG_INSTALL_ROOT/usr/openv/volmgr/bin/driver/sg.install is missing or not executable.
 Rerun $PKG_INSTALL_ROOT/usr/openv/volmgr/bin/driver/sg.install when the problem has been resolved."
fi


#####################################################################
## Logic from Update_NB-Java.sh ##
## Used to update NetBackup Java file NB-Java.tar.Z
## After the NB-Java.tar.Z file is updated clients can be updated.

TMPDIR=${TMPDIR:-/tmp}
JAVA_DIR=$PKG_INSTALL_ROOT/usr/openv/java

if [ ! -f $PKG_INSTALL_ROOT/usr/openv/NB-Java.tar.Z ] ; then
	/bin/echo "
Cannot update the NB-Java.tar.Z file.  Updates to NB-Java GUI 
on client machines must be installed directly from the patch."
	exit 1
fi

mkdir ${TMPDIR}/Nb-JaVa.TaR.$$
cd ${TMPDIR}/Nb-JaVa.TaR.$$
/bin/echo "
Collecting old NB-Java contents."
zcat $PKG_INSTALL_ROOT/usr/openv/NB-Java.tar.Z | /bin/tar xf -
/bin/rm -f java/allNB.jar java/allJBP.jar java/nbCommon.jar java/dbext.jar 
/bin/rm -f java/.nbjConf

/bin/cp ${JAVA_DIR}/allNB.jar java/allNB.jar
/bin/cp ${JAVA_DIR}/allJBP.jar java/allJBP.jar
/bin/cp ${JAVA_DIR}/nbCommon.jar java/nbCommon.jar
/bin/cp ${JAVA_DIR}/dbext.jar java/dbext.jar
/bin/cp ${JAVA_DIR}/.nbjConf java/.nbjConf
if [ -f ${JAVA_DIR}/nbjP.jar ]; then
	/bin/cp ${JAVA_DIR}/nbjP.jar java/nbjP.jar
fi

cd ${TMPDIR}/Nb-JaVa.TaR.$$

/bin/tar cf ${TMPDIR}/Nb-JaVa.TaR .
/bin/echo "
Compressing new NB-Java.tar file."
compress -vf ${TMPDIR}/Nb-JaVa.TaR

/bin/echo "
Saving old NB-Java contents as $PKG_INSTALL_ROOT/usr/openv/NB-Java.tar.pre51_3AS0949_M.Z"
/bin/mv $PKG_INSTALL_ROOT/usr/openv/NB-Java.tar.Z $PKG_INSTALL_ROOT/usr/openv/NB-Java.tar.pre51_3AS0949_M.Z

/bin/echo "
Moving New $PKG_INSTALL_ROOT/usr/openv/NB-Java.tar.Z file into place."
/bin/mv ${TMPDIR}/Nb-JaVa.TaR.Z $PKG_INSTALL_ROOT/usr/openv/NB-Java.tar.Z

cd ${TMPDIR}
/bin/rm -rf ${TMPDIR}/Nb-JaVa.TaR.$$

##############################################################
## Automatically update the Server's client HWOS binaries
##  simple call to 'cp_to_client -CopyOnly' instead of whole cp_update_to_client
OS_LEVEL=`uname -r | /bin/cut -d"." -f2` # Get the Marketing version
if [ -r $PKG_INSTALL_ROOT/usr/openv/netbackup/bin/goodies/new_clients ] ;then
	$PKG_INSTALL_ROOT/usr/openv/netbackup/bin/goodies/new_clients
	if [ -r $PKG_INSTALL_ROOT/usr/openv/netbackup/client/Solaris/Solaris$OS_LEVEL ] ;then
		cd $PKG_INSTALL_ROOT/usr/openv/netbackup/client/Solaris/Solaris$OS_LEVEL
		./cp_to_client -CopyOnly
	else
		/bin/echo "Solaris OS level $OS_LEVEL, not supported"
		/bin/echo "cp_to_client -CopyOnly attempt failed, retry manually"
	fi
else
	/bin/echo "$PKG_INSTALL_ROOT/usr/openv/netbackup/bin/goodies/new_clients is missing or
not executable. Rerun when fixed, then run 'cp_to_client -CopyOnly' from:
$PKG_INSTALL_ROOT/usr/openv/netbackup/client/Solaris/Solaris$OS_LEVEL"
fi

##############################################################
## New for Solaris 10 from cp_update_to_client
if [ "${OS_LEVEL}" -ge "10" ] ; then
		inetd=`/bin/ps -ef|grep inetd|grep -v grep|grep -v osinetd|awk '{print $2}'`
		if [ "${inetd}" != "" ]; then
			/bin/echo "
Running inetconv to convert and import NetBackup inetd.conf records."
                	rm -f /tmp/sol_inetd_conf.$$
                	grep '^bpcd' /etc/inetd.conf >> /tmp/sol_inetd_conf.$$
                	grep '^vnetd' /etc/inetd.conf >> /tmp/sol_inetd_conf.$$
                	grep '^vopied' /etc/inetd.conf >> /tmp/sol_inetd_conf.$$
                	grep '^bpjava-msvc' /etc/inetd.conf >> /tmp/sol_inetd_conf.$$
			inetconv -f -i /tmp/sol_inetd_conf.$$ > /dev/null 2>&1
			rm -f /tmp/sol_inetd_conf.$$
		fi
fi

exit 0
