# Claude Code Install Mirror

This directory mirrors the Claude Code release artifacts originally hosted at
`https://downloads.claude.ai/claude-code-releases`.

## Mirrored version

- Current mirrored version: `2.1.181`
- Original install script: `https://claude.ai/install.sh`
- Mirror base URL (local): `http://localhost:8080/claude-code-releases`
- Public mirror URL: `https://dev.tryliang.me/claude-code-releases`
- Public install command: `curl -fsSL https://dev.tryliang.me/install-claude.sh | bash`

## Layout

```
.
├── claude-code-releases -> .   # Symlink so /claude-code-releases/ works with simple HTTP servers
├── install.sh                   # Modified install script that points to the mirror
├── serve.py                     # Python HTTP server to serve the mirror
├── nginx.conf                   # Sample nginx configuration
├── README.md                    # This file
├── latest                       # Text file containing the current version
├── update-mirror.sh             # Helper to sync the mirror with upstream
├── verify-checksums.sh          # Helper to verify all mirrored binaries
└── 2.1.181/
    ├── manifest.json
    ├── darwin-arm64/claude
    ├── darwin-x64/claude
    ├── linux-arm64/claude
    ├── linux-x64/claude
    ├── linux-arm64-musl/claude
    ├── linux-x64-musl/claude
    ├── win32-x64/claude.exe
    └── win32-arm64/claude.exe
```

## How the original installer works

1. `curl -fsSL https://claude.ai/install.sh | bash` downloads the install script.
2. The script detects the OS/architecture (`darwin-x64`, `darwin-arm64`, `linux-x64`,
   `linux-arm64`, `linux-x64-musl`, `linux-arm64-musl`).
3. It fetches `https://downloads.claude.ai/claude-code-releases/latest` to get the
   latest version string.
4. It downloads `/<version>/manifest.json` and extracts the SHA-256 checksum for the
   detected platform.
5. It downloads `/<version>/<platform>/claude` and verifies the checksum.
6. The mirror scripts set up the launcher and shell integration **directly in bash**
   instead of running `claude install`, so the binary never contacts the upstream
   CDN. This makes the install work in networks where `downloads.claude.ai` is
   unreachable.
7. The downloaded binary is removed after installation.

## How to use this mirror

### Option 1: Python HTTP server

```bash
cd /home/youdt/claude/mirror
python3 serve.py --port 8080
```

Then on the target machine:

```bash
export CLAUDE_MIRROR_URL=http://<mirror-host>:8080/claude-code-releases
curl -fsSL http://<mirror-host>:8080/claude-code-releases/../install.sh | bash
```

> The mirror install script reads `CLAUDE_MIRROR_URL`; if unset it defaults to
> `http://localhost:8080/claude-code-releases`.
>
> The `claude-code-releases -> .` symlink lets simple HTTP servers expose the
> same `/claude-code-releases/` path used by nginx and the original CDN URL.

### Option 2: nginx

Copy `nginx.conf` into your nginx `sites-enabled` directory (adjust paths and port
as needed) and reload nginx.

### Option 3: Public HTTPS mirror (current setup)

A Docker container running nginx serves this mirror on `dev.tryliang.me` using
the existing Let's Encrypt certificate:

```bash
cd /home/youdt/claude/mirror
./run-nginx-docker.sh
```

Anyone can then install Claude Code with:

```bash
curl -fsSL https://dev.tryliang.me/install-claude.sh | bash
```

Files involved:
- `dev.tryliang.me.nginx.conf` — nginx virtual host
- `install-claude.sh` — install script defaulting to the public mirror URL
- `run-nginx-docker.sh` — helper to start the Docker container

### Option 4: Static file server

Serve the contents of this directory with any static file server and ensure the
URL path `/claude-code-releases/` maps to this directory.

## Updating the mirror

Run the helper script (or re-run the equivalent commands) to fetch a newer version:

```bash
./update-mirror.sh
```

## Verifying checksums

To verify all mirrored binaries against the manifest:

```bash
./verify-checksums.sh
```
