#!/bin/ksh
# IBM_PROLOG_BEGIN_TAG 
# This is an automatically generated prolog. 
#  
# bos720 src/bos/usr/sbin/projdata/projdata.sh 1.6 
#  
# Licensed Materials - Property of IBM 
#  
# Restricted Materials of IBM 
#  
# COPYRIGHT International Business Machines Corp. 2003,2008 
# All Rights Reserved 
#  
# US Government Users Restricted Rights - Use, duplication or 
# disclosure restricted by GSA ADP Schedule Contract with IBM Corp. 
#  
# IBM_PROLOG_END_TAG 

# static char sccsid[] = "@(#)99      1.6  src/bos/usr/sbin/projdata/projdata.sh, cmdaacct, bos720 11/18/08 23:43:25"

export PATH=/usr/bin:/usr/sbin:$PATH

SED=/usr/bin/sed
GREP=/usr/bin/grep
CUT=/usr/bin/cut
TR=/usr/bin/tr

echo "#ProjectName:ProjectNum:Aggregation:Dummy:Comments:UserName:Projects:GroupName:GrpProj:focus:"
if [ $1 ]
then
	if [ $1 = "useradd" ]
	then
        	echo ":::::$2::"
	elif [ $1 = "userchange" ]
	then
    	    echo ":::::`/usr/sbin/lsuser -a projects ALL | $SED s/"projects="//g | $TR ' ' ':'| $GREP $2`:"
	elif [ $1 = "grpadd" ]
	then
    	    echo ":::::::$2::"
	elif [ $1 = "grpchange" ]
	then
    	    echo ":::::::`/usr/sbin/lsgroup -a projects ALL | $SED s/"projects="//g | $TR ' ' ':'| $GREP $2`:"
	elif [ $1 = "focus" ]
	then
    	    focus=`/usr/bin/ls -l /etc/project/alter/.current | $CUT -d'>' -f2`
        	echo ":::::::::$focus:"
	elif [ $1 = "alt" ]
	then
		path=`/usr/bin/ls -l /etc/project/alter/.current | $CUT -d'>' -f2 | $CUT -d' ' -f2`
		if [ "$path" = "/etc/project" ]
		then
			path=$path/projdef
		else
			path=$path/.projdef
		fi
		$GREP "$2:" $path
	elif [ $1 = "path" ]
	then
    	    path=`/usr/bin/ls -l /etc/project/alter/.current | $CUT -d'>' -f2 | $CUT -d' ' -f2`/projdef
        	$GREP "$2:" $path
	else
    	    $GREP "$1:" /etc/project/projdef
	fi
fi
