#/bin/sh
#set -xv
: ${G1PROD:?} ${G1PRODPATH:?}
#
# Database Install routine for Pitney Bowes Software's GeoTAX - UNIX
# Pitney Bowes Software, Inc.
# (c) Copyright, 1997-2014
#
# This is the install database routine for GeoTAX.
# It will use the media information that is in the
# $G1PRODPATH/bin/gtxdbmenu script,
# $G1PRODPATH/bin/setmedia script, and the environment information from the
# $G1PRODPATH/bin/setup script, and the individual database script.
# 
# IMPORTANT NOTES FOR DATABASE INSTALL:
# =====================================
#	1) The setmedia and the setup scripts found in $G1PROD/bin
#	   may need to be modified for your system.  The database install
#	   process needs to know what media device the input data is mounted
#	   on, what the device names are, and file location where the database 
#          will reside.
#
#       2) If you need to change the default directory for a product's
#          database files, modify the information for individual product's
#          database load which is kept in the /usr/g1/xxx/bin/setxxxdb script.
#		where xxx = product code (e.g.: gtx)
#	   This will allow you to place different product databases into 
#	   different areas, or you may choose to put them together in one
#          location (default).
#
#       3) Info that needs to be set up in the setmedia script for installing:
# 	   - Which type of media for product and database install?
# 	   - Name of CDROM (mounted as ISO 9660 device)
#
#       4) Info that needs to be set up in the product setup file:
#	   - Location to put db file(s): $G1XXXDB
#               central area (default is $G1XXXDB) or local to product
#                       where XXX is the product code
#
# 
#================================
#
# Function to clear the screen. Try the clear shell command
# first, then try the tput command with a clear parameter and then
# try to clear each position (line) of the screen the hard way.
#
Clearit()
{
{ clear; } 2>/dev/null  ||
        { tput clear; } 2>/dev/null  ||
                { for i in \
                p01 p02 p03 p04 p05 p06 p07 p08 p09 p10   \
                p11 p12 p13 p14 p15 p16 p17 p18 p19 p20   \
                p21 p22 p23 p24 p25 p26 p27 p28 p29 p30   \
                p31 p32 p33 p34 p35 p36 p37 p38 p39 p40
                do
                        echo ""
                done
                }
}

#================================================================
# Startup routine
#================================================================
# Use to source setup
Clearit;
if [ -f $G1PRODPATH/bin/setup ]
then	
	. $G1PRODPATH/bin/setup
  elif
	[ -f ./setup ]
	then
		. ./setup
	else
		echo ""	
	        echo "\tWarning. setup not found."
		echo "\tPlease execute the installdb script from the"
		echo "\tGroup 1 product's bin area.\n"
                echo "\tInstallation canceled.\n"
                exit 1
fi

if [ -f $G1PRODPATH/bin/setmedia ]
then
	. $G1PRODPATH/bin/setmedia
  elif
	[ -f ./setmedia ]
	then
		. ./setmedia
	else
		echo ""	
	        echo "\tWarning. setmedia not found."
		echo "\tPlease execute the installdb script from the"
		echo "\tGroup 1 product's bin area.\n"
                echo "\tInstallation canceled.\n"
                exit 1
fi

$G1ECHO "======================================================================"
$G1ECHO "\n"
$G1ECHO "\t\t-- ${G1PRODNAME} Database Installation --"
$G1ECHO "\n"

#
# Display environment variables
#

$G1ECHO "\tThe environment for Database Installation is currently set to: "
$G1ECHO "\n"
$G1ECHO "\tDistribution type:	" $G1DBDIST
$G1ECHO "\tMounted CD directory:	" $G1CDDIR

$G1ECHO
$G1ECHO "\tPress enter to continue. \c"
read xxx

#==================================================================
# Main procedure starts here
#==================================================================
Clearit;
${G1PRODPATH}/bin/${G1PROD}dbmenu
