#!/sbin/sh
#
# Copyright (c) 1998 by Sun Microsystems, Inc.
# All rights reserved.
#


##############################################################################
# Set up the full package name to our main application class
VIPER_CONSOLE=/usr/sadm/bin/smc


##############################################################################
# Set up path to the java jre
if [ "$JAVA_HOME" = "" ]; then
	JAVA_HOME=/usr/java
	export JAVA_HOME
fi
JAVABIN=$JAVA_HOME/bin/java
if [ ! -f $JAVABIN ]; then
	echo "No Java home directory has been set"
	exit 1
fi


##############################################################################
#
#	The tool we want is the OsServerMgrCli tool.  This tool performs
# several tasks:  A(Add) M(Modify) X(Delete) V(View all objects or kust the 
# properties of one) 
#
TOOL=com.sun.admin.osservermgr.cli.OsServerMgrCli

SERVICETYPE="Wbem"

#DEBUGGING=ON
DEBUGGING=OFF


case $1 in
   ls) TASK=OV ;;
   list) TASK=OV ;;
   del) TASK=OX ;;
   delete) TASK=OX ;;
   add) TASK=OA ;;
   patch) TASK=P ;;

   *) MSG=`/usr/bin/gettext "Please specify one of the following operations:  list, delete, add, or patch"`
      /usr/bin/printf "${MSG}\n"
      exit 1 ;;
esac
shift


if [ $# -eq 0 ]
then
	${VIPER_CONSOLE} open -t \
		-J-Dosservermgr.Debugging=${DEBUGGING} \
		-T ${TOOL} "$@" -- -K ${TASK}
else
	HASOPTS=false
	export HASOPTS
	for i in $@
	do
		if [ " $i" = " --" ]
		then
			HASOPTS=true
			break
		fi
	done
	if [ $HASOPTS = "true" ]
	then
		${VIPER_CONSOLE} open -t \
			-J-Dosservermgr.Debugging=${DEBUGGING} \
			-T ${TOOL} "$@" -K ${TASK}
	else
		${VIPER_CONSOLE} open -t \
			-J-Dosservermgr.Debugging=${DEBUGGING} \
			-T ${TOOL} "$@" -- -K ${TASK}
	fi
fi

exit $?
