-
Notifications
You must be signed in to change notification settings - Fork 1
/
install.sh
executable file
·41 lines (30 loc) · 978 Bytes
/
install.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
#!/bin/bash
set -euo pipefail
os=$(uname -s)
if [ -n "${OS:-}" ]; then
os="$OS"
fi
arch=$(uname -m)
if [ -n "${ARCH:-}" ]; then
arch="$ARCH"
fi
os=$(echo "$os" | tr "[:upper:]" "[:lower:]")
arch=$(echo "$arch" | tr "[:upper:]" "[:lower:]")
if [[ "$arch" == "aarch64" ]]; then
arch="arm64"
elif [[ "$arch" == "x86_64" ]]; then
arch="amd64"
fi
binary_name="dorisdump-${os}-${arch}"
# get latest
latest_download_url=$(curl -s https://api.github.com/repos/Thearas/dorisdump/releases/latest | grep "browser_download_url.*${binary_name}" | cut -d : -f 2,3 | tr -d \")
if [[ -z "$latest_download_url" ]]; then
echo "No release found for ${os}-${arch}"
exit 1
fi
name=$(basename "$latest_download_url")
curl -sSL $latest_download_url -o "/tmp/$name"
tar -xzf "/tmp/$name" -C /usr/local/bin/ && mv "/usr/local/bin/$binary_name" /usr/local/bin/dorisdump
rm -f "/tmp/$name"
echo "Installed successfully."
/usr/local/bin/dorisdump completion print-help