Skip to content

Commit 9bee84b

Browse files
Add one-liner setup
1 parent b843815 commit 9bee84b

3 files changed

Lines changed: 105 additions & 0 deletions

File tree

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ Caddy exposes rich metrics through its admin API and Prometheus endpoint, but re
5151

5252
## Install
5353

54+
```bash
55+
curl -fsSL https://raw.githubusercontent.com/alexandre-daubois/ember/main/install.sh | sh
56+
```
57+
58+
Or with Homebrew:
59+
5460
```bash
5561
brew install alexandre-daubois/tap/ember
5662
```

docs/getting-started.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,18 @@ This guide covers installation, prerequisites, and your first run with Ember.
99

1010
## Installation
1111

12+
### One-liner
13+
14+
```bash
15+
curl -fsSL https://raw.githubusercontent.com/alexandre-daubois/ember/main/install.sh | sh
16+
```
17+
18+
This detects your platform (Linux/macOS, amd64/arm64), downloads the latest release from GitHub, and installs the binary to `/usr/local/bin`. You can override the install directory with `EMBER_INSTALL_DIR`:
19+
20+
```bash
21+
curl -fsSL https://raw.githubusercontent.com/alexandre-daubois/ember/main/install.sh | EMBER_INSTALL_DIR=~/.local/bin sh
22+
```
23+
1224
### Homebrew
1325

1426
```bash

install.sh

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
#!/bin/sh
2+
set -eu
3+
4+
REPO="alexandre-daubois/ember"
5+
INSTALL_DIR="${EMBER_INSTALL_DIR:-/usr/local/bin}"
6+
7+
fail() {
8+
printf "error: %s\n" "$1" >&2
9+
exit 1
10+
}
11+
12+
detect_os() {
13+
case "$(uname -s)" in
14+
Linux*) echo "linux" ;;
15+
Darwin*) echo "darwin" ;;
16+
*) fail "unsupported OS: $(uname -s)" ;;
17+
esac
18+
}
19+
20+
detect_arch() {
21+
case "$(uname -m)" in
22+
x86_64|amd64) echo "amd64" ;;
23+
aarch64|arm64) echo "arm64" ;;
24+
*) fail "unsupported architecture: $(uname -m)" ;;
25+
esac
26+
}
27+
28+
need_cmd() {
29+
if ! command -v "$1" > /dev/null 2>&1; then
30+
fail "'$1' is required but not found"
31+
fi
32+
}
33+
34+
need_cmd uname
35+
need_cmd mktemp
36+
need_cmd tar
37+
38+
OS=$(detect_os)
39+
ARCH=$(detect_arch)
40+
41+
if command -v curl > /dev/null 2>&1; then
42+
fetch() { curl -fsSL "$1"; }
43+
download() { curl -fsSL -o "$1" "$2"; }
44+
elif command -v wget > /dev/null 2>&1; then
45+
fetch() { wget -qO- "$1"; }
46+
download() { wget -qO "$1" "$2"; }
47+
else
48+
fail "'curl' or 'wget' is required but neither was found"
49+
fi
50+
51+
printf "Detecting platform... %s/%s\n" "$OS" "$ARCH"
52+
53+
LATEST_URL="https://api.github.com/repos/${REPO}/releases/latest"
54+
TAG=$(fetch "$LATEST_URL" | grep '"tag_name"' | head -1 | sed 's/.*"tag_name": *"//;s/".*//')
55+
56+
if [ -z "$TAG" ]; then
57+
fail "could not determine latest release"
58+
fi
59+
60+
VERSION="${TAG#v}"
61+
printf "Latest version: %s\n" "$VERSION"
62+
63+
ARCHIVE="ember_${VERSION}_${OS}_${ARCH}.tar.gz"
64+
DOWNLOAD_URL="https://github.com/${REPO}/releases/download/${TAG}/${ARCHIVE}"
65+
66+
TMPDIR=$(mktemp -d)
67+
trap 'rm -rf "$TMPDIR"' EXIT
68+
69+
printf "Downloading %s...\n" "$ARCHIVE"
70+
download "${TMPDIR}/${ARCHIVE}" "$DOWNLOAD_URL"
71+
72+
printf "Extracting...\n"
73+
tar -xzf "${TMPDIR}/${ARCHIVE}" -C "$TMPDIR"
74+
75+
if [ ! -f "${TMPDIR}/ember" ]; then
76+
fail "binary not found in archive"
77+
fi
78+
79+
printf "Installing to %s...\n" "$INSTALL_DIR"
80+
if [ -w "$INSTALL_DIR" ]; then
81+
mv "${TMPDIR}/ember" "${INSTALL_DIR}/ember"
82+
else
83+
sudo mv "${TMPDIR}/ember" "${INSTALL_DIR}/ember"
84+
fi
85+
chmod +x "${INSTALL_DIR}/ember"
86+
87+
printf "ember %s installed successfully!\n" "$VERSION"

0 commit comments

Comments
 (0)