ovs-docker: Use a different mechanism to check for commands.
authorGurucharan Shetty <gshetty@nicira.com>
Mon, 23 Feb 2015 05:52:04 +0000 (21:52 -0800)
committerGurucharan Shetty <gshetty@nicira.com>
Mon, 23 Feb 2015 17:18:00 +0000 (09:18 -0800)
Currently, the script uses '--version' option from different commands
to check for their availability. uuidgen on Centos6 has been reported
not to have the '--version' option causing failure in script invocation.

This commit looks for the utilities in $PATH instead. The code is
copied from build-aux/dist-docs.

Reported-by: Michael J. Smalley <michaeljsmalley@gmail.com>
Suggested-by: Ben Pfaff <blp@nicira.com>
Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
AUTHORS
utilities/ovs-docker

diff --git a/AUTHORS b/AUTHORS
index c85ecd4..6a54e8e 100644 (file)
--- a/AUTHORS
+++ b/AUTHORS
@@ -286,6 +286,7 @@ Maxime Brun             m.brun@alphalink.fr
 Madhu Venugopal         mavenugo@gmail.com
 Michael A. Collins      mike.a.collins@ark-net.org
 Michael Hu              mhu@nicira.com
+Michael J. Smalley      michaeljsmalley@gmail.com
 Michael Mao             mmao@nicira.com
 Michael Shigorin        mike@osdn.org.ua
 Mihir Gangar            gangarm@vmware.com
index 48908b1..099ba31 100755 (executable)
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-check_command_avail () {
-    while [ $# -ne 0 ]; do
-        if ("$1" --version) > /dev/null 2>&1; then :; else
-            echo >&2 "$UTIL: missing $1, cannot proceed"
-            exit 1
+# Check for programs we'll need.
+search_path () {
+    save_IFS=$IFS
+    IFS=:
+    for dir in $PATH; do
+        IFS=$save_IFS
+        if test -x "$dir/$1"; then
+            return 0
         fi
-        shift
     done
+    IFS=$save_IFS
+    echo >&2 "$0: $1 not found in \$PATH, please install and try again"
+    exit 1
 }
 
 ovs_vsctl () {
@@ -201,7 +206,9 @@ EOF
 }
 
 UTIL=$(basename $0)
-check_command_avail ovs-vsctl docker uuidgen
+search_path ovs-vsctl
+search_path docker
+search_path uuidgen
 
 if (ip netns) > /dev/null 2>&1; then :; else
     echo >&2 "$UTIL: ip utility not found (or it does not support netns),"\