-
Notifications
You must be signed in to change notification settings - Fork 64
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·83 lines (68 loc) · 1.89 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·83 lines (68 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/bin/bash
ARCH=$(uname -m)
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
if [ "$ARCH" = "x86_64" ] || [ "$ARCH" = "amd64" ]; then
ARCH="amd64"
ARCH_SUFFIX=""
elif [ "$ARCH" = "aarch64" ] || [ "$ARCH" = "arm64" ]; then
ARCH="arm64"
ARCH_SUFFIX="_arm64"
elif [ "$ARCH" = "armv7l" ]; then
ARCH="armv7"
ARCH_SUFFIX="_armv7"
elif [ "$ARCH" = "armv6l" ]; then
ARCH="armv6"
ARCH_SUFFIX="_armv6"
else
echo "The architecture $ARCH is not supported."
exit 1
fi
if [ "$OS" != "linux" ]; then
echo "The OS $OS is not supported."
exit 1
fi
if ! command -v unzip >/dev/null 2>&1; then
echo "The \"unzip\" command is required."
exit 1
fi
echo "Downloading e2ecp for $OS $ARCH..."
DOWNLOAD_URL=$(curl -s https://api.github.com/repos/schollz/e2ecp/releases/latest | \
grep 'browser_download_url' | \
grep "e2ecp_${OS}${ARCH_SUFFIX}.zip" | \
cut -d '"' -f 4 | head -n 1)
if [ -z "$DOWNLOAD_URL" ]; then
echo "Failed to locate a release asset for e2ecp ($OS $ARCH)."
exit 1
fi
TMPDIR=$(mktemp -d)
trap 'rm -rf "$TMPDIR"' EXIT
if ! curl -L "$DOWNLOAD_URL" -o "$TMPDIR/e2ecp.zip" --progress-bar; then
echo "Failed to download e2ecp."
exit 1
fi
if ! unzip -o "$TMPDIR/e2ecp.zip" -d "$TMPDIR" >/dev/null; then
echo "Failed to extract e2ecp."
exit 1
fi
BINARY_PATH="$TMPDIR/e2ecp"
if [ ! -f "$BINARY_PATH" ]; then
echo "e2ecp binary was not found in the downloaded archive."
exit 1
fi
chmod +x "$BINARY_PATH"
if [ "$(id -u)" -ne 0 ]; then
if command -v sudo >/dev/null 2>&1; then
SUDO="sudo"
else
echo "Please rerun as root or install sudo to write to /usr/local/bin."
exit 1
fi
else
SUDO=""
fi
if ! $SUDO mv "$BINARY_PATH" /usr/local/bin/e2ecp; then
echo "Failed to install e2ecp to /usr/local/bin."
exit 1
fi
echo "Installed e2ecp to /usr/local/bin/e2ecp"
/usr/local/bin/e2ecp --version || true