#!/bin/sh

# Make sure ORACLE_HOME is set
case $ORACLE_HOME in
  "") echo "ORACLE_HOME is not set."
      echo "Set and export ORACLE environment variables, then restart configure.sh execution."
      exit 1 ;;
esac

# Get Talkserver database IP
DEFLT="localhost";
echo -n "Enter Talkserver database IP address? [${DEFLT}]: $C"
read RD_TSDB
case $RD_TSDB in
  "") RD_TSDB=$DEFLT
esac

# Get Talkserver database instance name
DEFLT="ORCL";
echo -n "Enter Talkserver database instance name [${DEFLT}]: $C"
read RD_TSDBNAME	
case $RD_TSDBNAME in
  "") RD_TSDBNAME=$DEFLT
esac

# Set talkserver database ip address & instance name
ed /etc/talkserver.conf <<%
g/<database_ip_address>/s//$RD_TSDB/g
g/<database_instance_name>/s//$RD_TSDBNAME/g
w
%

# Set oracle vars for talkserver cron
rm -f /opt/hearme/talkserver/.oracle
env|grep ORACLE_HOME > /opt/hearme/talkserver/.oracle
echo "LD_LIBRARY_PATH=$ORACLE_HOME/lib" >> /opt/hearme/talkserver/.oracle
echo "ORACLE_SID=$RD_TSDBNAME" >> /opt/hearme/talkserver/.oracle
echo "export ORACLE_HOME LD_LIBRARY_PATH ORACLE_SID" >> /opt/hearme/talkserver/.oracle

# Install cron RPMs
rpm -Uvh --force cron_support/perl-DateManip-5.34-2.i386.rpm
rpm -Uvh --force cron_support/perl-DBI-1.13-2.i386.rpm
rpm -Uvh --force --nodeps cron_support/perl-DBD-Oracle-1.03-1.i386.rpm

echo "Talkserver installation complete."

