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