From 8de401df8b396877a47cccb191098ce43bea4e0e Mon Sep 17 00:00:00 2001 From: wimpie Date: Wed, 12 Jan 2005 15:46:19 +0000 Subject: Script to set mac address --- (limited to 'bin') diff --git a/bin/NS2SetMac.sh b/bin/NS2SetMac.sh index 51810ae..e6111c7 100755 --- a/bin/NS2SetMac.sh +++ b/bin/NS2SetMac.sh @@ -1,22 +1,34 @@ -# store/set MAC address for given interface +# this script is part of networksettings2 package +# purpose : set fixed MAC address for network devices that +# have random addresses (like usb) +# + NS2MacStore=/etc/NS2 [ ! -d ${NS2MacStore} ] && mkdir ${NS2MacStore} if [ -z "$1" ] -then +then exit 0 fi -if [ -f ${NS2MacStore}/$1.mac ] +if [ -f ${NS2MacStore}/$1.mac ] then # set this mac - /sbin/ifconfig $1 hw ether `cat ${NS2MacStore}/$1.mac` + X=`cat ${NS2MacStore}/$1.mac` + if [ ! -z "$X" ] + then + /sbin/ifconfig $1 hw ether $X + fi else # remember current mac for all times X=`/sbin/ifconfig $1 | grep HWaddr` X=${X#*HWaddr } # strip till HWaddr X=${X%% *} # remove trailing spaces - echo ${X} > ${NS2MacStore}/$1.mac + if [ ! -z "$X" ] + then + # valid mac address + echo ${X} > ${NS2MacStore}/$1.mac + fi fi exit 0 -- cgit v0.9.0.2