forked from AliyunContainerService/pouch
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathinstall_containerd.sh
executable file
·63 lines (45 loc) · 1.33 KB
/
install_containerd.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/env bash
set -euo pipefail
readonly CONTAINERD_VERSION="v1.2.4"
# containerd::check_version checks the command and the version.
containerd::check_version() {
local has_installed version
has_installed="$(command -v containerd || echo false)"
if [[ "${has_installed}" = "false" ]]; then
echo false
exit 0
fi
version="$(containerd -v | cut -d " " -f 3 | cut -c 2-)"
if [[ "${CONTAINERD_VERSION}" != "${version}" ]]; then
echo false
exit 0
fi
echo true
}
# containerd::install downloads the code and builds it.
containerd::install() {
local tmpdir pkgpath
# create gopath
tmpdir="$(mktemp -d /tmp/containerd-install-XXXXXX)"
trap 'rm -rf /tmp/containerd-install-*' EXIT
pkgpath="$tmpdir/src/github.com/containerd/containerd"
mkdir -p "${pkgpath}"
git clone -b "${CONTAINERD_VERSION}" https://github.com/containerd/containerd "${pkgpath}"
cd "${pkgpath}"
GOPATH=$tmpdir make BUILDTAGS=no_cri # build without cri plugin
make install
}
main() {
local has_installed
has_installed="$(containerd::check_version)"
if [[ "${has_installed}" = "true" ]]; then
echo "containerd-${CONTAINERD_VERSION} has been installed."
exit 0
fi
echo ">>>> install containerd-${CONTAINERD_VERSION} <<<<"
containerd::install
# final check
command -v containerd > /dev/null
echo
}
main