-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·132 lines (112 loc) · 4.06 KB
/
install.sh
File metadata and controls
executable file
·132 lines (112 loc) · 4.06 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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#!/usr/bin/env bash
# Plue CLI installer — https://plue.dev
#
# Install latest:
# curl -fsSL https://plue.dev/install.sh | bash
#
# Install specific version:
# PLUE_VERSION=v0.1.0 curl -fsSL https://plue.dev/install.sh | bash
#
# Install to custom directory:
# PLUE_INSTALL_DIR=~/.local/bin curl -fsSL https://plue.dev/install.sh | bash
#
set -euo pipefail
# GitHub repo for release downloads (public mirror of plue.dev/Plue-AI/cli)
GITHUB_REPO="Plue-AI/cli"
BINARY="plue"
INSTALL_DIR="${PLUE_INSTALL_DIR:-/usr/local/bin}"
# ── Detect OS ────────────────────────────────────────────────────
detect_os() {
case "$(uname -s)" in
Linux*) echo "linux" ;;
Darwin*) echo "darwin" ;;
*) echo "unsupported" ;;
esac
}
# ── Detect architecture ─────────────────────────────────────────
detect_arch() {
case "$(uname -m)" in
x86_64|amd64) echo "amd64" ;;
aarch64|arm64) echo "arm64" ;;
*) echo "unsupported" ;;
esac
}
# ── Resolve latest version tag ───────────────────────────────────
latest_version() {
local url="https://api.github.com/repos/${GITHUB_REPO}/releases/latest"
if command -v curl > /dev/null 2>&1; then
curl -fsSL "$url" | grep '"tag_name"' | head -1 | cut -d'"' -f4
elif command -v wget > /dev/null 2>&1; then
wget -qO- "$url" | grep '"tag_name"' | head -1 | cut -d'"' -f4
else
echo "Error: curl or wget is required" >&2
exit 1
fi
}
# ── Download helper ──────────────────────────────────────────────
download() {
local url="$1" dest="$2"
if command -v curl > /dev/null 2>&1; then
curl -fsSL -o "$dest" "$url"
elif command -v wget > /dev/null 2>&1; then
wget -qO "$dest" "$url"
fi
}
# ── Main ─────────────────────────────────────────────────────────
TMPDIR_CLEANUP=""
cleanup() { [ -n "$TMPDIR_CLEANUP" ] && rm -rf "$TMPDIR_CLEANUP"; }
trap cleanup EXIT
main() {
local os arch version archive url
os="$(detect_os)"
arch="$(detect_arch)"
if [ "$os" = "unsupported" ]; then
echo "Error: unsupported operating system: $(uname -s)" >&2
echo "Plue supports Linux and macOS." >&2
exit 1
fi
if [ "$arch" = "unsupported" ]; then
echo "Error: unsupported architecture: $(uname -m)" >&2
echo "Plue supports x86_64 (amd64) and aarch64 (arm64)." >&2
exit 1
fi
version="${PLUE_VERSION:-$(latest_version)}"
if [ -z "$version" ]; then
echo "Error: could not determine latest version." >&2
echo "Set PLUE_VERSION=v0.1.0 to install a specific version." >&2
exit 1
fi
archive="${BINARY}-${version}-${os}-${arch}.tar.gz"
url="https://github.com/${GITHUB_REPO}/releases/download/${version}/${archive}"
echo "Installing ${BINARY} ${version} (${os}/${arch})..."
TMPDIR_CLEANUP="$(mktemp -d)"
local tmpdir="$TMPDIR_CLEANUP"
echo "Downloading ${url}..."
download "$url" "${tmpdir}/${archive}"
echo "Extracting..."
tar xzf "${tmpdir}/${archive}" -C "$tmpdir"
echo "Installing to ${INSTALL_DIR}/${BINARY}..."
mkdir -p "$INSTALL_DIR"
if [ -w "$INSTALL_DIR" ]; then
mv "${tmpdir}/${BINARY}" "${INSTALL_DIR}/${BINARY}"
else
echo "(requires sudo)"
sudo mv "${tmpdir}/${BINARY}" "${INSTALL_DIR}/${BINARY}"
fi
chmod +x "${INSTALL_DIR}/${BINARY}"
echo ""
echo "Plue CLI ${version} installed to ${INSTALL_DIR}/${BINARY}"
echo ""
echo "Get started:"
echo " plue auth login"
echo " plue repo list"
echo ""
# Verify
if command -v plue > /dev/null 2>&1; then
echo "Installed: $(plue --version 2>/dev/null || echo 'OK')"
else
echo "Note: ${INSTALL_DIR} may not be in your PATH."
echo "Add it with: export PATH=\"${INSTALL_DIR}:\$PATH\""
fi
}
main "$@"