claude_install.sh
2.16 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
#!/usr/bin/env bash
set -euo pipefail
export DEBIAN_FRONTEND=${DEBIAN_FRONTEND:-noninteractive}
SCRIPT_DIR=$(CDPATH='' cd -- "$(dirname -- "$0")" && pwd)
BOOTSTRAP_SCRIPT=${CLAUDE_BOOTSTRAP_SCRIPT:-"$SCRIPT_DIR/bootstrap-claude-plugins.sh"}
CLAUDE_SKIP_BOOTSTRAP=${CLAUDE_SKIP_BOOTSTRAP:-0}
require_root() {
if [ "${EUID:-$(id -u)}" -ne 0 ]; then
echo "[error] 请使用 root 运行此脚本。" >&2
exit 1
fi
}
install_base_packages() {
echo "[1/5] 安装基础依赖..."
apt-get update
apt-get install -y --no-install-recommends \
bash \
ca-certificates \
curl \
git \
jq \
less \
procps \
ripgrep \
fd-find \
python3 \
python3-venv \
python3-pip \
nodejs \
npm
}
install_claude_code() {
echo "[2/5] 配置 Claude Code 官方 apt 源..."
install -d -m 0755 /etc/apt/keyrings
curl -fsSL https://downloads.claude.ai/keys/claude-code.asc \
-o /etc/apt/keyrings/claude-code.asc
chmod a+r /etc/apt/keyrings/claude-code.asc
cat >/etc/apt/sources.list.d/claude-code.list <<'EOF'
deb [signed-by=/etc/apt/keyrings/claude-code.asc] https://downloads.claude.ai/claude-code/apt/stable stable main
EOF
echo "[3/5] 安装 Claude Code..."
apt-get update
apt-get install -y claude-code
}
verify_install() {
echo "[4/5] 校验 Claude Code 安装..."
claude --version
}
run_bootstrap() {
if [ "$CLAUDE_SKIP_BOOTSTRAP" = "1" ]; then
echo "[5/5] 跳过插件 bootstrap。"
return
fi
if [ ! -x "$BOOTSTRAP_SCRIPT" ]; then
echo "[error] 未找到可执行 bootstrap 脚本: $BOOTSTRAP_SCRIPT" >&2
exit 1
fi
echo "[5/5] 执行默认插件 bootstrap..."
"$BOOTSTRAP_SCRIPT"
}
print_next_steps() {
cat <<'EOF'
安装完成。
认证方式二选一:
export ANTHROPIC_API_KEY=your_api_key
export CLAUDE_CODE_OAUTH_TOKEN=your_oauth_token
默认插件:
superpowers
pr-review-toolkit
claude-code-setup
ralph-loop
typescript-lsp
rust-analyzer-lsp
如需仅安装 Claude Code 而跳过插件初始化:
CLAUDE_SKIP_BOOTSTRAP=1 ./install-claude-code-debian13.sh
EOF
}
require_root
install_base_packages
install_claude_code
verify_install
run_bootstrap
print_next_steps