: $Workfile:   MakeAnAdministrator.sh  $ $Revision:   1.0  $
#**********************************************************************#
#*                                                                    *#
#* Copyright (c) 2002 by Sun Microsystems, Inc.                       *#
#* All rights reserved.                                               *#
#*                                                                    *#
#**********************************************************************#

USAGE="usage: msfinitr [admin-domain]"

help() {
echo "MSF initialize repository tool"
echo $USAGE
echo "   ADMIN-DOMAIN is the name of the administrative resource domain to create"
}

set -- `getopt h $*`

if test  "$1" != "--"
then
    case $1 in
    -h)
        help
        exit 0
        ;;
    *)
# illegal option encountered
        echo $USAGE
        exit 1
    esac
fi

#---
# This script assumes that it is located in the bin directory of the
# installed MSF product. If it is moved, then the MSF_HOME environment
# variable can be set to override the calculations here.
#---

#
# Determine where the installation of MSF is.
#
if [ "$MSF_HOME"A = "A" ]; then
    D=`dirname \`which $0\``
    B=`basename \`which $0\``
    abspath="`cd \"$D\" 2>/dev/null && pwd || echo \"$D\"`/$B"
    tmp1=`dirname $abspath`
    MSF_HOME=`dirname $tmp1`
fi
if [ ! -f "${MSF_HOME}/lib/secrt.jar" ]; then
    echo "Could not find runtime under '"${MSF_HOME}"'"
    exit 1
fi
if [ "$MSF_INSTANCE"A = "A" ]; then
    echo "Must specify value for environment variable MSF_INSTANCE"
    exit 1
else
    if [ ! -f "${MSF_HOME}/config/${MSF_INSTANCE}/MSFconfig.properties" ]; then
        echo "No configuration under '"${MSF_HOME}/config/${MSF_INSTANCE}"'"
        exit 1
    fi
fi

# make sure any unexpected 'kill' in PasswordReader resets terminal echo, etc.
saveterm=`stty -g`
trap "stty $saveterm" 0

java -DMSF_HOME=$MSF_HOME -DMSF_INSTANCE=$MSF_INSTANCE \
 -Djava.security.properties=$MSF_HOME/config/java.security \
 -Djava.library.path=$MSF_HOME/lib:$LD_LIBRARY_PATH \
 -classpath \
 $MSF_HOME/lib/secrt.jar:$MSF_HOME/lib/secrtpa.jar:$MSF_HOME/config/$MSF_INSTANCE \
 com.sun.emp.security.tools.MakeAnAdministrator $2

RET=$?
if test $RET -ne 0
then echo MakeAnAdministrator command terminated with error
fi
exit $RET
