summaryrefslogtreecommitdiff
path: root/scripts/runqemu-ifup
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2011-09-01 22:04:48 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2011-09-02 14:20:32 +0100
commit6b5706d1f9ce7a3fd4d8f819ff8f3fd789665647 (patch)
tree436599b7eda0bd343518cfcc81e72976dc16444e /scripts/runqemu-ifup
parent06625096f897235ed85f0d9a1355497f92938454 (diff)
downloadopenembedded-core-6b5706d1f9ce7a3fd4d8f819ff8f3fd789665647.tar.gz
openembedded-core-6b5706d1f9ce7a3fd4d8f819ff8f3fd789665647.tar.bz2
openembedded-core-6b5706d1f9ce7a3fd4d8f819ff8f3fd789665647.zip
scripts: Show sensible warning messages if expected binaries don't exist
[YOCTO #1438] Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/runqemu-ifup')
-rwxr-xr-xscripts/runqemu-ifup22
1 files changed, 17 insertions, 5 deletions
diff --git a/scripts/runqemu-ifup b/scripts/runqemu-ifup
index 987a37a1a7..870cb6bcb7 100755
--- a/scripts/runqemu-ifup
+++ b/scripts/runqemu-ifup
@@ -69,12 +69,29 @@ if [ "x$IFCONFIG" = "x" ]; then
# better than nothing...
IFCONFIG=/sbin/ifconfig
fi
+if [ ! -x "$IFCONFIG" ]; then
+ echo "$IFCONFIG cannot be executed"
+ exit 1
+fi
ROUTE=`which route`
if [ "x$ROUTE" = "x" ]; then
# better than nothing...
ROUTE=/sbin/route
fi
+if [ ! -x "$ROUTE" ]; then
+ echo "$ROUTE cannot be executed"
+ exit 1
+fi
+
+IPTABLES=`which iptables 2> /dev/null`
+if [ "x$IPTABLES" = "x" ]; then
+ IPTABLES=/sbin/iptables
+fi
+if [ ! -x "$IPTABLES" ]; then
+ echo "$IPTABLES cannot be executed"
+ exit 1
+fi
n=$[ (`echo $TAP | sed 's/tap//'` * 2) + 1 ]
$IFCONFIG $TAP 192.168.7.$n
@@ -83,11 +100,6 @@ dest=$[ (`echo $TAP | sed 's/tap//'` * 2) + 2 ]
$ROUTE add -host 192.168.7.$dest $TAP
# setup NAT for tap0 interface to have internet access in QEMU
-IPTABLES=`which iptables`
-if [ "x$IPTABLES" = "x" ]; then
- IPTABLES=/sbin/iptables
-fi
-
$IPTABLES -A POSTROUTING -t nat -j MASQUERADE -s 192.168.7.0/24
echo 1 > /proc/sys/net/ipv4/ip_forward
$IPTABLES -P FORWARD ACCEPT