-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·101 lines (87 loc) · 2.61 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#!/usr/bin/env bash
echo "Installing AB Tasty CLI..."
echo "------------------------"
# Determining the Linux distribution and architecture
distro=$(lsb_release -i -s)
arch=$(uname -m)
echo "Distribution: $distro"
echo "Architecture: $arch"
# Flagship CLI version
version="1.0.9"
echo "Version: v$version"
echo "------------------------"
# URL for downloading the archive based on the distribution and architecture
url=""
case "$distro" in
"Darwin")
case "$arch" in
"x86_64")
url="https://github.com/flagship-io/abtasty-cli/releases/download/v${version}/abtasty-cli_${version}_darwin_amd64.tar.gz"
;;
"arm64")
url="https://github.com/flagship-io/abtasty-cli/releases/download/v${version}/abtasty-cli_${version}_darwin_arm64.tar.gz"
;;
*)
echo "Unsupported architecture"
exit 1
;;
esac
;;
"Ubuntu"|"Debian"|"Raspbian")
echo "Downloading AB Tasty CLI..."
case "$arch" in
"i686")
url="https://github.com/flagship-io/abtasty-cli/releases/download/v${version}/abtasty-cli_${version}_linux_386.tar.gz"
;;
"x86_64")
url="https://github.com/flagship-io/abtasty-cli/releases/download/v${version}/abtasty-cli_${version}_linux_amd64.tar.gz"
echo $url
;;
"arm64")
url="https://github.com/flagship-io/abtasty-cli/releases/download/v${version}/abtasty-cli_${version}_linux_arm64.tar.gz"
;;
*)
echo "Unsupported architecture"
exit 1
;;
esac
;;
*)
echo "Unsupported distribution"
exit 1
;;
esac
# Downloading the archive to home directory (and check if url is not 404)
echo "Downloading AB Tasty CLI..."
wget -q --spider $url
if [ $? -eq 0 ]; then
wget -O ~/abtasty-cli.tar.gz $url -q --show-progress
else
echo "------------------------"
echo "AB Tasty CLI archive not found"
echo "------------------------"
exit 1
fi
# Extracting the archive (if it exists)
echo "Extracting AB Tasty CLI..."
if [ -f ~/flagship.tar.gz ]; then
tar -xzf ~/abtasty-cli.tar.gz -C ~/
else
echo "AB Tasty CLI archive not found"
exit 1
fi
# exit when any command fails
set -e
# Removing the archive
echo "Removing archive..."
rm ~/abtasty-cli.tar.gz
# Moving the binary to /usr/local/bin
echo "Moving Flagship CLI to /usr/local/bin..."
sudo mv ~/abtasty-cli /usr/local/bin/
# Making the binary executable
echo "Making Flagship CLI executable..."
sudo chmod +x /usr/local/bin/abtasty-cli
# Sending a message to the user
echo "-----------------------------------------"
echo "AB Tasty CLI successfully installed"
echo "-----------------------------------------"