-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·67 lines (50 loc) · 1.64 KB
/
install.sh
File metadata and controls
executable file
·67 lines (50 loc) · 1.64 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
#!/bin/bash
set -e
REPO="alDuncanson/latent"
INSTALL_DIR="/usr/local/bin"
detect_platform() {
local os arch
case "$(uname -s)" in
Linux*) os="linux" ;;
Darwin*) os="darwin" ;;
MINGW*|MSYS*|CYGWIN*) os="windows" ;;
*) echo "Unsupported OS: $(uname -s)" >&2; exit 1 ;;
esac
case "$(uname -m)" in
x86_64|amd64) arch="amd64" ;;
arm64|aarch64) arch="arm64" ;;
*) echo "Unsupported architecture: $(uname -m)" >&2; exit 1 ;;
esac
echo "${os}-${arch}"
}
get_latest_version() {
curl -sS "https://api.github.com/repos/${REPO}/releases/latest" | grep '"tag_name"' | cut -d'"' -f4
}
main() {
local platform version binary_name download_url tmp_dir
platform=$(detect_platform)
version=$(get_latest_version)
if [ -z "$version" ]; then
echo "Error: Could not determine latest version" >&2
exit 1
fi
binary_name="latent-${platform}"
download_url="https://github.com/${REPO}/releases/download/${version}/${binary_name}"
echo "Installing latent ${version} for ${platform}..."
tmp_dir=$(mktemp -d)
trap 'rm -rf "$tmp_dir"' EXIT
if ! curl -sSL -o "${tmp_dir}/latent" "$download_url"; then
echo "Error: Failed to download ${download_url}" >&2
exit 1
fi
chmod +x "${tmp_dir}/latent"
if [ -w "$INSTALL_DIR" ]; then
mv "${tmp_dir}/latent" "${INSTALL_DIR}/latent"
else
echo "Installing to ${INSTALL_DIR} (requires sudo)..."
sudo mv "${tmp_dir}/latent" "${INSTALL_DIR}/latent"
fi
echo "Installed latent ${version} to ${INSTALL_DIR}/latent"
echo "Run 'latent' to start"
}
main