From: Dwight Engen Date: Tue, 22 Jan 2013 20:59:44 +0000 (-0500) Subject: use which instead of type X-Git-Tag: lxc-0.9.0.alpha3~1^2~25 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=169bf5e07ed044a11fe6f5dd683615bee001ee36;p=thirdparty%2Flxc.git 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: Dwight Engen Acked-by: Serge E. Hallyn Acked-by: Stéphane Graber --- diff --git a/src/lxc/lxc-clone.in b/src/lxc/lxc-clone.in index 22f0376e4..76fc2f6e5 100644 --- a/src/lxc/lxc-clone.in +++ b/src/lxc/lxc-clone.in @@ -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 diff --git a/src/lxc/lxc-create.in b/src/lxc/lxc-create.in index 5cd9fdba5..9348d87e4 100644 --- a/src/lxc/lxc-create.in +++ b/src/lxc/lxc-create.in @@ -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 diff --git a/src/lxc/lxc-shutdown.in b/src/lxc/lxc-shutdown.in index a033b1075..fdcade2a4 100644 --- a/src/lxc/lxc-shutdown.in +++ b/src/lxc/lxc-shutdown.in @@ -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 diff --git a/templates/lxc-busybox.in b/templates/lxc-busybox.in index 439657f87..cb425ecf8 100644 --- a/templates/lxc-busybox.in +++ b/templates/lxc-busybox.in @@ -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 diff --git a/templates/lxc-ubuntu.in b/templates/lxc-ubuntu.in index 0ed8808c7..a2fc95201 100644 --- a/templates/lxc-ubuntu.in +++ b/templates/lxc-ubuntu.in @@ -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"