eleven / ocho Public

Clone
git clone https://amadan.net/eleven/ocho

Plain git — no account needed to clone.

Download

Download this file

1#!/usr/bin/env bash
2# Install (or update) the lchat server on this box.
3#
4# curl -fsSL https://github.com/elevenmessenger/releases/releases/download/server/install.sh | sudo bash
5#
6# Downloads the latest STABLE release for this machine's architecture from the
7# public releases repo, verifies its sha256 against the published checksum,
8# installs it at /opt/lchat/lchat, and runs `lchat bootstrap` (idempotent: it
9# installs/refreshes the systemd units, creates /data, enables the router and
10# the hourly auto-update timer, and installs the public status collectors +
11# their viewer pages + 5-minute timers). Re-running this script updates the
12# binary and refreshes the units; it never touches /data, so it's safe on a
13# live box.
14#
15# After install, the box keeps itself current from the stable channel — see
16# docs/self-hosting.md in the elevenmessenger/messenger repo.
17set -euo pipefail
18
19REPO="${LCHAT_RELEASES_REPO:-elevenmessenger/releases}"
20BASE="https://github.com/$REPO/releases/download/server"
21
22say() { printf '%s\n' "$*"; }
23fail() { printf 'install: %s\n' "$*" >&2; exit 1; }
24
25# Everything runs from main(), invoked on the last line — so a truncated
26# `curl | bash` transfer fails to parse and executes NOTHING, instead of
27# running whatever prefix happened to arrive.
28main() {
29
30[ "$(id -u)" = 0 ] || fail "must run as root (it installs systemd units and creates the service user) — re-run with sudo"
31[ -d /run/systemd/system ] || fail "this box isn't running systemd — lchat's supervision, zero-downtime deploys, and auto-updates are all systemd units (Ubuntu and Debian are the tested platforms)"
32[ -f /etc/debian_version ] || say "note: not a Debian-family system — Ubuntu/Debian are what we test on; continuing anyway"
33
34case "$(uname -m)" in
35x86_64) ARCH=amd64 ;;
36aarch64) ARCH=arm64 ;;
37*) fail "unsupported architecture $(uname -m) — builds are published for x86_64 (amd64) and aarch64 (arm64)" ;;
38esac
39BIN="lchat-linux-$ARCH"
40
41TMP="$(mktemp -d)"
42trap 'rm -rf "$TMP"' EXIT
43
44say "Downloading the latest stable lchat ($ARCH)..."
45curl -fsSL "$BASE/$BIN" -o "$TMP/$BIN" || fail "download failed — is $BASE/$BIN reachable?"
46curl -fsSL "$BASE/$BIN.sha256" -o "$TMP/$BIN.sha256" || fail "checksum download failed"
47(cd "$TMP" && sha256sum -c "$BIN.sha256" >/dev/null) || fail "sha256 verification FAILED — refusing to install (a truncated download, or something is tampering with the download path)"
48
49# Temp + rename on the same filesystem, so a crash mid-install never leaves a
50# half-written binary and a re-run always lands atomically over the old one.
51mkdir -p /opt/lchat
52install -m 0755 "$TMP/$BIN" /opt/lchat/lchat.new
53mv /opt/lchat/lchat.new /opt/lchat/lchat
54say "Installed $(/opt/lchat/lchat version) at /opt/lchat/lchat"
55
56say "Running bootstrap (systemd units, /data, router, auto-update timer)..."
57/opt/lchat/lchat bootstrap
58
59cat <<'EOF'
60
61Done. Next:
62
63 1. Point a DNS A record at this box, e.g. chat.example.com -> this IP
64 (ports 80 and 443 must be open — TLS certs issue automatically).
65 2. Create your chat:
66
67 lchat add-instance chat.example.com
68
69 It prints a one-click setup link — open it, and you're the admin.
70
71Add as many chats as you like (each is fully isolated). This box keeps itself
72up to date from the stable channel automatically; see `lchat update status`.
73Everything that matters lives in /data — back that up.
74
75Guide: https://github.com/elevenmessenger/releases#readme
76EOF
77
78}
79main "$@"
80