From 9e71adc5d1c496b1ba5ba35a32c423c3fa752299 Mon Sep 17 00:00:00 2001 From: Buddy Sandidge Date: Sun, 12 Apr 2020 13:47:26 -0700 Subject: [PATCH] add install script for minikube --- bin/install-minikube-system | 57 +++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100755 bin/install-minikube-system diff --git a/bin/install-minikube-system b/bin/install-minikube-system new file mode 100755 index 0000000..9c8e2f2 --- /dev/null +++ b/bin/install-minikube-system @@ -0,0 +1,57 @@ +#!/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