-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·52 lines (41 loc) · 1.1 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
#!/bin/bash
download() {
if command -v curl > /dev/null 2>&1; then
curl -fsSL "$1"
else
wget -qO- "$1"
fi
}
download_and_install() {
if ! [ -d ~/.blastoise ]; then
mkdir ~/.blastoise || abort "Could not create directory!"
fi
bin_url=`find_bin_file`
download "$bin_url" > ~/.blastoise/blastoise || return 1
chmod +x ~/.blastoise/blastoise || return 1
# add_to_path
}
find_bin_file() {
repository="ViktorAtterlonn/blastoise"
file_name="blastoise"
release_info=$(curl -s "https://api.github.com/repos/$repository/releases/latest")
# Extract the download URL
download_url=""
while IFS= read -r line; do
if [[ $line =~ "browser_download_url" ]]; then
download_url="${line#*\": \"}"
download_url="${download_url%\"*}"
break
fi
done <<< "$release_info"
if [ -n "$download_url" ]; then
echo $download_url
else
echo "File not found in the latest release."
fi
}
add_to_path() {
echo "export PATH=$PATH:~/.blastoise" >> ~/.zshrc
# echo "export PATH=$PATH:$path" >> ~/.bash_profile
}
download_and_install || abort "Install Error!"