#sccs	"@(#)combobrd:Install	1.8"

#
#***************************************************************************
#
#	Install script for RS-232 Expansion board.
#	6/85 -  C. Liu
#
#***************************************************************************
#
ERROR1="RS-232 Expansion software already installed.\n\n Please remove the current version of software before attempting to install software again.\n"

fgrep "RS232 Expansion Setup" $UA/Hardware > /tmp/t
if [ -s /tmp/t ]
then
	message $ERROR1
	rm -f /tmp/t
	exit 64
fi

rm -f /tmp/t

echo
echo '          Installing RS-232 expansion software ...'
echo

LIST1="/usr/lib/ua/CMB232.menu /usr/bin/CMB232.sh"
LIST2="001 002 003 004 005 006"

cp ./cmb.o /etc/lddrv
cp ./cmb.rc /etc/lddrv
cp ./cmbpcnt /etc/lddrv
cp ./cmbupd /etc/lddrv
cp ./CMB232.sh /usr/bin
ln /etc/lddrv/cmb.rc /etc/lddrv/cmb.brc
touch /usr/lib/ua/CMB232.menu

for i in $LIST1
do
	chown bin $i
	chgrp bin $i
	chmod 755 $i
done

#
# Update the master file in /etc/master.
#
echo '          Updating Systems files ...'
echo
masterupd -a init release cmb

#
# Create the new device entries
#
echo '          Creating entries for the new ports ...'
echo

/etc/mknod /dev/tty001 c 0 2
/etc/mknod /dev/tty002 c 0 3
/etc/mknod /dev/tty003 c 0 4
/etc/mknod /dev/tty004 c 0 5
/etc/mknod /dev/tty005 c 0 6
/etc/mknod /dev/tty006 c 0 7
chmod a+w  /dev/tty001
chmod a+w  /dev/tty002
chmod a+w  /dev/tty003
chmod a+w  /dev/tty004
chmod a+w  /dev/tty005
chmod a+w  /dev/tty006

#
# Add the new entries into the /etc/inittab table. - RWL 3/13/86
#
for i in $LIST2
do
	grep -v ":$i:2:respawn:" /etc/inittab > /tmp/inittab
	echo ":$i:2:respawn:/etc/getty tty$i 9600" >> /tmp/inittab
	mv /tmp/inittab /etc/inittab
	echo "TYPE='NONE'" > /etc/.rs232_$i
	chmod 777 /etc/.rs232_$i
done
chmod 644 /etc/inittab

#
# load the driver
#
echo '          Loading the driver software ...'
echo
cd /etc/lddrv
./lddrv -a cmb
./cmb.rc
# cmb.rc did a /usr/lib/lpshut 
/usr/lib/lpsched
echo "cmb" >> ./drivers
#
# Notify phone manager that the combo board is installed.
#
./cmbupd

#
# Append a new entry in the Hardware setup menu
#
echo '          Updating Administration files ...'
echo

cat >> /tmp/Hardware << -END-
Name = RS232 Expansion Setup
Expert
Default = Open
Open = SH -pwd /usr/bin/CMB232.sh
Help = EXEC -d /usr/bin/uahelp -h /usr/lib/ua/admin.hlp -t "Expanded RS232"

-END-
uaupd -r "RS232 Expansion Setup" -a /tmp/Hardware Hardware
rm -f /tmp/Hardware

grep "File[ 	]*=[ 	]*cmb" /etc/lddrv/InstDrv > /dev/null
if [ $? != 0 ]
then
	cat >> /etc/lddrv/InstDrv << -END-
Name=RS232 Expansion
File=cmb
Comment=RS232 Expansion software
-END-
fi

#
# done
#
echo
echo '          Installation of RS-232 software completed.'
echo
