#! /bin/sh
#
# $Id: poindmo.sh,v 1.6 1998/05/06 23:27:12 john Exp $ Copyright (c) 1996, Legato Systems, Inc.
#
# All rights reserved.
#

copyright()
{
COPYRIGHT="Copyright (c) 1990-1998, Legato Systems, Inc."
productname="BusinesSuite Module for Oracle"
RELEASE="2.1.2"

echo "          ${productname}(TM) - Release ${RELEASE}"
echo "${COPYRIGHT}  All rights reserved."
echo "This product includes software developed by the University of"
echo "California, Berkeley and its contributors."
echo ""
} # end copyright

installinit()
{

mypath="`expr X\"${0}\" : X'\(.*\)/.*' \| X\"${0}\" : X'\(/\)[^/]*$' \| 'X'`"
myname=`basename $0`

# NOTE: some systems put "Berkeley" utilities in /usr/ucb, others (e.g. SGI)
# put them in /usr/bsd.  Also, some systems use /usr/etc and other use
# /usr/sbin.  We include all variants in addition to the path to this
# program to be safe.
#
PATH=/usr/ucb:/usr/bsd:/bin:/usr/bin:/etc:/usr/etc:/usr/sbin:$mypath:$PATH
export PATH

if [ -f /bin/hostname ]; then
	host=`/bin/hostname`
elif [ -f /usr/ucb/hostname ]; then
	host=`/usr/ucb/hostname`
elif [ -f /usr/bsd/hostname ]; then
	host=`/usr/bsd/hostname`
elif [ -f /usr/local/bin/hostname ]; then
	host=`/usr/local/bin/hostname`
else
	host=
fi
if [ -r /bin/uname -o -r /usr/bin/uname ]; then
	uname=`uname`
	proc=`uname -p 2>&1`
	if [ "X${host}" = X ]; then
		host=`uname -n`
	fi
fi
if [ X${host} = X ]; then
	echo "no host name set - assuming loopback"
	hostname loopback
fi

# True if we have System V style /etc/rc*.d files
svrc=y
bsd_echo=true

fmt="fmt"

# save the args
ARGS="$*"

# find the binary type of /bin/sh
set X `file /bin/sh`
shift
# for some shells, the above 'set' results in 'X' being $0 and '/bin/sh:'
# in $1 so check for that and shift if it is true
if [ X"$1" = X/bin/sh: ]; then
	shift
fi
if [ X"$1" = Xsymbolic ]; then
	set X `file -L /bin/sh`
	shift
fi
bin_type="$1"
set X $ARGS
shift
} # end installinit

findarch()
{
#
# DEC's standard version of test doesn't know
# about -x option, so just use the -r option.
# note that we cannot use "elif", since this may be a BSD sh (news)!
#
if [ "X${proc}" = Xsparc ]; then
	# System V release 4 on SPARC, a.k.a. SunOS 5.0.x
	myarch=solaris
	default_bin=${BASEDIR}/sbin
	exdir=${BASEDIR}/sbin
	if [ -f /usr/ucb/echo ]; then
		bsd_echo=true
	else
		bsd_echo=false
	fi
else if [ "X${uname}" = XSunOS -a "X${proc}" = Xppc ]; then
	# System V release 4 on PPC, a.k.a. SunOS 5.x
	myarch=solppc
	default_bin=${BASEDIR}/sbin
	exdir=${BASEDIR}/sbin
	if [ -f /usr/ucb/echo ]; then
		bsd_echo=true
	else
		bsd_echo=false
	fi
else if [ "X${uname}" = XSunOS -a "X${proc}" = Xi386 ]; then
	# System V release 4 on i386, a.k.a. SunOS 5.0.x
	myarch=sol86
	default_bin=${BASEDIR}/sbin
	exdir=${BASEDIR}/sbin
	if [ -f /usr/ucb/echo ]; then
		bsd_echo=true
	else
		bsd_echo=false
	fi
else if [ "X${uname}" = XAIX ]; then
	myarch=aix6000
	bsd_echo=false
else if [ -r /usr/bin/arch ]; then
	myarch=`arch`
	default_bin=/usr/etc
	#
	# Since we explicitly set the PATH ourselves w/o the sys5 stuff,
	# we shouldn't get the sys5 echo behaviour from the shell.  We
	# don't use /bin/echo here because the sun386 /bin/echo will drop
	# lines after seeing a return within double quotes!
	#
	id="whoami"
else
	echo "ERROR: Cannot determine base machine type for \`${host}'."
	exit 1
fi	# aix
fi	# sun
fi	# sol86
fi	# solppc
fi	# solaris

# This is to allow installing with a default file generated by a form
# before obk_ize is run so that Compaq can use their front end to obk_ize.
if [ -x /tmp/default.cfg ]; then
. /tmp/default.cfg
fi
} # end findarch

setecho()
{
umask 22


if [ $bsd_echo = true ]; then
	echo_n()
	{

		echo -n "$*"
	}
else
	echo_n()
	{

		echo "$*\c"
	}
fi
} # end setecho

#
# explain function
#
# Print out a message explaining this program
#
explain()
{
echo " "
echo "***  Important Information for Completing your BMO Installation  ***"
echo "---------------------------------------------------------------------"
echo " "
echo "For Oracle7 Installations"
echo "The library libobk.so has been installed in /usr/lib."
echo "When you install the Oracle7 Enterprise Backup Utility you may"
echo "be prompted by the Oracle Installer to enter this location."
echo " "
echo "Oracle7 users will need to set the \$ORACLE_HOME variable in"
echo "the nsrdmo script"
echo " "
echo "---------------------------------------------------------------------"
echo " "
echo "For Oracle8 Installations"
echo "The library libobk.so has been installed in /usr/lib."
echo "you will now need to re-link the Oracle8 server in order to"
echo "use the BusinesSuite Module for Oracle"
echo " "
echo "As the oracle owner, you will need to shut down all oracle instances"
echo "and then run the following commands:"
echo " "
echo "cd \$ORACLE_HOME/rdbms/lib"
echo "make -f ins_rdbms.mk ioracle LLIBMM=/usr/lib/libobk.so"
echo " "
echo "or if you are running Oracle 8.0.4:"
echo " "
echo "make -f ins_rdbms.mk ioracle LLIBOBK=/usr/lib/libobk.so"
echo " "
echo "Oracle8 users upgrading from Legato Storage Manager will need"
echo "to remove the \$ORACLE_HOME/lib/libobk.so file before re-linking."
echo " "
echo "---------------------------------------------------------------------"
echo " "
}

#
# qecho
#	quite echo: if the qflag is no, then echo all arguments,
#	otherwise don't.
#
qecho()
{
	if [ ${qflag} = n ]; then
		echo "$*" | ${fmt}
	fi
}

#
# This creates the nsr/applogs directory
buildindexdirs()
{
	nsrhome=/nsr
	if [ ! -d ${nsrhome}/applogs ]; then
		mkdir ${nsrhome}/applogs
	fi
	chmod 777 ${nsrhome}/applogs
}

requestmain()
{
buildindexdirs
explain
}
#
# This will drive the request script for a pkgadd DMO package.
#
# Rules:
# 1) There should be mostly calls to shell functions that exist in
#    other install remove shell function files.
# 2) The shell functions called from this file can store shell
#    variables in ${DMOREQUEST} for use during other install phases.
#
DMOREQUEST=${DMOREQUEST-/tmp/dmorequest}
rm -f ${DMOREQUEST}

installinit $*

op=install
pflag=y
skip_execs=true

copyright
findarch
setecho
requestmain
