Skip to content

Commit

Permalink
feat(gcloud): add gcloud-install script
Browse files Browse the repository at this point in the history
  • Loading branch information
Deavon M. McCaffery committed Aug 31, 2017
1 parent 1e10b51 commit c9631bd
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 8 deletions.
8 changes: 4 additions & 4 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,11 @@ __prompt-install() {

local SHA_URI="https://api.github.com/repos/automotivemastermind/prompt/commits/master"
local PROMPT_SHA=$(curl $CURL_OPT $SHA_URI | grep sha | head -n 1 | sed 's#.*\:.*"\(.*\).*",#\1#')
local PROMPT_SHA_PATH=$HOME/.am/prompt/$PROMPT_SHA
local PROMPT_SHA_PATH=$HOME/.am/prompt/.sha

touch "$PROMPT_SHA_PATH"
echo $PROMPT_SHA > $PROMPT_SHA_PATH

source "$AM_PROMPT/bashrc"

echo -e "${CLR_SUCCESS}"
echo "#######################################"
Expand All @@ -136,8 +138,6 @@ __prompt-install() {
echo "#######################################"
echo "#######################################"
echo -e "${CLR_CLEAR}"

source "$AM_PROMPT/bashrc"
}

__prompt-install
5 changes: 4 additions & 1 deletion src/scripts/Darwin/minikube-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ minikube-install() {
echo "Installing minikube..."
brew update

for pkg in docker-machine-driver-xhyve kubernetes-cli Caskroom/cask/minikube kubernetes-helm; do
for pkg in docker-machine-driver-xhyve Caskroom/cask/minikube kubernetes-helm; do
if brew list -1 | grep -q "^${pkg}\$"; then
echo "upgrading: $pkg"
brew upgrade $pkg 1>/dev/null 2>&1
Expand All @@ -29,6 +29,9 @@ minikube-install() {
echo "Starting minikube..."
minikube start --insecure-registry localhost:5000

echo "Installing gcloud..."
gcloud-install

echo "Installing helm and tiller..."
helm init

Expand Down
52 changes: 52 additions & 0 deletions src/scripts/gcloud-install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/usr/bin/env bash

if [ ! -z "${AM_PROMPT_DEBUG:-}" ]; then
echo 'gcloud-install'
fi

__prompt-set-gcloud-path() {
if [ -e $HOME/.gcloud/bin/gcloud ]; then
export PATH=$PATH:~/.gcloud/bin
fi
}

gcloud-install() {
local GCLOUD_PATH=$HOME/.gcloud
local PLATFORM='linux'

if [ "$(uname)" == "Darwin" ]; then
PLATFORM='darwin'
fi

local URL=https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-sdk-161.0.0-$PLATFORM-x86_64.tar.gz

local TEMP=$(mktemp -d)
local FILENAME=$TEMP/gcloud-sdk.tar.gz
local EXPANDED=$TEMP/google-cloud-sdk

if ! type gcloud 1>/dev/null 2>&1; then

echo
echo "downloading gcloud-sdk"
curl -L $URL -o $FILENAME --silent 2>&1

tar -xf $FILENAME -C $TEMP 1>/dev/null 2>&1

rm -rf $GCLOUD_PATH 1>/dev/null 2>&1
mv $EXPANDED $GCLOUD_PATH 1>/dev/null 2>&1
rm -rf $TEMP 1>/dev/null 2>&1

echo
echo "installing gcloud-sdk"
~/.gcloud/install.sh --command-completion false --usage-reporting false --quiet --path-update false 2>&1

__prompt-set-gcloud-path
fi

echo
echo "installing and updating gcloud components"
gcloud components install kubectl docker-credential-gcr gsutil core --quiet 2>&1
gcloud components update --quiet 2>&1
}

__prompt-set-gcloud-path
10 changes: 7 additions & 3 deletions src/scripts/update-prompt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,15 @@ fi

update-prompt() {
local SHA=$(git-sha)
local SHA_PATH=$HOME/.am/prompt/$SHA
local SHA_PATH=$HOME/.am/prompt/.sha

if [ -f $SHA_PATH ]; then
echo "prompt: latest version already installed: $SHA"
return 1
CURRENT_SHA=$(cat $SHA_PATH)

if [ $SHA = $CURRENT_SHA ]; then
echo "prompt: latest version already installed: $SHA"
return 1
fi
fi

local CHANGELOG_URI="https://github.com/automotivemastermind/prompt/blob/master/CHANGELOG.md"
Expand Down

0 comments on commit c9631bd

Please sign in to comment.