-
-
Notifications
You must be signed in to change notification settings - Fork 35
/
install.sh
73 lines (66 loc) · 1.9 KB
/
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
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
#!/bin/sh
# Fetch the latest release tag from the GitHub API
latest_release_url="https://api.github.com/repos/umputun/spot/releases/latest"
tag_name=$(curl -s "$latest_release_url" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
# Detect architecture
arch=$(uname -m)
case $arch in
x86_64)
if [ "$(uname)" = "Darwin" ]; then
arch="macos_x86_64"
else
arch="linux_amd64"
fi
;;
aarch64)
if [ "$(uname)" = "Darwin" ]; then
arch="macos_arm64"
else
arch="linux_arm64"
fi
;;
armv*)
arch="linux_arm"
;;
*)
echo "Unsupported architecture: $arch"
exit 1
;;
esac
# Detect distribution and set package type
if grep -iq 'debian' /etc/os-release; then
pkg_type="deb"
elif grep -iq 'rhel' /etc/os-release || grep -iq 'amzn' /etc/os-release; then
pkg_type="rpm"
elif grep -iq 'alpine' /etc/os-release; then
pkg_type="apk"
elif [ "$(uname)" = "Darwin" ]; then
pkg_type="tar.gz"
else
echo "Unsupported distribution"
exit 1
fi
# Construct the download URL for the appropriate package
pkg_url="https://github.com/umputun/spot/releases/download/${tag_name}/spot_${tag_name}_${arch}.${pkg_type}"
echo "downloading from package url: $pkg_url"
# Download and install the package
pkg_file="spot_${tag_name}_${arch}.${pkg_type}"
wget -qO "$pkg_file" "$pkg_url"
echo "installing package file: $pkg_file"
if [ "$pkg_type" = "deb" ]; then
sudo dpkg -i "$pkg_file"
sudo apt-get -f install
elif [ "$pkg_type" = "rpm" ]; then
if command -v dnf > /dev/null; then
sudo dnf install "$pkg_file"
else
sudo yum install "$pkg_file"
fi
elif [ "$pkg_type" = "apk" ]; then
apk add --allow-untrusted "$pkg_file"
elif [ "$pkg_type" = "tar.gz" ]; then
tar xzf "$pkg_file"
mv spot spot-secrets /usr/local/bin/
fi
# Clean up
rm "$pkg_file"