#!/ibin/sh
#******************************************************************************
#       Mozilla component ccs script
#       input:
#           $1 is the name of the step
#           $2 is the keyword list (e.g., INSTALL, UPGRADE, REMOVE)
#           $3 is the package list
#=============================================================================

# Read arguments into variables
scriptname="$0"
step="$1"
keywords="$2"
pkglist="$3"

# Source in the standard functions library, ccsSetup.sh
. /ibin/ccsSetup.sh

# Set global variables indicating whether this is an upgrade or removal.
sso_upgrade=
for word in $keywords
do
    case "$word" in 
        UPGRADE) sso_upgrade=TRUE
                 ;;
    esac
done

PATH="/ibin:/bin:/usr/bin"
export PATH

# Check $IQM_FILE to determine how custom was invoked and the installation
# type. If IQM_FILE exists, source it in
customMode=LAYERED
[ "$IQM_FILE" ] && {
		# Invoking custom from the IQM.  IQM output will be stored
		# in $IQM_FILE.
		customMode="IQM"
		. $IQM_FILE
}

#=========================================================================
#  doPostexport
#=========================================================================
doPostexport()
{
    if [ -x /usr/bin/doctool ]; then
        /usr/bin/doctool --add \
            NetworkDoc/Internet/Mozilla/MozillaDoc.desktop > /dev/null 2>&1
        /usr/bin/doctool --add \
            NetworkDoc/Internet/Mozilla/.directory > /dev/null 2>&1
    fi

    # link to java plugin if it exists
    if [ -f $NEW_JAVA_PLUGIN ]
    then
        rm -f $MOZ_JAVA_PLUG
        ln -s $NEW_JAVA_PLUGIN $MOZ_JAVA_PLUG
    else
        [ -f $JAVA_PLUGIN ] && {
            rm -f $MOZ_JAVA_PLUG
            ln -s $JAVA_PLUGIN $MOZ_JAVA_PLUG
        }   
    fi
}
 
#====================================================================== INT ===
#  doPreunexport --
#------------------------------------------------------------------------------
doPreunexport() {
    # on 5.0.7 and later, we use docview instead of scohelp.  test
    # whether 'doctool' exists to determine whether it needs to be run.
    if [ -x /usr/bin/doctool ]; then
        /usr/bin/doctool --remove \
            NetworkDoc/Internet/Mozilla/MozillaDoc.desktop > /dev/null 2>&1
        /usr/bin/doctool --remove \
            NetworkDoc/Internet/Mozilla/.directory > /dev/null 2>&1
    fi

    # remove the java plugin
    rm -f $MOZ_JAVA_PLUG
}


#====================================================================== INT ===
#  main --
#
#------------------------------------------------------------------------------

JAVA_PLUGIN_DIR="/usr/local/lib/netscape/ojiplugin/lib/x86at/ns600"
NEW_JAVA_PLUGIN_DIR="/usr/java/jre/plugin/i386/ns610"
JAVA_PLUGIN="$JAVA_PLUGIN_DIR/libjavaplugin_oji.so"
NEW_JAVA_PLUGIN="$NEW_JAVA_PLUGIN_DIR/libjavaplugin_oji.so"
MOZ_JAVA_PLUG="/usr/lib/mozilla-1.6/plugins/libjavaplugin_oji.so"

case "$step" in
        POST_EXPORT)	doPostexport
                        ;;      
        PRE_UNEXPORT)	doPreunexport
                        ;;      
esac

exit 0
