-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
95 lines (74 loc) · 1.87 KB
/
Copy pathinstall.sh
File metadata and controls
95 lines (74 loc) · 1.87 KB
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
#!/usr/bin/env bash
set -e
REPO="shadowdara/finder"
INSTALL_DIR="${INSTALL_DIR:-$HOME/.local/bin}"
detect_os() {
case "$(uname -s)" in
Linux*) echo "linux" ;;
Darwin*) echo "darwin" ;;
MINGW*|MSYS*|CYGWIN*) echo "windows" ;;
*)
echo "Unsupported OS: $(uname -s)" >&2
exit 1
;;
esac
}
detect_arch() {
case "$(uname -m)" in
x86_64|amd64) echo "amd64" ;;
arm64|aarch64) echo "arm64" ;;
*)
echo "Unsupported architecture: $(uname -m)" >&2
exit 1
;;
esac
}
OS="$(detect_os)"
ARCH="$(detect_arch)"
echo "Detecting platform..."
echo " OS: $OS"
echo " Arch: $ARCH"
VERSION="$(
curl -fsSL \
"https://api.github.com/repos/${REPO}/releases/latest" |
grep '"tag_name":' |
sed -E 's/.*"([^"]+)".*/\1/'
)"
if [ -z "$VERSION" ]; then
echo "Could not determine latest version." >&2
exit 1
fi
echo " Version: $VERSION"
ARCHIVE="finder_${VERSION}_${OS}_${ARCH}"
if [ "$OS" = "windows" ]; then
ARCHIVE="${ARCHIVE}.zip"
else
ARCHIVE="${ARCHIVE}.tar.gz"
fi
URL="https://github.com/${REPO}/releases/download/${VERSION}/${ARCHIVE}"
TMP="$(mktemp -d)"
trap 'rm -rf "$TMP"' EXIT
echo "Downloading:"
echo " $URL"
curl -fL "$URL" -o "$TMP/archive"
mkdir -p "$INSTALL_DIR"
if [ "$OS" = "windows" ]; then
unzip -q "$TMP/archive" -d "$TMP/package"
else
mkdir "$TMP/package"
tar -xzf "$TMP/archive" -C "$TMP/package"
fi
if [ "$OS" = "windows" ]; then
cp "$TMP/package/finder.exe" "$INSTALL_DIR/finder.exe"
else
install -m 755 "$TMP/package/finder" "$INSTALL_DIR/finder"
fi
echo
echo "Finder installed successfully!"
echo
echo " $INSTALL_DIR/finder"
if [[ ":$PATH:" != *":$INSTALL_DIR:"* ]]; then
echo "export PATH=\"\$PATH:$INSTALL_DIR\"" >> "$HOME/.bashrc"
export PATH="$PATH:$INSTALL_DIR"
fi
source ~/.bashrc