#!/bin/sh

#############################################################################
#                                                                           #
#                PURPOSE                                                    #
#                #######                                                    #
#                                                                           #
#(1)  do uncompress the subdirectories                                      #
#                                                                           #
#(1a) delete the files which do the uncompress.                             #
#                                                                           #
#(2)  make the data base files for aatm, acip, aarp                         #
#                                                                           #
#(3)  creates start files for aatm acip and aarp                            #
#                                                                           #
#(4)  these files are created in the appropriate directories and            #
#     also linked to the /etc directory.                                    #
#                                                                           #
#                                                                           #
#                                                                           #
#############################################################################

arch=`arch -k`

current=`pwd`

# Milton -- AATMDIAG and AATMSNMP are added
AATMDIAG=$current/ADPT/diag/bin
AATMSNMP=$current/ADPT/aatmsnmp/bin
# Milton -- all executables will be linked in this directory
AATMADPT=$current/ADPT/bin
AATMDIR=$current/ADPT/aatm/bin
ACIPDIR=$current/ADPT/acip/bin
AARPDIR=$current/ADPT/aarp/bin
#	Milton -- created entry ALANEDIR
ALANEDIR=$current/ADPT/alane/bin
EZATMDIR=$current/ADPT/ezAtm/bin
EZLIBDIR=$current/ADPT/ezlib/lib
MANDIR=$current/ADPT/man/man8

hostname=`uname -n`

cd $MANDIR

if [ ! -z "`/bin/ls *.Z 2>/dev/null`" ]
then
	uncompress *.Z
fi

###############  EZLIBDIR #################################################

# Milton -- changing /usr.. to $current to uncompress the library files
# if [ ! -z "`/bin/ls /usr/ADPT/aatm/lib/*.Z 2>/dev/null`" ]
# then
#	uncompress /usr/ADPT/aatm/lib/*.Z
# fi

if [ ! -z "`/bin/ls $current/ADPT/aatm/lib/*.Z 2>/dev/null`" ]
then
	uncompress $current/ADPT/aatm/lib/*.Z
fi

if [ ! -f /usr/lib/libC.sa.5.0 -o -h /usr/lib/libC.so.5.0 ]
then
	rm -f /usr/lib/libC.sa.5.0
	ln -s $AATMDIR/../lib/libC.sa.5.0 /usr/lib
	rm -f /usr/lib/libC.so.5.0
	ln -s $AATMDIR/../lib/libC.so.5.0 /usr/lib
fi

# Milton -- setting up default dir for *.db file
#	    which is /usr/ADPT/aatm/bin for base.db
#	    which is /usr/ADPT/acip/bin for acip.db
#	    which is /usr/ADPT/aarp/bin for aarp.db
#	    which is /usr/ADPT/alane/bin for alane0.db

install -d /usr/ADPT/aatm/bin
install -d $AATMADPT

cd $AATMDIR

echo "******** INSTALLING AATM *********"

if [ ! -z "`/bin/ls *.Z 2>/dev/null`" ]
then
	uncompress *.Z
fi

###########################################################################
# make the base.db for this system

# for base.db

# Milton -- changing permissions of binaries
chown root aatmcnfg sigconf mkbasedb 

#script for making base.db
chmod 744 mkbasedb make_kernel_aatm
mkbasedb

# MAKE STARTAATM SCIPT FILE AND ALSO LINK IT IN /ETC DIRECTORY
# Milton -- changed the scripts to allow parameters -f, -q , -a to be passed
echo "#!/bin/sh" > $AATMDIR/startaatm
echo "#!/bin/sh" > $AATMDIR/stopaatm
echo >>$AATMDIR/startaatm
echo >> $AATMDIR/stopaatm
# echo "$AATMDIR/aatmcnfg -f $AATMDIR/base.db" >> $AATMDIR/startaatm
# echo "$AATMDIR/aatmcnfg -s "  >> $AATMDIR/stopaatm

# Milton
echo " $AATMDIR/aatmcnfg " '$1 $2 $3 $4'  >> $AATMDIR/startaatm
echo "$AATMDIR/aatmcnfg -s "  >> $AATMDIR/stopaatm

# Milton -- changing the link as requested
if [ ! -f $AATMADPT/startaatm ]
then
	ln -s $AATMDIR/startaatm  $AATMADPT/startaatm 
fi

if [ ! -f $AATMADPT/stopaatm ]
then
	ln -s $AATMDIR/stopaatm $AATMADPT/stopaatm 
fi

if [ ! -f $AATMADPT/aatmcnfg ]
then
	ln -s $AATMDIR/aatmcnfg  $AATMADPT/aatmcnfg
fi

if [ ! -f $AATMADPT/sigconf ]
then
	ln -s $AATMDIR/sigconf  $AATMADPT/sigconf
fi

#chmod u+x /etc/startaatm /etc/stopaatm
chmod u+x $AATMADPT/startaatm $AATMADPT/stopaatm
chmod u+x $AATMDIR/startaatm $AATMDIR/stopaatm

# SNMP 
cd $AATMSNMP
echo "******** INSTALLING SNMP *********"
 
if [ ! -z "`/bin/ls *.Z 2>/dev/null`" ]
then
        uncompress *.Z
fi

# Milton -- changing the permissions of binaries
chown root aatmsnmpd aatmsnmpd.conf

# Milton -- updating the path for aatmsnmp
echo "#!/bin/sh" > $AATMSNMP/startaatmsnmp
echo >>$AATMSNMP/startaatmsnmp
echo "$AATMSNMP/aatmsnmpd" >> $AATMSNMP/startaatmsnmp

cat > $AATMSNMP/stopaatmsnmp <<!
#!/bin/sh

tmp1=\`ps -agx | grep aatmsnmpd | egrep -v '(grep|kk)' | cut -c1-5,20-\`

if [ "\$tmp1" != "" ]
then
	tmp2=\`echo "\$tmp1" | cut -c1-5\`
        kill -9 \$tmp2
fi
!

# Milton -- changing the link as requested 
if [ ! -f $AATMADPT/startaatmsnmp ]
then
	ln -s  $AATMSNMP/aatmsnmpd $AATMADPT/aatmsnmpd
	ln -s  $AATMSNMP/aatmsnmpd.conf $AATMADPT/aatmsnmpd.conf
	ln -s $AATMSNMP/startaatmsnmp $AATMADPT/startaatmsnmp 
fi

if [ ! -f $AATMADPT/stopaatmsnmp ]
then
	ln -s $AATMSNMP/stopaatmsnmp $AATMADPT/stopaatmsnmp 
fi

# chmod u+x /etc/startaatmsnmp /etc/stopaatmsnmp
chmod u+x $AATMSNMP/startaatmsnmp $AATMSNMP/stopaatmsnmp
chmod u+x $AATMADPT/startaatmsnmp $AATMADPT/stopaatmsnmp

# Milton -- copying aatmsnmpd.conf /usr/ADPT/aatm/bin

cp $AATMSNMP/aatmsnmpd.conf /usr/ADPT/aatm/bin

#  Milton -- uncompressing aatmdiag
cd $AATMDIAG
 
echo "******** INSTALLING DIAG *********"
 
if [ ! -z "`/bin/ls *.Z 2>/dev/null`" ]
then
        uncompress *.Z
fi

# Milton -- changing the permissions of binaries
chown root aatmdiag

if [ ! -f $AATMADPT/aatmdiag ]
then
	ln -s $AATMDIAG/sigconf  $AATMADPT/sigconf
fi

cd $AATMDIR

#for configuring aatm driver

arch=`arch -k`

if [ "$arch" = "sun4c" ]
then
	cp aatm.o.sun4c /sys/$arch/OBJ/aatm.o
else
	cp aatm.o.sun4m /sys/$arch/OBJ/aatm.o
fi

if [ -f /sys/$arch/conf/files -a -z "`grep aatm /sys/$arch/conf/files`" ]
then
	cat >> /sys/$arch/conf/files <<!
sbusdev/aatm.c      optional aatm device-driver
!
fi

while [ 1 ]
do
	echo -n "Enter original kernel configuration file [default \"GENERIC\"] : "
	read configuration
	if [ -z "$configuration" ]
	then
		configuration=GENERIC
	fi

	if [  -f /sys/$arch/conf/$configuration ]
	then
		break
	else
		echo "/sys/$arch/conf/$configuration does not exist"
		echo
	fi
done

cp /sys/$arch/conf/$configuration /sys/$arch/conf/AATM
cat >> /sys/$arch/conf/AATM <<!
device-driver   aatm            # atm device driver
!

if [ -f /sys/sun/conf.c -a -z "`grep aatm /sys/sun/conf.c`" ]
then

cp /sys/sun/conf.c /sys/sun/conf.c.pre.aatm

awk '
/\/\*[0-9]*\*\// {
	lastmajor = substr($5, 3, length($5)-4);
}

/struct.*cdevsw/ {
	cdevsw = "yes"
	printf("#include \"aatm.h\"\n");
	printf("#if NAATM > 0\n");
	printf("extern struct streamtab aatm_info;\n");
	printf("#define aatmtab &aatm_info\n");
	printf("#else\n");
	printf("#define aatmtab 0\n");
	printf("#endif\n\n");
}

/}$/ {
	if ((cdevsw == "yes") && (added != "yes")) {
	printf("    },\n");
	printf("    {\n");
	printf("\tnodev,          nodev,          nodev,          nodev,          /*%d*/\n", lastmajor+1);
	printf("\tnodev,          nodev,          nodev,          0,\n");
	printf("\taatmtab,        0,\n");
	added = "yes";
	}
}
	
/};/ {
	if ((cdevsw == "yes") && (added != "yes")) {
	printf("    {\n");
	printf("\tnodev,          nodev,          nodev,          nodev,          /*%d*/\n", lastmajor+1);
	printf("\tnodev,          nodev,          nodev,          0,\n");
	printf("\taatmtab,        0,\n");
	printf("    }\n");
	added = "yes";
	}
}

{
	print $0;
}' /sys/sun/conf.c > /tmp/$$.install.aatm
mv /tmp/$$.install.aatm /sys/sun/conf.c

major=`awk '
/\/\*[0-9]*\*\// {
	lastmajor = substr($5, 3, length($5)-4);
}

END {
	print lastmajor
}' /sys/sun/conf.c`

rm /dev/aatm >/dev/null 2>&1
mknod /dev/aatm c 37 $major

fi

##########################   ACIP    #####################################
# Milton -- modified the message displayed below

if [ -d $ACIPDIR ]
then
echo
echo "******** INSTALLING ACIP *********"
fi

acip_ans="y"
if [ -d $ACIPDIR -a -d $AARPDIR ]
then
	echo
	echo "Do you want to configure ACIP now ? "
	echo " If this end system will also function as the ATM ARP Server "
	echo " and you choose NO here but want to config ACIP later "
	echo " you will need to config ACIP after completing this "
	echo " installation process with 'mkacipdb'"
	echo -n "default \"y\" [y,n] ? "
	read acip_ans
fi

if [ -d $ACIPDIR ]
then
cd $ACIPDIR

if [ ! -z "`/bin/ls *.Z 2>/dev/null`" ]
then
	uncompress *.Z
fi

# for acip.db
chmod u+x mkacipdb
if [ "$acip_ans" != "n" ]
then
mkacipdb
fi

# MAKE STARTACIP SCIPT FILE AND ALSO LINK IT IN /ETC DIRECTORY 
echo "#!/bin/sh" > $ACIPDIR/startacip 
echo "#!/bin/sh" > $ACIPDIR/stopacip
echo >> $ACIPDIR/startacip 
echo >> $ACIPDIR/stopacip 
# echo "$ACIPDIR/acipcnfg -f $ACIPDIR/acip.db" >> $ACIPDIR/startacip 
# echo "$ACIPDIR/acipcnfg -s "  >> $ACIPDIR/stopacip 

# Milton
echo "$ACIPDIR/acipcnfg " '$1 $2'  >> $ACIPDIR/startacip 
echo "$ACIPDIR/acipcnfg -s "  >> $ACIPDIR/stopacip 

# Milton -- changing the link  
if [ ! -f $AATMADPT/startacip ]
then
ln -s $ACIPDIR/startacip $AATMADPT/startacip 
ln -s $ACIPDIR/stopacip $AATMADPT/stopacip 
ln -s $ACIPDIR/acipcnfg $AATMADPT/acipcnfg
# ACC - set symbolic link to acipd
ln -s $ACIPDIR/acipd $AATMADPT/acipd
# ACC - set symbolic link to ndd
ln -s $ACIPDIR/ndd $AATMADPT/ndd
fi

# ACC -- copying acipd to /usr/ADPT/acip/bin
if [ "$acip_ans" != "n" ]
then
cp $ACIPDIR/acipd /usr/ADPT/acip/bin
fi

chmod u+x $ACIPDIR/startacip $ACIPDIR/stopacip
chmod u+x $AATMADPT/startacip $AATMADPT/stopacip
# chmod u+x /etc/startacip /etc/stopacip

# Making changes to configuration files only if ACIP 
# is to be installed. -ACC

if [ "$acip_ans" != "n" ]
then

arch=`arch -k`
cp acip.o /sys/$arch/OBJ

if [ -f /sys/$arch/conf/files -a -z "`grep acip /sys/$arch/conf/files`" ]
then
	cat >> /sys/$arch/conf/files <<!
acip/acip.c         optional acip
!
fi

if [ -f /sys/$arch/conf/AATM -a -z "`grep acip /sys/$arch/conf/AATM`" ]
then
	cat >> /sys/$arch/conf/AATM <<!
pseudo-device	acip 			# Classic IP 
!
fi

if [ -f /sys/sun/conf.c -a -z "`grep acip /sys/sun/conf.c`" ]
then

awk '
/\/\*[0-9]*\*\// {
	lastmajor = substr($5, 3, length($5)-4);
}

/struct.*cdevsw/ {
	cdevsw = "yes"
	printf("#include \"acip.h\"\n");
	printf("#if NACIP > 0\n");
	printf("extern struct streamtab acip_stream_info;\n");
	printf("#define aciptab &acip_stream_info\n");
	printf("#else\n");
	printf("#define aciptab 0\n");
	printf("#endif\n\n");
}

/}$/ {
	if ((cdevsw == "yes") && (added != "yes")) {
	printf("    },\n");
	printf("    {\n");
	printf("\tnodev,          nodev,          nodev,          nodev,          /*%d*/\n", lastmajor+1);
	printf("\tnodev,          nodev,          nodev,          0,\n");
	printf("\taciptab,        0,\n");
	added = "yes";
	}
}
	
/};/ {
	if ((cdevsw == "yes") && (added != "yes")) {
	printf("    {\n");
	printf("\tnodev,          nodev,          nodev,          nodev,          /*%d*/\n", lastmajor+1);
	printf("\tnodev,          nodev,          nodev,          0,\n");
	printf("\taciptab,        0,\n");
	printf("    }\n");
	added = "yes";
	}
}

{
	print $0;
}' /sys/sun/conf.c > /tmp/$$.install.acip
mv /tmp/$$.install.acip /sys/sun/conf.c

major=`awk '
/\/\*[0-9]*\*\// {
	lastmajor = substr($5, 3, length($5)-4);
}

END {
	print lastmajor
}' /sys/sun/conf.c`

rm /dev/acip >/dev/null 2>&1
mknod /dev/acip c 37 $major

fi

#
# tune ip perf
#
sed -e '/tcp_sendspace/s/tcp_sendspace.*/tcp_sendspace = 49152;/' \
    -e '/tcp_recvspace/s/tcp_recvspace.*/tcp_recvspace = 49152;/' \
    -e '/tcp_default_mss/s/tcp_default_mss.*/tcp_default_mss = 1460;/' \
    -e '/udp_sendspace/s/udp_sendspace.*/udp_sendspace = 49152;/' \
    -e '/udp_recvspace/s/udp_recvspace.*/udp_recvspace = 49152;/' \
    -e '/tcp_ttl/s/tcp_ttl.*/tcp_ttl = 64;		\/* default time to live for TCPs *\//' \
    -e '/udp_ttl/s/udp_ttl.*/udp_ttl = 64;		\/* default time to live for UDPs *\//' \
/sys/netinet/in_proto.c > /tmp/in_proto.c

cp /sys/netinet/in_proto.c /sys/netinet/in_proto.c.pre.aatm
mv /tmp/in_proto.c /sys/netinet

fi

# Making changes to configuration files only if ACIP 
# is to be installed. -ACC
fi

##########################   ALANE   ########################################
#	Added by Milton

if [ -d $ALANEDIR ]
then
echo
echo "*************** INSTALLING ALANE ****************"
fi

alane_ans="y"
if [ -d $ALANEDIR ]
then
	echo
	echo "Do you want to configure the ALANE interface now ? "
	echo " If you choose NO here but want to config ALANE later "
        echo " you will need to config ALANE after completing this "
	echo " installation process with 'mkalanedb'" 
	echo -n "default \"y\" [y,n] ? "
	read alane_ans
fi

if [ -d $ALANEDIR ]
then
cd $ALANEDIR

if [ ! -z "`/bin/ls *.Z 2>/dev/null`" ]
then
	uncompress *.Z
fi

# Milton -- changing permissions of binaries
chown root alanecnfg mkalanedb

# for lec.db
chmod 744 mkalanedb
if [ "$alane_ans" != "n" ]
then 
mkalanedb
fi

# MAKE STARTALANE SCRIPT FILE AND ALSO LINK IT IN /ETC DIRECTORY
echo "#!/bin/sh" > $ALANEDIR/startalane
echo "#!/bin/sh" > $ALANEDIR/stopalane
echo >> $ALANEDIR/startalane
echo >> $ALANEDIR/stopalane
# echo "$ALANEDIR/alanecnfg -f $ALANEDIR/lec.db" >> $ALANEDIR/startalane
# echo "$ALANEDIR/alanecnfg -s " >> $ALANEDIR/stopalane

# Milton
echo "$ALANEDIR/alanecnfg " '$1 $2' >> $ALANEDIR/startalane
echo "$ALANEDIR/alanecnfg -s " >> $ALANEDIR/stopalane

# Milton -- changing the link as requested
if [ ! -f $AATMADPT/startalane ]
then
ln -s $ALANEDIR/startalane  $AATMADPT/startalane
ln -s $ALANEDIR/stopalane  $AATMADPT/stopalane
ln -s $ALANEDIR/alanecnfg  $AATMADPT/alanecnfg
ln -s $ALANEDIR/alaned	$AATMADPT/alaned
fi

# Milton  -- copying alaned to /usr/ADPT/alane/bin
if [ "$alane_ans" != "n" ]
then 
cp $ALANEDIR/alaned /usr/ADPT/alane/bin
fi

chmod u+x $ALANEDIR/startalane $ALANEDIR/stopalane
# chmod u+x /etc/startalane /etc/stopalane
chmod u+x $AATMADPT/startalane $AATMADPT/stopalane

# Making changes to configuration files only if ALANE
# is to be installed. -ACC
if [ "$alane_ans" != "n" ]
then

arch=`arch -k`
cp alane.o /sys/$arch/OBJ

if [ -f /sys/$arch/conf/files -a -z "`grep alane /sys/$arch/conf/files`" ]
then
	cat >> /sys/$arch/conf/files <<!
alane/alane.c         optional alane
!
fi

if [ -f /sys/$arch/conf/AATM -a -z "`grep alane /sys/$arch/conf/AATM`" ]
then
	cat >> /sys/$arch/conf/AATM <<!
pseudo-device	alane 			# LAN Emulation 
!
fi

if [ -f /sys/sun/conf.c -a -z "`grep alane /sys/sun/conf.c`" ]
then

awk '
/\/\*[0-9]*\*\// {
	lastmajor = substr($5, 3, length($5)-4);
}

/struct.*cdevsw/ {
	cdevsw = "yes"
	printf("#include \"alane.h\"\n");
	printf("#if NALANE > 0\n");
	printf("extern struct streamtab alane_strtab;\n");
	printf("#define alanetab &alane_strtab\n");
	printf("#else\n");
	printf("#define alanetab 0\n");
	printf("#endif\n\n");
}

/}$/ {
	if ((cdevsw == "yes") && (added != "yes")) {
	printf("    },\n");
	printf("    {\n");
	printf("\tnodev,          nodev,          nodev,          nodev,          /*%d*/\n", lastmajor+1);
	printf("\tnodev,          nodev,          nodev,          0,\n");
	printf("\talanetab,        0,\n");
	added = "yes";
	}
}
	
/};/ {
	if ((cdevsw == "yes") && (added != "yes")) {
	printf("    {\n");
	printf("\tnodev,          nodev,          nodev,          nodev,          /*%d*/\n", lastmajor+1);
	printf("\tnodev,          nodev,          nodev,          0,\n");
	printf("\talanetab,        0,\n");
	printf("    }\n");
	added = "yes";
	}
}

{
	print $0;
}' /sys/sun/conf.c > /tmp/$$.install.alane
mv /tmp/$$.install.alane /sys/sun/conf.c

major=`awk '
/\/\*[0-9]*\*\// {
	lastmajor = substr($5, 3, length($5)-4);
}

END {
	print lastmajor
}' /sys/sun/conf.c`

rm /dev/alane >/dev/null 2>&1
mknod /dev/alane c 37 $major

fi

#
# tune ip perf
#
sed -e '/tcp_sendspace/s/tcp_sendspace.*/tcp_sendspace = 49152;/' \
    -e '/tcp_recvspace/s/tcp_recvspace.*/tcp_recvspace = 49152;/' \
    -e '/tcp_default_mss/s/tcp_default_mss.*/tcp_default_mss = 1460;/' \
    -e '/udp_sendspace/s/udp_sendspace.*/udp_sendspace = 49152;/' \
    -e '/udp_recvspace/s/udp_recvspace.*/udp_recvspace = 49152;/' \
    -e '/tcp_ttl/s/tcp_ttl.*/tcp_ttl = 64;		\/* default time to live for TCPs *\//' \
    -e '/udp_ttl/s/udp_ttl.*/udp_ttl = 64;		\/* default time to live for UDPs *\//' \
/sys/netinet/in_proto.c > /tmp/in_proto.c

cp /sys/netinet/in_proto.c /sys/netinet/in_proto.c.pre.aatm
mv /tmp/in_proto.c /sys/netinet

fi

# Making changes to configuration files only if ALANE
# is to be installed. -ACC
fi

##########################   EZATM   ########################################
if [ -d $EZATMDIR ]
then
cd $EZATMDIR
cd ..
uncompress ezmodaa ezmodab
cat ezmodaa ezmodab > $EZATMDIR/ezatm
rm ezmodaa ezmodab
cd $EZATMDIR
uncompress *.Z
chmod a+x ezatm
chmod a-x ezAtm.uid

fi

##########################   EZLIB   ########################################

if [ -d $EZLIBDIR ]
then
cd $EZLIBDIR
uncompress *.Z
echo
echo "The LD_LIBRARY_PATH environment MUST be set to also have "
echo "\"$EZLIBDIR\" in its path for GUI program \"ezatm\"."
echo
echo
fi

#############################################################################


##############################   AARP  ######################################
if [ -d $AARPDIR ]
then
echo
echo "******** INSTALLING AARP *********"
echo
fi

aarp_ans="y"
if [ -d $AARPDIR ]
then
	echo
	echo "Do you want to configure AARP now ? "
	echo " If this end system will also function as the ATM ARP Server "
	echo " and you choose NO here but want to config AARP later "
	echo " you will need to config AARP after completing this "
	echo " installation process with 'mkaarpdb'"
	echo -n "default \"y\" [y,n] ? "
	read aarp_ans
fi

if [ -d $AARPDIR ]
then
cd $AARPDIR

if [ ! -z "`/bin/ls *.Z 2>/dev/null`" ]
then
	uncompress *.Z
fi

# for aarp.db
chmod u+x mkaarpdb
if [ "$aarp_ans" != "n" ]
then
mkaarpdb
fi

# MAKE STARTAARP SCRIPT FILE AND ALSO LINK IT IN /ETC DIRECTORY
echo "#!/bin/sh" > $AARPDIR/startaarp
echo "#!/bin/sh" > $AARPDIR/stopaarp
echo >> $AARPDIR/startaarp
echo >> $AARPDIR/stopaarp
# echo "$AARPDIR/aarpcnfg -f $AARPDIR/aarp.db" >> $AARPDIR/startaarp
# echo "$AARPDIR/aarpcnfg -s "  >> $AARPDIR/stopaarp

# Milton
echo "$AARPDIR/aarpcnfg " '$1 $2' >> $AARPDIR/startaarp
echo "$AARPDIR/aarpcnfg -s "  >> $AARPDIR/stopaarp

# Milton -- changing the link
if [ ! -f $AATMADPT/startaarp ]
then
ln -s $AARPDIR/startaarp $AATMADPT/startaarp
ln -s $AARPDIR/stopaarp $AATMADPT/stopaarp
ln -s $AARPDIR/aarpcnfg $AATMADPT/aarpcnfg
# ACC - set symbolic link to aarpd
ln -s $AARPDIR/aarpd $AATMADPT/aarpd
fi

# ACC -- copying aarpd to /usr/ADPT/aarp/bin
if [ "$aarp_ans" != "n" ]
then
cp $AARPDIR/aarpd /usr/ADPT/aarp/bin
fi

chmod u+x  $AARPDIR/startaarp $AARPDIR/stopaarp 
# chmod u+x /etc/startaarp /etc/stopaarp 
chmod u+x  $AATMADPT/startaarp $AATMADPT/stopaarp

# Making changes to configuration files only if ACIP 
# is to be installed. -ACC
if [ "$aarp_ans" != "n" ]
then

arch=`arch -k`
cp aarp.o /sys/$arch/OBJ

if [ -f /sys/$arch/conf/files -a -z "`grep aarp /sys/$arch/conf/files`" ]
then
	cat >> /sys/$arch/conf/files <<!
aarp/aarp.c         optional aarp
!
fi

if [ -f /sys/$arch/conf/AATM -a -z "`grep aarp /sys/$arch/conf/AATM`" ]
then
	cat >> /sys/$arch/conf/AATM <<!
pseudo-device	aarp 			# Classic IP ARP Server
!
fi

if [ -f /sys/sun/conf.c -a -z "`grep aarp /sys/sun/conf.c`" ]
then

awk '
/\/\*[0-9]*\*\// {
	lastmajor = substr($5, 3, length($5)-4);
}

/struct.*cdevsw/ {
	cdevsw = "yes"
	printf("#include \"aarp.h\"\n");
	printf("#if NAARP > 0\n");
	printf("extern struct streamtab aarp_stream_info;\n");
	printf("#define aarptab &aarp_stream_info\n");
	printf("#else\n");
	printf("#define aarptab 0\n");
	printf("#endif\n\n");
}

/}$/ {
	if ((cdevsw == "yes") && (added != "yes")) {
	printf("    },\n");
	printf("    {\n");
	printf("\tnodev,          nodev,          nodev,          nodev,          /*%d*/\n", lastmajor+1);
	printf("\tnodev,          nodev,          nodev,          0,\n");
	printf("\taarptab,        0,\n");
	added = "yes";
	}
}
	
/};/ {
	if ((cdevsw == "yes") && (added != "yes")) {
	printf("    {\n");
	printf("\tnodev,          nodev,          nodev,          nodev,          /*%d*/\n", lastmajor+1);
	printf("\tnodev,          nodev,          nodev,          0,\n");
	printf("\taarptab,        0,\n");
	printf("    }\n");
	added = "yes";
	}
}

{
	print $0;
}' /sys/sun/conf.c > /tmp/$$.install.aarp
mv /tmp/$$.install.aarp /sys/sun/conf.c

major=`awk '
/\/\*[0-9]*\*\// {
	lastmajor = substr($5, 3, length($5)-4);
}

END {
	print lastmajor
}' /sys/sun/conf.c`

rm /dev/aarp >/dev/null 2>&1
mknod /dev/aarp c 37 $major

fi

fi

# Making changes to configuration files only if AARP
# is to be installed. -ACC
fi

#
# add start up scripts to /etc/rc.local
#
if [ -z "`grep startaatm /etc/rc.local`" ]
then
	cat >> /etc/rc.local <<!

#
# ATM BASE Driver
#
echo
echo Not Starting Adaptec AATM NIC.
#if [ -f $AATMADPT/startaatm ]
#then
#	echo Starting AATM NIC.
#	$AATMADPT/startaatm
#fi
!
fi

if [ -d $AARPDIR ]
then

if [ -z "`grep startaarp /etc/rc.local`" ]
then
	cat >> /etc/rc.local <<!

#
# ATM ARP Server
#
echo Not Starting Adaptec ATM ARP Server.
#if [ -f $AATMADPT/startaarp ]
#then
#	echo Starting ATM ARP Server.
#	$AATMADPT/startaarp
#fi
!
fi

fi

if [ -z "`grep startacip /etc/rc.local`" ]
then
	cat >> /etc/rc.local <<!

#
# ATM Classical IP
#
echo Not Starting Adaptec ATM Classical IP.
#if [ -f $AATMADPT/startacip ]
#then
#	echo Starting ATM Classical IP.
#	$AATMADPT/startacip	
#fi
!
fi


if [ -z "`grep startalane /etc/rc.local`" ]
then
	cat >> /etc/rc.local <<!

#
# ATM LAN Emulation
#
echo Not Starting Adaptec ATM LAN Emulation 
#if [ -f $AATMADPT/startalane ]
#then
#	echo Starting ATM LAN Emulation.
#	$AATMADPT/startalane
#fi
!
fi

if [ -z "`grep aatmsnmpd /etc/rc.local`" ]
then
	cat >> /etc/rc.local <<!

#
# ATM SNMP Agent
#
echo Not Starting Adaptec ATM SNMP Agent.
#if [ -f $AATMADPT/aatmsnmpd ]
#then
#	echo Starting ATM SNMP Agent.
#	$AATMADPT/aatmsnmpd
#fi
!
fi

echo
echo "******** CONFIGURING KERNEL *********"
echo

$AATMDIR/make_kernel_aatm

