#!/bin/sh

# @(#)postpatch	1.1   00/06/27     SMI#
#
# Check if the interconnect has been configured. If so,
# update the firmware on all units as soon as the patch 
# is installed.
#

# We may be installed as part of a jumpstart, so check
# the install root

ROOTDIR=${2:-/}

HOSTS=${ROOTDIR}/etc/inet/hosts
HOSTNAME_R=${ROOTDIR}/etc/hostname

# get a list of existing Corona interfaces

grep 'SUNRAY ADD' ${HOSTS} | awk '{ print $2 }' >/tmp/newthosts.$$
fgrep -l -f /tmp/newthosts.$$ ${HOSTNAME_R}.* 2>/dev/null | sed "s!${HOSTNAME_R}.!!" >/tmp/newtifs.$$
rm /tmp/newthosts.$$ 2>/dev/null

INTFS=`cat /tmp/newtifs.$$`
rm /tmp/newtifs.$$ 2>/dev/null

# Check if the Sun Ray interconnect has been configured

if [ -z "${INTFS}" ]; then
	echo ""
	echo "WARNING: Firmware download has not been enabled as the"
	echo "         interconnect framework is not configured."
	echo ""
	echo "Refer to the patch README file for information on manually"
	echo "configuring firmware downloads."
	echo ""
else
	BASEDIR=`pkginfo -R ${ROOTDIR} -r SUNWuto`
	$BASEDIR/SUNWut/sbin/utfwadm -A -a -n all
fi

#
# BugID 4356736 requires an update to auth.props

PROPS_FILE=${ROOTDIR}/etc/opt/SUNWut/auth.props

ENTRY_START="# Start 4356736"
ENTRY_END="# End 4356736"

NEWLINE="terminalTokens = MicroPayflex Mondex at88sc1608 Payflex Cyberflex_Access"

if [ -f ${PROPS_FILE} ]; then
	/bin/cp ${PROPS_FILE} /tmp/tmp.$$ || exit 2 
	
	sed "/^$ENTRY_START\$/,/^$ENTRY_END\$/d" /tmp/tmp.$$ > ${PROPS_FILE} || exit 2
	echo ${ENTRY_START} >> ${PROPS_FILE}
	echo ${NEWLINE} >> ${PROPS_FILE}
	echo ${ENTRY_END} >> ${PROPS_FILE}
	rm -rf /tmp/tmp.$$
fi
