From d1a84c9f3d387bfeaeaa0007dda8d90164633255 Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Thu, 1 Sep 2011 22:04:48 +0100 Subject: scripts: Show sensible warning messages if expected binaries don't exist [YOCTO #1438] (From OE-Core rev: 6b5706d1f9ce7a3fd4d8f819ff8f3fd789665647) Signed-off-by: Richard Purdie --- scripts/runqemu-ifup | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) (limited to 'scripts/runqemu-ifup') 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 -- cgit v1.2.3-54-g00ecf