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.

58 lines
1.5 KiB
Plaintext

#!/usr/bin/env bash
set -e
MINIKUBE_VERSION=${MINIKUBE_VERSION:-v1.9.2}
PREFIX_DIR=/usr/local
BIN_DIR=${PREFIX_DIR}/bin
MINIKUBE_PREFIX_DIR=${PREFIX_DIR}/apps/minikube
MINIKUBE_DEST_DIR=${MINIKUBE_PREFIX_DIR}/${MINIKUBE_VERSION}
MINIKUBE_CURRENT=${MINIKUBE_PREFIX_DIR}/current
if [[ $(uname) =~ Linux ]]; then
OS=linux
elif [[ $(uname) =~ Darwin ]]; then
OS=darwin
else
echo "unsupported os: $(uname)"
exit 1
fi
ARCH=
if [[ $(uname -m) == x86_64 ]]; then
ARCH=amd64
else
echo arch not yet supported: "$(uname -m)"
exit 1
fi
TMP_DIR=
if [[ ! -d ${MINIKUBE_DEST_DIR} ]]; then
sudo mkdir -p "${MINIKUBE_DEST_DIR}"
TMP_DIR=$(mktemp --directory)
DEST_FILE="${TMP_DIR}"/minikube
URL="https://github.com/kubernetes/minikube/releases/download/${MINIKUBE_VERSION}/minikube-${OS}-${ARCH}"
echo downloading minikube "${MINIKUBE_VERSION}" to temp directory "${TMP_DIR}"
curl --silent --location --output "${DEST_FILE}" "${URL}"
sudo chmod 755 "${DEST_FILE}"
sudo mv "${DEST_FILE}" "${MINIKUBE_DEST_DIR}"
sudo chown --recursive root:root "${MINIKUBE_DEST_DIR}"
else
echo minikube "${MINIKUBE_VERSION}" already installed
fi
cd "${MINIKUBE_PREFIX_DIR}"
[[ -s current ]] && sudo unlink current
sudo ln --symbolic "${MINIKUBE_VERSION}"/ current
echo current version set to "${MINIKUBE_VERSION}"
cd ${BIN_DIR}
[[ -L ${BIN_DIR}/minikube ]] || sudo ln --symbolic ${MINIKUBE_CURRENT}/minikube
if [[ $TMP_DIR != "" ]]; then
rm -rf "${TMP_DIR}"
echo removed up temp directory "${TMP_DIR}"
fi