#!/bin/sh
#
# Component Name: TivoliPlus
#
# $Source: /tivoli/development/src/2.0/plus/Link/src/wcrtsol,v $
#
# $Revision: 1.3 $
#
# Description:
#
# (C) COPYRIGHT Tivoli Systems, Inc. 1995-2000
# Unpublished Work
# All Rights Reserved
# Licensed Material - Property of Tivoli Systems, Inc.
#


#This script will create the policy region and collection for a new solution
#product

[ "$DEBUG" = true ] && set -xv

THIS_CMD=`echo $0 | tr "\\\\\\\\" "/"`; THIS_CMD=`basename $THIS_CMD`
USAGE=`wbindmsg LinkCmdCat 13 "Usage: %1\\$s solution-name state-name bitmap [ icondsl ]" "$THIS_CMD" 2> /dev/null`
if [ ! "$USAGE" ]; then
	USAGE="Usage: $THIS_CMD solution-name state-name bitmap [ icondsl ]"
fi

if [ $# -lt 3 ] ; then
	echo $USAGE
	exit 1
fi


#
#	Set up environment (similar to old /etc/Tivoli/setup_env.sh)
#
OSERV=`objcall 0.0.0 get_oserv`; export OSERV
INST_DIR=`objcall $OSERV query install_dir | tr "\\\\\\\\" "/"`; export INST_DIR
INTERP=`objcall $OSERV query interp`; export INTERP
BINDIR=$INST_DIR/$INTERP; export BINDIR
PLUSDIR=$INST_DIR/generic_unix/TME/PLUS
LINKDIR=$PLUSDIR/LINK; export LINKDIR
DBDIR=`objcall $OSERV query db_dir | tr "\\\\\\\\" "/"`; export DBDIR
TEMP=/tmp; export TEMP
if [ x"$OS" = x"Windows_NT" ]; then
	TEMP=$DBDIR/tmp
fi
if [ ! -d $TEMP ]; then
	$LINKDIR/mkdir.sh $TEMP
fi
PATH=$LINKDIR:$PATH; export PATH


NAME=$1
STATE=$2
BITMAP=$3
ICONDSL=$4
#Determine the name of the top level PolicyRegion to use
if [ x"$TOP_PR_TO_USE" = x ] ; then
	TIVOLI_SOLUTIONS="TivoliPlus"
else
	TIVOLI_SOLUTIONS="$TOP_PR_TO_USE"
fi

if [ ! "$WINSTRUCTED" = true ]; then
  #Create Policy Region for this module
  wcrtspr "$NAME"
fi

# If a override was not specified dump GenericCollection dialog file
if [ -n "$ICONDSL" ]; then
	ICONDLG=$ICONDSL
else
	ICONDLG=$TEMP/dialog.d
	wgetdialog -I normal -r GenericCollection > $ICONDLG
fi

#Add a state to Generic Collection for this Solution
waddstate GenericCollection "$STATE" $ICONDLG "$BITMAP"

# Only delete this if it's the temporary dialog from the generic collection
if [ -z "$ICONDSL" ]; then
	rm $ICONDLG
fi

#Create Solutions Collection
wcrtscoll "$NAME" "$TIVOLI_SOLUTIONS" "$STATE"

exit 0
 
