# The contents of this file are subject to the Interbase Public
# License Version 1.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy
# of the License at http://www.Inprise.com/IPL.html
#
# Software distributed under the License is distributed on an
# "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
# or implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code was created by Inprise Corporation
# and its predecessors. Portions created by Inprise Corporation are
# Copyright (C) Inprise Corporation.
#
# All Rights Reserved.
# Contributor(s): ______________________________________.
#! /bin/sh
#
# /usr/interbase/install	-- Install InterBase
#
cd interbase
CD=`pwd`
if [ -f /usr/interbase ]; then
    echo /usr/interbase is not a directory 
    echo InterBase installation failed 
    exit 1
fi
if [ -d /usr/interbase ] ; then
    cd /usr/interbase
    TARGET=`pwd`
    if [ $CD != $TARGET ]; then
	echo invalid installation directory $CD 
	echo InterBase installation failed 
	exit 1 
    fi
fi
#
# run our set_prot script, since the
# DELTA box doesn't seem able to carry permissions
# across the tar process
#
cd ..
chmod uog=xrw interbase
chown root interbase
chgrp bin interbase
cd interbase
chown root install	
chgrp bin  install
chmod uog=rx install
chown root		\
	bin examples help include lib	\
	bin/*		\
	examples/*	\
	help/*		\
	include/*	\
	lib/*		\
	services.isc	\
	inetd.conf.isc	\
        interbase.msg	\
	isc_ins.hlp	\
	isc_lic.dat     \
	lock_header_t

chgrp bin		\
	bin examples help include lib	\
	bin/*		\
	examples/*	\
	help/*		\
	include/*	\
	lib/*		\
	services.isc	\
	inetd.conf.isc	\
        interbase.msg	\
	isc_ins.hlp	\
	isc_lic.dat     \
	lock_header_t

chmod uog=rx bin/*

chmod uog=r		\
	examples/*	\
	help/help.gbak	\
	help/help.gdb	\
	include/*	\
	lib/*		\
	services.isc	\
	inetd.conf.isc	\
        interbase.msg	\
	isc_ins.hlp	\
	lock_header_t

chmod u=rw,go=r isc_lic.dat

chmod u=xrw,go=rx help examples bin include lib
chmod u+s,g+s bin/gds_inet_srvr	\
	bin/gds_relay \
	bin/gds_drop
set -x
#
# Move standard include file to /usr/include
#
cp /usr/interbase/include/gds.h /usr/include/gds.h
cp /usr/interbase/include/perf.h /usr/include/perf.h
cp /usr/interbase/include/ibase.h /usr/include/ibase.h
# 
# Move pipe and full libraries to /lib/386 and re-initialize table of contents
#
cp /usr/interbase/lib/gds.a /usr/lib/libgds.a
if [ -f /usr/interbase/lib/gds_b.a ]; then
    cp /usr/interbase/lib/gds_b.a /usr/lib/libgds_b.a
fi
cp /usr/interbase/lib/gds_pipe.a /usr/lib/gds_pipe.a
cp /usr/interbase/lib/gds_inet_svr.a /usr/lib/gds_inet_svr.a
#
# Protect examples and QLI help database
#
chmod uog=rw isc.gdb
chmod uog=rw help/help.gdb
chmod uog=rw examples/v3/atlas.gdb
chmod uog=rw examples/v3/emp.gdb
chmod uog=rw examples/v4/employee.gdb
#
# If TCP is installed, update both services and servers databases
#
if [ -f /etc/services ] ; then
    grep -s gds_db /etc/services  
    if test $? != 0 ; then
        cat /etc/services services.isc > services
	mv services /etc/services
	chmod u=rw,go=r /etc/services
    fi
fi
if [ -f /etc/inetd.conf ] ; then
    grep -s gds_db /etc/inetd.conf  
    if test $? != 0 ; then
        cat /etc/inetd.conf inetd.conf.isc > inetd.conf
	mv inetd.conf /etc/inetd.conf
	chmod u=rw,go=r /etc/inetd.conf
    fi
fi
