#!/bin/sh
#
#***************************************************************************
#* $VRTScprght: Copyright 1993 - 2004 VERITAS Software Corporation, All Rights Reserved $ *
#***************************************************************************
#
# postpatch script

## Automatically update the Server's client OS binaries
OS_LEVEL=`uname -r | /bin/cut -c3` # Get the Marketing version
if [ -r /usr/openv/netbackup/client/Solaris/Solaris$OS_LEVEL ] ;then
	cd /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 attempt failed, retry manually"
fi

## 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=/usr/openv/java

if [ ! -f /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 /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 /usr/openv/NB-Java.tar.pre50_1_M.Z"
/bin/mv /usr/openv/NB-Java.tar.Z /usr/openv/NB-Java.tar.pre50_1_M.Z

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

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

/bin/echo " In order to update any NetBackup Java Clients, run:"
/bin/echo "  /usr/openv/netbackup/bin/update_clients -Install_Java"

exit 0
