#!/bin/ksh -p
#
# $(ID)
#
# Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
#

set -u
########################################################################
#
# Update Smart Card Services configuration
#
########################################################################

PATH=/usr/bin:/bin:/usr/sbin:/sbin
export PATH

########################################################################
#
# Operation entry points, one for each keyword.  This is where the
# specific work for this feature happens.
#
########################################################################


#
# disable()
#
disable() {

    rm -rf $SED_PCSCVALIDATECONF
    if [ -f $PCSCVALIDATECONF ]; then
	cp $PCSCVALIDATECONF  $SED_PCSCVALIDATECONF
	sed '/pcscdValidate-SunRay.so.1/d' $SED_PCSCVALIDATECONF > \
	    $PCSCVALIDATECONF
    fi
    rm -rf $SED_PCSCVALIDATECONF
    
}

#
# enable()
#
enable() {

    rm -rf $SED_PCSCVALIDATECONF
    if [ -d /usr/lib/smartcard ]; then
        grep pcscdValidate-SunRay.so.1 $PCSCVALIDATECONF >/dev/null
        if [ $? != 0 ]; then
	    cp $PCSCVALIDATECONF  $SED_PCSCVALIDATECONF
	    sed '/pcscdValidate.so.1/i\
pcscdValidate-SunRay.so.1 -s 2 -e 500 -x /etc/dt/config/Xservers' \
		$SED_PCSCVALIDATECONF > $PCSCVALIDATECONF
	    rm -rf $SED_PCSCVALIDATECONF
        fi
    fi

}


#########################################
# LOCAL VARIABLES
# They must defined here to resolve the some of parameter resolution
# problem
#########################################
local_variables() {
	PCSCVALIDATECONF=/usr/lib/smartcard/pcscd_validate.conf	
	SED_PCSCVALIDATECONF=$SUNWUTVAR/tmp/sed_pcscd_validate.conf.$$
}


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

#########################################
#
# variables used in the shared script utctl-shlib
#
#########################################

DESCR="Update Smart Card Services configuration"

########################################################################
#
# Execution starts here
########################################################################

PROGPATH=`dirname $0`
. $PROGPATH/utctl-shlib
