#!/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
PATH=$PATH:/etc:/bin:/usr/ucb
export PATH
if [ ! -d SCO -a ! -d DELTA -a ! -d DG  -a ! -d SCO_EV ]; then
    RUNNER=`whoami`
    if [ ! -z "$RUNNER" ]; then
        if [ "$RUNNER" != "root" ]; then
            echo 'set_prot must be run as "root" or super user'
            exit 1
        fi
    else
        echo 'set_prot must be run as "root" or super user'
        exit 1
    fi
fi
set -x
cd source/interbase
chown root		\
	.		\
	bin examples examples/v3 examples/v4 examples/v5 help include intl lib \
	bin/*		\
	examples/v3/*	\
	examples/v4/*	\
	examples/v5/*	\
	help/*		\
	include/*	\
	intl/*		\
	lib/*		\
	inetd.conf.isc	\
	install		\
	interbase.msg	\
	isc4.gdb	\
	services.isc

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

chmod uog=rx install bin/*

chmod uog=r		\
	examples/v3/*	\
	examples/v4/*	\
	examples/v5/*	\
	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 examples/v5 \
	include intl lib

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

chmod u+s,g+s bin/gds_relay

chmod u+s,g+s bin/gds_wal_writer

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 isc_config ]; then
    chown root isc_config
    chgrp bin isc_config
    chmod uog=r	isc_config
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 README ]; then
    chown root README
    chgrp bin README
    chmod uog=r	README
fi

if [ -f bin/gds_dnet_server ]; then
    chmod u+s,g+s bin/gds_dnet_server
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 bin/gds_drop ]; then
    chmod u+s,g+s bin/gds_drop
fi

if [ -f bin/gds_drop5 ]; then
    chmod u+s,g+s bin/gds_drop5
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	\
	lib/gds.sl.0	\
	lib/gds.sl.1	\
	lib/gdsintl	\
	intl/gdsintl	\
	lib/bridge5
fi

if [ -f lib/gdslib ]; then
    chmod uog=rx	\
	lib/gdslib	\
	lib/pyxislib	\
	lib/gdsintl	\
	lib/bridge5
fi

if [ -f lib/ib_udf ]; then
    chmod uog=rx	\
	lib/ib_udf	\
	lib/ib_util.s*
fi

