-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·61 lines (59 loc) · 1.46 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
#!/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=tfexe_$bin"
download_path=$(mktemp -d -t tfexe.XXXXXXXXXX)
download_executable="${download_path}/tfexe"
echo "Downloading tfexe latest version"
wget --quiet "https://github.com/Ant0wan/tfexe/releases/latest/download/tfexe_${bin}" -O "${download_executable}"
echo "Downloaded successfully"
if [ "$bin" = "${arch}-pc-windows-gnu" ]; then
dest="${TFEXE_INSTALL_PATH:-/bin}/"
echo "Installing tfexe to ${dest} ..."
mv "${download_executable}" "$dest"
retVal=$?
if [ $retVal -ne 0 ]; then
echo "Failed to install tfexe"
exit $retVal
else
echo "tfexe installed at ${dest} successfully"
fi
else
dest="${TFEXE_INSTALL_PATH:-/usr/local/bin}/"
echo "Installing tfexe 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 tfexe"
exit $retVal
fi
fi
echo "Cleaning temporary downloaded files directory ${download_path} ..."
rm -rf "${download_path}"