-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·76 lines (65 loc) · 2.71 KB
/
install.sh
File metadata and controls
executable file
·76 lines (65 loc) · 2.71 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
#!/usr/bin/env bash
BIN_NAME="${1:-${CLAUDEBOX_BIN_NAME:-${CLAUDE_BIN_NAME:-claudebox}}}"
INSTALL_DIR="${CLAUDEBOX_INSTALL_DIR:-${CLAUDE_INSTALL_DIR:-/usr/local/bin}}"
BIN_PATH="$INSTALL_DIR/$BIN_NAME"
echo "🚀 Starting Claude Code setup (binary: $BIN_NAME)..."
# Check for Docker
if ! command -v docker &>/dev/null; then
echo "❌ Docker is not installed. Please install Docker first."
exit 1
fi
echo "📁 Creating ~/.claude directory..."
mkdir -p ~/.claude
echo "🔐 Creating SSH directory for Claude Code..."
mkdir -p "$HOME/.ssh/claudebox"
if [ -f "$HOME/.ssh/claudebox/id_ed25519" ]; then
echo "🔑 SSH key already exists at $HOME/.ssh/claudebox/id_ed25519"
read -rp " Replace existing key? [y/N] " response
if [[ "$response" =~ ^[Yy]$ ]]; then
echo "🗝️ Generating new SSH key for Claude..."
ssh-keygen -t ed25519 -C "claude@claude.ai" -f "$HOME/.ssh/claudebox/id_ed25519" -N ""
else
echo " Keeping existing key."
fi
else
echo "🗝️ Generating SSH key for Claude..."
ssh-keygen -t ed25519 -C "claude@claude.ai" -f "$HOME/.ssh/claudebox/id_ed25519" -N ""
fi
CLAUDE_TAG="latest"
_minimal="${CLAUDEBOX_MINIMAL:-${CLAUDE_MINIMAL:-}}"
[ -n "$_minimal" ] && CLAUDE_TAG="latest-minimal"
if [ "${CLAUDEBOX_SKIP_PULL:-}" = "1" ]; then
echo "📦 Skipping image pull (CLAUDEBOX_SKIP_PULL=1)"
elif docker image inspect "psyb0t/claudebox:$CLAUDE_TAG" >/dev/null 2>&1; then
echo "📦 Image psyb0t/claudebox:$CLAUDE_TAG already present locally, skipping pull (set CLAUDEBOX_FORCE_PULL=1 to override)"
[ "${CLAUDEBOX_FORCE_PULL:-}" = "1" ] && docker pull "psyb0t/claudebox:$CLAUDE_TAG"
else
echo "📦 Pulling Claude Code image (tag: $CLAUDE_TAG)..."
docker pull "psyb0t/claudebox:$CLAUDE_TAG"
fi
# get wrapper.sh — from same dir if running locally, otherwise download from GitHub
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]:-/dev/null}")" 2>/dev/null && pwd)"
WRAPPER_TMP="$(mktemp /tmp/claude-wrapper-XXXXXX.sh)"
if [ -f "$SCRIPT_DIR/wrapper.sh" ]; then
echo "📝 Using local wrapper.sh..."
cp "$SCRIPT_DIR/wrapper.sh" "$WRAPPER_TMP"
else
echo "📝 Downloading wrapper.sh..."
if ! curl -fsSL "https://raw.githubusercontent.com/psyb0t/docker-claudebox/master/wrapper.sh" -o "$WRAPPER_TMP"; then
echo "❌ Failed to download wrapper.sh"
rm -f "$WRAPPER_TMP"
exit 1
fi
fi
if [ ! -s "$WRAPPER_TMP" ]; then
echo "❌ wrapper.sh is empty — download failed"
rm -f "$WRAPPER_TMP"
exit 1
fi
echo "📝 Installing $BIN_NAME to $BIN_PATH..."
sudo install -m 755 "$WRAPPER_TMP" "$BIN_PATH"
rm -f "$WRAPPER_TMP"
echo "✅ Claude Code setup complete! You can now use '$BIN_NAME' command from any directory."
echo ""
echo "🔑 Don't forget to add your public key to GitHub:"
echo " $HOME/.ssh/claudebox/id_ed25519.pub"