-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·162 lines (138 loc) · 5.05 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·162 lines (138 loc) · 5.05 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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
#!/bin/sh
set -e
REPO="PRTIMES/jooto-cli"
INSTALL_DIR="${INSTALL_DIR:-/usr/local/bin}"
BINARY_NAME="jooto"
# Cleanup on exit
TMPDIR_CREATED=""
cleanup() {
if [ -n "$TMPDIR_CREATED" ] && [ -d "$TMPDIR_CREATED" ]; then
rm -rf "$TMPDIR_CREATED"
fi
}
trap cleanup EXIT INT TERM
# Check required commands
for cmd in curl tar; do
if ! command -v "$cmd" >/dev/null 2>&1; then
echo "Error: '$cmd' is required but not found." >&2
exit 1
fi
done
# Detect OS
OS_RAW="$(uname -s)"
case "$OS_RAW" in
Darwin|darwin) OS="darwin" ;;
Linux|linux) OS="linux" ;;
*)
echo "Error: Unsupported OS: $OS_RAW" >&2
exit 1
;;
esac
# Detect architecture
ARCH_RAW="$(uname -m)"
case "$ARCH_RAW" in
arm64|aarch64) ARCH="arm64" ;;
x86_64) ARCH="amd64" ;;
*)
echo "Error: Unsupported architecture: $ARCH_RAW" >&2
exit 1
;;
esac
# Validate supported combinations
if [ "$OS" = "darwin" ] && [ "$ARCH" = "amd64" ]; then
echo "Error: macOS on x86_64 (Intel) is not supported. Only Apple Silicon (arm64) is supported." >&2
exit 1
fi
echo "Detected: ${OS}/${ARCH}"
# Create temp dir (used for API response and download)
TMPDIR_CREATED="$(mktemp -d)"
RELEASE_JSON="${TMPDIR_CREATED}/release.json"
# Get latest release tag
API_URL="https://api.github.com/repos/${REPO}/releases/latest"
echo "Fetching latest release..."
# Use < /dev/null to prevent curl from consuming stdin (needed for curl|sh usage)
curl -sfL "$API_URL" -o "$RELEASE_JSON" < /dev/null
if command -v jq >/dev/null 2>&1; then
TAG="$(jq -r '.tag_name' "$RELEASE_JSON")"
else
TAG="$(grep '"tag_name"' "$RELEASE_JSON" | sed 's/.*"tag_name"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/')"
fi
if [ -z "$TAG" ] || [ "$TAG" = "null" ]; then
echo "Error: Failed to fetch latest release tag." >&2
exit 1
fi
echo "Latest version: ${TAG}"
# Download public release asset
ASSET_NAME="${BINARY_NAME}_${OS}_${ARCH}.tar.gz"
ARCHIVE="${TMPDIR_CREATED}/${BINARY_NAME}.tar.gz"
# Find asset download URL from release
ASSET_ID=""
if command -v jq >/dev/null 2>&1; then
ASSET_URL="$(jq -r ".assets[] | select(.name==\"${ASSET_NAME}\") | .browser_download_url" "$RELEASE_JSON")"
else
ASSET_ID="$(grep -B 3 "\"name\": \"${ASSET_NAME}\"" "$RELEASE_JSON" | grep '"id"' | head -1 | sed 's/[^0-9]//g')"
ASSET_URL=""
if [ -n "$ASSET_ID" ]; then
ASSET_URL="https://api.github.com/repos/${REPO}/releases/assets/${ASSET_ID}"
fi
fi
if [ -z "$ASSET_URL" ] || [ "$ASSET_URL" = "null" ]; then
echo "Error: Asset '${ASSET_NAME}' not found in release ${TAG}." >&2
exit 1
fi
echo "Downloading ${ASSET_NAME} (${TAG})..."
if [ -n "$ASSET_ID" ]; then
curl -sfL -H "Accept: application/octet-stream" -o "$ARCHIVE" "$ASSET_URL" < /dev/null
else
curl -sfL -o "$ARCHIVE" "$ASSET_URL" < /dev/null
fi
# Extract
tar -xzf "$ARCHIVE" -C "$TMPDIR_CREATED"
if [ ! -f "${TMPDIR_CREATED}/${BINARY_NAME}" ]; then
echo "Error: Binary '${BINARY_NAME}' not found in archive." >&2
exit 1
fi
chmod +x "${TMPDIR_CREATED}/${BINARY_NAME}"
# Install
echo "Installing ${BINARY_NAME} to ${INSTALL_DIR}..."
mkdir -p "$INSTALL_DIR" 2>/dev/null || true
if [ -w "$INSTALL_DIR" ]; then
mv "${TMPDIR_CREATED}/${BINARY_NAME}" "${INSTALL_DIR}/${BINARY_NAME}"
else
echo "Write permission denied for ${INSTALL_DIR}, using sudo..."
sudo mv "${TMPDIR_CREATED}/${BINARY_NAME}" "${INSTALL_DIR}/${BINARY_NAME}"
fi
echo "Successfully installed ${BINARY_NAME} ${TAG} to ${INSTALL_DIR}/${BINARY_NAME}"
# Claude Code plugin installation
if command -v claude >/dev/null 2>&1; then
echo ""
printf "Install Claude Code plugin for AI integration? (y/N) "
# Read from /dev/tty to work correctly in curl|sh usage
if read -r INSTALL_PLUGIN < /dev/tty 2>/dev/null; then
case "$INSTALL_PLUGIN" in
[yY]|[yY][eE][sS])
echo "Adding jooto-cli marketplace..."
if claude plugin marketplace add "${REPO}"; then
echo "Installing jooto plugin..."
if claude plugin install jooto@jooto-cli; then
echo "Claude Code plugin installed successfully."
echo "Run /jooto in Claude Code to get started."
else
echo "Warning: Failed to install jooto plugin." >&2
echo "You can install manually: claude plugin install jooto@jooto-cli" >&2
fi
else
echo "Warning: Failed to add marketplace." >&2
echo "You can add manually: claude plugin marketplace add ${REPO}" >&2
fi
;;
*)
echo "Skipping Claude Code plugin installation."
echo "You can install later: claude plugin marketplace add ${REPO} && claude plugin install jooto@jooto-cli"
;;
esac
else
echo "Skipping Claude Code plugin (non-interactive shell)."
echo "To install: claude plugin marketplace add ${REPO} && claude plugin install jooto@jooto-cli"
fi
fi