#!/bin/sh
#
# Copyright (c) 2001 by Sun Microsystems, Inc.
# All rights reserved.
#
# ident "@(#)postbackout        1.0     02/02/01 SMI"
#

# postbackout script for ttymux point patch 111406
#
#

# Only run this script if this is a Netra ct machine.

if [ `uname -i` != "SUNW,UltraSPARC-IIi-Netract" ] 
then
	exit 0
fi

EXIT=0

# Remove ttymux driver 
# clean up /etc/driver_aliases and /etc/name_to_major. 
#
#
if [ -f $ROOTDIR/kernel/drv/sparcv9/ttymux ]; then
	exit 0
else
        $ROOTDIR/usr/sbin/rem_drv -b $ROOTDIR ttymux || EXIT=1
fi

if [ $EXIT = 1 ]
then
        echo " Cannot remove ttymux driver. "
        exit 1
fi

# Modify /etc/iu.ap by removing the entry for ttymux
if /bin/fgrep -s "	ttymux	-1	0	ldterm ttcompat" ${ROOTDIR}/etc/iu.ap ; then
   echo "Deleting ttymux entry from /etc/iu.ap."
   /bin/grep -v "	ttymux	-1	0	ldterm ttcompat" ${ROOTDIR}/etc/iu.ap > /tmp/iu.ap
   if [ $? != 0 ] ; then
                echo "${ROOTDIR}/etc/iu.ap file modification failed"
                EXIT=1
        else
                mv /tmp/iu.ap ${ROOTDIR}/etc/iu.ap
                echo "/etc/iu.ap file successfully modified"
        fi
fi

# Modify /etc/dacf.conf by removing the entry for ttymux
if /bin/fgrep -s "driver-minorname=\"ttymux:con\" ttymux_dacf:ttymux_config post-attach -" ${ROOTDIR}/etc/dacf.conf ; then
   echo "Deleting ttymux entry from /etc/dacf.conf."
   /bin/grep -v "driver-minorname=\"ttymux:con\" ttymux_dacf:ttymux_config post-attach -" ${ROOTDIR}/etc/dacf.conf > /tmp/dacf.conf
   if [ $? != 0 ] ; then
                echo "${ROOTDIR}/etc/dacf.conf file modification failed"
                EXIT=1
        else
                mv /tmp/dacf.conf ${ROOTDIR}/etc/dacf.conf
                echo "/etc/dacf.conf file successfully modified"
        fi
fi

exit $EXIT

