#!/bin/sh
#
#ident	"@(#)u4ftlogging	1.5	99/06/24	SMI"
#
#   This script starts/stops the Ultra-4FT logging daemon
#
#   It should be called with start/stop arguments as one of the rc
#   startup/shutdown scripts, and daily (with the "rotate" argument)
#   from a cron job.
#
#   If the Ultra-4FT logging package is not installed, it does nothing.
#

if [ `uname -i` != "SUNW,Ultra-4FT" ]
then
        # Not an ft1800
        exit 0
fi

U4FTLOGPKG=SUNWlogu

if /bin/pkginfo -q $U4FTLOGPKG
then
        U4FTLOGCTL=`/usr/sbin/pkgchk -l $U4FTLOGPKG |
			sed -n '/Pathname.*\/u4ftlogctl$/s,[^ 	]*[	 ],,p'`
        if [ -x $U4FTLOGCTL ]
        then
                if [ $# -ne 1 ]
                then
                        $U4FTLOGCTL ${@+"$@"}
                else
                        #
                        # Apply the command to each of a standard set of logs
                        #
                        # NB: the empty string implies "status", but doesn't
                        # compress after rotation.  If you want the status
                        # log compressed, change "" to "status".
                        #
                        for log in "" "debug" "nvlog"
                        do
                                $U4FTLOGCTL $1 $log
                        done
                fi
        fi
fi

# Report the last reset reason when logging is being started
BASEDIR=`pkgparam SUNWcmsu BASEDIR`
CMSHOME=$BASEDIR/usr/platform/SUNW,Ultra-4FT/SUNWcms
U4FTCTL=$CMSHOME/lib/u4ftctl
export CMSHOME

case $1 in
        start)
                [ -x $U4FTCTL ] && \
		$U4FTCTL report_message 0 \
		"OBP reports reset-reason as `$U4FTCTL prop_find_strings / reset-reason`" ;;
esac
