Skip to content

Commit fb3725e

Browse files
committed
Enhance installation instructions and script for gapura-sentinel. Added GitHub Release installation method in README and install.md, and improved install.sh to download and verify the latest release automatically.
1 parent da761bf commit fb3725e

3 files changed

Lines changed: 80 additions & 13 deletions

File tree

README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,15 @@ Contoh pakai:
5454

5555
### Sentinel (host) — `gapura-sentinel`
5656

57-
Build:
57+
Install (recommended, from GitHub Release):
58+
59+
```bash
60+
curl -fsSL https://raw.githubusercontent.com/sangkan-dev/gapura/main/scripts/install.sh -o install.sh
61+
chmod +x install.sh
62+
./install.sh
63+
```
64+
65+
Build from source (alternative):
5866

5967
```bash
6068
cd sentinel

docs/install.md

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,16 @@ This guide installs **`gapura-sentinel`** on a Linux SSH host and configures Ope
66

77
- Linux host running OpenSSH (`sshd`)
88
- Outbound HTTPS to your EVM RPC endpoint
9-
- `gapura-sentinel` binary built on the host or copied over
9+
- `curl`, `jq`, `sha256sum` (untuk install dari GitHub Release)
1010

1111
## Quick install (script)
1212

13-
From the repo root on the target host:
13+
### Install dari GitHub Release (default)
1414

1515
```bash
16-
cd gapura
17-
cd sentinel && cargo build --release
18-
19-
./scripts/install.sh
16+
curl -fsSL https://raw.githubusercontent.com/sangkan-dev/gapura/main/scripts/install.sh -o install.sh
17+
chmod +x install.sh
18+
./install.sh
2019
```
2120

2221
The script:
@@ -27,6 +26,18 @@ The script:
2726
- writes `/etc/ssh/sshd_config.d/99-gapura.conf`
2827
- runs `sshd -t`
2928

29+
### Install dari source (alternatif)
30+
31+
Jika kamu tidak ingin download artifact, kamu bisa build dari source:
32+
33+
```bash
34+
git clone https://github.com/sangkan-dev/gapura.git
35+
cd gapura
36+
cd sentinel && cargo build --release
37+
cd ..
38+
SENTINEL_BIN=./sentinel/target/release/gapura-sentinel ./scripts/install.sh
39+
```
40+
3041
## Configure
3142

3243
1. Edit `/etc/gapura/sentinel.toml`:

scripts/install.sh

Lines changed: 54 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,71 @@
77
# - Optional disk cache dir /var/lib/gapura/cache
88
# - Writes sshd config fragment /etc/ssh/sshd_config.d/99-gapura.conf
99
#
10-
# Requires: sudo/root, OpenSSH, and a built binary at:
11-
# sentinel/target/release/gapura-sentinel
10+
# Default behavior: download `gapura-sentinel` from GitHub Releases and install it.
11+
# Fallback: set `SENTINEL_BIN=/path/to/gapura-sentinel` to install a local binary.
1212
set -euo pipefail
1313

1414
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
1515

1616
SENTINEL_BIN="${SENTINEL_BIN:-$ROOT/sentinel/target/release/gapura-sentinel}"
17+
REPO="${REPO:-sangkan-dev/gapura}"
18+
TMP_DIR="${TMP_DIR:-/tmp/gapura-install.$$}"
1719
INSTALL_BIN_DIR="${INSTALL_BIN_DIR:-/usr/local/bin}"
1820
CONFIG_DIR="${CONFIG_DIR:-/etc/gapura}"
1921
CACHE_DIR="${CACHE_DIR:-/var/lib/gapura/cache}"
2022
SSHD_FRAGMENT="${SSHD_FRAGMENT:-/etc/ssh/sshd_config.d/99-gapura.conf}"
2123
SENTINEL_USER="${SENTINEL_USER:-gapura-sentinel}"
2224

23-
if [[ ! -x "$SENTINEL_BIN" ]]; then
24-
echo "missing executable: $SENTINEL_BIN" >&2
25-
echo "build it with: (cd sentinel && cargo build --release)" >&2
26-
exit 1
25+
need() {
26+
command -v "$1" >/dev/null 2>&1 || { echo "missing dependency: $1" >&2; exit 1; }
27+
}
28+
29+
download_latest_release() {
30+
need curl
31+
need jq
32+
need sha256sum
33+
34+
mkdir -p "$TMP_DIR"
35+
local api="https://api.github.com/repos/$REPO/releases/latest"
36+
echo "==> fetching latest release: $REPO"
37+
local json
38+
json="$(curl -fsSL "$api")"
39+
40+
local url_bin url_sums
41+
url_bin="$(echo "$json" | jq -r '.assets[] | select(.name=="gapura-sentinel-linux-x86_64") | .browser_download_url' | head -n1)"
42+
url_sums="$(echo "$json" | jq -r '.assets[] | select(.name=="SHA256SUMS") | .browser_download_url' | head -n1)"
43+
44+
if [[ -z "$url_bin" || "$url_bin" == "null" ]]; then
45+
echo "release asset not found: gapura-sentinel-linux-x86_64" >&2
46+
exit 1
47+
fi
48+
if [[ -z "$url_sums" || "$url_sums" == "null" ]]; then
49+
echo "release asset not found: SHA256SUMS" >&2
50+
exit 1
51+
fi
52+
53+
echo "==> downloading artifacts"
54+
curl -fL "$url_bin" -o "$TMP_DIR/gapura-sentinel-linux-x86_64"
55+
curl -fL "$url_sums" -o "$TMP_DIR/SHA256SUMS"
56+
57+
echo "==> verifying checksum"
58+
(cd "$TMP_DIR" && sha256sum -c SHA256SUMS --ignore-missing)
59+
60+
chmod +x "$TMP_DIR/gapura-sentinel-linux-x86_64"
61+
SENTINEL_BIN="$TMP_DIR/gapura-sentinel-linux-x86_64"
62+
}
63+
64+
cleanup() {
65+
if [[ "${TMP_DIR:-}" == /tmp/gapura-install.* && -d "${TMP_DIR:-}" ]]; then
66+
rm -rf "$TMP_DIR" || true
67+
fi
68+
}
69+
trap cleanup EXIT
70+
71+
if [[ -x "$SENTINEL_BIN" ]]; then
72+
echo "==> installing from local binary: $SENTINEL_BIN"
73+
else
74+
download_latest_release
2775
fi
2876

2977
sudo mkdir -p "$INSTALL_BIN_DIR"

0 commit comments

Comments
 (0)