From d48cc50e9e56fac2d6cad6cf13cf37746014441a Mon Sep 17 00:00:00 2001 From: caoyuan Date: Tue, 13 Sep 2016 23:40:01 +0800 Subject: [PATCH] Use "type" to take place of "which" and update the output When run tools/init-runonce without some client installed,it's retrun not friendly and confuse people,such as user does not install python-openstackclient, it will return "openstack not installed".This patch update it. Use "type" command to avoid "which" TrivialFix Change-Id: I53789a767b3a2727bf2cb848c2881272e313e14c --- tools/init-runonce | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tools/init-runonce b/tools/init-runonce index ffd6dd87ec..054386c689 100755 --- a/tools/init-runonce +++ b/tools/init-runonce @@ -12,10 +12,14 @@ unset LANGUAGE LC_ALL=C export LC_ALL for i in curl nova neutron openstack; do - if [[ ! $(which $i) ]]; then - echo "$i not installed. Please install $i before proceeding" - exit 1 - fi + if [[ ! $(type $i 2>/dev/null) ]]; then + if [ "$i" == 'curl' ]; then + echo "$i not installed. Please install $i before proceeding" + else + echo "python-${i}client not installed. Please install python-${i}client before proceeding" + fi + exit + fi done # Move to top level directory REAL_PATH=$(python -c "import os,sys;print os.path.realpath('$0')")