fix: use command -v instead of which in agent bootstrap (#2307)

Certain distros don't ship with `which` (arch) and `command -v` is
built-in to the shell, so this is much more compatible.
This commit is contained in:
Colin Adler
2022-06-13 21:20:15 -05:00
committed by GitHub
parent 0a949aaff2
commit 961ddad925

View File

@@ -20,11 +20,11 @@ Start-Process -FilePath $env:TEMP\sshd.exe -ArgumentList "agent" -PassThru`
set -eux pipefail
BINARY_LOCATION=$(mktemp -d -t tmp.coderXXXXXX)/coder
BINARY_URL=${ACCESS_URL}bin/coder-linux-${ARCH}
if which curl >/dev/null 2>&1; then
if command -v curl >/dev/null 2>&1; then
curl -fsSL --compressed "${BINARY_URL}" -o "${BINARY_LOCATION}"
elif which wget >/dev/null 2>&1; then
elif command -v wget >/dev/null 2>&1; then
wget -q "${BINARY_URL}" -O "${BINARY_LOCATION}"
elif which busybox >/dev/null 2>&1; then
elif command -v busybox >/dev/null 2>&1; then
busybox wget -q "${BINARY_URL}" -O "${BINARY_LOCATION}"
else
echo "error: no download tool found, please install curl, wget or busybox wget"