mirror of
https://github.com/cexll/myclaude.git
synced 2026-02-05 02:30:26 +08:00
Previously install.sh only wrote PATH to ~/.bashrc (or ~/.zshrc), which doesn't work for non-interactive login shells like `bash -lc` used by Claude Code, because Ubuntu's ~/.bashrc exits early for non-interactive shells. Now writes to both: - bash: ~/.bashrc + ~/.profile - zsh: ~/.zshrc + ~/.zprofile Each file is checked independently for idempotency. Closes #128 Generated with SWE-Agent.ai Co-Authored-By: SWE-Agent.ai <noreply@swe-agent.ai>
85 lines
2.4 KiB
Bash
85 lines
2.4 KiB
Bash
#!/bin/bash
|
|
set -e
|
|
|
|
if [ -z "${SKIP_WARNING:-}" ]; then
|
|
echo "⚠️ WARNING: install.sh is LEGACY and will be removed in future versions."
|
|
echo "Please use the new installation method:"
|
|
echo " python3 install.py --install-dir ~/.claude"
|
|
echo ""
|
|
echo "Set SKIP_WARNING=1 to bypass this message"
|
|
echo "Continuing with legacy installation in 5 seconds..."
|
|
sleep 5
|
|
fi
|
|
|
|
# Detect platform
|
|
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
|
|
ARCH=$(uname -m)
|
|
|
|
# Normalize architecture names
|
|
case "$ARCH" in
|
|
x86_64) ARCH="amd64" ;;
|
|
aarch64|arm64) ARCH="arm64" ;;
|
|
*) echo "Unsupported architecture: $ARCH" >&2; exit 1 ;;
|
|
esac
|
|
|
|
# Build download URL
|
|
REPO="cexll/myclaude"
|
|
VERSION="latest"
|
|
BINARY_NAME="codeagent-wrapper-${OS}-${ARCH}"
|
|
URL="https://github.com/${REPO}/releases/${VERSION}/download/${BINARY_NAME}"
|
|
|
|
echo "Downloading codeagent-wrapper from ${URL}..."
|
|
if ! curl -fsSL "$URL" -o /tmp/codeagent-wrapper; then
|
|
echo "ERROR: failed to download binary" >&2
|
|
exit 1
|
|
fi
|
|
|
|
INSTALL_DIR="${INSTALL_DIR:-$HOME/.claude}"
|
|
BIN_DIR="${INSTALL_DIR}/bin"
|
|
mkdir -p "$BIN_DIR"
|
|
|
|
mv /tmp/codeagent-wrapper "${BIN_DIR}/codeagent-wrapper"
|
|
chmod +x "${BIN_DIR}/codeagent-wrapper"
|
|
|
|
if "${BIN_DIR}/codeagent-wrapper" --version >/dev/null 2>&1; then
|
|
echo "codeagent-wrapper installed successfully to ${BIN_DIR}/codeagent-wrapper"
|
|
else
|
|
echo "ERROR: installation verification failed" >&2
|
|
exit 1
|
|
fi
|
|
|
|
# Auto-add to shell config files with idempotency
|
|
if [[ ":${PATH}:" != *":${BIN_DIR}:"* ]]; then
|
|
echo ""
|
|
echo "WARNING: ${BIN_DIR} is not in your PATH"
|
|
|
|
# Detect shell and set config files
|
|
if [ -n "$ZSH_VERSION" ]; then
|
|
RC_FILE="$HOME/.zshrc"
|
|
PROFILE_FILE="$HOME/.zprofile"
|
|
else
|
|
RC_FILE="$HOME/.bashrc"
|
|
PROFILE_FILE="$HOME/.profile"
|
|
fi
|
|
|
|
# Idempotent add: check if complete export statement already exists
|
|
EXPORT_LINE="export PATH=\"${BIN_DIR}:\$PATH\""
|
|
FILES_TO_UPDATE=("$RC_FILE" "$PROFILE_FILE")
|
|
|
|
for FILE in "${FILES_TO_UPDATE[@]}"; do
|
|
if [ -f "$FILE" ] && grep -qF "${EXPORT_LINE}" "$FILE" 2>/dev/null; then
|
|
echo " ${BIN_DIR} already in ${FILE}, skipping."
|
|
else
|
|
echo " Adding to ${FILE}..."
|
|
echo "" >> "$FILE"
|
|
echo "# Added by myclaude installer" >> "$FILE"
|
|
echo "${EXPORT_LINE}" >> "$FILE"
|
|
fi
|
|
done
|
|
|
|
echo " Done. Restart your shell or run:"
|
|
echo " source ${PROFILE_FILE}"
|
|
echo " source ${RC_FILE}"
|
|
echo ""
|
|
fi
|