|
| 1 | +# Installer - Quick Installation Tool for GitHub Release Binaries |
1 | 2 |
|
2 | | -# `installer` |
3 | | - |
4 | | -Quickly install pre-compiled binaries from Github releases. |
5 | | - |
6 | | -Installer is an HTTP server which returns shell scripts. The returned script will detect platform OS and architecture, choose from a selection of URLs, download the appropriate file, un(zip|tar|gzip) the file, find the binary (largest file) and optionally move it into your `PATH`. Useful for installing your favourite pre-compiled programs on hosts using only `curl`. |
| 3 | +An intelligent HTTP service for quickly installing pre-compiled binaries from GitHub Releases. It automatically detects your system platform (OS and architecture), selects the appropriate asset, downloads, extracts, and optionally moves it to your system PATH. |
7 | 4 |
|
8 | 5 | [](https://pkg.go.dev/github.com/jpillora/installer) |
9 | 6 | [](https://github.com/jpillora/installer/actions?workflow=CI) |
10 | 7 |
|
11 | | -## Cloudflare Workers |
| 8 | +## Features |
12 | 9 |
|
13 | | -### Install |
| 10 | +- 🚀 **One-Command Installation**: Install GitHub Release binaries directly via `curl` |
| 11 | +- 🔍 **Smart Search**: Automatically searches the web for repositories when not found |
| 12 | +- 🎯 **Platform Detection**: Auto-detects OS (Linux, macOS, BSD, etc.) and architecture (amd64, arm64, 386, etc.) |
| 13 | +- 📦 **Multiple Format Support**: Supports `.zip`, `.tar.gz`, `.tar.bz2`, `.tar.xz`, `.gz`, `.bz2` and more |
| 14 | +- 🎭 **Multi-Binary Support**: Install multiple binaries from a single release |
| 15 | +- ☁️ **Cloudflare Workers**: Deploy as Cloudflare Workers for global edge acceleration |
| 16 | +- 🔒 **Private Repository Support**: Access private repos via `GITHUB_TOKEN` |
14 | 17 |
|
15 | | -- [Install Wrangler](https://developers.cloudflare.com/workers/wrangler/install-and-update/) |
16 | | -- [Install Tiny Go](https://tinygo.org/getting-started/install/) |
17 | | -- Install quicktemplate QTC |
18 | | -```sh |
19 | | -go install github.com/valyala/quicktemplate/qtc@latest |
| 18 | +## Quick Start |
| 19 | + |
| 20 | +### Basic Usage |
| 21 | + |
| 22 | +```bash |
| 23 | +# Install a repository (to current directory) |
| 24 | +curl https://your-domain.workers.dev/user/repo | bash |
| 25 | + |
| 26 | +# Install to /usr/local/bin/ (use the ! suffix) |
| 27 | +curl https://your-domain.workers.dev/user/repo! | bash |
| 28 | + |
| 29 | +# Install a specific version |
| 30 | +curl https://your-domain.workers.dev/user/ [email protected]! | bash |
| 31 | + |
| 32 | +# Use repository name only (will attempt search) |
| 33 | +curl https://your-domain.workers.dev/micro! | bash |
20 | 34 | ``` |
21 | 35 |
|
22 | | -### Deploy |
| 36 | +### Install Multiple Binaries |
23 | 37 |
|
24 | | -```sh |
25 | | -wrangler deploy |
| 38 | +```bash |
| 39 | +# Install both client and server from one release |
| 40 | +curl https://your-domain.workers.dev/xtaci/kcptun!?mp=client,server | bash |
26 | 41 | ``` |
27 | 42 |
|
28 | | -### Call Workers |
| 43 | +## Usage |
29 | 44 |
|
30 | | -- Support multiple binaries, support both exact and fuzzy matching for files |
| 45 | +### URL Format |
31 | 46 |
|
32 | | -```sh |
33 | | -# mp means multi program |
34 | | -# mp fuzzy matching: client_linux_amd64, you can just input client |
35 | | -curl https://your-workers-domain.workers.dev/xtaci/kcptun!?mp=client,server | bash |
36 | | -mv /usr/local/bin/client /usr/local/bin/kcptun_client |
37 | | -mv /usr/local/bin/server /usr/local/bin/kcptun_server |
38 | | -/usr/local/bin/kcptun_client -v |
39 | | -/usr/local/bin/kcptun_server -v |
40 | | -# exact matching, only install sslocal and ssserver |
41 | | -curl https://xxx-yyy.zzz.workers.dev/shadowsocks/shadowsocks-rust!?mp=sslocal,ssserver | bash |
42 | | -mv /usr/local/bin/sslocal /usr/local/bin/ss_client |
43 | | -mv /usr/local/bin/ssserver /usr/local/bin/ss_server |
44 | | -/usr/local/bin/ss_client -V |
45 | | -/usr/local/bin/ss_server -V |
| 47 | +``` |
| 48 | +https://your-domain.workers.dev/<user>/<repo>@<release>!?<parameters> |
46 | 49 | ``` |
47 | 50 |
|
| 51 | +### Path Parameters |
48 | 52 |
|
49 | | -## Usage |
| 53 | +- `user` - GitHub username (optional, uses default if omitted) |
| 54 | +- `repo` - Repository name (required) |
| 55 | +- `release` - Release version (optional, defaults to `latest`) |
| 56 | +- `!` - Install to `/usr/local/bin/` (optional, without it installs to current directory) |
| 57 | + |
| 58 | +### Query Parameters |
| 59 | + |
| 60 | +| Parameter | Description | Example | |
| 61 | +|-----------|-------------|---------| |
| 62 | +| `mp` | Install multiple programs (comma-separated) | `?mp=client,server` | |
| 63 | +| `as` | Rename the binary | `?as=rg` | |
| 64 | +| `os` | Override OS detection | `?os=linux` | |
| 65 | +| `arch` | Override architecture detection | `?arch=arm64` | |
| 66 | +| `type` | Output format (`script`, `json`, `text`) | `?type=json` | |
| 67 | +| `select` | Select specific asset variant | `?select=musl` | |
| 68 | +| `insecure` | Skip SSL verification | `?insecure=1` | |
| 69 | + |
| 70 | +## Examples |
| 71 | + |
| 72 | +### Install micro Editor |
50 | 73 |
|
51 | | -```sh |
52 | | -# install <user>/<repo> from github |
53 | | -curl https://i.jpillora.com/<user>/<repo>@<release>! | bash |
| 74 | +```bash |
| 75 | +curl https://your-domain.workers.dev/zyedidia/micro! | bash |
| 76 | +micro --version |
54 | 77 | ``` |
55 | 78 |
|
56 | | -```sh |
57 | | -# search web for github repo <query> |
58 | | -curl https://i.jpillora.com/<query>! | bash |
| 79 | +### Install Caddy Web Server |
| 80 | + |
| 81 | +```bash |
| 82 | +curl https://your-domain.workers.dev/caddyserver/ [email protected]! | bash |
| 83 | +caddy version |
59 | 84 | ``` |
60 | 85 |
|
61 | | -*Or you can use* `wget -qO- <url> | bash` |
| 86 | +### Install and Rename ripgrep |
62 | 87 |
|
63 | | -**Path API** |
| 88 | +```bash |
| 89 | +curl https://your-domain.workers.dev/BurntSushi/ripgrep!?as=rg | bash |
| 90 | +rg --version |
| 91 | +``` |
64 | 92 |
|
65 | | -* `user` Github user (defaults to @jpillora, customisable if you [host your own](#host-your-own), searches the web to pick most relevant `user` when `repo` not found) |
66 | | -* `repo` Github repository belonging to `user` (**required**) |
67 | | -* `release` Github release name (defaults to the **latest** release) |
68 | | -* `!` When provided, downloads binary directly into `/usr/local/bin/` (defaults to working directory) |
| 93 | +### Install Multiple Binaries (kcptun) |
69 | 94 |
|
70 | | -**Query Params** |
| 95 | +```bash |
| 96 | +curl https://your-domain.workers.dev/xtaci/kcptun!?mp=client,server | bash |
| 97 | +mv /usr/local/bin/client /usr/local/bin/kcptun-client |
| 98 | +mv /usr/local/bin/server /usr/local/bin/kcptun-server |
| 99 | +``` |
71 | 100 |
|
72 | | -* `?type=` Force the return type to be one of: `script` or `homebrew` |
73 | | - * `type` is normally detected via `User-Agent` header |
74 | | - * `type=homebrew` is **not** working at the moment – see [Homebrew](#homebrew) |
75 | | -* `?insecure=1` Force `curl`/`wget` to skip certificate checks |
76 | | -* `?as=` Force the binary to be named as this parameter value |
77 | | -* `?os=` Explicit set OS (ignore system OS) |
78 | | -* `?arch=` Explicit set architecture (ignore system arch) |
| 101 | +### Install shadowsocks-rust |
79 | 102 |
|
80 | | -## Security |
| 103 | +```bash |
| 104 | +curl https://your-domain.workers.dev/shadowsocks/shadowsocks-rust!?mp=sslocal,ssserver | bash |
| 105 | +``` |
81 | 106 |
|
82 | | -:warning: Although I promise [my instance of `installer`](https://i.jpillora.com/) is simply a copy of this repo - you're right to be wary of piping shell scripts from unknown servers, so you can host your own server [here](#host-your-own) or just leave off `| bash` and checkout the script yourself. |
| 107 | +### Use in Docker |
83 | 108 |
|
84 | | -## Examples |
| 109 | +```dockerfile |
| 110 | +FROM ubuntu:22.04 |
| 111 | +RUN apt-get update && apt-get install -y curl |
| 112 | +RUN curl https://your-domain.workers.dev/zyedidia/micro! | bash |
| 113 | +CMD ["/bin/bash"] |
| 114 | +``` |
85 | 115 |
|
86 | | -* https://i.jpillora.com/serve |
87 | | -* https://i.jpillora.com/cloud-torrent |
88 | | -* https://i.jpillora.com/yudai/[email protected] |
89 | | -* https://i.jpillora.com/mholt/caddy |
90 | | -* https://i.jpillora.com/caddy |
91 | | -* https://i.jpillora.com/rclone |
92 | | -* https://i.jpillora.com/ripgrep?as=rg |
| 116 | +### Debug Installation |
93 | 117 |
|
94 | | - ```sh |
95 | | - $ curl -s i.jpillora.com/mholt/caddy! | bash |
96 | | - Downloading mholt/caddy v0.8.2 (https://github.com/mholt/caddy/releases/download/v0.8.2/caddy_darwin_amd64.zip) |
97 | | - ######################################################################## 100.0% |
98 | | - Downloaded to /usr/local/bin/caddy |
99 | | - $ caddy --version |
100 | | - Caddy 0.8.2 |
101 | | - ``` |
| 118 | +```bash |
| 119 | +# View script without executing |
| 120 | +curl https://your-domain.workers.dev/jpillora/serve |
102 | 121 |
|
103 | | -## Private repos |
| 122 | +# Run with debug output |
| 123 | +DEBUG=1 curl https://your-domain.workers.dev/jpillora/serve! | bash |
104 | 124 |
|
105 | | -You'll have to set `GITHUB_TOKEN` on both your server (instance of `installer`) and client (before you run `curl https://i.jpillora.com/foobar | bash`) |
| 125 | +# Get JSON asset information |
| 126 | +curl "https://your-domain.workers.dev/jpillora/serve?type=json" |
| 127 | +``` |
106 | 128 |
|
107 | | -See https://github.com/jpillora/installer/issues/31 for how this could improved |
| 129 | +## Deployment |
108 | 130 |
|
109 | | -## Host your own |
| 131 | +### Cloudflare Workers (Recommended) |
110 | 132 |
|
111 | | -* Install installer with installer |
| 133 | +#### Prerequisites |
112 | 134 |
|
113 | | - ```sh |
114 | | - curl -s https://i.jpillora.com/installer | bash |
115 | | - ``` |
| 135 | +```bash |
| 136 | +# Install Wrangler CLI |
| 137 | +npm install -g wrangler |
116 | 138 |
|
117 | | -* Install from source |
| 139 | +# Install TinyGo |
| 140 | +brew install tinygo # macOS |
118 | 141 |
|
119 | | - ```sh |
120 | | - go get github.com/jpillora/installer |
121 | | - ``` |
| 142 | +# Install quicktemplate |
| 143 | +go install github.com/valyala/quicktemplate/qtc@latest |
| 144 | +``` |
122 | 145 |
|
123 | | -* Install on [Fly.io](https://fly.io) |
| 146 | +#### Configure |
124 | 147 |
|
125 | | - * Clone this repo |
126 | | - * Setup the `fly` CLI tool |
127 | | - * Create a new app |
128 | | - * Replace `app = "installer"` in `fly.toml` with your app name |
129 | | - * Run `fly deploy` |
| 148 | +Edit `wrangler.jsonc`: |
130 | 149 |
|
131 | | -## Force a particular `user/repo` |
| 150 | +```jsonc |
| 151 | +{ |
| 152 | + "vars": { |
| 153 | + "DEFAULT_USER": "your-github-username", |
| 154 | + "GITHUB_TOKEN": "ghp_xxxxx" // Optional |
| 155 | + } |
| 156 | +} |
| 157 | +``` |
132 | 158 |
|
133 | | -In some cases, people want an installer server for a single tool |
| 159 | +#### Deploy |
134 | 160 |
|
135 | | -```sh |
136 | | -export FORCE_USER=zyedidia |
137 | | -export FORCE_REPO=micro |
138 | | -./installer |
| 161 | +```bash |
| 162 | +make build |
| 163 | +wrangler deploy |
139 | 164 | ``` |
140 | 165 |
|
141 | | -Then calls to `curl localhost:3000` will return the install script for `zyedidia/micro` |
| 166 | +### Fly.io |
142 | 167 |
|
143 | | -### Homebrew |
| 168 | +```bash |
| 169 | +fly auth login |
| 170 | +fly deploy |
| 171 | +``` |
| 172 | + |
| 173 | +### Run Locally |
| 174 | + |
| 175 | +```bash |
| 176 | +# Install dependencies |
| 177 | +go mod download |
144 | 178 |
|
145 | | -Currently, installing via Homebrew does not work. Homebrew was intended to be supported with: |
| 179 | +# Run |
| 180 | +go run main.go |
146 | 181 |
|
| 182 | +# Or with custom config |
| 183 | +PORT=8080 USER=myusername go run main.go |
147 | 184 | ``` |
148 | | -#does not work |
149 | | -brew install https://i.jpillora.com/serve |
| 185 | + |
| 186 | +#### Environment Variables |
| 187 | + |
| 188 | +| Variable | Description | Default | |
| 189 | +|----------|-------------|---------| |
| 190 | +| `PORT` | Listen port | `3000` | |
| 191 | +| `USER` / `DEFAULT_USER` | Default GitHub user | `cxjava` | |
| 192 | +| `GITHUB_TOKEN` | GitHub API token (optional) | - | |
| 193 | +| `FORCE_USER` | Lock to specific user (optional) | - | |
| 194 | +| `FORCE_REPO` | Lock to specific repo (optional) | - | |
| 195 | + |
| 196 | +## Supported Platforms |
| 197 | + |
| 198 | +### Operating Systems |
| 199 | +Linux, macOS, FreeBSD, OpenBSD, NetBSD, DragonFly BSD, Android, Solaris |
| 200 | + |
| 201 | +### Architectures |
| 202 | +amd64, arm64, 386, arm, loong64, ppc64, ppc64le, riscv64, mips, mips64, s390x, wasm |
| 203 | + |
| 204 | +### Compression Formats |
| 205 | +`.zip`, `.tar.gz`, `.tgz`, `.tar.bz2`, `.tar.xz`, `.txz`, `.gz`, `.bz2`, `.bin` |
| 206 | + |
| 207 | +## Tips |
| 208 | + |
| 209 | +### GitHub API Rate Limits |
| 210 | + |
| 211 | +GitHub API limits: |
| 212 | +- Unauthenticated: 60 requests/hour |
| 213 | +- Authenticated: 5000 requests/hour |
| 214 | + |
| 215 | +Get a token at https://github.com/settings/tokens and set: |
| 216 | + |
| 217 | +```bash |
| 218 | +export GITHUB_TOKEN=ghp_xxxxxxxxxxxx |
150 | 219 | ``` |
151 | 220 |
|
152 | | -However, homebrew formulas require an SHA1 hash of each binary and currently, the only way to get is to actually download the file. It **might** be acceptable to download all assets if the resulting `.rb` file was cached for a long time. |
| 221 | +### Apple Silicon Compatibility |
153 | 222 |
|
154 | | -#### MIT License |
| 223 | +The script automatically detects ARM64 versions. If unavailable, falls back to amd64 (runs via Rosetta 2). |
155 | 224 |
|
156 | | -Copyright © 2020 Jaime Pillora <[email protected]> |
| 225 | +### Security Warning |
157 | 226 |
|
158 | | -Permission is hereby granted, free of charge, to any person obtaining |
159 | | -a copy of this software and associated documentation files (the |
160 | | -'Software'), to deal in the Software without restriction, including |
161 | | -without limitation the rights to use, copy, modify, merge, publish, |
162 | | -distribute, sublicense, and/or sell copies of the Software, and to |
163 | | -permit persons to whom the Software is furnished to do so, subject to |
164 | | -the following conditions: |
| 227 | +⚠️ Piping scripts from the internet to bash carries security risks. Always inspect scripts first or deploy your own instance. |
| 228 | + |
| 229 | +```bash |
| 230 | +# Inspect before executing |
| 231 | +curl https://your-domain.workers.dev/user/repo |
| 232 | +``` |
165 | 233 |
|
166 | | -The above copyright notice and this permission notice shall be |
167 | | -included in all copies or substantial portions of the Software. |
| 234 | +## License |
168 | 235 |
|
169 | | -THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, |
170 | | -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
171 | | -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
172 | | -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY |
173 | | -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
174 | | -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
175 | | -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 236 | +MIT License - Copyright © 2020 Jaime Pillora <[email protected]> |
0 commit comments