summaryrefslogtreecommitdiff
path: root/hack/lib/install.sh
diff options
context:
space:
mode:
authorfisherxu <xufei40@huawei.com>2019-08-30 21:09:16 +0800
committerfisherxu <xufei40@huawei.com>2019-09-04 12:00:47 +0800
commita5ae88977493c14c2a42d52d45ec468b7b7df4e5 (patch)
treed778403cde749101a99977d7b63902159e24462a /hack/lib/install.sh
parentMerge pull request #1090 from fisherxu/update-make (diff)
downloadkubeedge-a5ae88977493c14c2a42d52d45ec468b7b7df4e5.tar.gz
add local-up kubeedge script
Diffstat (limited to 'hack/lib/install.sh')
-rw-r--r--hack/lib/install.sh68
1 files changed, 68 insertions, 0 deletions
diff --git a/hack/lib/install.sh b/hack/lib/install.sh
new file mode 100644
index 000000000..e4076ae3e
--- /dev/null
+++ b/hack/lib/install.sh
@@ -0,0 +1,68 @@
+#!/usr/bin/env bash
+
+# Copyright 2019 The KubeEdge Authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# check if kubectl installed
+function check_prerequisites {
+ echo "checking prerequisites"
+ which kubectl >/dev/null 2>&1
+ if [[ $? -ne 0 ]]; then
+ echo "kubectl not installed, exiting."
+ exit 1
+ else
+ echo -n "found kubectl, " && kubectl version --short --client
+ fi
+}
+
+# check if kind installed
+function check_kind {
+ echo "checking kind"
+ which kind >/dev/null 2>&1
+ if [[ $? -ne 0 ]]; then
+ echo "installing kind ."
+ GO111MODULE="on" go get sigs.k8s.io/kind@v0.5.1
+ export PATH=$PATH:$GOPATH/bin
+ else
+ echo -n "found kind, version: " && kind version
+ fi
+}
+
+verify_go_version(){
+ if [[ -z "$(command -v go)" ]]; then
+ echo "Can't find 'go' in PATH, please fix and retry.
+See http://golang.org/doc/install for installation instructions."
+ exit 1
+ fi
+
+ local go_version
+ IFS=" " read -ra go_version <<< "$(go version)"
+ local minimum_go_version
+ minimum_go_version=go1.12.1
+ if [[ "${minimum_go_version}" != $(echo -e "${minimum_go_version}\n${go_version[2]}" | sort -s -t. -k 1,1 -k 2,2n -k 3,3n | head -n1) && "${go_version[2]}" != "devel" ]]; then
+ echo "Detected go version: ${go_version[*]}.
+Kubernetes requires ${minimum_go_version} or greater.
+Please install ${minimum_go_version} or later."
+ exit 1
+ fi
+}
+
+verify_docker_installed(){
+ # verify the docker installed
+ command -v docker >/dev/null || {
+ echo "must install the docker first"
+ exit 1
+ }
+}
+