-
Notifications
You must be signed in to change notification settings - Fork 0
/
install
executable file
·41 lines (32 loc) · 1.11 KB
/
install
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
#!/bin/sh
set -e
owner="jonhadfield"
repo="ipscout"
githubUrl=${githubUrl:-"https://github.com"}
downloadFolder="${TMPDIR:-/tmp}"
executable_folder="/usr/local/bin"
get_arch() {
case $(uname -m) in
"x86_64" | "amd64" ) echo "amd64" ;;
"i386" | "i486" | "i586") echo "386" ;;
"aarch64" | "arm64" | "arm") echo "arm64" ;;
*) echo "${NIL}" ;;
esac
}
get_os(){
uname -s | awk '{print tolower($0)}'
}
file_name="${repo}_$(get_os)_$(get_arch).tar.gz"
downloaded_file="${downloadFolder}/${file_name}"
asset_uri="${githubUrl}/${owner}/${repo}/releases/latest/download/${file_name}"
echo "[1/2] Download ${asset_uri} to ${downloadFolder}"
rm -f "${downloaded_file}"
curl --fail --location --output "${downloaded_file}" "${asset_uri}"
echo "[2/3] Install ${repo} to ${executable_folder}"
tar -xz -f "${downloaded_file}"
[ "$(uname)" = "Linux" ] && sudo install -C ${repo} ${executable_folder}
[ "$(uname)" = "darwin" ] && install -C ${repo} ${executable_folder}
echo "[3/3] Clean up"
rm "${downloaded_file}"
echo "${repo} was successfully installed to ${executable_folder}/${repo}"
exit 0