home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 1999 March B
/
SCO_CASTOR4RRT.iso
/
nwnet
/
root
/
usr
/
lib
/
netcfg
/
init
/
ipx
/
ipx~
Wrap
Text File
|
1998-08-19
|
6KB
|
235 lines
#!/bin/ksh
#
#
# Copyright (C) 1997, The Santa Cruz Operation, Inc.
# All Rights Reserved.
#
# The information in this file is provided for the exclusive use of
# the licensees of The Santa Cruz Operation, Inc. Such users have the
# right to use, modify, and incorporate this code into other products
# for purposes authorized by the license agreement provided they include
# this notice and the associated copyright notice with any such product.
# The information in this file is provided "AS IS" without warranty.
#
#ident "@(#)ipx 1.7"
#
: ${OK=0} ${FAIL=1} ${RELINK=2} ${CANCEL=3}
PATH=/bin:/usr/bin:/etc:/etc/conf/bin:/usr/sbin:"$PATH"
LOWER_PRD=$1
LOWER_IF=$2
UPPER_PRD=$3
UPPER_IF=$4
CONFIGURE=$5
IPX_NEWCFG=/usr/lib/ipxrt/tmp/config
IPX_TMPDIR=/usr/lib/ipxrt/tmp
NWCONFIG=/etc/netware/nwconfig
IPX_NETCONFIGDIR=/usr/lib/netcfg/bin
UPGRADE_CONFIG=${IPX_TMPDIR}/upgrade_config
NCFGPROMPTER=/usr/sbin/ncfgprompter
NWDISCOVER=/usr/sbin/nwdiscover
NETCFG=/usr/sbin/netcfg
STARTNPS=/usr/sbin/startnps
TCP=tcp
IPXCHK=$IPX_NETCONFIGDIR/ipx.chk
NWCM=/usr/sbin/nwcm
if [ ! -d $IPX_TMPDIR ]
then
mkdir -p $IPX_TMPDIR
chmod 755 $IPX_TMPDIR
fi
. $IPX_NETCONFIGDIR/ipx.sh
# Shell Variables from lli Driver
#------------------------------------------------------------------------
# NODE - Required to create chain
# UNITS - Optional, only usable if the lli driver supports the MACUNITSEL
# ioctl.
#------------------------------------------------------------------------
tmp=$IPX_TMPDIR/ipx$$
##############################################################################
#
# Generate config data based on saved ISL info.
#
get_isl_config() {
. /isl/ifile
if [ "${LOWER_PRD}" = "${TCP}" ]
then
adapter=/dev/nwip
else
adapter=$_adapter
fi
#
# check for request to autodetect and if so do it
# If AUTO_DISCOVERY is set then try and find any active frame
# type and network number.
# If a frame type is set but no network number, try
# and find an activer network on that frame type
# If its an NWIP configuration then try and run nwdiscover
# on that irrespective of frame type.
if [ $IPX_FRAME_TYPE = "AUTO_DISCOVER" -o $IPX_NETWORK_NUMBER -eq 0 ]
then
if [ $IPX_FRAME_TYPE = "AUTO_DISCOVER" -o $adapter = "/dev/nwip" ]
then
set `$NWDISCOVER -d $adapter 2>/dev/null` > /dev/null 2>&1
else
set `$NWDISCOVER -d $adapter -f$IPX_FRAME_TYPE 2>/dev/null` > /dev/null 2>&1
fi
if [ $? -eq 0 -a "$3" != "" ]
then
IPX_FRAME_TYPE=$3
IPX_NETWORK_NUMBER=0x$9
else
# autodiscovery failed
# set sensible values
IPX_FRAME_TYPE=ETHERNET_802.2
IPX_NETWORK_NUMBER=0xb0b0b0b0
fi
fi
/* ensure that the network number is acceptible
* to nwcm
*/
IPX_NETWORK_NUMBER=`echo $IPX_NETWORK_NUMBER | sed -e "s/0[xX]//" -e "s/^/0x/" `
echo lan_1_adapter=$adapter > $IPX_NEWCFG
echo lan_1_network=$IPX_NETWORK_NUMBER >> $IPX_NEWCFG
echo lan_1_frame_type=$IPX_FRAME_TYPE >> $IPX_NEWCFG
echo ipx_start_at_boot=on >> $IPX_NEWCFG
}
##############################################################################
#
# main()
#
$IPXCHK
trap "cleanup $FAIL" 1 2 3 15
# Check to see if chain is already configured, if so do nothing.
#
$NETCFG -s | grep "ipx#$LOWER_PRD" > /dev/null 2>&1 && cleanup $OK
save_config
# netcfg sets $CONFIGURE to "Y" if this is the first ipx to be
# installed.
if [ "${CONFIGURE}" = "Y" ] ; then
# Set up environment variables required for the prompter backend.
_ncfg_state="INITIAL_INIT"
$NWCM -s ipx_start_at_boot=on >/dev/null 2>&1
else
if [ "${LOWER_PRD}" = "-" ] ; then
# A product above us (ie. NUC) has just been installed.
# We have nothing to do in this case, so just return.
cleanup $OK
fi
# Check if the maximum number of IPX chains will be exceeded.
#
set -- `$NETCFG -s | fgrep '^ipx' | wc`
if [ "$2" -gt 8 ] ; then
echo "Cannot add additional lans: IPX/SPX allows a maximum of 8 lans"
cleanup $FAIL
fi
# Check if this is nwip being installed. When installed
# it runs over all NICS configured for tcp so only allow
# one install over tcp
#
if [ "${LOWER_PRD}" = "${TCP}" ] ; then
set -- `$NETCFG -s | fgrep '^ipx#${TCP}' | wc`
if [ "$2" -ne 0 ] ; then
cleanup $OK
fi
fi
# configuring a new LAN.
_ncfg_state="INIT"
fi
_adapter=/dev/$LOWER_PRD
configfile=${tmp}ipx.out
#
# Get variables from ifile when we're in the post-reboot
# stage of an installation.
#
# Convert it to a form which can be used by ipx.uc; otherwise, invoke the
# netcfg prompter to interactively query the user. Place the output
# of this operation in $configfile.
#
if [ -f /isl/ifile -a -f /etc/rc2.d/S02POSTINST ]
then
get_isl_config
else
get_adapter_info
$NCFGPROMPTER ${IPX_NETCONFIGDIR}/ipxBE \
$_ncfg_state \
$_adapter \
"$_media_types" \
$_interface \
> $configfile
case $? in
0)
;;
1)
echo "Error in ${IPX_NETCONFIGDIR}/ipxBE"
cleanup $FAIL
;;
3)
if [ "${CONFIGURE}" = "Y" ] ; then
$NWCM -s ipx_start_at_boot=off >/dev/null 2>&1
fi
cleanup $CANCEL
;;
*)
if [ "${CONFIGURE}" = "Y" ] ; then
$NWCM -s ipx_start_at_boot=off >/dev/null 2>&1
fi
cleanup $FAIL
;;
esac
fi
#
# Update /etc/netware/nwconfig with the attributes found in the $configfile
#
$IPX_NETCONFIGDIR/ipx.uc $configfile $_ncfg_state $_adapter $_interface
UC_RET=$?
#
# If this is the first install try and start the stack
#
if [ "${_ncfg_state}" = "INITIAL_INIT" -a ! -f /etc/rc2.d/S02POSTINST ]
then
$STARTNPS >/dev/null 2>&1
if [ $? -eq 0 ]
then
cleanup $OK
fi
fi
cleanup $UC_RET