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
This commit is contained in:
caoyuan 2016-09-13 23:40:01 +08:00
parent 0d28b311eb
commit d48cc50e9e

View File

@ -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')")