Skip to content

Instantly share code, notes, and snippets.

@chmouel
Last active April 23, 2019 15:21
Show Gist options
  • Save chmouel/9edc254aa18faa1323072b50f9854e6b to your computer and use it in GitHub Desktop.
Save chmouel/9edc254aa18faa1323072b50f9854e6b to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# Chmouel Boudjnah <[email protected]>
RELEASETYPE=4.0.0-0.ci
LATEST=https://openshift-release.svc.ci.openshift.org/releasestream/${RELEASETYPE}/latest/download
set -e
READLINK=readlink;type -p greadlink >/dev/null 2>/dev/null && READLINK=greadlink #osx brew readlink detection
SED=sed;type -p gsed >/dev/null 2>/dev/null && SED=gsed #osx brew sed detection
SD=$($READLINK -f $(dirname $0))
rurl=$(curl -Ls -o /dev/null -w %{url_effective} ${LATEST})
# wait until binaries are generated
while true;do
clients=$(curl -Ls ${rurl}|$SED -n -e 's/<[^>]*>//g' -e '/^openshift-/p')
[[ -n ${clients} ]] && break || sleep 5
done
rm -rf ${SD}/.old-clients; [[ -d ${SD}/clients ]] && mv ${SD}/clients ${SD}/.old-clients
mkdir -p ${SD}/clients
platform=$(uname)
case ${platform} in
*Linux)
platform=linux
;;
Darwin)
platform=mac
;;
esac
for client in ${clients};do
[[ ${client} != *-${platform}-${RELEASETYPE}* ]] && continue
echo -n "Downloading: \"${client}\" "
curl -Ls ${rurl}/${client} | tar xzf - -C ${SD}/clients
echo "done..."
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment