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

USAGE="usage: msflog {-s|-f|-p|-t|-d directory}"
help() {
echo "MSF Security Logging administration tool"
echo $USAGE
echo "   -s    start the Security Loggers in background process(es)"
echo "   -f    flip the active Security Logger process(es) to new file(s)"
echo "   -p    print statistics from the active Security Logger process(es)"
echo "   -t    terminate the active Security Logger process(es)"
echo "   -d    change to 'directory' for the active Security Logger file(s)"
}

#---
# 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

set -- `getopt d:fhpst $*`

if test  "$1" != "--"
then
    case $1 in
    -h)
        help
        exit 0
        ;;
    -s)
        echo starting Security Loggers...
        ;;
    -f)
        echo flipping Security Loggers to new log files...
        ;;
    -d)
        echo flipping Security Loggers to new directory for log files...
        ;;
    -t)
        echo terminating Security Loggers...
        ;;
    -p)
        echo printing Security Loggers statistics...
        ;;
    *)
# illegal option encountered
        echo $USAGE
        exit 1
    esac
else
# no option specified
        echo $USAGE
        exit 2
fi

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.DirectSecurityLoggers $1 $2
