summaryrefslogtreecommitdiff
path: root/bin
Side-by-side diff
Diffstat (limited to 'bin') (more/less context) (show whitespace changes)
-rwxr-xr-xbin/NS2SetMac.sh16
1 files changed, 14 insertions, 2 deletions
diff --git a/bin/NS2SetMac.sh b/bin/NS2SetMac.sh
index 51810ae..e6111c7 100755
--- a/bin/NS2SetMac.sh
+++ b/bin/NS2SetMac.sh
@@ -1,3 +1,7 @@
-# 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
@@ -12,5 +16,9 @@ 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
@@ -18,5 +26,9 @@ else
X=${X#*HWaddr } # strip till HWaddr
X=${X%% *} # remove trailing spaces
+ if [ ! -z "$X" ]
+ then
+ # valid mac address
echo ${X} > ${NS2MacStore}/$1.mac
fi
+fi
exit 0