#!/bin/sh
# 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): ______________________________________.
# Shell script to set the protections on files in
# the installation directory and copy stuff over from ../interbase
# Also deletes extra .gdb, core and .gbl files and removes the COFF comment
# section from executables.
# stripping executables is commented out.

RUNNER=`who am i`
set $RUNNER
if [ "$1" != "root" ]; then
    echo 'copy_set_prot must be run as "root" or super user'
    exit 1
fi
PATH=$PATH:/etc:/bin:.
export PATH
set -x
copy -romv ../interbase source/usr/interbase
find . \( -name \*.gbl -o -name core -o -name isc_event1 \) -print | xargs rm
rm -f interbase/install interbase/lock_header interbase/interbase.log
rm -f interbase/isc_lic.dat
mcs -d source/usr/interbase/bin/*
mcs -a "Interbase version V4.0A built `date`" source/usr/interbase/bin/*
#strip source/usr/interbase/bin/*
cd source/usr/interbase
chown root		\
	.		\
	bin examples help include intl lib	\
	bin/*		\
	examples/*	\
	examples/*/*	\
	help/*		\
	include/*	\
	intl/*		\
	lib/*		\
	inetd.conf.isc	\
	install		\
	interbase.msg	\
	isc4.gdb	\
	services.isc

chgrp bin		\
	.		\
	bin examples help include intl lib	\
	bin/*		\
	examples/*	\
	examples/*/*	\
	help/*		\
	include/*	\
	intl/*		\
	lib/*		\
	inetd.conf.isc	\
	install		\
	interbase.msg	\
	isc4.gdb	\
	services.isc

chmod uog=rx install bin/*

chmod uog=r		\
	examples/*/*	\
	help/*		\
	include/*	\
	intl/*		\
	lib/*		\
	inetd.conf.isc	\
	interbase.msg	\
	services.isc

chmod uog=rwx . help

chmod u=rwx,go=rx bin examples examples/v3 examples/v4 include intl lib

chmod uog=rw isc4.gdb help/help.gdb examples/*/*.gdb

chmod u+s,g+s	\
	bin/gds_relay

if [ -f bin/gds_inet_srvr ]
then
    chmod u+s,g+s	\
	bin/gds_inet_srvr
else
    chmod u+s,g+s	\
	bin/gds_inet_server
fi

if [ -f isc_ins.hlp ]; then
    chown root	\
        isc_ins.hlp
    chgrp bin		\
        isc_ins.hlp
    chmod uog=r		\
        isc_ins.hlp
else
    chown root	\
	isc_ins_hlp.dat
    chgrp bin		\
	isc_ins_hlp.dat
    chmod uog=r		\
	isc_ins_hlp.dat
fi

if [ -f lock_header_t ]; then
    chown root	\
        lock_header_t
    chgrp bin		\
        lock_header_t
    chmod uog=r		\
        lock_header_t
else
    chown root	\
	lock_header_template
    chgrp bin		\
	lock_header_template
    chmod uog=r		\
	lock_header_template
fi

if [ -f servers.isc ]; then
    chown root	\
        servers.isc
    chgrp bin		\
        servers.isc
    chmod uog=r		\
        servers.isc
fi

if [ -f bin/gds_dnet_server ]; then
    chmod u+s,g+s	\
        bin/gds_dnet_server
fi

if [ -f bin/gds_drop ]; then
    chmod u+s,g+s	\
	bin/gds_drop
fi

if [ -f bin/gds_lock_mgr ]; then
    chmod u+s,g+s	\
        bin/gds_lock_mgr
fi

if [ -f bin/gds_lock_manager ]; then
    chmod u+s,g+s	\
	bin/gds_lock_manager
fi

if [ -f lib/gds_s.a ]; then
    chmod uog=rx	\
	lib/gds_s	\
	lib/gdsf_s
fi

if [ -f lib/gds.sl ]; then
    chmod uog=rx	\
	lib/gds.sl
fi

if [ -f lib/gdslib ]; then
    chmod uog=rx	\
	lib/gdslib	\
	lib/dsqllib	\
	lib/pyxislib	\
	lib/bridge
fi
rm -f isc_lic.dat interbase.log lock_header install isc_event1
rm -f isc_lock1.gbl
cd ../../..
docut -c -i
