@@ -16,27 +16,6 @@ function command_exists () {
16
16
fi
17
17
}
18
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
- KUBEBUILDER_DIR=/usr/local/kubebuilder
27
-
28
- # Check if folder containing kubebuilder executable exists and is not empty
29
- if [ -d " $KUBEBUILDER_DIR " ]; then
30
- if [ " $( ls -A $KUBEBUILDER_DIR ) " ]; then
31
- echo " \n/usr/local/kubebuilder folder is not empty. Please delete or backup it before to install ${KUBEBUILDER_VERSION_NAME} "
32
- exit 1
33
- fi
34
- fi
35
-
36
- # Check if curl, tar commands/programs exist
37
- command_exists curl
38
- command_exists tar
39
-
40
19
# Determine OS
41
20
OS=" $( uname) "
42
21
case $OS in
@@ -62,17 +41,42 @@ case $HW in
62
41
;;
63
42
esac
64
43
44
+ # Check if curl, tar commands/programs exist
45
+ command_exists curl
46
+ command_exists tar
47
+
48
+ if [ " x${KUBEBUILDER_VERSION} " = " x" ] ; then
49
+ KUBEBUILDER_VERSION=$( curl -L -s https://api.github.com/repos/kubernetes-sigs/kubebuilder/releases/latest | \
50
+ grep tag_name | sed " s/ *\" tag_name\" : *\"\\ (.*\\ )\" ,*/\\ 1/" )
51
+ fi
52
+
53
+ KUBEBUILDER_VERSION=${KUBEBUILDER_VERSION# " v" }
54
+ KUBEBUILDER_VERSION_NAME=" kubebuilder_${KUBEBUILDER_VERSION} "
55
+ KUBEBUILDER_DIR=/usr/local/kubebuilder
56
+
57
+ # Check if folder containing kubebuilder executable exists and is not empty
58
+ if [ -d " $KUBEBUILDER_DIR " ]; then
59
+ if [ " $( ls -A $KUBEBUILDER_DIR ) " ]; then
60
+ echo " \n/usr/local/kubebuilder folder is not empty. Please delete or backup it before to install ${KUBEBUILDER_VERSION_NAME} "
61
+ exit 1
62
+ fi
63
+ fi
64
+
65
65
TMP_DIR=$( mktemp -d)
66
+ pushd $TMP_DIR
66
67
67
68
# Downloading Kuberbuilder compressed file using curl program
68
69
URL=" https://github.com/kubernetes-sigs/kubebuilder/releases/download/v${KUBEBUILDER_VERSION} /${KUBEBUILDER_VERSION_NAME} _${OSEXT} _${ARCH} .tar.gz"
69
70
echo " Downloading ${KUBEBUILDER_VERSION_NAME} \nfrom $URL \n"
70
71
curl -L " $URL " | tar xz -C $TMP_DIR
71
72
72
73
echo " Downloaded executable files"
73
- ls " $TMP_DIR / $ {KUBEBUILDER_VERSION_NAME} _${OSEXT} _${ARCH} /bin"
74
+ ls " ${KUBEBUILDER_VERSION_NAME} _${OSEXT} _${ARCH} /bin"
74
75
75
76
echo " Moving files to $KUBEBUILDER_DIR folder\n"
76
- mv $TMP_DIR / $ {KUBEBUILDER_VERSION_NAME} _${OSEXT} _${ARCH} $TMP_DIR / kubebuilder && sudo mv -f $TMP_DIR / kubebuilder /usr/local/
77
+ mv ${KUBEBUILDER_VERSION_NAME} _${OSEXT} _${ARCH} kubebuilder && sudo mv -f kubebuilder /usr/local/
77
78
79
+ echo " Add kubebuilder to your path; e.g copy paste in your shell and/or edit your ~/.profile file"
80
+ echo " export PATH=\$ PATH:/usr/local/kubebuilder/bin"
81
+ popd
78
82
rm -rf $TMP_DIR
0 commit comments