You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
1.1 KiB
Bash
41 lines
1.1 KiB
Bash
#!/usr/bin/env bash
|
|
|
|
# shellcheck disable=SC1090
|
|
source "${XDG_DATA_HOME}/buddy-up/includes/utils.sh"
|
|
|
|
APP=linkerd
|
|
VERSION=${VERSION:-stable-2.10.2}
|
|
DATA_DIR="${XDG_DATA_HOME}/apps/releases"
|
|
DEST_DIR="${DATA_DIR}/${APP}/${VERSION}"
|
|
|
|
URL=
|
|
if [[ $(get_os) == "linux" ]]; then
|
|
URL=https://github.com/linkerd/linkerd2/releases/download/${VERSION}/linkerd2-cli-${VERSION}-$(get_os)-$(get_arch)
|
|
else
|
|
URL=https://github.com/linkerd/linkerd2/releases/download/${VERSION}/linkerd2-cli-${VERSION}-$(get_os)
|
|
fi
|
|
|
|
[[ -d "${DEST_DIR}" ]] || mkdir -p "${DEST_DIR}"
|
|
|
|
if [[ ! -f "${DEST_DIR}/${APP}" ]]; then
|
|
temp_dir="$(mktemp -d)"
|
|
curl --location --output "$temp_dir/${APP}" "${URL}"
|
|
chmod 755 "$temp_dir/${APP}"
|
|
mv "$temp_dir/${APP}" "${DEST_DIR}/${APP}"
|
|
fi
|
|
|
|
cd "${DEST_DIR}/.." || exit 1
|
|
if [[ -L current ]]; then
|
|
unlink current
|
|
fi
|
|
ln -s "${VERSION}" current
|
|
cd - >/dev/null 2>/dev/null || exit 1
|
|
|
|
if [[ -L "$XDG_BIN_HOME/${APP}" ]]; then
|
|
unlink "$XDG_BIN_HOME/${APP}"
|
|
fi
|
|
|
|
cd "$XDG_BIN_HOME" || exit 1
|
|
REL_LINK="$(relative_path "${XDG_BIN_HOME}" "${DATA_DIR}/${APP}/current/${APP}")"
|
|
ln -s "${REL_LINK}" "${APP}"
|