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

USAGE="usage: msfupdkey"

help() {
echo "MSF tool to update passwords on keyfile"
echo $USAGE
}

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 \`whence $0\``
    B=`basename \`whence $0\``
    abspath="`cd \"$D\" 2>/dev/null && pwd || echo \"$D\"`/$B"
    MSF_HOME=`dirname $(dirname $abspath)`
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.
trap "stty icanon echo" 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 \
 com.sun.emp.security.tools.UpdateKeyFile

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