|
Harald Hoyer |
2d3fda |
From e7dc1e42cdf519c20c9f104153ef778462fcdbd9 Mon Sep 17 00:00:00 2001
|
|
Harald Hoyer |
2d3fda |
From: Harald Hoyer <harald@redhat.com>
|
|
Harald Hoyer |
2d3fda |
Date: Thu, 5 Jul 2012 12:54:13 +0200
|
|
Harald Hoyer |
2d3fda |
Subject: [PATCH] network: factor out parse_ifname_opts() for ifname-genrules
|
|
Harald Hoyer |
2d3fda |
|
|
Harald Hoyer |
2d3fda |
---
|
|
Harald Hoyer |
2d3fda |
modules.d/40network/ifname-genrules.sh | 2 ++
|
|
Harald Hoyer |
2d3fda |
modules.d/40network/net-lib.sh | 16 ++++++++++++++++
|
|
Harald Hoyer |
2d3fda |
modules.d/40network/parse-ifname.sh | 16 +---------------
|
|
Harald Hoyer |
2d3fda |
3 files changed, 19 insertions(+), 15 deletions(-)
|
|
Harald Hoyer |
2d3fda |
|
|
Harald Hoyer |
2d3fda |
diff --git a/modules.d/40network/ifname-genrules.sh b/modules.d/40network/ifname-genrules.sh
|
|
Harald Hoyer |
2d3fda |
index e188c88..b0b429c 100755
|
|
Harald Hoyer |
2d3fda |
--- a/modules.d/40network/ifname-genrules.sh
|
|
Harald Hoyer |
2d3fda |
+++ b/modules.d/40network/ifname-genrules.sh
|
|
Harald Hoyer |
2d3fda |
@@ -7,6 +7,8 @@ if ! getarg ifname= >/dev/null ; then
|
|
Harald Hoyer |
2d3fda |
return
|
|
Harald Hoyer |
2d3fda |
fi
|
|
Harald Hoyer |
2d3fda |
|
|
Harald Hoyer |
2d3fda |
+command -v parse_ifname_opts >/dev/null || . /lib/net-lib.sh
|
|
Harald Hoyer |
2d3fda |
+
|
|
Harald Hoyer |
2d3fda |
{
|
|
Harald Hoyer |
2d3fda |
for p in $(getargs ifname=); do
|
|
Harald Hoyer |
2d3fda |
parse_ifname_opts $p
|
|
Harald Hoyer |
2d3fda |
diff --git a/modules.d/40network/net-lib.sh b/modules.d/40network/net-lib.sh
|
|
Harald Hoyer |
2d3fda |
index 9132e4d..9a1e004 100644
|
|
Harald Hoyer |
2d3fda |
--- a/modules.d/40network/net-lib.sh
|
|
Harald Hoyer |
2d3fda |
+++ b/modules.d/40network/net-lib.sh
|
|
Harald Hoyer |
2d3fda |
@@ -289,3 +289,19 @@ ip_to_var() {
|
|
Harald Hoyer |
2d3fda |
esac
|
|
Harald Hoyer |
2d3fda |
fi
|
|
Harald Hoyer |
2d3fda |
}
|
|
Harald Hoyer |
2d3fda |
+
|
|
Harald Hoyer |
2d3fda |
+parse_ifname_opts() {
|
|
Harald Hoyer |
2d3fda |
+ local IFS=:
|
|
Harald Hoyer |
2d3fda |
+ set $1
|
|
Harald Hoyer |
2d3fda |
+
|
|
Harald Hoyer |
2d3fda |
+ case $# in
|
|
Harald Hoyer |
2d3fda |
+ 7)
|
|
Harald Hoyer |
2d3fda |
+ ifname_if=$1
|
|
Harald Hoyer |
2d3fda |
+ # udev requires MAC addresses to be lower case
|
|
Harald Hoyer |
2d3fda |
+ ifname_mac=$(echo $2:$3:$4:$5:$6:$7 | sed 'y/ABCDEF/abcdef/')
|
|
Harald Hoyer |
2d3fda |
+ ;;
|
|
Harald Hoyer |
2d3fda |
+ *)
|
|
Harald Hoyer |
2d3fda |
+ die "Invalid arguments for ifname="
|
|
Harald Hoyer |
2d3fda |
+ ;;
|
|
Harald Hoyer |
2d3fda |
+ esac
|
|
Harald Hoyer |
2d3fda |
+}
|
|
Harald Hoyer |
2d3fda |
diff --git a/modules.d/40network/parse-ifname.sh b/modules.d/40network/parse-ifname.sh
|
|
Harald Hoyer |
2d3fda |
index ce73a72..d5156b3 100755
|
|
Harald Hoyer |
2d3fda |
--- a/modules.d/40network/parse-ifname.sh
|
|
Harald Hoyer |
2d3fda |
+++ b/modules.d/40network/parse-ifname.sh
|
|
Harald Hoyer |
2d3fda |
@@ -18,21 +18,7 @@ if ! getarg ifname= >/dev/null ; then
|
|
Harald Hoyer |
2d3fda |
return
|
|
Harald Hoyer |
2d3fda |
fi
|
|
Harald Hoyer |
2d3fda |
|
|
Harald Hoyer |
2d3fda |
-parse_ifname_opts() {
|
|
Harald Hoyer |
2d3fda |
- local IFS=:
|
|
Harald Hoyer |
2d3fda |
- set $1
|
|
Harald Hoyer |
2d3fda |
-
|
|
Harald Hoyer |
2d3fda |
- case $# in
|
|
Harald Hoyer |
2d3fda |
- 7)
|
|
Harald Hoyer |
2d3fda |
- ifname_if=$1
|
|
Harald Hoyer |
2d3fda |
- # udev requires MAC addresses to be lower case
|
|
Harald Hoyer |
2d3fda |
- ifname_mac=$(echo $2:$3:$4:$5:$6:$7 | sed 'y/ABCDEF/abcdef/')
|
|
Harald Hoyer |
2d3fda |
- ;;
|
|
Harald Hoyer |
2d3fda |
- *)
|
|
Harald Hoyer |
2d3fda |
- die "Invalid arguments for ifname="
|
|
Harald Hoyer |
2d3fda |
- ;;
|
|
Harald Hoyer |
2d3fda |
- esac
|
|
Harald Hoyer |
2d3fda |
-}
|
|
Harald Hoyer |
2d3fda |
+command -v parse_ifname_opts >/dev/null || . /lib/net-lib.sh
|
|
Harald Hoyer |
2d3fda |
|
|
Harald Hoyer |
2d3fda |
# Check ifname= lines
|
|
Harald Hoyer |
2d3fda |
for p in $(getargs ifname=); do
|