home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 1999 March B
/
SCO_CASTOR4RRT.iso
/
nwnet
/
root
/
usr
/
lib
/
netcfg
/
bin
/
ipx.uc
/
ipx
Wrap
Text File
|
1998-08-19
|
5KB
|
200 lines
#!/bin/tcl
#
#
# 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.uc 1.5"
#
# This file is used to update the netware configuration
#cmdtrace on [ open "/tmp/ipxuc.log" a+ ]
# Global constants:
set OK 0
set FAIL 1
set RELINK 2
set CANCEL 3
set REBOOT 2
set configFile "/etc/netware/nwconfig"
#
# file containing nwcm commands to update the configuration
#
set IPX_NEWCFG "/usr/lib/ipxrt/tmp/config"
set NWCM "/usr/sbin/nwcm.be"
set NETINFO "/usr/sbin/netinfo"
set NETCONFIG "/etc/netconfig"
set TCP tcp
set IPX_TMPDIR "/usr/lib/ipxrt/tmp"
source /usr/lib/netcfg/bin/ipx.fn
# main Main MAIN
global attrFile ncfgState adapter interface dbg dbgfd
loadlibindex /usr/lib/sysadm.tlib
set attrFile [lindex $argv 0]
set ncfgState [lindex $argv 1]
set adapter [lindex $argv 2]
if [ cequal $adapter "/dev/${TCP}" ] {
set adapter /dev/nwip
}
set interface [lindex $argv 3]
exec cp $configFile $IPX_TMPDIR
set dbg 0
if {$dbg} then {
if {[set dbgfd [open "/tmp/ipxuc.dbg" w]] == -1} then {
set dbg 0
}
}
switch $ncfgState {
INITIAL_INIT -
INIT -
RECONF {
#
# someone wants the netware config updated
# all netware parameters involved are in
# the IPX_NEWCFG file
#
if { [set config_fd [open $IPX_NEWCFG r]] == -1 } {
return "ERROR cannot open file $IPX_NEWCFG for reading"
}
if [ cequal $adapter "/dev/nwip" ] {
if [catch {exec $NETINFO -a -d nwip -p inet} ret] {
puts "netinfo error:"
puts $ret
exit $FAIL
}
}
#
# Some default nwcm values cannot be set directly and
# have to be set using the -r option to nwcm.
# If Setting a value fails its probably a good idea
# to set it to the default anyway - so do it.
#
while { [ gets $config_fd line ] != -1 } {
if [catch {exec $NWCM -s $line} ret] {
#puts "nwcm error:$NWCM $line"
#puts $ret
#puts "setting to default"
#
# get the parameter from the line
#
set splitline [split $line = ]
set param [lindex $splitline 0 ]
if [catch {exec $NWCM -r $param} ret] {
puts "nwcm error:$NWCM $line"
puts $ret
}
}
}
close $config_fd
exec rm $IPX_NEWCFG
}
REMOVE {
#
# the remove script has been called
# simply remove the network configured
# over the interface.
#
# XXX If this is the only interface configured
# and ipx_auto_discovery is set you maybe want to
# warn the user that rebooting the system is
# likely to reconfigure the card
#
#
# Repeatedly remove any ipx's configured over
# the card since several ipx lan's can be
# configured over one NIC.
#
set resetPParams { \
adapter \
network \
rip_ageout_intervals \
frame_type \
}
while {[set number [FindIpxLanNumber adapter $adapter] ]} {
foreach pp $resetPParams {
if [catch {exec $NWCM -r lan_${number}_$pp } ret] {
puts "nwcm error:$NWCM $line"
puts $ret
}
}
}
#
# reset to default any of the other parameters which
# might have been modified so that if the number
# gets re-used then we don't acquire old values
#
# remove the netinfo entry for the nwip driver
if [ cequal $adapter "/dev/nwip" ] {
if [catch {exec $NETINFO -r -d nwip} ret] {
puts "netinfo error:"
puts $ret
exit $FAIL
}
}
}
default {
echo "ipx.uc:unknown command" $ncfgState
exit $FAIL
}
}
if [ catch {exec diff $configFile $IPX_TMPDIR/nwconfig} ret ] {
#
# things have changed - suggest a reboot
#
# check to see if we want netconfig entries present or not
#
catch {exec $NWCM -v "ipx_start_at_boot"} ret
if [ cequal $ret "ipx_start_at_boot=off" ] {
exec grep -v "^\[is\]px " $NETCONFIG > $IPX_TMPDIR/netconfig
exec mv $IPX_TMPDIR/netconfig $NETCONFIG
} else {
if [ catch { exec grep "^\[is\]px " $NETCONFIG } ret ] {
exec echo "spx tpi_cots_ord v netware spx /dev/nspx2 /usr/lib/novell.so\nipx tpi_clts v netware ipx /dev/ipx /usr/lib/novell.so" >> $NETCONFIG
}
}
exec rm $IPX_TMPDIR/nwconfig
exit $REBOOT
}
exec rm $IPX_TMPDIR/nwconfig
exit $OK