-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·86 lines (71 loc) · 2.25 KB
/
install.sh
File metadata and controls
executable file
·86 lines (71 loc) · 2.25 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
#!/bin/sh
set -e
# Kai installer — https://kaicontext.com
# Usage:
# curl -sSL https://get.kaicontext.com | sh
# curl -sSL https://get.kaicontext.com | VERSION=0.3.1 sh
REPO="kaicontext/kai"
INSTALL_DIR="/usr/local/bin"
BINARY="kai"
VERSION="${VERSION:-latest}"
main() {
os="$(uname -s | tr '[:upper:]' '[:lower:]')"
arch="$(uname -m)"
case "$arch" in
x86_64|amd64) arch="amd64" ;;
arm64|aarch64) arch="arm64" ;;
*)
echo "Error: unsupported architecture: $arch" >&2
exit 1
;;
esac
case "$os" in
linux) ;;
darwin) ;;
*)
echo "Error: unsupported OS: $os" >&2
exit 1
;;
esac
asset="${BINARY}-${os}-${arch}.gz"
if [ "$VERSION" = "latest" ]; then
url="https://github.com/${REPO}/releases/latest/download/${asset}"
else
url="https://github.com/${REPO}/releases/download/v${VERSION}/${asset}"
fi
echo "Installing kai ${VERSION} (${os}/${arch})..."
tmpdir="$(mktemp -d)"
trap 'rm -rf "$tmpdir"' EXIT
echo " Downloading ${url}..."
if command -v curl >/dev/null 2>&1; then
curl -fsSL "$url" -o "${tmpdir}/${asset}"
elif command -v wget >/dev/null 2>&1; then
wget -q "$url" -O "${tmpdir}/${asset}"
else
echo "Error: curl or wget required" >&2
exit 1
fi
echo " Extracting..."
gunzip "${tmpdir}/${asset}"
chmod +x "${tmpdir}/${BINARY}-${os}-${arch}"
# Install to INSTALL_DIR, use sudo if needed
if [ -w "$INSTALL_DIR" ]; then
mv "${tmpdir}/${BINARY}-${os}-${arch}" "${INSTALL_DIR}/${BINARY}"
else
echo " Installing to ${INSTALL_DIR} (requires sudo)..."
sudo mv "${tmpdir}/${BINARY}-${os}-${arch}" "${INSTALL_DIR}/${BINARY}"
fi
echo ""
echo "kai ${VERSION} installed to ${INSTALL_DIR}/${BINARY}"
echo ""
# Run kai init if we're in a project directory
if [ -d ".git" ] || [ -f "package.json" ] || [ -f "go.mod" ] || [ -f "Cargo.toml" ] || [ -f "requirements.txt" ] || [ -f "Makefile" ] || [ -f "pom.xml" ]; then
echo "Running kai init..."
echo ""
kai init
else
echo "Run 'kai init' in your project to get started."
echo ""
fi
}
main