Skip to content

Commit 5c1337b

Browse files
support downloading release with or without architecture type
1 parent 8d71c67 commit 5c1337b

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

src/credhub-cli/install.sh

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
USERNAME=${USERNAME:-${_REMOTE_USER:-"automatic"}}
66

7-
set -e
7+
set -eo pipefail
88

99
export TMPDIR=$(mktemp -d /tmp/feature.XXXXXX)
1010
trap "rm -rf $TMPDIR" EXIT
@@ -101,12 +101,23 @@ export DEBIAN_FRONTEND=noninteractive
101101

102102
### BEGIN install
103103

104+
REPO="cloudfoundry/credhub-cli"
105+
ARCH="amd64"
106+
104107
# Soft version matching
105-
find_version_from_git_tags VERSION "https://github.com/cloudfoundry/credhub-cli" "tags/"
108+
find_version_from_git_tags VERSION "https://github.com/$REPO" "tags/"
106109

107110
check_packages curl ca-certificates
108111
echo "Downloading credhub..."
109-
curl -sL "https://github.com/cloudfoundry/credhub-cli/releases/download/${VERSION}/credhub-linux-${VERSION}.tgz" | tar -zxC "$TMPDIR"
112+
113+
# Try to download the release with the architecture type
114+
if curl -sL -o /dev/null -w "%{http_code}" "https://github.com/$REPO/releases/download/$VERSION/credhub-linux-$ARCH-$VERSION.tgz" | grep -q "200"; then
115+
curl -sL "https://github.com/$REPO/releases/download/$VERSION/credhub-linux-$ARCH-$VERSION.tgz" | tar -zxC "$TMPDIR"
116+
else
117+
# Fall back to the older naming convention
118+
curl -sL "https://github.com/$REPO/releases/download/$VERSION/credhub-linux-$VERSION.tgz" | tar -zxC "$TMPDIR"
119+
fi
120+
110121
install "$TMPDIR/credhub" /usr/local/bin/credhub
111122
credhub --version
112123

0 commit comments

Comments
 (0)