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

USAGE="usage: msfconvdb {oracle|sybase|db2} <schema pw> <admin pw> <user pw>"

help() {
echo "MSF repository conversion tool"
echo $USAGE
echo "   oracle if converting MSF repository on an Oracle RDBMS"
echo "   sybase if converting MSF repository on a Sybase RDBMS"
echo "   db2 if converting MSF repository on a Db2 RDBMS"
echo "   SCHEMA PW for authenticating that user-name"
echo "   ADMIN PW for authenticating that user-name"
echo "   USER PW for authenticating that user-name"
}

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.
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:$MSF_HOME/config/$MSF_INSTANCE \
 com.sun.emp.security.utilities.ConvertDBP1toP2 $2 $3 $4 $5

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