-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·98 lines (85 loc) · 2.54 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
#!/usr/bin/env bash
echo "Installing GoJelastic..."
echo "------------------------"
# Determining the Linux distribution and architecture
distro=$(lsb_release -i -s)
arch=$(uname -m)
echo "Distribution: $distro"
echo "Architecture: $arch"
# GoJelastic version
version="v0.1.6"
echo "Version: $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/yoanbernabeu/GoJelastic/releases/download/${version}/GoJelastic-${version}-darwin-amd64.tar.gz"
;;
"arm64")
url="https://github.com/yoanbernabeu/GoJelastic/releases/download/${version}/GoJelastic-${version}-darwin-arm64.tar.gz"
;;
*)
echo "Unsupported architecture"
exit 1
;;
esac
;;
"Ubuntu"|"Debian"|"Raspbian")
echo "Downloading GoJelastic..."
case "$arch" in
"i686")
url="https://github.com/yoanbernabeu/GoJelastic/releases/download/${version}/GoJelastic-${version}-linux-386.tar.gz"
;;
"x86_64")
url="https://github.com/yoanbernabeu/GoJelastic/releases/download/${version}/GoJelastic-${version}-linux-amd64.tar.gz"
echo $url
;;
"arm64")
url="https://github.com/yoanbernabeu/GoJelastic/releases/download/${version}/GoJelastic-${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 GoJelastic..."
wget -q --spider $url
if [ $? -eq 0 ]; then
wget -O ~/GoJelastic.tar.gz $url -q --show-progress
else
echo "------------------------"
echo "GoJelastic archive not found"
echo "------------------------"
exit 1
fi
# Extracting the archive (if it exists)
echo "Extracting GoJelastic..."
if [ -f ~/GoJelastic.tar.gz ]; then
tar -xzf ~/GoJelastic.tar.gz -C ~/
else
echo "GoJelastic archive not found"
exit 1
fi
# Removing the archive
echo "Removing archive..."
rm ~/GoJelastic.tar.gz
# Moving the binary to /usr/local/bin
echo "Moving GoJelastic to /usr/local/bin..."
sudo mv ~/GoJelastic /usr/local/bin/
# Making the binary executable
echo "Making GoJelastic executable..."
sudo chmod +x /usr/local/bin/GoJelastic
# Sending a message to the user
echo "-----------------------------------------"
echo "GoJelastic successfully installed"
echo "-----------------------------------------"