Skip to content

Commit

Permalink
adjust install.sh for the latest release
Browse files Browse the repository at this point in the history
Signed-off-by: yuswift <yuswift2018@gmail.com>
  • Loading branch information
swiftslee committed Jul 23, 2021
1 parent b576cf1 commit 83bca4d
Showing 1 changed file with 10 additions and 16 deletions.
26 changes: 10 additions & 16 deletions scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -70,37 +70,31 @@ fi

KUBEBUILDER_VERSION=${KUBEBUILDER_VERSION#"v"}
KUBEBUILDER_VERSION_NAME="kubebuilder_${KUBEBUILDER_VERSION}"
KUBEBUILDER_DIR=/usr/local/kubebuilder
KUBEBUILDER_DIR=/usr/local/bin/kubebuilder

# Check if folder containing kubebuilder executable exists and is not empty
if [ -d "$KUBEBUILDER_DIR" ]; then
if [ "$(ls -A $KUBEBUILDER_DIR)" ]; then
echo "\n/usr/local/kubebuilder folder is not empty. Please delete or backup it before to install ${KUBEBUILDER_VERSION_NAME}"
exit 1
fi
if [ "$(ls -A $KUBEBUILDER_DIR)" ]; then
echo "\n/usr/local/bin/kubebuilder already exists. Please delete or backup it before to install ${KUBEBUILDER_VERSION_NAME}"
exit 1
fi

TMP_DIR=$(mktemp -d)
pushd $TMP_DIR

# Downloading Kubebuilder compressed file using curl program
URL="https://github.com/kubernetes-sigs/kubebuilder/releases/download/v${KUBEBUILDER_VERSION}/${KUBEBUILDER_VERSION_NAME}_${OSEXT}_${ARCH}.tar.gz"
URL="https://github.com/kubernetes-sigs/kubebuilder/releases/download/v${KUBEBUILDER_VERSION}/kubebuilder_${OSEXT}_${ARCH}"
echo "Downloading ${KUBEBUILDER_VERSION_NAME}\nfrom $URL\n"
curl -L "$URL"| tar xz -C $TMP_DIR
curl -Lo kubebuilder_${OSEXT}_${ARCH} "$URL"
chmod a+x kubebuilder_${OSEXT}_${ARCH}

echo "Downloaded executable files"
ls "${KUBEBUILDER_VERSION_NAME}_${OSEXT}_${ARCH}/bin"
ls "kubebuilder_${OSEXT}_${ARCH}"

if [[ -z "${PROW}" ]]; then
MOVE="sudo mv"
else
MOVE="mv"
fi

echo "Moving files to $KUBEBUILDER_DIR folder\n"
mv ${KUBEBUILDER_VERSION_NAME}_${OSEXT}_${ARCH} kubebuilder && sudo mv -f kubebuilder /usr/local/

echo "Add kubebuilder to your path; e.g copy paste in your shell and/or edit your ~/.profile file"
echo "export PATH=\$PATH:/usr/local/kubebuilder/bin"
popd
rm -rf $TMP_DIR
echo "Moving files to /us/local/bin folder\n"
mv kubebuilder_${OSEXT}_${ARCH} kubebuilder && sudo mv -f kubebuilder /usr/local/bin/

0 comments on commit 83bca4d

Please sign in to comment.