[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] Change uses of \s within sed regexps -- some versions of sed do not support this



# HG changeset patch
# User emellor@xxxxxxxxxxxxxxxxxxxxxx
# Node ID a20a9ec0e51095738b175eb146e41592caf3b51f
# Parent  c5ee3b6f25b3edc4780a919a918648adfbc62585
Change uses of \s within sed regexps -- some versions of sed do not support this
escape.

Allow the vif-nat and vif-route scripts to have netdev specified, rather than
hard-coding eth0.

Signed-off-by: Ewan Mellor <ewan@xxxxxxxxxxxxx>

diff -r c5ee3b6f25b3 -r a20a9ec0e510 tools/examples/README.incompatibilities
--- a/tools/examples/README.incompatibilities   Mon Nov 28 01:47:28 2005
+++ b/tools/examples/README.incompatibilities   Mon Nov 28 11:05:07 2005
@@ -23,3 +23,9 @@
 Gentoo doesn't have ifup/ifdown; appropriate alternatives are defined in
 xen-network-common.sh.
 
+
+sed
+---
+
+\s is not supported in regexps on Debian etch (sed 4.1.2), Ubuntu 4.10.  We
+hand-craft character classes instead.
diff -r c5ee3b6f25b3 -r a20a9ec0e510 tools/examples/vif-common.sh
--- a/tools/examples/vif-common.sh      Mon Nov 28 01:47:28 2005
+++ b/tools/examples/vif-common.sh      Mon Nov 28 11:05:07 2005
@@ -103,3 +103,37 @@
       frob_iptable
   fi
 }
+
+
+##
+# ip_of interface
+#
+# Print the IP address currently in use at the given interface, or nothing if
+# the interface is not up.
+#
+function ip_of()
+{
+  ip addr show "$1" | sed -n 's/^.*inet \([0-9.]*\).*$/\1/p'
+}
+
+
+##
+# dom0_ip
+#
+# Print the IP address of the interface in dom0 through which we are routing.
+# This is the IP address on the interface specified as "netdev" as a parameter
+# to these scripts, or eth0 by default.  This function will call fatal if no
+# such interface could be found.
+#
+function dom0_ip()
+{
+  local nd=${netdev:-eth0}
+  local result=$(ip_of "$nd")
+  if [ -z "$result" ]
+  then
+      fatal
+"$netdev is not up.  Bring it up or specify another interface with " \
+"netdev=<if> as a parameter to $0."
+  fi
+  echo "$result"
+}
diff -r c5ee3b6f25b3 -r a20a9ec0e510 tools/examples/vif-nat
--- a/tools/examples/vif-nat    Mon Nov 28 01:47:28 2005
+++ b/tools/examples/vif-nat    Mon Nov 28 11:05:07 2005
@@ -37,7 +37,7 @@
 netmask=$netmask.$(( (($intmask & 0x0000FF00)) >> 8 ))
 netmask=$netmask.$(( $intmask & 0x000000FF ))
 
-main_ip=$(ip addr show eth0 | sed -e '/inet /!d;s/^.*inet \([^\s*]\)\s.*$/\1/')
+main_ip=$(dom0_ip)
 
 case "$command" in
     online)
diff -r c5ee3b6f25b3 -r a20a9ec0e510 tools/examples/vif-route
--- a/tools/examples/vif-route  Mon Nov 28 01:47:28 2005
+++ b/tools/examples/vif-route  Mon Nov 28 11:05:07 2005
@@ -23,7 +23,7 @@
 dir=$(dirname "$0")
 . "$dir/vif-common.sh"
 
-main_ip=$(ip addr show eth0 | sed -e '/inet /!d;s/^.*inet \([^\s*]\)\s.*$/\1/')
+main_ip=$(dom0_ip)
 
 case "$command" in
     online)

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.