Commit 169bf5e0 by Dwight Engen Committed by Stéphane Graber

use which instead of type

This is for consistency with the rest of lxc, and also because type checks for shell builtins, a behavior that we do not want in these cases. Ensure stderr for which is redirected to /dev/null also. Signed-off-by: 's avatarDwight Engen <dwight.engen@oracle.com> Acked-by: 's avatarSerge E. Hallyn <serge.hallyn@ubuntu.com> Acked-by: 's avatarStéphane Graber <stgraber@ubuntu.com>
parent 2b0e17e4
......@@ -197,7 +197,7 @@ lxc-info -n $lxc_orig --state-is RUNNING || container_running=False
sed -i '/lxc.rootfs/d' $lxc_path/$lxc_new/config
if [ -b $oldroot ]; then
which vgscan >/dev/null || { echo "$(basename $0): lvm is not installed" >&2; false; }
which vgscan >/dev/null 2>&1 || { echo "$(basename $0): lvm is not installed" >&2; false; }
lvdisplay $oldroot > /dev/null 2>&1 || { echo "$(basename $0): non-lvm blockdev cloning is not supported" >&2; false; }
lvm=TRUE
# ok, create a snapshot of the lvm device
......
......@@ -222,7 +222,7 @@ if [ "$backingstore" = "_unset" ] || [ "$backingstore" = "btrfs" ]; then
fi
if [ "$backingstore" = "lvm" ]; then
which vgscan > /dev/null
which vgscan > /dev/null 2>&1
if [ $? -ne 0 ]; then
echo "$(basename $0): vgscan not found (is lvm2 installed?)" >&2
exit 1
......
......@@ -108,8 +108,8 @@ if [ "$(id -u)" != "0" ]; then
exit 1
fi
which lxc-info > /dev/null || { echo "lxc-info not found."; exit 1; }
which lxc-wait > /dev/null || { echo "lxc-wait not found."; exit 1; }
which lxc-info > /dev/null 2>&1 || { echo "lxc-info not found."; exit 1; }
which lxc-wait > /dev/null 2>&1 || { echo "lxc-wait not found."; exit 1; }
pid=`lxc-info -n $lxc_name -p 2>/dev/null | awk '{ print $2 }'`
if [ "$pid" = "-1" ]; then
......
......@@ -153,7 +153,7 @@ configure_busybox()
{
rootfs=$1
type busybox >/dev/null
which busybox >/dev/null 2>&1
if [ $? -ne 0 ]; then
echo "busybox executable is not accessible"
......@@ -194,7 +194,7 @@ configure_busybox()
# add ssh functionality if dropbear package available on host
type dropbear >/dev/null
which dropbear >/dev/null 2>&1
if [ $? -eq 0 ]; then
# copy dropbear binary
cp $(which dropbear) $rootfs/usr/sbin
......
......@@ -609,7 +609,7 @@ arch=$(arch)
# Code taken from debootstrap
if [ -x /usr/bin/dpkg ] && /usr/bin/dpkg --print-architecture >/dev/null 2>&1; then
arch=`/usr/bin/dpkg --print-architecture`
elif type udpkg >/dev/null 2>&1 && udpkg --print-architecture >/dev/null 2>&1; then
elif which udpkg >/dev/null 2>&1 && udpkg --print-architecture >/dev/null 2>&1; then
arch=`/usr/bin/udpkg --print-architecture`
else
arch=$(arch)
......@@ -666,11 +666,7 @@ if [ $hostarch = "i386" -a $arch = "amd64" ]; then
exit 1
fi
type debootstrap
if [ $? -ne 0 ]; then
echo "'debootstrap' command is missing"
exit 1
fi
which debootstrap >/dev/null 2>&1 || { echo "'debootstrap' command is missing" >&2; false; }
if [ -z "$path" ]; then
echo "'path' parameter is required"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment