#!/bin/sh class=ether . /etc/obj/generic # >>> rcs_revision, rcs_author and rcs_date removed from here, as CVS # >>> was messing them up. For the record they would have been # >>> 1.5, gdmr and 2001/06/13 11:21:40 respectively. See also the # >>> history at the end of this file. ########################################################################## # ether configuration object ########################################################################## changefile=/var/obj/tmp/ether.changes ########################################################################## Start() { ########################################################################## Generic_Start; LoadResources debug cleanlog_freq cleanlog_zap setaddrs OverrideResources [ "$debug" ] && Debug start if [ "$setaddrs" ] ; then # First take care of the eeprom settings. This covers # newer interface cards. eeprom_mode=`eeprom 'local-mac-address?' | awk -F= '{print $2}'` if [ "$eeprom_mode" = "true" ] ; then [ "$debug" ] && Debug "'local-mac-address?' is OK" else Info "Setting eeprom 'local-mac-address?'" eeprom 'local-mac-address?=true' echo "eeprom 'local-mac-address?' setting changed" \ > $changefile fi # Now check the interfaces. We only need to look at # old-style le and qe ones, as new-style ones (hme) # are already covered above. Only to do anything if # there's more than one of them. Those odd-looking # echo statements are there to lose spaces and newlines. ifList=`ifconfig -a | egrep "^qe|^le" | sed -e 's/: .*//'` ifList=`echo $ifList` [ "$debug" ] && Debug "ifList: $ifList" ResWriteList="$ResWriteList ifList" if [ "$ifList" != "" ] ; then for i in $ifList ; do [ "$debug" ] && Debug "Set addr for $i" ifAddr=`ifconfig $i | \ egrep "inet" | \ awk '{print $2}'` hasEther=`ifconfig $i | egrep "ether"` if [ "$hasEther" ] ; then ethAddr=`echo $ifAddr | awk -F. \ '{printf "2:0:%x:%x:%x:%x", \ $1, $2, $3, $4}'` if [ "$notTheFirst" ] ; then Info "$i: $ethAddr" ifconfig $i ether $ethAddr else [ "$debug" ] && \ Debug "Skip first: $i" notTheFirst="yes" fi else Info "$i: virtual interface" fi done ; fi fi WriteResources debug cleanlog_freq cleanlog_zap setaddrs ifList if [ "$debug" ]; then ReadResources ShowResources DEBUG $reslist fi OK "$start_type" exit 0 } ########################################################################### Doc() { ########################################################################### # # Print documentation # sed 's/^/[DOC] '$obj': /' <<-EOF This object sets the machine's ether MAC addresses to unique values. hme and qfe are handled by telling the eeprom to do the right thing. If there are multiple le and qe interfaces then the object explicitly sets them. EOF Generic_Doc; OK "doc"; } ########################################################################### # Process the methods ########################################################################### DoMethod "$@" ########################################################################### # # $Log: old-ether-object.txt,v $ # Revision 1.2 2019/03/20 15:52:10 gdmr # rcs fixup # # Revision 1.1 2019/03/20 15:41:05 gdmr # Add to CVS # # Revision 1.5 2001/06/13 11:21:40 gdmr # Excise ifN # # Revision 1.4 2001/06/13 11:17:43 gdmr # Unconditionally scan all "old" interfaces, but skip setting the first # # Revision 1.3 2000/05/24 09:45:50 gdmr # Define changefile # # Revision 1.2 2000/05/19 12:55:01 gdmr # RCS tidy # # Revision 1.1 2000/05/19 12:24:05 gdmr # Initial revision # #