#!/bin/sh
#
# Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
# Use is subject to license terms.
#
# ident	"@(#)i.pkcs11confbase	1.2	05/01/10 SMI"

while read src dest
do
	if [ ! -f $dest ] ; then
		cp $src $dest
	else
		#check if destination already has metaslot configuration line
		egrep '^metaslot' $dest > /dev/null 2>& 1
		if [ $? != 0 ] ; then
			#metaslot line doesn't exist, need to add it
			metaslot_config=`egrep '^metaslot' $src`

			if [ $? = 0 ] ; then
				export metaslot_config
				nawk '/^# End SUNWcsr/ \
                        		{ print ENVIRON["metaslot_config"] } \
                        		{ print } \
				' ${dest} > ${dest}.$$
				mv -f ${dest}.$$ ${dest}
			
			fi
		fi
	fi
done
exit 0
