Skip to content

Commit 4658025

Browse files
committed
Remove additional bin/bash comment. Exit the installation process if /usr/local/kubebuilder folder exists. Rename KUBEBUILDER_VAR_NAME
1 parent 99c17c9 commit 4658025

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

scripts/install.sh

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/bin/bash
2+
3+
#
4+
# This file will be fetched as: curl -L https://git.io/getLatestKubebuilder | sh -
5+
# so it should be pure bourne shell, not bash (and not reference other scripts)
6+
#
7+
# The script fetches the latest kubebuilder release candidate and untars it.
8+
# It lets users to do curl -L https://git.io//getLatestKubebuilder | KUBEBUILDER_VERSION=1.0.5 sh -
9+
# for instance to change the version fetched.
10+
11+
OS="$(uname)"
12+
if [ "x${OS}" = "xDarwin" ] ; then
13+
OSEXT="darwin"
14+
else
15+
OSEXT="linux"
16+
fi
17+
ARCH=amd64
18+
19+
if [ "x${KUBEBUILDER_VERSION}" = "x" ] ; then
20+
KUBEBUILDER_VERSION=$(curl -L -s https://api.github.com/repos/kubernetes-sigs/kubebuilder/releases/latest | \
21+
grep tag_name | sed "s/ *\"tag_name\": *\"\\(.*\\)\",*/\\1/")
22+
fi
23+
24+
KUBEBUILDER_VERSION=${KUBEBUILDER_VERSION#"v"}
25+
KUBEBUILDER_VERSION_NAME="kubebuilder_${KUBEBUILDER_VERSION}"
26+
URL="https://github.com/kubernetes-sigs/kubebuilder/releases/download/v${KUBEBUILDER_VERSION}/${KUBEBUILDER_VERSION_NAME}_${OSEXT}_${ARCH}.tar.gz"
27+
echo "Downloading ${KUBEBUILDER_VERSION_NAME} from $URL ..."
28+
curl -L "$URL" | tar xz
29+
30+
echo "Downloaded these executable files into $NAME: "
31+
ls "${KUBEBUILDER_VERSION_NAME}_${OSEXT}_${ARCH}/bin"
32+
mv ${KUBEBUILDER_VERSION_NAME}_${OSEXT}_${ARCH} kubebuilder && sudo mv -f kubebuilder /usr/local/
33+
RETVAL=$?
34+
35+
if [ $RETVAL -eq 0 ]; then
36+
echo "Add kubebuilder to your path; e.g copy paste in your shell and/or ~/.profile:"
37+
echo "export PATH=\$PATH:/usr/local/kubebuilder/bin"
38+
else
39+
echo "\n/usr/local/kubebuilder folder is not empty. Please delete or backup it before to install ${KUBEBUILDER_VERSION_NAME}"
40+
fi

0 commit comments

Comments
 (0)