summaryrefslogtreecommitdiff
authorwimpie <wimpie>2005-01-12 15:46:19 (UTC)
committer wimpie <wimpie>2005-01-12 15:46:19 (UTC)
commit8de401df8b396877a47cccb191098ce43bea4e0e (patch) (side-by-side diff)
tree36d83b0b4b27c7aedfadfcd66ac93ddab11ad970
parent551fd59bc878f0f95aac939a5a9fdedd14707d17 (diff)
downloadopie-8de401df8b396877a47cccb191098ce43bea4e0e.zip
opie-8de401df8b396877a47cccb191098ce43bea4e0e.tar.gz
opie-8de401df8b396877a47cccb191098ce43bea4e0e.tar.bz2
Script to set mac address
Diffstat (more/less context) (ignore whitespace changes)
-rwxr-xr-xbin/NS2SetMac.sh22
1 files changed, 17 insertions, 5 deletions
diff --git a/bin/NS2SetMac.sh b/bin/NS2SetMac.sh
index 51810ae..e6111c7 100755
--- a/bin/NS2SetMac.sh
+++ b/bin/NS2SetMac.sh
@@ -1,2 +1,6 @@
-# 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
@@ -6,3 +10,3 @@ NS2MacStore=/etc/NS2
if [ -z "$1" ]
-then
+then
exit 0
@@ -10,6 +14,10 @@ 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
@@ -19,3 +27,7 @@ else
X=${X%% *} # remove trailing spaces
- echo ${X} > ${NS2MacStore}/$1.mac
+ if [ ! -z "$X" ]
+ then
+ # valid mac address
+ echo ${X} > ${NS2MacStore}/$1.mac
+ fi
fi