#!/bin/ksh -p
#
# ident "@(#)pkg-libusbut.ksh	1.1 09/03/27 SMI"
#
# Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
# Use is subject to license terms.
#

set -u

function disable {

    typeset LIBUSBUT_PLUGIN_LNK="/usr/sfw/lib/libusb_plugins/libusbut.so.1"

    if [ -h "$LIBUSBUT_PLUGIN_LNK" ] ; then
	rm "$LIBUSBUT_PLUGIN_LNK"
    fi

    return 0

}

function enable {

    # postinstall script migrated for IPS packaging for SUNWlibusbut
    # - Sun Ray support for libusb
    # Need to check for SUNWlibusb : Sun wrapper library for libusb
    
      
    typeset LIBUSB_WRAPPER_DIR="/usr/sfw/lib"
    typeset LIBUSB_PLUGINDIR="$LIBUSB_WRAPPER_DIR/libusb_plugins"
    
    typeset LIBUSB_SUNRAY_PLUGIN="/opt/SUNWut/lib/libusbut.so.1"
    
    #
    # SUNWlibusb pkg is needed along with SUNWlibusbut for 
    # Sun Ray libusb support
    #
    
    if [ ! -d "$LIBUSB_PLUGINDIR" ]; then 
	echo "The SUNWlibusb pkg is not installed on your system."
	echo "Please install this package from the Supplemental"
	echo "area of this software. Refer to libusbut man page"
	echo "to complete libusb installation by creating a sym link."
    else
	/bin/ln -s $LIBUSB_SUNRAY_PLUGIN $LIBUSB_PLUGINDIR
    fi
    
    return 0
    
}


########################################################################
# Local Variables
# They must defined here to resolve some of the parameter resolution
# problem
########################################################################
local_variables() {
    return
}


########################################################################
#
# Configurable parameter
#
########################################################################
# NONE


########################################################################
#
# Variables used in the shared script utctl-shlib
#
########################################################################
DESCR="Supports libusbut. Checks if libusb package is installed "


########################################################################
#
# Execution starts here
#
PROGPATH=`dirname $0`
. $PROGPATH/utctl-shlib
