-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·46 lines (46 loc) · 1.13 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
#!/bin/sh
set -o errexit
get_machine_arch () {
machine_arch=""
case $(uname -m) in
x86_64) machine_arch="x86_64" ;;
arm64) machine_arch="aarch64" ;;
aarch64) machine_arch="aarch64" ;;
esac
echo $machine_arch
}
arch=$(get_machine_arch)
case "$(uname -s)" in
Darwin*)
bin="${arch}-apple-darwin"
;;
MINGW64*)
bin="${arch}-pc-windows-gnu"
;;
MSYS_NT*)
bin="${arch}-pc-windows-gnu"
;;
*)
bin="${arch}-unknown-linux-musl"
;;
esac
echo "bin=tfam_$bin"
download_path=$(mktemp -d -t tfam.XXXXXXXXXX)
download_executable="${download_path}/tfam"
echo "Downloading tfam latest version"
wget --quiet "https://github.com/Ant0wan/tfam/releases/latest/download/tfam_${bin}" -O "${download_executable}"
echo "Downloaded successfully"
dest="${TFEXE_INSTALL_PATH:-/usr/local/bin}/"
echo "Installing tfam to ${dest} ..."
if [ -w "$dest" ]; then SUDO=""; else
SUDO="sudo";
fi
$SUDO mkdir -p "$dest"
$SUDO install -c -v "${download_executable}" "$dest"
retVal=$?
if [ $retVal -ne 0 ]; then
echo "Failed to install tfam"
exit $retVal
fi
echo "Cleaning temporary downloaded files directory ${download_path} ..."
rm -rf "${download_path}"