Add helm install script

main
Buddy Sandidge 4 years ago
parent 465f393a32
commit ff0a131e55

@ -62,8 +62,10 @@ unlink_if_set () {
mkdir_if_missing () {
dir="$1"
sudo=$2
if [ ! -d "${dir}" ]; then
mkdir -p "${dir}"
# shellcheck disable=SC2086
$sudo mkdir -p "${dir}"
fi
}
@ -73,11 +75,7 @@ extract_zip () {
args="${3}"
sudo="${4}"
if [ -d "${dest}" ]; then
return
fi
$sudo mkdir -p "${dest}"
mkdir_if_missing "${dest}" "${sudo}"
tmp_dir="$(mktemp -d)"
zipfile=${tmp_dir}/release.zip
curl --silent --location --output "${zipfile}" "${url}"
@ -92,11 +90,7 @@ extract_tarball () {
args="${3}"
sudo="${4}"
if [ -d "${dest}" ]; then
return
fi
$sudo mkdir -p "${dest}"
mkdir_if_missing "${dest}" "${sudo}"
tmp_dir="$(mktemp -d)"
tarball=${tmp_dir}/release.tar.gz
curl --silent --location --output "${tarball}" "${url}"

@ -0,0 +1,37 @@
#!/usr/bin/env bash
# shellcheck disable=SC1090
source "${XDG_DATA_HOME}/buddy-up/includes/utils.sh"
APP=helm
VERSION=${VERSION:-3.6.0}
DEST="${XDG_DATA_HOME}/apps/releases/${APP}"
if [[ ! -d "${DEST}/${VERSION}" ]]; then
URL_TAR=https://get.helm.sh/helm-v${VERSION}-$(get_os)-$(get_arch).tar.gz
URL_SHA=https://get.helm.sh/helm-v${VERSION}-$(get_os)-$(get_arch).tar.gz.sha256
DL_DIR="$(mktemp -d)"
SHA_PATH=${DL_DIR}/helm.tar.gz.sha256
TAR_PATH=${DL_DIR}/helm.tar.gz
curl --silent --location --output "${SHA_PATH}" "${URL_SHA}"
curl --silent --location --output "${TAR_PATH}" "${URL_TAR}"
if [[ $(cat "${SHA_PATH}") != $(openssl dgst -sha256 "${TAR_PATH}" | sed -e 's/^.* //') ]]; then
echo 'checksum does not match'
rm -rf "${DL_DIR}"
exit 1
fi
mkdir_if_missing "${DEST}/${VERSION}"
tar xzf "${TAR_PATH}" --directory "${DEST}/${VERSION}" --strip-component 1
rm -rf "${DL_DIR}"
fi
set_current_link "${DEST}" "${VERSION}"
unlink_if_set "$XDG_BIN_HOME/${APP}"
cd "$XDG_BIN_HOME" || exit 1
ln -s "$(relative_path "${XDG_BIN_HOME}" "${DEST}/current/${APP}")" ${APP}
cd - >/dev/null || exit 1
Loading…
Cancel
Save