#sccs "@(#) /b4/law/sccs/ate/s.Remove 1.1"

set +e

LIST0="async_main umodem"
LIST1="ELD.ft BLD.ft VBM.ft SCLD.ft UK.ft ROMC.ft ROMG.ft system.144.ft"
LIST2="te.hlp"


# check if async_ma is an active process

ps -e | grep async_ma | \
  while read PID TTY TIME COMMAND
do
	if [ "$COMMAND" = "async_ma" ]
	then	
	message -i "Currently someone is using ATE, therefore; this ATE REMOVE will not take place."
	exit 64
	fi
done

if [ $? = 64 ]
then
	exit 64
fi

echo "               Updating Suffixes file ..."

uaupd -r "Modem Profile" Suffixes
uaupd -r "RS-232 Profile" Suffixes

echo "               Updating Comm_pkgs file ..."

uaupd -r ATE_Modem Comm_pkgs
uaupd -r ATE_Serial Comm_pkgs

# Test if update comm_packages file exist
# if file exist, EXEC /etc/cpupd to inform phone manager to update comm packages

if [  -f /etc/cpupd ]
then
	/etc/cpupd
fi


echo '               Removing ATE...'

for i in $LIST2
do

	rm -f /usr/lib/ua/$i
done

for i in $LIST0
do

	rm -f /usr/bin/$i
done

# restore foundation version of fonts if needed

for i in $LIST1
do
	mv /usr/lib/wfont/.$i.tmp /usr/lib/wfont/$i 2>/dev/null
done

# restore foundation version of umodem

mv /usr/bin/.umodem.tmp /usr/bin/umodem 2>/dev/null

# remove the ate driver
/etc/lddrv/lddrv -d ate
masterupd -d ate

rm -f /etc/lddrv/ate.o /etc/lddrv/ate /etc/lddrv/ifile.ate

fgrep -v ate /etc/lddrv/drivers > /tmp/temp
mv /tmp/temp /etc/lddrv/drivers
fgrep -v "Name=ATE" /etc/lddrv/InstDrv > /tmp/temp
fgrep -v "File=ate" /tmp/temp>/tmp/temp2
fgrep -v "Maps the Numeric Keypad" /tmp/temp2 > /etc/lddrv/InstDrv
rm /tmp/temp /tmp/temp2
