#!/bin/sh
#
#bcpyrght
#***************************************************************************
#* $VRTScprght: Copyright 1993 - 2005 VERITAS Software Corporation, All Rights Reserved $ 
#***************************************************************************
#ecpyrght
# 

#$Id: nonroot_admin_nbjava.sh,v 1.7 2005/03/31 07:00:14 $

# Script for setting permissions on files in /usr/openv/java for allowing
# nonroot administration of NB.
#
# This script has one argument - the name of a file system group.
# 
# This script should be rerun if any patch is installed that replaces
# any file in /usr/openv/java.
#
# This script must be run from the root account.
# This script does not check for a valid file system group name.
#
# It is only necessary to run this script if you want some nonroot users
# to be able to change the following NBJava GUI only files.
# /usr/openv/java/auth.conf
# /usr/openv/java/Debug.properties
# /usr/openv/java/nbj.conf 
#
# It is not necessary to run this script to set up nonroot administrators 
# for the NBJava GUI Capabilities Authorization.  Only updates to the 
# auth.conf file are necessary.  However, this file is owned and writeable 
# only by root.
#
##

PATH=/bin:/usr/bin:/usr/ucb:$PATH; export PATH

OS=`uname -s`
if [ "$OS" = "Linux" ]
then
	unset POSIXLY_CORRECT
	ECHO="/bin/echo -e"
else
	ECHO="/usr/bin/echo"
fi

$ECHO "\nOptions:"
$ECHO "\n  1. Change group ownership and permissions on nbj.conf, auth.conf"
$ECHO "     and Debug.properties."
$ECHO "  2. Revert the group ownership and permissions of the above files to"
$ECHO "     their original values."
$ECHO "\nSpecify one of the above options (1/2): \c"
read option

case $option in
   1) ;;
   2) ;;
   *)
      $ECHO "\n\t>>> You have provided an invalid option."
      $ECHO "\t>>> Please rerun this script and try again.\n"
      exit 1 ;;
esac

FILES="Debug.properties auth.conf nbj.conf"

cd /usr/openv/java
if [ "${option}" = "1" ]
then
	$ECHO "\nEnter privileged group name for the nonroot users: \c"
	read grp_name
	chgrp $grp_name ${FILES}
	chmod 664 ${FILES}
else
	chgrp bin ${FILES}
	chmod 644 ${FILES}
fi

# The end ...
