sirius-press/install.sh

160 lines
5.2 KiB
Bash
Raw Normal View History

feat(sirius-press): a WordPress where the account is a key, not a mailbox WordPress makes two assumptions this project cannot accept: that identity comes from an email address, and that a site lives at one server. Both are things somebody else can take away — a mailbox is rented from a provider who can close it or be compelled to open it, and a server is one seizure from being gone. Sirius Press replaces the first and hedges the second. Signing in means signing a challenge with the key that controls a CashAddress. The address is recovered from the signature, so nothing is typed but the signature itself, and the result is an ordinary WordPress session cookie — roles, capabilities, nonces and the REST API never learn the login was different. Three ways to produce one: a wallet the browser already exposes, a phrase used once in the page and wiped, or a signature pasted in from any BIP-137 wallet, which needs no JavaScript and lets the key stay on a machine that never touches the web. There is no password reset, and the recovery page says so plainly rather than offering a form that cannot work. A reset mechanism is by construction a way to take an account from its owner, and it is always easier to attack than the cryptography it bypasses. Publishing a post also exports it as static HTML to the name's storage on Sia, signed by the key that owns the name, so the site keeps answering when the server does not. Email as a feature is untouched. wp_mail() still works, SMTP still sends, and contact forms still deliver to addresses real people typed. Only mail to the site's own unroutable placeholder addresses is diverted to an in-app inbox. The objection was to email as identity, not to email. Core is pinned and patched rather than vendored. WordPress 7.1.1 is 149 MB and 5,008 files; the fork's entire core diff is 75 lines in wp-admin/install.php. Carrying the former to express the latter would bury the patch where nobody reviews it and make every clone of the monorepo pay for it. Upstream releases still merge through tools/update-wordpress.sh, which reapplies the series and says exactly which hunk needs a human. The cryptography is implemented twice — PHP on the server, JavaScript in the page — because the server must verify and the browser must sign. Both are pinned against libauth, the library the Sirius portal wallet and the BNS gateway already use, so a disagreement of one byte fails the test suite rather than presenting as a rejected login at three in the morning. 132 checks, no framework, about a second.
2026-09-21 01:39:38 +02:00
#!/usr/bin/env bash
# Sirius Press installer.
#
# curl -fsSL https://silentmode.st/sirius-press/install.sh | bash
#
# Brings up a working instance on a fresh Ubuntu 22.04 or 24.04 VPS: Docker if
# it is missing, the repository, generated passwords, and the stack running
# behind nginx.
#
# Two things this script will not do, both on purpose:
#
# It does not pipe anything else into a shell. Docker is installed from the
# distribution's own packages, not from get.docker.com — you are already
# trusting one curl-to-bash by running this, and chaining a second is how a
# supply chain gets long.
#
# It does not ask for, generate or store a wallet phrase. The site's
# publishing key is entered later in wp-admin, by a person, over whatever
# TLS they have arranged — not typed into a terminal session that scrolls
# into a log.
set -euo pipefail
REPO="${SIRIUS_PRESS_REPO:-https://code.silentmode.st/silentmode/sirius-press.git}"
DIR="${SIRIUS_PRESS_DIR:-/opt/sirius-press}"
PORT="${SIRIUS_PRESS_PORT:-80}"
BRANCH="${SIRIUS_PRESS_BRANCH:-master}"
bold() { printf '\033[1m%s\033[0m\n' "$*"; }
say() { printf '\033[1m→\033[0m %s\n' "$*"; }
warn() { printf '\033[33mwarning:\033[0m %s\n' "$*" >&2; }
die() { printf '\033[31merror:\033[0m %s\n' "$*" >&2; exit 1; }
[ "$(id -u)" -eq 0 ] || die "run this as root, or with sudo."
# --------------------------------------------------------------- prerequisites
say "checking prerequisites"
if ! command -v docker >/dev/null 2>&1; then
say "installing Docker from the distribution repositories"
export DEBIAN_FRONTEND=noninteractive
apt-get update -qq
apt-get install -y -qq docker.io docker-compose-v2 git curl \
|| die "could not install Docker. Install it yourself and run this again."
systemctl enable --now docker
else
command -v git >/dev/null 2>&1 || apt-get install -y -qq git
fi
if docker compose version >/dev/null 2>&1; then
COMPOSE="docker compose"
elif command -v docker-compose >/dev/null 2>&1; then
COMPOSE="docker-compose"
else
die "Docker is installed but Compose is not. Install docker-compose-v2."
fi
# ------------------------------------------------------------------ the code
if [ -d "$DIR/.git" ]; then
say "updating $DIR"
git -C "$DIR" fetch --quiet origin "$BRANCH"
git -C "$DIR" checkout --quiet "$BRANCH"
git -C "$DIR" pull --quiet --ff-only origin "$BRANCH" \
|| warn "could not fast-forward; leaving the checkout as it is."
else
say "cloning into $DIR"
mkdir -p "$(dirname "$DIR")"
git clone --quiet --branch "$BRANCH" --depth 1 "$REPO" "$DIR" \
|| die "could not clone $REPO"
fi
cd "$DIR/docker"
# ---------------------------------------------------------------- the config
random() { head -c 32 /dev/urandom | od -An -tx1 | tr -d ' \n'; }
if [ -f .env ]; then
say "keeping the existing .env"
else
say "writing .env with generated passwords"
# shellcheck source=tools/wordpress.lock
source "$DIR/tools/wordpress.lock"
{
echo "# Written by install.sh on $(date -u +%Y-%m-%dT%H:%M:%SZ)."
echo "DB_NAME=wordpress"
echo "DB_USER=wordpress"
echo "DB_PASSWORD=$(random)"
echo "DB_ROOT_PASSWORD=$(random)"
echo "SITE_URL="
echo "HTTP_PORT=$PORT"
echo "WP_DEBUG=false"
echo "SIRIUS_PRESS_KEY=$(random)"
echo "WP_VERSION=$WP_VERSION"
echo "WP_URL=$WP_URL"
echo "WP_SHA256=$WP_SHA256"
} > .env
chmod 600 .env
fi
# ------------------------------------------------------------------- run it
say "building the image (this is the slow part — a few minutes on a small VPS)"
$COMPOSE build --quiet 2>&1 | tail -5 || die "the image did not build."
say "starting"
$COMPOSE up -d || die "the stack did not start. Try: cd $DIR/docker && $COMPOSE logs"
# Give the app a moment, then check that something answers. A silent failure
# here is the difference between "installed" and "installed and working".
say "waiting for the site to answer"
url="http://127.0.0.1:${PORT}/wp-admin/install.php"
ok=0
for _ in $(seq 1 60); do
code="$(curl -fsS -o /dev/null -w '%{http_code}' --max-time 5 "$url" 2>/dev/null || true)"
case "$code" in
200|30[0-9]) ok=1; break ;;
esac
sleep 2
done
ip="$(curl -fsS --max-time 5 https://api.ipify.org 2>/dev/null || hostname -I 2>/dev/null | awk '{print $1}')"
suffix=""
[ "$PORT" = "80" ] || suffix=":$PORT"
echo
if [ "$ok" -eq 1 ]; then
bold "Sirius Press is running."
else
bold "Sirius Press started, but nothing answered on port $PORT yet."
warn "Check with: cd $DIR/docker && $COMPOSE logs -f app"
fi
cat <<EOF
Finish setup: http://${ip:-your-server}${suffix}/wp-admin/install.php
The setup screen asks for a wallet address instead of an email address.
You can leave it blank and attach one later from your profile.
Next:
1. Point your BCNR name's p or ip record at ${ip:-this server}.
See ${DIR}/docs/bcnr-records.md
2. In wp-admin, open Sirius Press and set the name this site publishes under.
3. Decide whether this server may hold your publishing key, or whether you
would rather sign exports from your browser. Manual is the default and
the safer answer. See ${DIR}/docs/publishing.md
Managing it:
cd ${DIR}/docker
${COMPOSE} logs -f app # what the site is doing
${COMPOSE} restart # after changing .env
git -C ${DIR} pull && ${COMPOSE} build && ${COMPOSE} up -d # upgrade
EOF