#!/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 unset the protections on files in
# the installation directory
PATH=$PATH:/etc:/bin:/usr/ucb
export PATH
if [ $# != 1 ]; then
    echo 'Usage: unset_prot {user}'
    exit 1
fi
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 'unset_prot must be run as "root" or super user'
            exit 1
        fi
    else
        echo 'unset_prot must be run as "root" or super user'
        exit 1
    fi
fi
set -x
cd source/interbase
chown $1		\
	.		\
	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 gds		\
	.		\
	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 ug=rwx install bin/* lib/* intl/*

chmod ug=rw	\
	examples/v3/*	\
	examples/v4/*	\
	examples/v5/*	\
	help/*		\
	include/*	\
	inetd.conf.isc	\
	interbase.msg	\
	services.isc

chmod ug=rwx bin examples examples/v3 examples/v4 examples/v5 include intl lib

chown root bin/gds_relay
chmod u+s,g+s bin/gds_relay

chown root bin/gds_wal_writer
chmod u+s,g+s bin/gds_wal_writer

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

if [ -f bin/inet_dbg ]; then
    chown root bin/inet_dbg
    chmod u+s,g+s bin/inet_dbg
fi

if [ -f isc_ins.hlp ]; then
    chown $1 isc_ins.hlp
    chgrp gds isc_ins.hlp
    chmod ug=rw isc_ins.hlp
else
    chown $1 isc_ins_hlp.dat
    chgrp gds isc_ins_hlp.dat
    chmod ug=rw isc_ins_hlp.dat
fi

if [ -f isc_config ]; then
    chown $1 isc_config
    chgrp gds isc_config
    chmod ug=rw isc_config
fi

if [ -f lock_header_t ]; then
    chown $1 lock_header_t
    chgrp gds lock_header_t
    chmod ug=rw lock_header_t
else
    chown $1 lock_header_template
    chgrp gds lock_header_template
    chmod ug=rw lock_header_template
fi

if [ -f servers.isc ]; then
    chown $1 servers.isc
    chgrp gds servers.isc
    chmod ug=rw servers.isc
fi

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

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

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

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

if [ -f bin/gds_drop5 ]; then
    chown root bin/gds_drop5
    chmod u+s,g+s bin/gds_drop5
fi

if [ -f lib/gdslib ]; then
    chmod +w		\
	*		\
	com/*		\
	examples/*	\
	include/*	\
	intl/*		\
	lib/*
fi
