-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·65 lines (54 loc) · 1.89 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·65 lines (54 loc) · 1.89 KB
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
64
65
#!/usr/bin/env sh
# Install docker-run-export as a Docker CLI plugin in the
# current user's ~/.docker/cli-plugins/ directory.
#
# Usage:
# curl -fsSL https://raw.githubusercontent.com/dokku/docker-run-export/main/install.sh | sh
# VERSION=v0.2.0 curl -fsSL https://raw.githubusercontent.com/dokku/docker-run-export/main/install.sh | sh
#
# Environment variables:
# VERSION Release tag to install (defaults to the latest release).
# PLUGIN_DIR Override destination directory (defaults to $HOME/.docker/cli-plugins).
set -eu
NAME="docker-run-export"
PLUGIN_NAME="docker-dre"
REPO="dokku/docker-run-export"
PLUGIN_DIR="${PLUGIN_DIR:-${HOME}/.docker/cli-plugins}"
os="$(uname -s | tr '[:upper:]' '[:lower:]')"
case "$os" in
linux | darwin) ;;
*)
echo "error: unsupported OS: $os" >&2
exit 1
;;
esac
arch="$(uname -m)"
case "$arch" in
x86_64 | amd64) arch="amd64" ;;
aarch64 | arm64) arch="arm64" ;;
*)
echo "error: unsupported architecture: $arch" >&2
exit 1
;;
esac
if [ -z "${VERSION:-}" ]; then
VERSION="$(curl -fsSL "https://api.github.com/repos/${REPO}/releases/latest" \
| sed -n 's/.*"tag_name": "\(.*\)".*/\1/p' | head -n1)"
fi
if [ -z "$VERSION" ]; then
echo "error: could not determine latest version; set VERSION explicitly" >&2
exit 1
fi
# Release assets are tarballs named like docker-run-export_<VER>_<os>_<arch>.tgz
# containing a single binary docker-run-export-<arch>.
asset="${NAME}_${VERSION#v}_${os}_${arch}.tgz"
url="https://github.com/${REPO}/releases/download/${VERSION}/${asset}"
tmpdir="$(mktemp -d)"
trap 'rm -rf "$tmpdir"' EXIT INT TERM
echo "downloading ${url}"
curl -fsSL "$url" -o "${tmpdir}/${asset}"
tar -xzf "${tmpdir}/${asset}" -C "$tmpdir"
mkdir -p "$PLUGIN_DIR"
install -m 0755 "${tmpdir}/${NAME}-${arch}" "${PLUGIN_DIR}/${PLUGIN_NAME}"
echo "installed ${NAME} ${VERSION} to ${PLUGIN_DIR}/${PLUGIN_NAME}"
echo "try: docker dre version"